0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 23:01:04 +08:00

builds/zos/* portability files to z/OS UNIX

builds/zos includes:
    README.md: Overview of z/OS UNIX System Services port (Markdown)
    makelibzmq: Compile src/*.cpp and make libzmq.a
    maketests:  Compile tests/*.cpp and make test_* executables
    runtests:   Run tests/test_* executables and report results
    makeclean:  Remove built files
    zc++: /bin/c++ wrapper supplying required build arguments
    cxxall: run zc++ for all *.cpp files in directory

    platform.hpp: pre-generated (and edited) src/platform.hpp for z/OS
    test_fork.cpp: updated tests/test_fork.cpp that completes on z/OS
This commit is contained in:
Ewen McNeill 2014-07-22 12:05:51 +12:00
parent 81b9f21bdd
commit 6e0c1c0a80
9 changed files with 1105 additions and 0 deletions

285
builds/zos/README.md Normal file
View File

@ -0,0 +1,285 @@
# ZeroMQ on z/OS UNIX System Services
ZeroMQ has been successfully built on z/OS, using [z/OS UNIX System
Services](http://www-03.ibm.com/systems/z/os/zos/features/unix/),
a certified UNIX environment for the [IBM
z-series](http://www-03.ibm.com/systems/z/). The build is possible
with the shell scripts in this directory, as described below.
Tested build combinations:
* ZeroMQ 4.0.4, using IBM XL C/C++ compiler, as XPLINK in ILP32 mode
* ZeroMQ 4.0.4, using IBM XL C/C++ compiler, as XPLINK in LP64 mode
(Other combinations are likely to work, possibly with minor changes,
but have not been tested.)
There are some minor limitations (detailed below), but all core
functionality tests run successfully.
## Quickstart on z/OS UNIX System Services
Assuming [z/OS UNIX System
Services](http://www-03.ibm.com/systems/z/os/zos/features/unix/) is
installed, and the [z/OS XL C/C++
compiler suite](http://www-03.ibm.com/software/products/en/czos) is
installed, ZeroMQ can be built as follows:
* Download and extract ZeroMQ tar file
* Ensure contents of this directory are present at `builds/zos`
within that extracted diretory (eg, `zeromq-VERSION/builds/zos/`;
copy these files in, if not already present, and make sure the
shell scripts are executable)
* (Optional) set ZCXXFLAGS for additional compile flags (see below)
* Build the `libzmq.a` static library with:
cd zeromq-VERSION
builds/zos/makelibzmq
* (Optional, but recommended) build the core tests with:
builds/zos/maketests
* (Optional, but recommended) run the core tests:
builds/zos/runtests
* To remove built files, to start again (eg, rebuild with different
compile/link flags):
builds/zos/makeclean
## Compilation flags
To build with optimisation:
* set `ZCXXFLAGS` to "`-O2`" before starting build process above
To build with debugging symbols:
* set `ZCXXFLAGS` to "`-g`" before starting build process above
To build in 64-bit mode:
The default build is
[ILP32](http://publib.boulder.ibm.com/infocenter/zvm/v6r1/index.jsp?topic=/com.ibm.zos.r9.cbcux01/lp64cop.htm),
the default for the IBM XL C/C++ compiler. To build in LP64 mode
(64-bit):
* set `ZCXXFLAGS` to "`-Wc,lp64 -Wl,lp64`" before starting build
(64-bit mode can be combined with optimisation or debug symbols.)
Other build flags can be used in `ZXCCFLAGS` if desired. Beware that
they are passed through (Bourne) shell expansion, and passed to both
the compile and link stages; some experimentation of argument quoting
may be required (and arguments requiring parenthesis are particularly
complicated).
## ZeroMQ test status on z/OS UNIX System Services
As of 2014-07-22, 41 of the 43 tests in the core ZeroMQ test suite
pass. There are two tests that are expected to fail:
0. `test_abstract_ipc`: tests Linux-specific IPC functions, and is
expected to fail on non-Linux platforms.
0. `test_fork`: tests ability to use ZeroMQ both before *and* after
fork (and before exec()); this relies on the ability to use
pthreads both before *and* after fork. On z/OS (and some other
UNIX compliant platforms) functions like `pthreads_create` (used
by ZeroMQ) cannot be used after fork and before exec; on z/OS the
call after fork fails with `ELEMULTITHREADFORK` (errno=257). (On
z/OS it appears possible to use z/OS *after* fork, *providing* it
has not been used before fork -- the problem is the two separate
initialisations of the threading library before and after fork
attempting to mix together.) In practice this is unlikely to
affect many real-world programs -- most programs use threads or
fork without exec, but not both.
These two "expected to fail" tests are listed as XFAIL_TESTS, and
`runtests` will still consider the test run successful when they fail
as expected.
In addition there are some other minor test issues:
* `test_security_curve` does not do any meaningful testing, as a
result of the CURVE support not being compiled in; it requires
[`libsodium`](http://doc.libsodium.org/), which has not been
ported to z/OS UNIX System Services yet.
* `test_monitor` will sometimes fail with `SIGPIPE` (about 1 run
in 4); this appears to be a problem with SIGPIPE not being ignored
and has been reported upstream.
* `test_spec_rep` (and possibly other tests) occassionally fail with
`Resource temporarily unavailable`, which is a result of EAGAIN
not being properly caught in all places and the function call
retried. This has also been reported upstream.
## ZeroMQ on z/OS UNIX System Services: Portability notes
### *.cpp
The source code in ZeroMQ is a combination of a C++ core library
(in `*.cpp` and `*.hpp` files), and a C wrapper (also in `*.cpp`
files). It is all compiled with the C++ compiler. The IBM XL C/C++
complier (at least the version used for initial porting) insists
that C++ source be in `*.C` files (note capital C). To work around
this issue the compile flag `-+` is used (specified in the `zc++`
compiler wrapper), which tells the compiler the file should be
considered C++ despite the file extension.
### XPLINK
The library (and tests) are built in
[XPLINK](http://www.redbooks.ibm.com/abstracts/sg245991.html) mode
with the flags `-Wc,xplink -Wl,xplink` (specified in the `zc++`
compiler wrapper). This is [recommended by IBM for C++
code](http://publib.boulder.ibm.com/infocenter/zvm/v5r4/index.jsp?topic=/com.ibm.zos.r9.ceea200/xplrunt.htm)
due to the small functions. (Amongst other things, using XPLINK
enables function calls with some arguments passed in registers.)
### long long
ZeroMQ makes use of `uint64_t` (which is `unsigned long long` in ILP32
mode). To enable this the compile flag `-Wc,lang(longlong)` is passed
to enable `long long`. This is passed from the `zc++` compiler wrapper
in order to be able to specifically quote the argument to protect the
parentheses from shell expansion.
### BSD-style sockets, with IPv6 support
ZeroMQ uses BSD-style socket handling, with extensions to support IPv6.
BSD-style sockets were merged into SysV-derived UNIX at least a decade
ago, and are required as part of the X/Open Portability Guide at least
as of XPG 4.2. To access this functionality two feature macros are
defined:
* _XOPEN_SOURCE_EXTENDED=1
* _OPEN_SYS_SOCK_IPV6
The first enables the XPG 4.2 features (including functionality like
`getsockname()`), and the latter exposes IPv6 specific functionality
like `sa_family_t`. These flags are defined in the `cxxall` script.
(The traditional BSD-sockets API, exposed with `_OE_SOCKETS` cannot
be used because it does not support functions like `getsockname()`,
nor does it support IPv6 -- and the API definitions prevent compiling
in LP64 mode due to assumptions about long being 32 bits. Using
`_XOPEN_SOURCE_EXTENDED=1` avoids all these problems.)
### pthreads
ZeroMQ uses the pthreads library to create additional threads to handle
background communication without blocking the main application. This
functionaity is enabled on z/OS UNIX System Services by defining:
* _OPEN_THREADS=3
which is done in the `cxxall` script. (The "3" value exposes later
pthreads functionality like `pthread_atfork`, although ZeroMQ does not
currently use all these features.)
## `platform.hpp` on z/OS UNIX System Services
The build (described above) on z/OS UNIX System Services uses a static
pre-built `platform.hpp` file. (By default `src/platform.hpp` is
dynamically generated as a result of running the `./configure` script.)
The master version of this is in `builds/zos/platform.hpp`.
The pre-built file is used because z/OS does not have the GNU auto tools
(`automake`, `autoconf`, `libtool`, etc) installed, and particularly the
libtool replacement does not work properly with the IBM XL C/C++
compiler.
The `./configure` script (only supplied in the tarballs); built with
`automake` and `autoconf` on another platform), with one small edit,
was used to generate the z/OS `platform.hpp` and then two small changes
(described below) were made by hand to the generated `platform.hpp`.
To be able to run the ./configure script to completion (in tcsh
syntax):
* Edit `./configure` and add:
openedition)
;;
immediately before the line:
as_fn_error $? "unsupported system: ${host_os}." "$LINENO" 5
(somewhere around 17637). This avoids the configure script giving
up early because `openedition` is not recognised.
* set `CXX` to point that the full path to the `builds/zos/zc++` wrapper, eg
setenv CXX "/u/0mq/zeromq-4.0.4/builds/zos/zc++"
* set `CPPFLAGS` to for the feature macros required, eg:
setenv CPPFLAGS "-D_XOPEN_SOURCE_EXTENDED=1 -D_OPEN_THREADS=3 -D_OPEN_SYS_SOCK_IPV6"
* set `CXXFLAGS` to enable XPLINK:
setenv CXXFLAGS "-Wc,xplink -Wl,xplink -+"
* run configure script with `--disable-eventfd` (`sys/eventfd.h` does
not exist, but the test for its existance has a false positive on
z/OS UNIX System Services, apparently due to the way the `c++`
compiler wrapper passes errors back from the IBM XL C/C++ compiler), viz:
./configure --disable-eventfd
All going well several Makefiles, and `src/platform.hpp` should be
produced. Two additional changes are required to `src/platform.hpp`
which can be appended to the end:
/* ---- Special case for z/OS Unix Services: openedition ---- */
#include <pthread.h>
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
(many includes require pthreads-related methods or data structures to
be defined, but not all of them include `pthread.h`, and the value
`NI_MAXHOST` is not defined on z/OS UNIX System Services -- the 1025
value is the conventional value on other platforms).
Having done this the Makefiles can be used to compile individual files
if desired, eg:
cd src
make zmq.o
but note:
* IBM Make will warn of duplicate prerequisites on *every* run of
`make`, and both the generated `src/Makefile` and `tests/Makefile`
have several duplicates. (For `src/Makefile` edit
`libzmq_la_SOURCES` to remove the duplicates.)
* IBM Make does not understand the `@` prefix (eg, `@echo`) as a way
to avoid echoing the command, resulting in an error and the command
being echoed anyway.
* Many of the make targets result in GNU auto tools (`aclocal`, etc)
being invoked, which are likely to fail, and most of the
library-related targets will invoke `libtool` which will cause
compile failures (due to differences in expected arguments).
However running `./configure` to regenerate `src/platform.hpp` may
be useful for later versions of ZeroMQ which add more feature tests.

