Skip to content

Commit

Permalink
Initial changes for Open XL z/os support
Browse files Browse the repository at this point in the history
Includes all the initial work done a while ago made
in order to support compiling with Open XL in context
of z/OS.
  • Loading branch information
Deigue committed Apr 24, 2024
1 parent e2d8e0f commit f778bc3
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 19 deletions.
6 changes: 5 additions & 1 deletion include_core/AtomicSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
inline void __yield() { _mm_pause(); }
#elif defined(__GNUC__) && (defined(J9X86) || defined(J9HAMMER)) /* defined(_MSC_VER) */
inline void __yield() { __asm volatile ("pause"); }
#elif defined(J9ZOS390) /* defined(__GNUC__) && (defined(J9X86) || defined(J9HAMMER)) */
#elif defined(__clang__) && defined(J9ZOS390)
inline void __yield() { __asm volatile ("* AtomicOperations::__yield"); }
#elif defined(J9ZOS390)
#pragma convlit(suspend)
inline void __yield() { __asm__ volatile (" nop 0"); }
#pragma convlit(resume)
Expand All @@ -102,6 +104,8 @@
#pragma convlit(suspend)
inline void __nop() { __asm__ volatile (" nop 0"); }
#pragma convlit(resume)
#elif defined(J9ZOS390) && defined(__clang__)
inline void __nop() { __asm__ volatile (" NOP"); }
#else /* GCC && XL */
inline void __nop() { __asm__ volatile ("nop"); }
#endif
Expand Down
2 changes: 2 additions & 0 deletions include_core/omrsig.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ typedef __sighandler_t sighandler_t;
typedef void (*sighandler_t)(int sig);
#elif defined(J9ZOS390) || defined(AIXPPC)
typedef void (*sighandler_t)(int sig);
#if !defined(__GNUC__)
#define __THROW
#endif
#elif defined(OMR_OS_WINDOWS)
/* Use sig_handler_t instead of sighandler_t for Windows. Define it for compatibility. */
#define sig_handler_t sighandler_t
Expand Down
2 changes: 1 addition & 1 deletion omrsigcompat/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ top_srcdir := ..
include $(top_srcdir)/omrmakefiles/configure.mk

MODULE_NAME := omrsig
ARTIFACT_TYPE := c_shared
ARTIFACT_TYPE := cxx_shared
OBJECTS := omrsig
OBJECTS := $(addsuffix $(OBJEXT),$(OBJECTS))
ifeq (win,$(OMR_HOST_OS))
Expand Down
1 change: 1 addition & 0 deletions port/common/omrgetsysname.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "omrcomp.h"

struct OMRPortLibrary;
/**
* Get the zOS SYSNAME sysparm.
*
Expand Down
2 changes: 1 addition & 1 deletion port/unix/omrshmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ omrshmem_openSharedMemory (OMRPortLibrary *portLibrary, intptr_t fd, const char
goto failDontUnlink;
}
} else {
#if defined(__GNUC__) || defined(AIXPPC)
#if (defined(__GNUC__) || defined(AIXPPC)) && !defined(J9ZOS390)
#if defined(OSX)
/*Use ._key for OSX*/
if (buf.shm_perm._key != controlinfo->common.ftok_key)
Expand Down
2 changes: 1 addition & 1 deletion port/unix/omrshsem_deprecated.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ omrshsem_openSemaphore(struct OMRPortLibrary *portLibrary, intptr_t fd, char *ba
goto failDontUnlink;
}
} else {
#if defined(__GNUC__) || defined(AIXPPC) || defined(OMRZTPF)
#if (defined(__GNUC__) || defined(AIXPPC) || defined(J9ZTPF)) && !defined(J9ZOS390)
#if defined(OSX)
/*Use _key for OSX*/
if (buf.sem_perm._key != controlinfo->ftok_key)
Expand Down
17 changes: 14 additions & 3 deletions port/zos390/omrintrospect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,26 @@
#include "omrintrospect_common.h"
#include "omrutil.h"

#pragma linkage(getthent, OS_UPSTACK)
#if defined(OMR_ENV_DATA64)
#pragma linkage(getthent, OS)
#pragma map(getthent, "BPX4GTH")
#else
#pragma linkage(getthent, OS_UPSTACK)
#pragma map(getthent, "BPX1GTH")
#endif

#pragma linkage(pthread_quiesce, OS_UPSTACK)
#if defined(OMR_ENV_DATA64)
#pragma map(pthread_quiesce, "BPX4PTQ")
#else
#pragma linkage(pthread_quiesce, OS_UPSTACK)
#pragma map(pthread_quiesce, "BPX1PTQ")
#endif

#if defined(OMR_ENV_DATA64)
#else
#pragma linkage(pthread_quiesce_and_get_np_X, OS_UPSTACK)
#pragma map(pthread_quiesce_and_get_np_X, "BPX1PQG")
#endif

#ifdef MAX_NAME
#undef MAX_NAME
Expand All @@ -60,8 +64,11 @@

typedef __mcontext_t_ thread_context;


#if defined(__clang__)
#pragma pack(push, 1)
#else
#pragma pack(packed)
#endif

/* Program routine entry area (XPLINK) */
typedef struct XPLINK_Routine_entry {
Expand Down Expand Up @@ -633,6 +640,10 @@ struct tcb {
#define QUIESCE_SRB 9 /* Quiesce threads type = SRBs @DGA */
/* Skip 10 and 11 due to collision with BPXZCONS Freeze/Unfreeze Fast */

#if defined(__clang__)
#pragma pack(pop)
#else
#pragma pack(reset)
#endif

#endif
16 changes: 8 additions & 8 deletions port/zos390/omrsimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* The RSM Internal Table (RIT) reached from the `ritp' address field in PVT. The
* field of interest here is the total amount of online storage.
*/
typedef _Packed struct J9RIT {
typedef struct __attribute__((packed)) J9RIT {
uint8_t ritFiller1[296]; /**< 0:296 Fields irrelevant to our current purpose. */
uint64_t rittos; /**< 296:8 The total amount of online storage at IPL */
/**< Ignore rest of the fields in RIT. */
Expand All @@ -58,7 +58,7 @@ typedef _Packed struct J9RIT {
* The Page Vector Table (PVT). Reached from the virtual address found at offset 356 of
* CVT.
*/
typedef _Packed struct J9PVT {
typedef struct __attribute__((packed)) J9PVT {
uint8_t pvtFiller1[4]; /**< 0:4 PVT Control Block Identifier 'PVT' */
J9RIT *__ptr32 pvtritp; /**< 4:4 Address of the start of RSM Internal Table (RIT) */
/**< Ignore rest of the fields in PVT. */
Expand All @@ -73,7 +73,7 @@ typedef _Packed struct J9PVT {
* CCVCPUCT - No of online CPUs
* CCVUTILP - System CPU utilization
*/
typedef _Packed struct J9CCT {
typedef struct __attribute__((packed)) J9CCT {
uint8_t cctFiller1[72]; /**< 0:72 Ignore fields not relevant to current implementation */
uint32_t ccvrbswt; /**< 72:4 Recent base system wait time */
uint8_t cctFiller2[4]; /**< 76:4 Ignore fields not relevant to current implementation */
Expand All @@ -91,7 +91,7 @@ typedef _Packed struct J9CCT {
* Fields of interest:
* RMCTCCT - CPU Management Control Table
*/
typedef _Packed struct J9RMCT {
typedef struct __attribute__((packed)) J9RMCT {
uint8_t rmctname[4]; /**< 0:4 Block Identification */
J9CCT *__ptr32 rmctcct; /**< 4:4 CPU Management Control Table */
/**< Ignore rest of the RMCT */
Expand All @@ -106,7 +106,7 @@ typedef _Packed struct J9RMCT {
* ASMNVSC - Count of non-VIO allocated slots
* ASMERRS - Count of bad slots
*/
typedef _Packed struct J9ASMVT {
typedef struct __attribute__((packed)) J9ASMVT {
uint8_t asmvtFiller1[112]; /**< 0:112 Ignore fields not relevant to current implementation */
uint32_t asmslots; /**< 112:4 Count of total local slots in all open local page data sets */
uint32_t asmvsc; /**< 116:4 Count of total local slots allocated to VIO private area pages */
Expand All @@ -122,7 +122,7 @@ typedef _Packed struct J9ASMVT {
* RCEPOOL - No of frames currently available to system
* RCEAFC - Total no of frames currently on all available frame queues
*/
typedef _Packed struct J9RCE {
typedef struct __attribute__((packed)) J9RCE {
uint8_t rceid[4]; /**< 0:4 RCE control block Id */
int32_t rcepool; /**< 4:4 No of frames currently available to system */
uint8_t rceFiller1[128]; /**< 8:128 Ignore fields not relevant to current implementation */
Expand All @@ -140,7 +140,7 @@ typedef _Packed struct J9RCE {
* CVTASMVT - Pointer to auxiliary storage management vector table (ASMVT)
* CVTRCEP - Address of the RSM Control & Enumeration Area
*/
typedef _Packed struct J9CVT {
typedef struct __attribute__((packed)) J9CVT {
uint8_t cvtFiller1[356]; /**< 0:356 Ignore fields not relevant to current implementation */
J9PVT *__ptr32 cvtpvtp; /**< 356:4 Address of Page Vector Table (PVT). */
uint8_t cvtFiller2[244]; /**< 360:244 Ignore fields not relevant to current implementation */
Expand All @@ -160,7 +160,7 @@ typedef _Packed struct J9CVT {
* Fields of interest:
* FLCCVT - Address of CVT after IPL
*/
typedef _Packed struct J9PSA {
typedef struct __attribute__((packed)) J9PSA {
uint8_t psaFiller1[16]; /**< 0:16 Ignore 16 bytes before CVT pointer */
J9CVT *__ptr32 flccvt; /**< 16:4 Address of CVT after IPL */
/**< Ignore rest of the PSA */
Expand Down
6 changes: 5 additions & 1 deletion thread/common/thrprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,11 @@ omrthread_get_handle(omrthread_t thread)
In order to work around the compiler error, we have to reach inside
the structure do the dirty work. The handle may not even be correct! */
uintptr_t *tempHandle;
tempHandle = (uintptr_t *)&(thread->handle.__[0]);
#if defined(__GNUC__)
tempHandle = (uintptr_t *)&(thread->handle.__);
#else
tempHandle = (uintptr_t *)&(thread->handle.__[0]);
#endif
return *tempHandle;
#else
return (uintptr_t)thread->handle;
Expand Down
8 changes: 8 additions & 0 deletions thread/zos390/omrgetthent.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
#pragma linkage(BPX1GTH,OS)
#endif /* _LP64 */

#if defined(__clang__)
#pragma pack(push, 1)
#else
#pragma pack(packed)
#endif

/*
PGTHA DSECT , I N P U T - - - - - - - - - - -
Expand Down Expand Up @@ -553,6 +557,10 @@ struct j9pg_thread_data {
char padding[256];
};

#if defined(__clang__)
#pragma pack(pop)
#else
#pragma pack(reset)
#endif

#endif /* OMRGETTHENT_H */
7 changes: 6 additions & 1 deletion util/a2e/headers/prefixpath.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
#ifndef COMPILER_HEADER_PATH_PREFIX
#define COMPILER_HEADER_PATH_PREFIX /usr/include
#endif

#if defined(__clang__)
#define PREFIXPATH(h) <COMPILER_HEADER_PATH_PREFIX/h>
#else
#define STR2(x) <##x##>
/* Need to do double indirection to force the macro to be expanded */
#define STR(x) STR2(x)
#define PREFIXPATH(h) STR(COMPILER_HEADER_PATH_PREFIX/h)
#endif
#endif /* __clang */
#endif /* _PREFIX_PATH */
4 changes: 2 additions & 2 deletions util/omrutil/gettimebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ getTimebase(void)
#endif /* OMR_ENV_DATA64 */
#endif /* GCC 4.8 */

#elif defined(LINUX) && defined(S390)
asm("stck %0" : "=m" (tsc));
#elif (defined(LINUX) && defined(S390)) || (defined(__clang__) && defined(J9ZOS390))
asm(" stck %0" : "=m" (tsc));
#elif defined(J9ZOS390)
__stck((unsigned long long*)&tsc);
#elif defined(LINUX) && (defined(OMR_ARCH_ARM) || defined(OMR_ARCH_RISCV) || defined(RISCV64))
Expand Down

0 comments on commit f778bc3

Please sign in to comment.