summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcore_unix_p.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-06-30 12:30:45 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-08 02:18:14 +0000
commit3c689c4b3fd24ead8726444723536452d0e89d85 (patch)
treec1d5718cdb4f109f34f7d1e9e78eb482b84369c8 /src/corelib/kernel/qcore_unix_p.h
parent49ab284d3445c61a0ea819bbe2dd2ed54241d2e9 (diff)
QLockFile: Move the check for Linux /proc to a central place
I'll need it soon in QTemporaryFile. This also reduces the overhead, since QFile::exists -> QFileInfo::exists needs to check if there's a file engine that handles "/proc/version" (there isn't), convert the UTF-16 filename to UTF-8 and QFileSystemEngine::fillMetaData will issue a more expensive stat(2) syscall. access(2) is cheaper. This commit also introduces QT_LINUX_ALWAYS_HAVE_PROCFS that isn't defined anywhere, but could be passed during configure with -D if a build wants it. Change-Id: I1eba2b016de74620bfc8fffd14ccfd1593d59ade Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcore_unix_p.h')
-rw-r--r--src/corelib/kernel/qcore_unix_p.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index eca575ba01..ea5d98cbf3 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -340,6 +340,21 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
timespec qt_gettime() Q_DECL_NOTHROW;
void qt_nanosleep(timespec amount);
+/* non-static */
+inline bool qt_haveLinuxProcfs()
+{
+#ifdef Q_OS_LINUX
+# ifdef QT_LINUX_ALWAYS_HAVE_PROCFS
+ return true;
+# else
+ static const bool present = (access("/proc/version", F_OK) == 0);
+ return present;
+# endif
+#else
+ return false;
+#endif
+}
+
Q_CORE_EXPORT int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts);
static inline int qt_poll_msecs(struct pollfd *fds, nfds_t nfds, int timeout)