62
builds/zos/cxxall Normal file
View File

@ -0,0 +1,62 @@
#! /bin/sh
# Attempt to compile all *.cpp files in the current directory, that are
# not already compiled. Uses zc++ wrapper around C++ compiler, to add
# additional compile arguments.
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-19
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-19
#---------------------------------------------------------------------------
VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status
export VERBOSE
# Locate compiler wrapper
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
ZCXX="${BIN_DIR}/zc++"
# Determine compile flags
CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -D_OPEN_THREADS=3 -D_OPEN_SYS_SOCK_IPV6"
CXXFLAGS="-DHAVE_CONFIG_H -D_REENTRANT -D_THREAD_SAFE -DZMQ_FORCE_POLL"
case $(pwd) in
*src) CXXFLAGS="${CXXFLAGS} -I."
;;
*tests) CXXFLAGS="${CXXFLAGS} -I. -I../src -I../include"
;;
*) echo "Currently only builds in src/ and tests/" >&2
exit 1
;;
esac
skip() {
SRC="$1"
OBJ="$2"
if [ -n "${VERBOSE}" ]; then
echo " ${SRC} compiled already"
fi
}
compile() {
SRC="$1"
OBJ="$2"
echo "CXX ${SRC}"
"${ZCXX}" ${CXXFLAGS} ${CPPFLAGS} -+ -c -o "${OBJ}" "${SRC}"
}
for SRC in *.cpp; do
OBJ=$(echo $SRC | sed 's/\.cpp/.o/;')
if [ -f "${OBJ}" ]; then
if [ "${OBJ}" -nt "${SRC}" ]; then
skip "${SRC}" "${OBJ}"
else
compile "${SRC}" "${OBJ}"
fi
else
compile "${SRC}" "${OBJ}"
fi
done

