From: Daniel Richard G Date: Wed, 17 Aug 2016 23:59:39 +0000 (-0700) Subject: thread: port to z/OS X-Git-Tag: v1.0~6684 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=7ff47774637ba94c1dffc2ff2f137c82ed31df96;p=gnulib.git thread: port to z/OS * lib/glthread/thread.c, lib/glthread/thread.h: Rudimentary gl_thread support for z/OS. --- diff --git a/ChangeLog b/ChangeLog index 2b75f35eaa..e6d5b06c13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2016-08-17 Daniel Richard G. + thread: port to z/OS + * lib/glthread/thread.c, lib/glthread/thread.h: + Rudimentary gl_thread support for z/OS. + maint: port tests to z/OS errno behavior * tests/test-nonblocking-reader.h: * tests/test-nonblocking-writer.h: diff --git a/lib/glthread/thread.c b/lib/glthread/thread.c index 6278d9a14c..9f60c4674f 100644 --- a/lib/glthread/thread.c +++ b/lib/glthread/thread.c @@ -33,7 +33,7 @@ #include -#ifdef PTW32_VERSION +#if defined PTW32_VERSION || defined __MVS__ const gl_thread_t gl_null_thread /* = { .p = NULL } */; diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h index 82c9245438..e96cf58baf 100644 --- a/lib/glthread/thread.h +++ b/lib/glthread/thread.h @@ -172,6 +172,15 @@ typedef pthread_t gl_thread_t; # define gl_thread_self_pointer() \ (pthread_in_use () ? pthread_self ().p : NULL) extern const gl_thread_t gl_null_thread; +# elif defined __MVS__ + /* On IBM z/OS, pthread_t is a struct with an 8-byte '__' field. + The first three bytes of this field appear to uniquely identify a + pthread_t, though not necessarily representing a pointer. */ +# define gl_thread_self() \ + (pthread_in_use () ? pthread_self () : gl_null_thread) +# define gl_thread_self_pointer() \ + (pthread_in_use () ? *((void **) pthread_self ().__) : NULL) +extern const gl_thread_t gl_null_thread; # else # define gl_thread_self() \ (pthread_in_use () ? pthread_self () : (pthread_t) NULL)