Add gettid() for FreeBSD/OSX/Solaris
authorJens Axboe <jaxboe@fusionio.com>
Tue, 12 Jul 2011 20:33:53 +0000 (22:33 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Tue, 12 Jul 2011 20:33:53 +0000 (22:33 +0200)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
os/os-freebsd.h
os/os-mac.h
os/os-solaris.h

index 7a79dd0f70ca42c5063d7a58741f61fba75a62ed..fad051ff0bfcecf3673bb215d103ff09609a5304 100644 (file)
@@ -13,6 +13,7 @@
 #define FIO_USE_GENERIC_RAND
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_GETTID
 
 #define OS_MAP_ANON            MAP_ANON
 
@@ -51,6 +52,14 @@ static inline unsigned long long os_phys_mem(void)
        return mem;
 }
 
+static inline int gettid(void)
+{
+       long lwpid;
+
+       thr_self(&lwpid);
+       return (int) lwpid;
+}
+
 #ifdef MADV_FREE
 #define FIO_MADV_FREE  MADV_FREE
 #endif
index 7446a43d47e8c842a72b5b4e2e4469184ce4a974..0d3cae3cb5e43e1a7d5e5a97fb6b604d2d60ac50 100644 (file)
@@ -22,6 +22,7 @@
 #define FIO_HAVE_POSIXAIO
 #define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_USE_GENERIC_RAND
+#define FIO_HAVE_GETTID
 
 #define OS_MAP_ANON            MAP_ANON
 
@@ -147,4 +148,9 @@ static inline unsigned long long os_phys_mem(void)
        sysctl(mib, 2, &mem, &len, NULL, 0);
        return mem;
 }
+
+static inline int gettid(void)
+{
+       return mach_thread_self();
+}
 #endif
index 681d4a60729e5f8207c79c9a0fc9ac41ede3c72e..e1627d71f179ef3356d26e85000cf1f4e61eca8c 100644 (file)
@@ -119,6 +119,11 @@ static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
        return 0;
 }
 
+static inline int gettid(void)
+{
+       return pthread_self();
+}
+
 /*
  * Should be enough, not aware of what (if any) restrictions Solaris has
  */