[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: IBM z/OS compatibility issues - pthread
From: |
Bruno Haible |
Subject: |
Re: IBM z/OS compatibility issues - pthread |
Date: |
Sat, 21 Dec 2019 06:30:14 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) |
Hi Daniel,
> > Can you please do a fresh start on this?
> > - Create a testdir for module 'pthread-rwlock'.
> > - Build it with -D_UNIX95_THREADS -D_XOPEN_SOURCE=600.
>
> That gives me the same compile error as a full build:
>
> source='/tmp/testdir/gltests/test-pthread.c' object='test-pthread.o'
> libtool=no \
> DEPDIR=.deps depmode=aix /bin/sh /tmp/testdir/build-aux/depcomp \
> xlc-wrap -DHAVE_CONFIG_H -I. -I/tmp/testdir/gltests -I..
> -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I/tmp/testdir/gltests
> -I.. -I/tmp/testdir/gltests/.. -I../gllib -I/tmp/testdir/gltests/../gllib
> -D_UNIX95_THREADS -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 -g -q64
> -qfloat=ieee -qlanglvl=extc99 -qenumsize=4 -c -o test-pthread.o
> /tmp/testdir/gltests/test-pthread.c
> ERROR CCN3221 /tmp/testdir/gltests/test-pthread.c:35 Initializer must be a
> valid constant expression.
> WARNING CCN3196 /tmp/testdir/gltests/test-pthread.c:56 Initialization
> between types "void*" and "unsigned long" is not allowed.
> CCN0793(I) Compilation failed for file /tmp/testdir/gltests/test-pthread.c.
> Object file not created.
> make[4]: *** [test-pthread.o] Error 12
> make[4]: Leaving directory `/tmp/gnulib-build/gltests'
> make[3]: *** [all-recursive] Error 1
> make[3]: Leaving directory `/tmp/gnulib-build/gltests'
> make[2]: *** [all] Error 2
> make[2]: Leaving directory `/tmp/gnulib-build/gltests'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/tmp/gnulib-build'
> make: *** [all] Error 2
>
> Whatever magic exists to work around a missing PTHREAD_RWLOCK_INITIALIZER,
> I'm not seeing it...
Oh, I see now. We do have a workaround for this situation in the 'lock'
module, but not in the 'pthread-rwlock' module.
Since PTHREAD_RWLOCK_INITIALIZER_NP is documented [1], we can use it, as you
suggest.
[1]
https://www.ibm.com/support/knowledgecenter/cs/SSLTBW_2.2.0/com.ibm.zos.v2r2.bpxbd00/pthrdh.htm
2019-12-21 Bruno Haible <address@hidden>
pthread-thread, lock: On z/OS, use PTHREAD_RWLOCK_INITIALIZER_NP.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00001.html>
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00167.html>
* lib/pthread.in.h (PTHREAD_RWLOCK_INITIALIZER): Define to
PTHREAD_RWLOCK_INITIALIZER_NP when possible.
* lib/glthread/lock.h: Allow PTHREAD_RWLOCK_INITIALIZER_NP as an
alternative to PTHREAD_RWLOCK_INITIALIZER.
* lib/glthread/lock.c: Likewise.
diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c
index 2537839..9d84090 100644
--- a/lib/glthread/lock.c
+++ b/lib/glthread/lock.c
@@ -254,7 +254,7 @@ glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER ||
(defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__
> 1)))
-# ifdef PTHREAD_RWLOCK_INITIALIZER
+# if defined PTHREAD_RWLOCK_INITIALIZER || defined
PTHREAD_RWLOCK_INITIALIZER_NP
# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
/* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h
index ffbec15..890c459 100644
--- a/lib/glthread/lock.h
+++ b/lib/glthread/lock.h
@@ -308,7 +308,7 @@ typedef pthread_mutex_t gl_lock_t;
# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER ||
(defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__
> 1)))
-# ifdef PTHREAD_RWLOCK_INITIALIZER
+# if defined PTHREAD_RWLOCK_INITIALIZER || defined
PTHREAD_RWLOCK_INITIALIZER_NP
typedef pthread_rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
@@ -316,8 +316,13 @@ typedef pthread_rwlock_t gl_rwlock_t;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
-# define gl_rwlock_initializer \
- PTHREAD_RWLOCK_INITIALIZER
+# if defined PTHREAD_RWLOCK_INITIALIZER
+# define gl_rwlock_initializer \
+ PTHREAD_RWLOCK_INITIALIZER
+# else
+# define gl_rwlock_initializer \
+ PTHREAD_RWLOCK_INITIALIZER_NP
+# endif
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
# else /* glibc with bug
https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index a6fb3d9..1baa938 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -281,7 +281,11 @@ typedef unsigned int pthread_rwlockattr_t;
# define PTHREAD_RWLOCK_INITIALIZER \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER,
PTHREAD_COND_INITIALIZER, 0, 0 }
#else
-# if !@HAVE_PTHREAD_T@
+# if @HAVE_PTHREAD_T@
+# if !defined PTHREAD_RWLOCK_INITIALIZER && defined
PTHREAD_RWLOCK_INITIALIZER_NP /* z/OS */
+# define PTHREAD_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER_NP
+# endif
+# else
# if !GNULIB_defined_pthread_rwlock_types
typedef int pthread_rwlock_t;
typedef unsigned int pthread_rwlockattr_t;