8000 PR2 for zOS support by v1gnesh · Pull Request #7973 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PR2 for zOS support #7973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ option(EXTENSION_STATIC_BUILD
"Extension build linking statically with DuckDB. Required for building linux loadable extensions."
FALSE)

if(WIN32)
if(WIN32 OR ZOS)
set(EXTENSION_STATIC_BUILD TRUE)
endif()

Expand Down Expand Up @@ -648,6 +648,8 @@ function(build_loadable_extension_directory NAME OUTPUT_DIRECTORY PARAMETERS)
# Note that on MacOS we need to use the -exported_symbol whitelist feature due to a lack of -exclude-libs flag in mac's ld variant
set(WHITELIST "-Wl,-exported_symbol,_${NAME}_init -Wl,-exported_symbol,_${NAME}_version -Wl,-exported_symbol,_${NAME}_storage_ini*")
target_link_libraries(${TARGET_NAME} duckdb_static ${DUCKDB_EXTRA_LINK_FLAGS} -Wl,-dead_strip ${WHITELIST})
elseif (ZOS)
target_link_libraries(${TARGET_NAME} duckdb_static ${DUCKDB_EXTRA_LINK_FLAGS})
else()
# For GNU we rely on fvisibility=hidden to hide the extension symbols and use -exclude-libs to hide the duckdb symbols
set_target_properties(${TARGET_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ namespace duckdb_jemalloc {
* system overhead.
*/
//#define JEMALLOC_PURGE_MADVISE_FREE
#define JEMALLOC_PURGE_MADVISE_DONTNEED
#define JEMALLOC_PURGE_MADVISE_DONTNEED
/* #undef JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS */

/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */
Expand Down
2 changes: 1 addition & 1 deletion src/include/duckdb/common/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#pragma once

#if (defined(DUCKDB_USE_STANDARD_ASSERT) || !defined(DEBUG)) && !defined(DUCKDB_FORCE_ASSERT)
#if (defined(DUCKDB_USE_STANDARD_ASSERT) || !defined(DEBUG)) && !defined(DUCKDB_FORCE_ASSERT) && !defined(__MVS__)

#include <assert.h>
#define D_ASSERT assert
Expand Down
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ add_definitions(-DDUCKDB_ROOT_DIRECTORY="${PROJECT_SOURCE_DIR}")

add_executable(unittest unittest.cpp ${ALL_OBJECT_FILES})

if(NOT WIN32 AND NOT SUN)
if(NOT WIN32
AND NOT SUN
AND NOT ZOS)
target_link_libraries(unittest duckdb test_helpers)
if(${BUILD_TPCE})
target_link_libraries(unittest tpce)
Expand Down
5 changes: 5 additions & 0 deletions test/extension/loadable_extension_optimizer_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ using namespace duckdb;
#include <sys/types.h>
#include <arpa/inet.h>

#ifdef __MVS__
#define _XOPEN_SOURCE_EXTENDED 1
#include <strings.h>
#endif

class WaggleExtension : public OptimizerExtension {
public:
WaggleExtension() {
Expand Down
5 changes: 5 additions & 0 deletions test/extension/test_remote_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#include <sys/types.h>
#include <arpa/inet.h>

#ifdef __MVS__
#define _XOPEN_SOURCE_EXTENDED 1
#include <strings.h>
#endif

using namespace duckdb;
using namespace std;

Expand Down
4 changes: 4 additions & 0 deletions test/persistence/test_locking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <sys/mman.h>
#include <unistd.h>

#ifdef __MVS__
#define MAP_ANONYMOUS 0x0
#endif

using namespace duckdb;
using namespace std;

Expand Down
4 changes: 4 additions & 0 deletions test/persistence/test_persistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <sys/mman.h>
#include <unistd.h>

#ifdef __MVS__
#define MAP_ANONYMOUS 0x0
#endif

using namespace duckdb;
using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion test/sqlite/termcolor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define TERMCOLOR_OS_WINDOWS
#elif defined(__APPLE__)
#define TERMCOLOR_OS_MACOS
#elif defined(__unix__) || defined(__unix)
#elif defined(__unix__) || defined(__unix) || defined(__MVS__)
#define TERMCOLOR_OS_LINUX
#else
#error unsupported platform
Expand Down
79 changes: 3 additions & 76 deletions third_party/concurrentqueue/lightweightsemaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C" {
#include <chrono>
#elif defined(__MVS__)
#include <zos-semaphore.h>
#include <chrono>
#endif

namespace duckdb_moodycamel
Expand Down Expand Up @@ -162,9 +163,9 @@ class Semaphore
}
}
};
#elif defined(__unix__)
#elif defined(__unix__) || defined(__MVS__)
//---------------------------------------------------------
// Semaphore (POSIX, Linux)
// Semaphore (POSIX, Linux, zOS aka MVS)
//---------------------------------------------------------
class Semaphore
{
Expand Down Expand Up @@ -256,80 +257,6 @@ class Semaphore
}
}
};
#elif defined(__MVS__)
//---------------------------------------------------------
// Semaphore (MVS aka z/OS)
//---------------------------------------------------------
class Semaphore
{
private:
sem_t m_sema;

Semaphore(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
Semaphore& operator=(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;

public:
Semaphore(int initialCount = 0)
{
assert(initialCount >= 0);
int rc = sem_init(&m_sema, 0, initialCount);
assert(rc == 0);
(void)rc;
}

~Semaphore()
{
sem_destroy(&m_sema);
}

bool wait()
{
// http://stackoverflow.com/questions/2013181/gdb-causes-sem-wait-to-fail-with-eintr-error
int rc;
do {
rc = sem_wait(&m_sema);
} while (rc == -1 && errno == EINTR);
return rc == 0;
}

bool try_wait()
{
int rc;
do {
rc = sem_trywait(&m_sema);
} while (rc == -1 && errno == EINTR);
return rc == 0;
}

bool timed_wait(std::uint64_t usecs)
{
struct timespec ts;
const int usecs_in_1_sec = 1000000;
const int nsecs_in_1_sec = 1000000000;

ts.tv_sec = usecs / usecs_in_1_sec;
ts.tv_nsec = (usecs % usecs_in_1_sec) * 1000;

int rc;
do {
rc = sem_timedwait(&m_sema, &ts);
} while (rc == -1 && errno == EINTR);
return rc == 0;
}

void signal()
{
while (sem_post(&m_sema) == -1);
}

void signal(int count)
{
while (count-- > 0)
{
while (sem_post(&m_sema) == -1);
}
}
};
#else
#error Unsupported platform! (No semaphore wrapper available)
#endif
Expand Down
13 changes: 13 additions & 0 deletions third_party/libpg_query/pg_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <mutex>
#include <cstring>

#ifdef __MVS__
#include <zos-tls.h>
#endif

// max parse tree size approx 100 MB, should be enough
#define PG_MALLOC_SIZE 10240
Expand All @@ -26,7 +29,17 @@ struct pg_parser_state_str {
size_t malloc_ptr_size;
};

#ifdef __MVS__
// --------------------------------------------------------
// Permanent - WIP
// static __tlssim<parser_state> pg_parser_state_impl();
// #define pg_parser_state (*pg_parser_state_impl.access())
// --------------------------------------------------------
// Temporary
static parser_state pg_parser_state;
#else
static __thread parser_state pg_parser_state;
#endif

#ifndef __GNUC__
__thread PGNode *duckdb_newNodeMacroHolder;
Expand Down
9 changes: 9 additions & 0 deletions third_party/libpg_query/src_backend_parser_scansup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "parser/scansup.hpp"
#include "mb/pg_wchar.hpp"

#ifdef __MVS__
#include <zos-tls.h>
#endif

namespace duckdb_libpgquery {

/* ----------------
Expand Down Expand Up @@ -60,7 +64,12 @@ char *downcase_truncate_identifier(const char *ident, int len, bool warn) {
return downcase_identifier(ident, len, warn, true);
}

#ifdef __MVS__
static __tlssim<bool> pg_preserve_identifier_case_impl(false);
#define pg_preserve_identifier_case (*pg_preserve_identifier_case_impl.access())
#else
static __thread bool pg_preserve_identifier_case = false;
#endif

void set_preserve_identifier_case(bool preserve) {
pg_preserve_identifier_case = preserve;
Expand Down
4 changes: 4 additions & 0 deletions tools/shell/linenoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
#include "utf8proc_wrapper.hpp"
#include <unordered_set>
#include <vector>
#ifdef __MVS__
#include <strings.h>
#include <sys/time.h>
#endif

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
// disable highlighting on windows (for now?)
Expand Down
4 c 99EB hanges: 2 additions & 2 deletions tools/sqlite3_api_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if(NOT AMALGAMATION_BUILD)
endif()
link_threads(sqlite3_api_wrapper_static)

if(NOT WIN32)
if(NOT WIN32 AND NOT ZOS)
add_library(sqlite3_api_wrapper SHARED ${SQLITE_API_WRAPPER_FILES})
target_link_libraries(sqlite3_api_wrapper duckdb ${DUCKDB_EXTRA_LINK_FLAGS})
link_threads(sqlite3_api_wrapper)
Expand All @@ -37,7 +37,7 @@ include_directories(test/include)
add_subdirectory(test)

add_executable(test_sqlite3_api_wrapper ${SQLITE_TEST_FILES})
if(WIN32)
if(WIN32 OR ZOS)
target_link_libraries(test_sqlite3_api_wrapper sqlite3_api_wrapper_static)
else()
target_link_libraries(test_sqlite3_api_wrapper sqlite3_api_wrapper)
Expand Down
0