Use pthread_self instead of thr_self on BSD
PATCH 1/1 Use pthread_self instead of thr_self on BSD
The attached patch uses pthread_self to get the thread ID instead of the non-POSIX thr_self This fixes a compiler warning on FreeBSD.
Signature · 1 line
Bruce Cran
os/os-freebsd.h +2 -4
@@ -2,6 +2,7 @@#define FIO_OS_FREEBSD_H #include <errno.h> +#include <pthread.h> #include <sys/sysctl.h> #include <sys/disk.h>
@@ -54,10 +55,7 @@ static inline unsigned long long os_phys_mem(void)static inline int gettid (void ) { -long lwpid; - -thr_self (&lwpid); -return (int ) lwpid; +return (int )pthread_self (); }#ifdef MADV_FREE
os/os-netbsd.h +2 -4
@@ -2,6 +2,7 @@#define FIO_OS_NETBSD_H #include <errno.h> +#include <pthread.h> #include <sys/param.h> /* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */ #define rb_node _rb_node
@@ -48,10 +49,7 @@ static inline unsigned long long os_phys_mem(void)static inline int gettid (void ) { -long lwpid; - -thr_self (&lwpid); -return (int ) lwpid; +return (int )pthread_self (); }#ifdef MADV_FREE
Quoted 2 lines · Bruce Cran
The attached patch uses
pthread_selfto get the thread ID instead of the non-POSIXthr_selfThis fixes a compiler warning on FreeBSD.
Does pthread_self() return a thread ID in the PID name space, so to speak?
Signature · 1 line
Jens Axboe
Quoted 6 lines · Jens Axboe
Quoted 2 lines · Bruce Cran
The attached patch uses
pthread_selfto get the thread ID instead of the non-POSIXthr_selfThis fixes a compiler warning on FreeBSD.Does
pthread_self()return a thread ID in the PID name space, so to speak?
Hmm no, it doesn't seem to. In that case <sys/thr.h> should probably be included to get the definition of thr_self().
Signature · 1 line
Bruce Cran
Quoted 10 lines · Bruce Cran
Quoted 6 lines · Jens Axboe
Quoted 2 lines · Bruce Cran
The attached patch uses
pthread_selfto get the thread ID instead of the non-POSIXthr_selfThis fixes a compiler warning on FreeBSD.Does
pthread_self()return a thread ID in the PID name space, so to speak?Hmm no, it doesn't seem to. In that case <
sys/thr.h> should probably be included to get the definition ofthr_self().
I suspected as much, most OS' will return a unique ID but not something you can otherwise use. How about the below?
os/os-freebsd.h +1 -0
@@ -4,6 +4,7 @@#include <errno.h> #include <sys/sysctl.h> #include <sys/disk.h> +#include <sys/thr.h> #include "../file.h"
os/os-netbsd.h +1 -0
@@ -3,6 +3,7 @@#include <errno.h> #include <sys/param.h> +#include <sys/thr.h> /* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */ #define rb_node _rb_node#include <sys/sysctl.h>
Signature · 1 line
Jens Axboe
Quoted 1 line · Jens Axboe
I suspected as much, most OS' will return a unique ID but not something you can otherwise use. How about the below?
That should work.
Signature · 1 line
Bruce Cran
Quoted 5 lines · Bruce Cran
Quoted 2 lines · Jens Axboe
I suspected as much, most OS' will return a unique ID but not something you can otherwise use. How about the below?
That should work.
Great, pushing that out, too.
Signature · 1 line
Jens Axboe