]> Savannah Git Hosting - gnulib.git/commitdiff
thread: port to z/OS
authorDaniel Richard G <skunk@iSKUNK.ORG>
Wed, 17 Aug 2016 23:59:39 +0000 (16:59 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 18 Aug 2016 00:44:56 +0000 (17:44 -0700)
* lib/glthread/thread.c, lib/glthread/thread.h:
Rudimentary gl_thread support for z/OS.

ChangeLog
lib/glthread/thread.c
lib/glthread/thread.h

index 2b75f35eaab93044a62a4c1cdea25594d7240fb6..e6d5b06c13bac74324d10af473028cc3fdeb49d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2016-08-17  Daniel Richard G.  <skunk@iSKUNK.ORG>
 
+       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:
index 6278d9a14cd93a197c2bee47b0b6981f2d0efc35..9f60c4674f6ae40fbfcd49f82d5f6a295dad7cfb 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <pthread.h>
 
-#ifdef PTW32_VERSION
+#if defined PTW32_VERSION || defined __MVS__
 
 const gl_thread_t gl_null_thread /* = { .p = NULL } */;
 
index 82c9245438978fb2866d8ca6203c8b4438f182ec..e96cf58baf27157b7109b4d2c29f2cb9d21ff70f 100644 (file)
@@ -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)