Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH] Use pthread_self instead of thr_self on BSD
@ 2011-07-30  9:43 Bruce Cran
  2011-07-30 10:55 ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Cran @ 2011-07-30  9:43 UTC (permalink / raw)
  To: Jens Axboe; +Cc: fio

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

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.

-- 
Bruce Cran

[-- Attachment #2: fio.diff --]
[-- Type: text/plain, Size: 1108 bytes --]

diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index fad051f..9da792e 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -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
diff --git a/os/os-netbsd.h b/os/os-netbsd.h
index 7f5f484..c4a923f 100644
--- a/os/os-netbsd.h
+++ b/os/os-netbsd.h
@@ -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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use pthread_self instead of thr_self on BSD
  2011-07-30  9:43 [PATCH] Use pthread_self instead of thr_self on BSD Bruce Cran
@ 2011-07-30 10:55 ` Jens Axboe
  2011-07-30 11:17   ` Bruce Cran
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2011-07-30 10:55 UTC (permalink / raw)
  To: Bruce Cran; +Cc: fio

On 2011-07-30 11:43, Bruce Cran wrote:
> 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.

Does pthread_self() return a thread ID in the PID name space, so to
speak?

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use pthread_self instead of thr_self on BSD
  2011-07-30 10:55 ` Jens Axboe
@ 2011-07-30 11:17   ` Bruce Cran
  2011-07-30 11:23     ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Cran @ 2011-07-30 11:17 UTC (permalink / raw)
  To: Jens Axboe; +Cc: fio

On 30/07/2011 11:55, Jens Axboe wrote:
> On 2011-07-30 11:43, Bruce Cran wrote:
>> 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.
> 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().

-- 
Bruce Cran


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use pthread_self instead of thr_self on BSD
  2011-07-30 11:17   ` Bruce Cran
@ 2011-07-30 11:23     ` Jens Axboe
  2011-07-30 12:36       ` Bruce Cran
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2011-07-30 11:23 UTC (permalink / raw)
  To: Bruce Cran; +Cc: fio

On 2011-07-30 13:17, Bruce Cran wrote:
> On 30/07/2011 11:55, Jens Axboe wrote:
>> On 2011-07-30 11:43, Bruce Cran wrote:
>>> 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.
>> 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().

I suspected as much, most OS' will return a unique ID but not something
you can otherwise use. How about the below?

diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index fad051f..317d403 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -4,6 +4,7 @@
 #include <errno.h>
 #include <sys/sysctl.h>
 #include <sys/disk.h>
+#include <sys/thr.h>
 
 #include "../file.h"
 
diff --git a/os/os-netbsd.h b/os/os-netbsd.h
index 7f5f484..e03866d 100644
--- a/os/os-netbsd.h
+++ b/os/os-netbsd.h
@@ -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>

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use pthread_self instead of thr_self on BSD
  2011-07-30 11:23     ` Jens Axboe
@ 2011-07-30 12:36       ` Bruce Cran
  2011-07-30 12:57         ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Cran @ 2011-07-30 12:36 UTC (permalink / raw)
  To: Jens Axboe; +Cc: fio

On 30/07/2011 12:23, Jens Axboe wrote:
> 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.

-- 
Bruce Cran


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use pthread_self instead of thr_self on BSD
  2011-07-30 12:36       ` Bruce Cran
@ 2011-07-30 12:57         ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2011-07-30 12:57 UTC (permalink / raw)
  To: Bruce Cran; +Cc: fio

On 2011-07-30 14:36, Bruce Cran wrote:
> On 30/07/2011 12:23, Jens Axboe wrote:
>> 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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-30 12:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-30  9:43 [PATCH] Use pthread_self instead of thr_self on BSD Bruce Cran
2011-07-30 10:55 ` Jens Axboe
2011-07-30 11:17   ` Bruce Cran
2011-07-30 11:23     ` Jens Axboe
2011-07-30 12:36       ` Bruce Cran
2011-07-30 12:57         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox