From: Jens Axboe Date: Tue, 12 Jul 2011 20:33:53 +0000 (+0200) Subject: Add gettid() for FreeBSD/OSX/Solaris X-Git-Tag: fio-1.56~2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=e8d588e4d31f9d1e93b14499d23760d1d3d2db6b Add gettid() for FreeBSD/OSX/Solaris Signed-off-by: Jens Axboe --- diff --git a/os/os-freebsd.h b/os/os-freebsd.h index 7a79dd0f..fad051ff 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -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 diff --git a/os/os-mac.h b/os/os-mac.h index 7446a43d..0d3cae3c 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -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 diff --git a/os/os-solaris.h b/os/os-solaris.h index 681d4a60..e1627d71 100644 --- a/os/os-solaris.h +++ b/os/os-solaris.h @@ -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 */