Discussion:
Build breakage due to missing semaphore.h on z/OS
(too old to reply)
Daniel Richard G.
2017-02-20 21:12:37 UTC
Permalink
Raw Message
Building current Git on z/OS fails with

source='/u/username/testdir/gltests/test-lock.c' object='test-lock.o' libtool=no \
DEPDIR=.deps depmode=aix /bin/sh /u/username/testdir/build-aux/depcomp \
xlc-wrap -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I/u/username/testdir/gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I/u/username/testdir/gltests -I.. -I/u/username/testdir/gltests/.. -I../gllib -I/u/username/testdir/gltests/../gllib -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 -g -qfloat=ieee -qlanglvl=extc99 -c -o test-lock.o /u/username/testdir/gltests/test-lock.c
ERROR CCN3296 /u/username/testdir/gltests/test-lock.c:110 #include file <semaphore.h> not found.
ERROR CCN3046 /u/username/testdir/gltests/test-lock.c:147 Syntax error.
ERROR CCN3278 /u/username/testdir/gltests/test-lock.c:148 The structure definition must specify a member list.
[...]


The problem may be found in test-lock.c:

#if USE_POSIX_THREADS
/* Whether to use a semaphore to communicate information between threads.
If set to 0, a lock is used. If set to 1, a semaphore is used.
Uncomment this to reduce the dependencies of this test. */
# define USE_SEMAPHORE 1
#endif

...

#include "glthread/thread.h"
#include "glthread/yield.h"
#if USE_SEMAPHORE
# include <errno.h>
# include <semaphore.h>
#endif

$ ls /usr/include/semaphore.h
ls: FSUM6785 File or directory "/usr/include/semaphore.h" is not found

z/OS has POSIX threads (and pthread.h), but there is no semaphore.h
header. The sem_*() functions do not appear to exist on this platform.

I worked around this with a quick-and-dirty "#if defined(__MVS__)", but
a better fix may be to use HAVE_SEMAPHORE_H.


--Daniel
--
Daniel Richard G. || ***@iSKUNK.ORG
My ASCII-art .sig got a bad case of Times New Roman.
Bruno Haible
2017-02-20 21:36:28 UTC
Permalink
Raw Message
Hi Daniel,
Post by Daniel Richard G.
Building current Git on z/OS fails with
source='/u/username/testdir/gltests/test-lock.c' object='test-lock.o' libtool=no \
DEPDIR=.deps depmode=aix /bin/sh /u/username/testdir/build-aux/depcomp \
xlc-wrap -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I/u/username/testdir/gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I/u/username/testdir/gltests -I.. -I/u/username/testdir/gltests/.. -I../gllib -I/u/username/testdir/gltests/../gllib -D_XOPEN_SOURCE=600 -DNSIG=39 -qhaltonmsg=CCN3296 -g -qfloat=ieee -qlanglvl=extc99 -c -o test-lock.o /u/username/testdir/gltests/test-lock.c
ERROR CCN3296 /u/username/testdir/gltests/test-lock.c:110 #include file <semaphore.h> not found.
ERROR CCN3046 /u/username/testdir/gltests/test-lock.c:147 Syntax error.
ERROR CCN3278 /u/username/testdir/gltests/test-lock.c:148 The structure definition must specify a member list.
[...]
#if USE_POSIX_THREADS
/* Whether to use a semaphore to communicate information between threads.
If set to 0, a lock is used. If set to 1, a semaphore is used.
Uncomment this to reduce the dependencies of this test. */
# define USE_SEMAPHORE 1
#endif
...
#include "glthread/thread.h"
#include "glthread/yield.h"
#if USE_SEMAPHORE
# include <errno.h>
# include <semaphore.h>
#endif
$ ls /usr/include/semaphore.h
ls: FSUM6785 File or directory "/usr/include/semaphore.h" is not found
z/OS has POSIX threads (and pthread.h), but there is no semaphore.h
header. The sem_*() functions do not appear to exist on this platform.
I worked around this with a quick-and-dirty "#if defined(__MVS__)", but
a better fix may be to use HAVE_SEMAPHORE_H.
Thanks for the report and explanations. The following patch should fix it.
Pushed.


2017-02-20 Bruno Haible <***@clisp.org>

lock tests: Fix build failure on z/OS.
Reported by Daniel Richard G. <***@iskunk.org>.
* modules/lock-tests (configure.ac): Test for <semaphore.h>.
* tests/test-lock.c (USE_SEMAPHORE): Don't set if <semaphore.h> does not
exist.

diff --git a/modules/lock-tests b/modules/lock-tests
index b7f1a73..bfab1f4 100644
--- a/modules/lock-tests
+++ b/modules/lock-tests
@@ -8,6 +8,7 @@ usleep
yield

configure.ac:
+AC_CHECK_HEADERS_ONCE([semaphore.h])

Makefile.am:
TESTS += test-rwlock1 test-lock
diff --git a/tests/test-lock.c b/tests/test-lock.c
index f3da4cc..c6bc399 100644
--- a/tests/test-lock.c
+++ b/tests/test-lock.c
@@ -58,7 +58,7 @@
synchronization/communication between different CPUs. */
#define USE_VOLATILE 0

-#if USE_POSIX_THREADS
+#if USE_POSIX_THREADS && HAVE_SEMAPHORE_H
/* Whether to use a semaphore to communicate information between threads.
If set to 0, a lock is used. If set to 1, a semaphore is used.
Uncomment this to reduce the dependencies of this test. */
Daniel Richard G.
2017-02-20 22:10:48 UTC
Permalink
Raw Message
Post by Bruno Haible
Thanks for the report and explanations. The following patch should fix it.
Pushed.
lock tests: Fix build failure on z/OS.
* modules/lock-tests (configure.ac): Test for <semaphore.h>.
* tests/test-lock.c (USE_SEMAPHORE): Don't set if <semaphore.h> does not
exist.
Thanks Bruno, I've confirmed that this resolves the issue.


--Daniel
--
Daniel Richard G. || ***@iSKUNK.ORG
My ASCII-art .sig got a bad case of Times New Roman.
Loading...