Add gettid() for proper thread affinity on Linux
[fio.git] / os / os-linux.h
index 024ef89ae23d1d4548b6c4a7982de9db1b6913b2..a36552ba68ba93caf6ca58e5fc9761fc53c0b88d 100644 (file)
@@ -32,7 +32,6 @@
 #define FIO_HAVE_BLKTRACE
 #define FIO_HAVE_STRSEP
 #define FIO_HAVE_FALLOCATE
-#define FIO_HAVE_LINUX_FALLOCATE
 #define FIO_HAVE_POSIXAIO_FSYNC
 #define FIO_HAVE_PSHARED_MUTEX
 #define FIO_HAVE_CL_SIZE
 #define FIO_HAVE_TRIM
 #define FIO_HAVE_BINJECT
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_GETTID
+
+/*
+ * Can only enable this for newer glibcs, or the header and defines are
+ * missing
+ */
+#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 6
+#define FIO_HAVE_LINUX_FALLOCATE
+#endif
 
 #ifdef SYNC_FILE_RANGE_WAIT_BEFORE
 #define FIO_HAVE_SYNC_FILE_RANGE
@@ -102,6 +110,11 @@ static inline int ioprio_set(int which, int who, int ioprio)
        return syscall(__NR_ioprio_set, which, who, ioprio);
 }
 
+static inline int gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+
 /*
  * Just check for SPLICE_F_MOVE, if that isn't there, assume the others
  * aren't either.