configure: add gettid() test
authorJens Axboe <axboe@kernel.dk>
Wed, 22 May 2019 23:12:55 +0000 (17:12 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 22 May 2019 23:12:55 +0000 (17:12 -0600)
Apparently some newer glibcs now have it, decades after the
fact.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure
os/os-dragonfly.h
os/os-linux.h
os/os-mac.h
os/os-netbsd.h
os/os-openbsd.h
os/os-solaris.h
os/os-windows.h
os/os.h

index d71387c07d10505a4073ad0047ba66a1808e89c2..ee421663f396acfe7b6fa473354baf5103ab2a78 100755 (executable)
--- a/configure
+++ b/configure
@@ -2374,6 +2374,21 @@ EOF
 fi
 print_config "MADV_HUGEPAGE" "$thp"
 
 fi
 print_config "MADV_HUGEPAGE" "$thp"
 
+##########################################
+# check for gettid()
+gettid="no"
+cat > $TMPC << EOF
+#include <unistd.h>
+int main(int argc, char **argv)
+{
+  return gettid();
+}
+EOF
+if compile_prog "" "" "gettid"; then
+  gettid="yes"
+fi
+print_config "gettid" "$gettid"
+
 #############################################################################
 
 if test "$wordsize" = "64" ; then
 #############################################################################
 
 if test "$wordsize" = "64" ; then
@@ -2645,6 +2660,9 @@ fi
 if test "$__kernel_rwf_t" = "yes"; then
   output_sym "CONFIG_HAVE_KERNEL_RWF_T"
 fi
 if test "$__kernel_rwf_t" = "yes"; then
   output_sym "CONFIG_HAVE_KERNEL_RWF_T"
 fi
+if test "$gettid" = "yes"; then
+  output_sym "CONFIG_HAVE_GETTID"
+fi
 if test "$fallthrough" = "yes"; then
   CFLAGS="$CFLAGS -Wimplicit-fallthrough"
 fi
 if test "$fallthrough" = "yes"; then
   CFLAGS="$CFLAGS -Wimplicit-fallthrough"
 fi
index eb92521fa5ed4edab58134f1dbdff17c88fc26a2..3c460ae2f33105574769450cba7fe817362c66a6 100644 (file)
@@ -202,10 +202,12 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
        return mem;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return (int) lwp_gettid();
 }
 static inline int gettid(void)
 {
        return (int) lwp_gettid();
 }
+#endif
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
index ba58bf7d962380413f15441d259eea8573f3c26e..36339ef3e94250200c909e4fbad2fcf8dffcd7f4 100644 (file)
@@ -124,10 +124,12 @@ static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio)
        return syscall(__NR_ioprio_set, which, who, ioprio);
 }
 
        return syscall(__NR_ioprio_set, which, who, ioprio);
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return syscall(__NR_gettid);
 }
 static inline int gettid(void)
 {
        return syscall(__NR_gettid);
 }
+#endif
 
 #define SPLICE_DEF_SIZE        (64*1024)
 
 
 #define SPLICE_DEF_SIZE        (64*1024)
 
index 0b9c870761df96677a90a80f183a1c850fec2a36..a073300c40c5ed6fea8c2ec2ff4933776ef7066d 100644 (file)
@@ -90,10 +90,12 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
        return mem;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return mach_thread_self();
 }
 static inline int gettid(void)
 {
        return mach_thread_self();
 }
+#endif
 
 /*
  * For some reason, there's no header definition for fdatasync(), even
 
 /*
  * For some reason, there's no header definition for fdatasync(), even
index c06261d4a2a8407d7d7640df6c19d38a4e9f60a3..88fb3ef1c1a8710cdb118d9b5f5fdd21e04eddfa 100644 (file)
@@ -65,10 +65,12 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
        return mem;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return (int) _lwp_self();
 }
 static inline int gettid(void)
 {
        return (int) _lwp_self();
 }
+#endif
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
index 70f58b49ce3572a9f24b414a998ed79e6ab32a49..43a649d447bcaeaa3d72f6cdd4dcd58194bd4393 100644 (file)
@@ -65,10 +65,12 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
        return mem;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return (int)(intptr_t) pthread_self();
 }
 static inline int gettid(void)
 {
        return (int)(intptr_t) pthread_self();
 }
+#endif
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
 
 static inline unsigned long long get_fs_free_size(const char *path)
 {
index 1a411af664e8de947fc0497f59a12648e8d60fe0..f1966f449d9f4acb6fa7b20c3b376ae6f384fb8c 100644 (file)
@@ -164,10 +164,12 @@ static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
        return 0;
 }
 
        return 0;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return pthread_self();
 }
 static inline int gettid(void)
 {
        return pthread_self();
 }
+#endif
 
 /*
  * Should be enough, not aware of what (if any) restrictions Solaris has
 
 /*
  * Should be enough, not aware of what (if any) restrictions Solaris has
index dc958f5c17189465310a48fb2a1ff28bcc3b6581..3e9f73413b26a5f2c5e778b63df4281f2e7df994 100644 (file)
@@ -162,10 +162,12 @@ static inline unsigned long long os_phys_mem(void)
        return (unsigned long long) pages * (unsigned long long) pagesize;
 }
 
        return (unsigned long long) pages * (unsigned long long) pagesize;
 }
 
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return GetCurrentThreadId();
 }
 static inline int gettid(void)
 {
        return GetCurrentThreadId();
 }
+#endif
 
 static inline int init_random_seeds(uint64_t *rand_seeds, int size)
 {
 
 static inline int init_random_seeds(uint64_t *rand_seeds, int size)
 {
diff --git a/os/os.h b/os/os.h
index 756ece4b1916874da24ab18441406ad5a84e6de9..e47296801345d312249a277445e32bb42a6477a1 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -373,11 +373,13 @@ static inline int CPU_COUNT(os_cpu_mask_t *mask)
 #endif
 
 #ifndef FIO_HAVE_GETTID
 #endif
 
 #ifndef FIO_HAVE_GETTID
+#ifndef CONFIG_HAVE_GETTID
 static inline int gettid(void)
 {
        return getpid();
 }
 #endif
 static inline int gettid(void)
 {
        return getpid();
 }
 #endif
+#endif
 
 #ifndef FIO_HAVE_SHM_ATTACH_REMOVED
 static inline int shm_attach_to_open_removed(void)
 
 #ifndef FIO_HAVE_SHM_ATTACH_REMOVED
 static inline int shm_attach_to_open_removed(void)