35
builds/zos/makeclean Normal file
View File

@ -0,0 +1,35 @@
#! /bin/sh
# Remove built object files and test executables
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
set -e # Stop on errors
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"
TESTS="${TOP}/tests"
# Remove object/library files
echo "Removing libzmq built files"
(cd "${SRC}" && rm -f *.o *.a *.dbg)
# Remove test object files
echo "Removing libzmq tests"
(cd "${TESTS}" && rm -f *.o *.dbg)
(cd "${TESTS}";
EXES=$(ls test_* | grep -v "\.")
if [ -n "${EXES}" ]; then
rm ${EXES}
fi
)

30
builds/zos/makelibzmq Normal file
View File

@ -0,0 +1,30 @@
#! /bin/sh
# Build libzmq.a
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-21
#---------------------------------------------------------------------------
set -e # Stop on errors
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"
# Install pre-generated platform.hpp
cp -p "${BIN_DIR}/platform.hpp" "${SRC}/platform.hpp"
# Compile all the source
cd "${SRC}"
"${BIN_DIR}/cxxall"
# Make static library
ar r libzmq.a *.o

79
builds/zos/maketests Normal file
View File

@ -0,0 +1,79 @@
#! /bin/sh
# Build tests/* executables; assumes that libzmq.a is already built
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-21
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
set -e # Stop on errors
VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status
export VERBOSE
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate compiler wrapper
ZCXX="${BIN_DIR}/zc++"
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"
TESTS="${TOP}/tests"
if [ -f "${SRC}/platform.hpp" -a -f "${SRC}/libzmq.a" ]; then
:
else
echo "Error: run makezmqlib to build libzmq.a first" >&2
exit 1
fi
# Copy in replacement test with timeout, if main version is not already
# up to date
#
if [ -f "${TESTS}/test_fork.cpp" ] &&
grep "TIMEOUT" "${TESTS}/test_fork.cpp" >/dev/null 2>&1; then
: # Already copied in
else
echo "Updating test_fork.cpp to version with master timeout"
cp -p "${BIN_DIR}/test_fork.cpp" "${TESTS}/test_fork.cpp"
fi
# Compile all the source
cd "${TESTS}"
"${BIN_DIR}/cxxall"
# Link all the executables that are not already linked
skip() {
OBJ="$1"
EXE="$2"
if [ -n "${VERBOSE}" ]; then
echo "${OBJ} linked to ${EXE}"
fi
}
compile() {
OBJ="$1"
EXE="$2"
echo " LD ${EXE}"
"${ZCXX}" -L ../src -o "${EXE}" "${OBJ}" -lzmq
}
for OBJ in *.o; do
EXE=$(echo "${OBJ}" | sed 's/\.o//;')
if [ -f "${EXE}" ]; then
if [ "${EXE}" -nt "${OBJ}" ]; then
skip "${OBJ}" "${EXE}"
else
compile "${OBJ}" "${EXE}"
fi
else
compile "${OBJ}" "${EXE}"
fi
done

