Skip to content

Commit

Permalink
Explicit header definitions for Open XL warnings
Browse files Browse the repository at this point in the history
Open XL 2.1 on z/OS reports some of the implicit declarations
as errors, and requires these to be explicitly defined. Most of
the underlying changes are to address this concern and some other
fixes pertaining to compilation errors.

zos.cmake now uses XOPEN_SOURCE=600, which implies/includes already
namespaces from POSIX_SOURCE, XOPEN_SOURCE_THREADED, ISOC99_SOURCE.
See feature test macros: https://www.ibm.com/docs/en/zos/3.1.0?topic=files-feature-test-macros
timer.h - unneeded conditional removed
Array.hpp - uninitialized variable addressed

Signed-off-by: Gaurav Chaudhari <[email protected]>
  • Loading branch information
Deigue committed Jul 24, 2024
1 parent 56cb81f commit 47e80bf
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 20 deletions.
4 changes: 1 addition & 3 deletions cmake/modules/platform/os/zos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@

list(APPEND OMR_PLATFORM_DEFINITIONS
-D_ALL_SOURCE
-D_XOPEN_SOURCE=600
-D_OPEN_THREADS=3
-D_POSIX_SOURCE
-D_XOPEN_SOURCE_EXTENDED
-D_ISOC99_SOURCE
-D__STDC_LIMIT_MACROS
-DLONGLONG
-DJ9ZOS390
Expand Down
2 changes: 1 addition & 1 deletion compiler/cs2/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AIXTimer {
};

typedef AIXTimer PlatformTimer;
#elif defined(LINUX) || defined(OSX) || (defined (__MVS__) && defined (_XOPEN_SOURCE_EXTENDED))
#elif defined(LINUX) || defined(OSX) || defined (__MVS__)
/**
* \brief Linux-specific timer class.
*
Expand Down
2 changes: 1 addition & 1 deletion compiler/infra/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ template<class T> class TR_Array
uint32_t prevSize = _nextIndex * sizeof(T);
uint32_t newSize = size * sizeof(T);

char * tmpArray;
char * tmpArray = nullptr;
if (_trMemory)
tmpArray = (char*)_trMemory->allocateMemory(newSize, _allocationKind, TR_MemoryBase::Array);
else if (_trPersistentMemory)
Expand Down
4 changes: 4 additions & 0 deletions include_core/unix/thrdsup.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ int linux_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, c
intptr_t init_thread_library(void);
intptr_t set_pthread_priority(pthread_t handle, omrthread_prio_t j9ThreadPriority);
intptr_t set_pthread_name(pthread_t self, pthread_t thread, const char *name);
intptr_t sem_init_zos(j9sem_t s, int pShared, int initValue);
intptr_t sem_destroy_zos(j9sem_t s);
intptr_t sem_wait_zos(j9sem_t s);
intptr_t sem_post_zos(j9sem_t s);

extern struct J9ThreadLibrary default_library;

Expand Down
2 changes: 1 addition & 1 deletion port/zos390/omrcel4ro31.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ omr_cel4ro31_call(OMR_CEL4RO31_infoBlock *infoBlock);
* @return whether CEL4RO31 runtime support is available.
*/
BOOLEAN
omr_cel4ro31_isSupported(void);
omr_cel4ro31_is_supported(void);

/**
* A helper routine to return an error message associated with the CEL4RO31 return code.
Expand Down
1 change: 1 addition & 0 deletions port/zos390/omrgetjobid.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <stdlib.h>
#include "omrport.h"
#include "omrgetjobid.h"
#include "omrportpriv.h"

#define JOBID_STRING_LENGTH 9

Expand Down
1 change: 1 addition & 0 deletions port/zos390/omrgetjobname.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void
omrget_jobname(struct OMRPortLibrary *portLibrary, char *jobname, uintptr_t length)
{
char *tmp_jobname = (char *)__malloc31(J9_MAX_JOBNAME);
extern void _JOBNAME(char *); /* defined in omrjobname.s */

if (NULL != tmp_jobname) {
char *ascname = NULL;
Expand Down
1 change: 1 addition & 0 deletions port/zos390/omrgetsysname.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*******************************************************************************/

#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
#include "omrgetsysname.h"

Expand Down
1 change: 1 addition & 0 deletions port/zos390/omrgetuserid.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ omrget_userid(char *userid, uintptr_t length)
uintptr_t result = 0;

userid[0] = '\0';
extern void _USERID(char *); /* defined in omruserid.s */

if (NULL != tmp_userid) {
char *ascname = NULL;
Expand Down
20 changes: 11 additions & 9 deletions port/zos390/omrintrospect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@
#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
#else /* defined(OMR_ENV_DATA64) */
#pragma linkage(getthent, OS_UPSTACK)
#pragma map(getthent, "BPX1GTH")
#endif
#endif /* defined(OMR_ENV_DATA64) */

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

#if !defined(OMR_ENV_DATA64)
#pragma linkage(pthread_quiesce_and_get_np_X, OS_UPSTACK)
#pragma map(pthread_quiesce_and_get_np_X, "BPX1PQG")
#endif /* !defined(OMR_ENV_DATA64) */

#ifdef MAX_NAME
#undef MAX_NAME
Expand All @@ -60,8 +63,7 @@

typedef __mcontext_t_ thread_context;


#pragma pack(packed)
#pragma pack(1)

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

#pragma pack(reset)
#pragma pack(pop)

#endif
1 change: 1 addition & 0 deletions port/zos390/omrosbacktrace_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/

#include "omrport.h"
#include "omrportpriv.h"
#include "omrsignal_context.h"
#include <stdio.h>
#include <signal.h>
Expand Down
10 changes: 9 additions & 1 deletion port/zos390/omrosdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* @brief Dump formatting
*/

#if defined(__open_xl__)
#define _EXT
#endif /* defined(__open_xl__) */

#include <errno.h>
#include <stdio.h>
Expand All @@ -37,7 +40,9 @@
#include <time.h>
#include <pwd.h>
#include <ctest.h>
#include "omrgetjobname.h"
#include "omrport.h"
#include "omrportpriv.h"
#if defined(J9ZOS390) && !defined(OMR_EBCDIC)
#include "atoe.h"
#endif
Expand Down Expand Up @@ -321,7 +326,7 @@ tdump_wrapper(struct OMRPortLibrary *portLibrary, char *filename, char *dsnName)
static intptr_t
tdump(struct OMRPortLibrary *portLibrary, char *asciiLabel, char *ebcdicLabel, uint32_t *returnCode, uint32_t *reasonCode)
{
struct ioparms_t {
struct ioparmss_t {
uint64_t plist[256];
uint32_t retcode;
uint32_t rsncode;
Expand All @@ -333,6 +338,9 @@ tdump(struct OMRPortLibrary *portLibrary, char *asciiLabel, char *ebcdicLabel, u
char dsn[256];
} *dsnPattern31;

/* Defined in omrgenerate_ieat_dump.s */
extern void _TDUMP(struct ioparms_t *ioparms, struct dsn_pattern_t *dsn_pattern);

/* _TDUMP subroutine expects 31 bit addresses */
ioParms31 = __malloc31(sizeof(*ioParms31));
if (ioParms31 == NULL) {
Expand Down
1 change: 1 addition & 0 deletions port/zos390/omrsignal_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "omrport.h"
#include "omrportpriv.h"
#include <strings.h>
#include <unistd.h>
#include "omrsignal_context.h"
#include "omrceeocb.h"
Expand Down
1 change: 1 addition & 0 deletions port/zos390/omrsignal_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ uint32_t infoForVR(struct OMRPortLibrary *portLibrary, OMRUnixSignalInfo *info,
uint32_t infoForModule(struct OMRPortLibrary *portLibrary, struct OMRUnixSignalInfo *info, int32_t index, const char **name, void **value);
uint32_t infoForControl(struct OMRPortLibrary *portLibrary, struct OMRUnixSignalInfo *info, int32_t index, const char **name, void **value);
uint32_t infoForSignal(struct OMRPortLibrary *portLibrary, struct OMRUnixSignalInfo *info, int32_t index, const char **name, void **value);
void fillInJumpInfo(struct OMRPortLibrary *portLibrary, void *contextInfo, void *jumpInfo);
void fillInUnixSignalInfo(struct OMRPortLibrary *portLibrary, void *contextInfo, struct OMRUnixSignalInfo *signalInfo);
BOOLEAN checkIfResumableTrapsSupported(struct OMRPortLibrary *portLibrary);

4 changes: 0 additions & 4 deletions thread/unix/thrdsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ intptr_t init_thread_library(void);
static intptr_t zos_init_yielding(void);
#endif
intptr_t sem_getvalue_zos(j9sem_t s);
intptr_t sem_init_zos(j9sem_t s, int pShared, int initValue);
void call_omrthread_init(void);
intptr_t sem_destroy_zos(j9sem_t s);
intptr_t sem_wait_zos(j9sem_t s);
intptr_t sem_trywait_zos(j9sem_t s);
intptr_t sem_post_zos(j9sem_t s);

#if defined (OMRZTPF)
void ztpf_init_proc(void);
Expand Down
1 change: 1 addition & 0 deletions util/omrutil/unix/zos/getstoragekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
uintptr_t
getStorageKey(void)
{
extern uintptr_t _GETPSW(); /* defined in getpsw.s */
/* The storage key is returned in bits 8-11 of the PSW */
return ((_GETPSW() >> 20) & 0xF);
}

0 comments on commit 47e80bf

Please sign in to comment.