From bf1aea0d5b0d7b59ee522122ebf4dad69c7e8ce8 Mon Sep 17 00:00:00 2001 From: "Shuowang (Wayne) Zhang" Date: Mon, 31 Aug 2020 11:26:12 -0400 Subject: [PATCH] zos: introduce zoslib This commit introduces ZOSLIB for z/OS, which is a C/C++ library that implements additional POSIX APIs not available in the LE C Runtime Library, and provides API for EBCDIC <-> ASCII conversion. This library requires the linker to be set to CXX when building for z/OS. ZOSLIB is designed to be installed separately, and then linked to libuv with the `-DZOSLIB_DIR` option. PR-URL: https://github.com/libuv/libuv/pull/3060 Reviewed-By: Richard Lau --- CMakeLists.txt | 20 ++++++++++++++++++++ test/run-benchmarks.c | 10 ++++++++++ test/run-tests.c | 10 ++++++++++ 3 files changed, 40 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd60b4f2..a4b9164c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,6 +266,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") endif() if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + enable_language(CXX) list(APPEND uv_defines PATH_MAX=1024) list(APPEND uv_defines _AE_BIMODAL) list(APPEND uv_defines _ALL_SOURCE) @@ -298,6 +299,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") -qarch=10 -qasm -qasmlib=sys1.maclib:sys1.modgen) + find_library(ZOSLIB + NAMES zoslib + PATHS ${ZOSLIB_DIR} + PATH_SUFFIXES lib + ) + list(APPEND uv_libraries ${ZOSLIB}) endif() if(CMAKE_SYSTEM_NAME STREQUAL "OS400") @@ -360,6 +367,10 @@ target_include_directories(uv $ PRIVATE $) +if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + target_include_directories(uv PUBLIC $) + set_target_properties(uv PROPERTIES LINKER_LANGUAGE CXX) +endif() target_link_libraries(uv ${uv_libraries}) add_library(uv_a STATIC ${uv_sources}) @@ -371,6 +382,10 @@ target_include_directories(uv_a $ PRIVATE $) +if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + target_include_directories(uv_a PUBLIC $) + set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX) +endif() target_link_libraries(uv_a ${uv_libraries}) if(LIBUV_BUILD_TESTS) @@ -593,6 +608,11 @@ if(LIBUV_BUILD_TESTS) add_test(NAME uv_test_a COMMAND uv_run_tests_a WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + set_target_properties(uv_run_benchmarks_a PROPERTIES LINKER_LANGUAGE CXX) + set_target_properties(uv_run_tests PROPERTIES LINKER_LANGUAGE CXX) + set_target_properties(uv_run_tests_a PROPERTIES LINKER_LANGUAGE CXX) + endif() endif() if(UNIX OR MINGW) diff --git a/test/run-benchmarks.c b/test/run-benchmarks.c index 980c9be8..22a2f2ea 100644 --- a/test/run-benchmarks.c +++ b/test/run-benchmarks.c @@ -28,6 +28,16 @@ /* Actual benchmarks and helpers are defined in benchmark-list.h */ #include "benchmark-list.h" +#ifdef __MVS__ +#include "zos-base.h" +/* Initialize environment and zoslib */ +__attribute__((constructor)) void init() { + zoslib_config_t config; + init_zoslib_config(&config); + init_zoslib(config); +} +#endif + static int maybe_run_test(int argc, char **argv); diff --git a/test/run-tests.c b/test/run-tests.c index ffcfaecb..0d6bce1a 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -36,6 +36,16 @@ /* Actual tests and helpers are defined in test-list.h */ #include "test-list.h" +#ifdef __MVS__ +#include "zos-base.h" +/* Initialize environment and zoslib */ +__attribute__((constructor)) void init() { + zoslib_config_t config; + init_zoslib_config(&config); + init_zoslib(config); +} +#endif + int ipc_helper(int listen_after_write); int ipc_helper_heavy_traffic_deadlock_bug(void); int ipc_helper_tcp_connection(void);