277
builds/zos/platform.hpp Normal file
View File

@ -0,0 +1,277 @@
/* src/platform.hpp. Generated from platform.hpp.in by configure. */
/* src/platform.hpp.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <alloca.h> header file. */
/* #undef HAVE_ALLOCA_H */
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the `clock_gettime' function. */
/* #undef HAVE_CLOCK_GETTIME */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
/* Define to 1 if you have the `freeifaddrs' function. */
#define HAVE_FREEIFADDRS 1
/* Define to 1 if you have the `gethrtime' function. */
/* #undef HAVE_GETHRTIME */
/* Define to 1 if you have the `getifaddrs' function. */
#define HAVE_GETIFADDRS 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <ifaddrs.h> header file. */
#define HAVE_IFADDRS_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `iphlpapi' library (-liphlpapi). */
/* #undef HAVE_LIBIPHLPAPI */
/* Define to 1 if you have the `nsl' library (-lnsl). */
/* #undef HAVE_LIBNSL */
/* Define to 1 if you have the `pthread' library (-lpthread). */
/* #undef HAVE_LIBPTHREAD */
/* Define to 1 if you have the `rpcrt4' library (-lrpcrt4). */
/* #undef HAVE_LIBRPCRT4 */
/* Define to 1 if you have the `rt' library (-lrt). */
/* #undef HAVE_LIBRT */
/* Define to 1 if you have the `socket' library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Define to 1 if you have the `sodium' library (-lsodium). */
/* #undef HAVE_LIBSODIUM */
/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
/* #undef HAVE_LIBWS2_32 */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#define HAVE_NETINET_TCP_H 1
/* Define to 1 if you have the `perror' function. */
#define HAVE_PERROR 1
/* Define to 1 if you have the `socket' function. */
#define HAVE_SOCKET 1
/* Define to 1 if stdbool.h conforms to C99. */
/* #undef HAVE_STDBOOL_H */
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/eventfd.h> header file. */
/* #undef HAVE_SYS_EVENTFD_H */
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define to 1 if the system has the type `_Bool'. */
/* #undef HAVE__BOOL */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#define NO_MINUS_C_MINUS_O 1
/* Name of package */
#define PACKAGE "zeromq"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "zeromq-dev@lists.zeromq.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "zeromq"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "zeromq 4.0.4"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "zeromq"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "4.0.4"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
#define VERSION "4.0.4"
/* Force to use mutexes */
/* #undef ZMQ_FORCE_MUTEXES */
/* Have AIX OS */
/* #undef ZMQ_HAVE_AIX */
/* Have Android OS */
/* #undef ZMQ_HAVE_ANDROID */
/* Have Cygwin */
/* #undef ZMQ_HAVE_CYGWIN */
/* Have eventfd extension. */
/* #undef ZMQ_HAVE_EVENTFD */
/* Have FreeBSD OS */
/* #undef ZMQ_HAVE_FREEBSD */
/* Have HPUX OS */
/* #undef ZMQ_HAVE_HPUX */
/* Have ifaddrs.h header. */
#define ZMQ_HAVE_IFADDRS 1
/* Have Linux OS */
/* #undef ZMQ_HAVE_LINUX */
/* Have MinGW32 */
/* #undef ZMQ_HAVE_MINGW32 */
/* Have NetBSD OS */
/* #undef ZMQ_HAVE_NETBSD */
/* Have OpenBSD OS */
/* #undef ZMQ_HAVE_OPENBSD */
/* Have OpenPGM extension */
/* #undef ZMQ_HAVE_OPENPGM */
/* Have DarwinOSX OS */
/* #undef ZMQ_HAVE_OSX */
/* Have QNX Neutrino OS */
/* #undef ZMQ_HAVE_QNXNTO */
/* Whether SOCK_CLOEXEC is defined and functioning. */
/* #undef ZMQ_HAVE_SOCK_CLOEXEC */
/* Have Solaris OS */
/* #undef ZMQ_HAVE_SOLARIS */
/* Whether SO_KEEPALIVE is supported. */
/* #undef ZMQ_HAVE_SO_KEEPALIVE */
/* Whether TCP_KEEPALIVE is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPALIVE */
/* Whether TCP_KEEPCNT is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPCNT */
/* Whether TCP_KEEPIDLE is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPIDLE */
/* Whether TCP_KEEPINTVL is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPINTVL */
/* Have uio.h header. */
#define ZMQ_HAVE_UIO 1
/* Have Windows OS */
/* #undef ZMQ_HAVE_WINDOWS */
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
/* #undef _UINT32_T */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef ssize_t */
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
/* #undef uint32_t */
/* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */
/* #undef volatile */
/* ---- Special case for z/OS Unix Services: openedition ---- */
#include <pthread.h>
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif

210
builds/zos/runtests Normal file
View File

@ -0,0 +1,210 @@
#! /bin/sh
# Run ZeroMQ tests, in order. This is extracted from the tests/Makefile
# which won't run as-is because it relies on libtool building things, and
# thus creating various libtool files, which don't work well on z/OS
#
# noinst_PROGRAMS needs to be kept in sync with tests/Makefile.am, as it
# defines the order in which tests are run.
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-19
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-21
#---------------------------------------------------------------------------
set -e # Stop if a test fails
# Test order taken from tests/Makefile.am
noinst_PROGRAMS="test_system
test_pair_inproc
test_pair_tcp
test_reqrep_inproc
test_reqrep_tcp
test_hwm
test_reqrep_device
test_sub_forward
test_invalid_rep
test_msg_flags
test_connect_resolve
test_immediate
test_last_endpoint
test_term_endpoint
test_monitor
test_router_mandatory
test_router_raw_empty
test_probe_router
test_stream
test_disconnect_inproc
test_ctx_options
test_ctx_destroy
test_security_null
test_security_plain
test_security_curve
test_iov
test_spec_req
test_spec_rep
test_spec_dealer
test_spec_router
test_spec_pushpull
test_req_correlate
test_req_relaxed
test_conflate
test_inproc_connect
test_issue_566
test_abstract_ipc
test_many_sockets
test_shutdown_stress
test_pair_ipc
test_reqrep_ipc
test_timeo
test_fork"
if [ -n "${1}" ]; then
TESTS="$*" # Run tests on command line
else
TESTS="${noinst_PROGRAMS}"
fi
# Explanation of tests expected to fail:
# test_abstract_ipc: Relies on Linux-specific IPC functionality
# test_fork: Relies on using pthreads _after_ fork, _before_ exec
#
# (Note: there _must_ be spaces either side of the tests names to match)
XFAIL_TESTS="
test_abstract_ipc
test_fork
"
verbose() {
echo "Starting: $@" >&2
"$@"
}
# Uncomment TESTS_ENVIRONMENT=verbose to see "Starting: TEST" messages
#TESTS_ENVIRONMENT=verbose
TESTS_ENVIRONMENT=
#---------------------------------------------------------------------------
# Change to tests directory if necessary
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
TESTDIR="${TOP}/tests"
case "$(pwd)" in
*tests) ;;
*) echo "Changing to ${TESTDIR}"
cd "${TESTDIR}"
;;
esac
if [ -x "test_system" ]; then
:
else
echo "Run makelibzmq and maketests before runtests" >&2
exit 1
fi
#---------------------------------------------------------------------------
# check-TESTS: target from tests/Makefile, converted from Make syntax to
# shell syntax
failed=0; all=0; xfail=0; xpass=0; skip=0;
srcdir=.; export srcdir;
list="${TESTS}";
red=""; grn=""; lgn=""; blu=""; std="";
if test -n "$list"; then
for tst in $list; do
if test -f ./$tst; then dir=./;
elif test -f $tst; then dir=;
else dir="${srcdir}/"; fi;
if ${TESTS_ENVIRONMENT} ${dir}$tst; then
all=`expr $all + 1`;
case " ${XFAIL_TESTS} " in
*"$tst"*)
xpass=`expr $xpass + 1`;
failed=`expr $failed + 1`;
col=$red; res=XPASS;
;;
*)
col=$grn; res=PASS;
;;
esac;
elif test $? -ne 77; then
all=`expr $all + 1`;
case " ${XFAIL_TESTS} " in
*"$tst"*)
xfail=`expr $xfail + 1`;
col=$lgn; res=XFAIL;
;;
*)
failed=`expr $failed + 1`;
col=$red; res=FAIL;
;;
esac;
else
skip=`expr $skip + 1`;
col=$blu; res=SKIP;
fi;
echo "${col}$res${std}: $tst";
done;
if test "$all" -eq 1; then
tests="test";
All="";
else
tests="tests";
All="All ";
fi;
if test "$failed" -eq 0; then
if test "$xfail" -eq 0; then
banner="$All$all $tests passed";
else
if test "$xfail" -eq 1; then failures=failure; else failures=failures; fi;
banner="$All$all $tests behaved as expected ($xfail expected $failures)";
fi;
else
if test "$xpass" -eq 0; then
banner="$failed of $all $tests failed";
else
if test "$xpass" -eq 1; then passes=pass; else passes=passes; fi;
banner="$failed of $all $tests did not behave as expected ($xpass unexpected $passes)";
fi;
fi;
dashes="$banner";
skipped="";
if test "$skip" -ne 0; then
if test "$skip" -eq 1; then
skipped="($skip test was not run)";
else
skipped="($skip tests were not run)";
fi;
test `echo "$skipped" | wc -c` -le `echo "$banner" | wc -c` ||
dashes="$skipped"; \
fi;
report="";
if test "$failed" -ne 0 && test -n "${PACKAGE_BUGREPORT}"; then
report="Please report to ${PACKAGE_BUGREPORT}";
test `echo "$report" | wc -c` -le `echo "$banner" | wc -c` ||
dashes="$report";
fi;
dashes=`echo "$dashes" | sed s/./=/g`;
if test "$failed" -eq 0; then
col="$grn";
else
col="$red";
fi;
echo "${col}$dashes${std}";
echo "${col}$banner${std}";
test -z "$skipped" || echo "${col}$skipped${std}";
test -z "$report" || echo "${col}$report${std}";
echo "${col}$dashes${std}";
test "$failed" -eq 0;
else :; fi

85
builds/zos/test_fork.cpp Normal file
View File

@ -0,0 +1,85 @@
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "testutil.hpp"
#include <unistd.h> // For alarm()
const char *address = "tcp://127.0.0.1:6571";
#define NUM_MESSAGES 5
#define TIMEOUT_SECS 5 // Global timeout
int main (void)
{
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create and bind pull socket to receive messages
void *pull = zmq_socket (ctx, ZMQ_PULL);
assert (pull);
int rc = zmq_bind (pull, address);
assert (rc == 0);
int pid = fork ();
if (pid == 0) {
// Child process
// Immediately close parent sockets and context
zmq_close (pull);
zmq_term (ctx);
// Create new context, socket, connect and send some messages
void *child_ctx = zmq_ctx_new ();
assert (child_ctx);
void *push = zmq_socket (child_ctx, ZMQ_PUSH);
assert (push);
rc = zmq_connect (push, address);
assert (rc == 0);
int count;
for (count = 0; count < NUM_MESSAGES; count++)
zmq_send (push, "Hello", 5, 0);
zmq_close (push);
zmq_ctx_destroy (child_ctx);
exit (0);
}
else {
// Parent process
alarm(TIMEOUT_SECS); // Set upper limit on runtime
int count;
for (count = 0; count < NUM_MESSAGES; count++) {
char buffer [5];
int num_bytes = zmq_recv (pull, buffer, 5, 0);
assert (num_bytes == 5);
}
int child_status;
while (true) {
rc = waitpid (pid, &child_status, 0);
if (rc == -1 && errno == EINTR)
continue;
assert (rc > 0);
// Verify the status code of the child was zero
assert (WEXITSTATUS (child_status) == 0);
break;
}
exit (0);
}
return 0;
}

42
builds/zos/zc++ Normal file
View File

@ -0,0 +1,42 @@
#! /bin/sh
# Wrapper around IBM C++ compiler to add "-+" to preprocessor calls
# and thus work with C++ in files other than *.C. Also add -Wc,lang(longlong)
# with appropriate quoting to avoid shell confusion -- this is difficult
# to get through both ./configure arguments _and_ Makefile/shell expansion
# safely so more easily added in this wrapper.
#
# Finally, by default will enable xplink for C++ compatibilty and performance
# (c++ standard library requires xplink enabled).
#
# Additional compile/link flags can be passed in as ZCXXFLAGS, eg:
#
# For debug: ZXCCFLAGS=-g ...
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-18
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-21
#---------------------------------------------------------------------------
CPPFLAGS="-+"
LONGLONG="-Wc,lang(longlong)"
XPLINK="${XPLINK:--Wc,xplink -Wl,xplink}"
CXX="/bin/c++"
ZCXXFLAGS="${ZCXXFLAGS:-}" # Extra compile/link arguments, eg "-g"
# For debugging calling conventions issues
#echo "Called with: $0 $@" >>/tmp/zc++.log 2>&1
#exec >>/tmp/zc++.log 2>&1
#set -x
case "$1" in
-E) exec "${CXX}" "${CPPFLAGS}" "$@"
;;
-o) exec "${CXX}" ${ZCXXFLAGS} "${LONGLONG}" "${CPPFLAGS}" ${XPLINK} "$@"
;;
-c) exec "${CXX}" ${ZCXXFLAGS} "${LONGLONG}" "${CPPFLAGS}" ${XPLINK} "$@"
;;
-L) # Special case for linking via C++, called from linkall
exec "${CXX}" ${ZCXXFLAGS} ${XPLINK} "$@"
;;
*) exec "${CXX}" ${ZCXXFLAGS} "${LONGLONG}" ${XPLINK} "$@"
;;
esac