diff --git a/runtime/oti/j9porterror.h b/runtime/oti/j9porterror.h index f294accf802..feea14ff2b5 100644 --- a/runtime/oti/j9porterror.h +++ b/runtime/oti/j9porterror.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 1998, 2015 IBM Corp. and others + * Copyright (c) 1998, 2017 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -245,15 +245,15 @@ * 0xFFF5xxxx for __getipc (zOS) * @{ */ -#define J9PORT_ERROR_SYSV_IPC_FTOK_ERROR (-2 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SEMGET_ERROR (-3 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SEMCTL_ERROR (-4 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SEMOP_ERROR (-5 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SHMGET_ERROR (-6 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SHMCTL_ERROR (-7 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SHMAT_ERROR (-8 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_SHMDT_ERROR (-9 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) -#define J9PORT_ERROR_SYSV_IPC_GETIPC_ERROR (-10 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT) +#define J9PORT_ERROR_SYSV_IPC_FTOK_ERROR ((I_32)((U_32)-2 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SEMGET_ERROR ((I_32)((U_32)-3 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SEMCTL_ERROR ((I_32)((U_32)-4 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SEMOP_ERROR ((I_32)((U_32)-5 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SHMGET_ERROR ((I_32)((U_32)-6 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SHMCTL_ERROR ((I_32)((U_32)-7 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SHMAT_ERROR ((I_32)((U_32)-8 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_SHMDT_ERROR ((I_32)((U_32)-9 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) +#define J9PORT_ERROR_SYSV_IPC_GETIPC_ERROR ((I_32)((U_32)-10 << J9PORT_ERROR_SYSTEM_CALL_CODE_SHIFT)) #define J9PORT_ERROR_SYSV_IPC_ERRNO_BASE -750 #define J9PORT_ERROR_SYSV_IPC_ERRNO_EACCES (J9PORT_ERROR_SYSV_IPC_ERRNO_BASE) diff --git a/runtime/port/sysvipc/j9shmem.c b/runtime/port/sysvipc/j9shmem.c index 42b8d43be8c..e25f790e413 100644 --- a/runtime/port/sysvipc/j9shmem.c +++ b/runtime/port/sysvipc/j9shmem.c @@ -1613,14 +1613,16 @@ openSharedMemory (J9PortLibrary *portLibrary, intptr_t fd, const char *baseFile, goto failDontUnlink; } } else { -#if defined (__GNUC__) || defined (AIXPPC) -#if defined (__GNUC__) - /*Use .__key for __GNUC__*/ - if (buf.shm_perm.__key != controlinfo->common.ftok_key) -#endif -#if defined (AIXPPC) +#if defined(__GNUC__) || defined(AIXPPC) +#if defined(OSX) + /*Use ._key for OSX*/ + if (buf.shm_perm._key != controlinfo->common.ftok_key) +#elif defined(AIXPPC) /*Use .key for AIXPPC*/ if (buf.shm_perm.key != controlinfo->common.ftok_key) +#elif defined(__GNUC__) + /*Use .__key for __GNUC__*/ + if (buf.shm_perm.__key != controlinfo->common.ftok_key) #endif { Trc_PRT_shmem_j9shmem_openSharedMemory_Msg("The pair in our control file is no longer valid."); diff --git a/runtime/port/sysvipc/j9shsem_deprecated.c b/runtime/port/sysvipc/j9shsem_deprecated.c index df4116f8a5f..ded21cee931 100644 --- a/runtime/port/sysvipc/j9shsem_deprecated.c +++ b/runtime/port/sysvipc/j9shsem_deprecated.c @@ -1077,18 +1077,19 @@ openSemaphore(struct J9PortLibrary *portLibrary, intptr_t fd, char *baseFile, j9 goto failDontUnlink; } } else { -#if defined (__GNUC__) || defined (AIXPPC) || defined(J9ZTPF) -#if defined (__GNUC__) && !defined(J9ZTPF) - /*Use .__key for __GNUC__*/ - if (buf.sem_perm.__key != controlinfo->ftok_key) -#endif -#if defined (AIXPPC) +#if defined(__GNUC__) || defined(AIXPPC) || defined(J9ZTPF) +#if defined(OSX) + /*Use _key for OSX*/ + if (buf.sem_perm._key != controlinfo->ftok_key) +#elif defined(AIXPPC) /*Use .key for AIXPPC*/ if (buf.sem_perm.key != controlinfo->ftok_key) -#endif -#if defined(J9ZTPF) - /*Use .key for z/TPF */ +#elif defined(J9ZTPF) + /*Use .key for z/TPF */ if (buf.key != controlinfo->ftok_key) +#elif defined(__GNUC__) + /*Use .__key for __GNUC__*/ + if (buf.sem_perm.__key != controlinfo->ftok_key) #endif { Trc_PRT_shsem_j9shsem_opensemaphore_Msg("The pair in our control file is no longer valid.");