From d913a2c23718a26e5402bf1b6861dce4ecc04684 Mon Sep 17 00:00:00 2001 From: Gaurav Chaudhari Date: Mon, 22 Jul 2024 14:35:45 -0400 Subject: [PATCH] Open XL attribute packed and misc fixes These changes includes some of the uncategorized fixes, header fixes and the recommended __attribute__((packed)) notation usage that works with both Open XL and XLC. Signed-off-by: Gaurav Chaudhari --- runtime/port/sysvipc/j9shmem.c | 3 +- runtime/port/sysvipc/j9shsem_deprecated.c | 2 +- runtime/port/zos390/j9hypervisor_systemz.h | 35 ++++++++++++++++++++++ runtime/port/zos390/j9sysinfo_helpers.h | 4 +-- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 runtime/port/zos390/j9hypervisor_systemz.h diff --git a/runtime/port/sysvipc/j9shmem.c b/runtime/port/sysvipc/j9shmem.c index e215ac681b3..d214daa834f 100644 --- a/runtime/port/sysvipc/j9shmem.c +++ b/runtime/port/sysvipc/j9shmem.c @@ -47,6 +47,7 @@ #include "portpriv.h" #include "j9sharedhelper.h" #include "j9shmem.h" +#include "omrutil.h" #include "protect_helpers.h" #include "j9SysvIPCWrappers.h" #include "shchelp.h" @@ -1726,7 +1727,7 @@ openSharedMemory (J9PortLibrary *portLibrary, intptr_t fd, const char *baseFile, goto failDontUnlink; } } else { -#if defined(__GNUC__) || defined(AIXPPC) +#if (defined(__GNUC__) && !defined(J9ZOS390)) || defined(AIXPPC) #if defined(OSX) /*Use ._key for OSX*/ if (buf.shm_perm._key != controlinfo->common.ftok_key) diff --git a/runtime/port/sysvipc/j9shsem_deprecated.c b/runtime/port/sysvipc/j9shsem_deprecated.c index 808f356a953..421a70169d1 100644 --- a/runtime/port/sysvipc/j9shsem_deprecated.c +++ b/runtime/port/sysvipc/j9shsem_deprecated.c @@ -1077,7 +1077,7 @@ openSemaphore(struct J9PortLibrary *portLibrary, intptr_t fd, char *baseFile, j9 goto failDontUnlink; } } else { -#if defined(__GNUC__) || defined(AIXPPC) || defined(J9ZTPF) +#if (defined(__GNUC__) && !defined(J9ZOS390)) || defined(AIXPPC) || defined(J9ZTPF) #if defined(OSX) /*Use _key for OSX*/ if (buf.sem_perm._key != controlinfo->ftok_key) diff --git a/runtime/port/zos390/j9hypervisor_systemz.h b/runtime/port/zos390/j9hypervisor_systemz.h new file mode 100644 index 00000000000..a756deb0fe1 --- /dev/null +++ b/runtime/port/zos390/j9hypervisor_systemz.h @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright IBM Corp. and others 2024 + * + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which accompanies this + * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ + * or the Apache License, Version 2.0 which accompanies this distribution and + * is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * This Source Code may also be made available under the following + * Secondary Licenses when the conditions for such availability set + * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU + * General Public License, version 2 with the GNU Classpath + * Exception [1] and GNU General Public License, version 2 with the + * OpenJDK Assembly Exception [2]. + * + * [1] https://www.gnu.org/software/classpath/license.html + * [2] https://openjdk.org/legal/assembly-exception.html + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 + *******************************************************************************/ + +/** + * @file + * @ingroup Port + * @brief Hypervisor Detection helper functions common to z/VM & and PR/SM Hypervisor + */ + +#ifndef J9HYPERVISOR_SYSTEMZ_H_ +#define J9HYPERVISOR_SYSTEMZ_H_ + +intptr_t +systemz_startup(struct J9PortLibrary *portLibrary); + +#endif diff --git a/runtime/port/zos390/j9sysinfo_helpers.h b/runtime/port/zos390/j9sysinfo_helpers.h index 5357676ef9f..75b82f45cbe 100644 --- a/runtime/port/zos390/j9sysinfo_helpers.h +++ b/runtime/port/zos390/j9sysinfo_helpers.h @@ -43,7 +43,7 @@ extern "C" { */ extern int getstfle(int lastDoubleWord, uint64_t *bits); -typedef __packed struct J9LPDat { +typedef __attribute__((packed)) struct J9LPDat { int32_t length; /**< 0:4 length of area */ uint8_t version; /**< 4:1 version */ uint8_t flags; /**< 5:1 flags */ @@ -76,7 +76,7 @@ typedef __packed struct J9LPDat { uint8_t reserved2[8]; /* 96:8 reserved for future use */ } J9LPDat; -typedef __packed struct J9LPDatServiceTableEntry { +typedef __attribute__((packed)) struct J9LPDatServiceTableEntry { int32_t serviceUncapped; /**< 0:4 basic-mode service units accumulated while the partition * was uncapped */