diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 47a078d5b63..e95f32f4f7d 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -480,12 +480,13 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], #### OS DEFINES, these should be independent on toolchain if test "x$OPENJDK_TARGET_OS" = xlinux; then CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64" - CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" + CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64" elif test "x$OPENJDK_TARGET_OS" = xmacosx; then CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE" CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" elif test "x$OPENJDK_TARGET_OS" = xaix; then CFLAGS_OS_DEF_JVM="-DAIX -D_LARGE_FILES" + CFLAGS_OS_DEF_JDK="-D_LARGE_FILES" elif test "x$OPENJDK_TARGET_OS" = xbsd; then CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE" elif test "x$OPENJDK_TARGET_OS" = xwindows; then @@ -543,7 +544,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], ALWAYS_DEFINES_JVM="-D_GNU_SOURCE" elif test "x$TOOLCHAIN_TYPE" = xxlc; then ALWAYS_DEFINES_JVM="-D_REENTRANT" - ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" + ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -DSTDC" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then # Access APIs for Windows 8 and above # see https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 diff --git a/make/modules/jdk.hotspot.agent/Lib.gmk b/make/modules/jdk.hotspot.agent/Lib.gmk index d21c969c188..ebdbfecd461 100644 --- a/make/modules/jdk.hotspot.agent/Lib.gmk +++ b/make/modules/jdk.hotspot.agent/Lib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,10 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(call isTargetOs, linux), true) - SA_CFLAGS := -D_FILE_OFFSET_BITS=64 - -else ifeq ($(call isTargetOs, macosx), true) +ifeq ($(call isTargetOs, macosx), true) SA_CFLAGS := -D_GNU_SOURCE -mno-omit-leaf-frame-pointer \ -mstack-alignment=16 -fPIC LIBSA_EXTRA_SRC := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent diff --git a/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c b/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c index 991849697dd..f5fc6cf4295 100644 --- a/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c +++ b/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -138,13 +138,13 @@ void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) { char *args = NULL; jstring cmdexe = NULL; char fn[32]; - struct stat64 stat_buf; + struct stat stat_buf; /* * Stat /proc/ to get the user id */ snprintf(fn, sizeof fn, "/proc/%d", pid); - if (stat64(fn, &stat_buf) == 0) { + if (stat(fn, &stat_buf) == 0) { unix_getUserInfo(env, jinfo, stat_buf.st_uid); JNU_CHECK_EXCEPTION(env); } diff --git a/src/java.base/linux/native/libnio/ch/FileDispatcherImpl.c b/src/java.base/linux/native/libnio/ch/FileDispatcherImpl.c index 207e61431dc..02d3c57f1f3 100644 --- a/src/java.base/linux/native/libnio/ch/FileDispatcherImpl.c +++ b/src/java.base/linux/native/libnio/ch/FileDispatcherImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ Java_sun_nio_ch_FileDispatcherImpl_transferFrom0(JNIEnv *env, jobject this, jint srcFD = fdval(env, srcFDO); jint dstFD = fdval(env, dstFDO); - off64_t offset = (off64_t)position; + loff_t offset = (loff_t)position; size_t len = (size_t)count; jlong n = my_copy_file_range_func(srcFD, NULL, dstFD, &offset, len, 0); if (n < 0) { @@ -91,7 +91,7 @@ Java_sun_nio_ch_FileDispatcherImpl_transferTo0(JNIEnv *env, jobject this, if (append == JNI_TRUE) return IOS_UNSUPPORTED_CASE; - off64_t offset = (off64_t)position; + loff_t offset = (loff_t)position; jlong n; if (my_copy_file_range_func != NULL) { size_t len = (size_t)count; diff --git a/src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c b/src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c index cf8592e1ced..37628f5621a 100644 --- a/src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c +++ b/src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -165,7 +165,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_fs_LinuxNativeDispatcher_posix_1fadvise(JNIEnv* env, jclass this, jint fd, jlong offset, jlong len, jint advice) { - return posix_fadvise64((int)fd, (off64_t)offset, (off64_t)len, (int)advice); + return posix_fadvise((int)fd, (off_t)offset, (off_t)len, (int)advice); } // Copy all bytes from src to dst, within the kernel if possible, diff --git a/src/java.base/share/native/libjli/jli_util.h b/src/java.base/share/native/libjli/jli_util.h index d2ea01b1d41..cacb0d65cb0 100644 --- a/src/java.base/share/native/libjli/jli_util.h +++ b/src/java.base/share/native/libjli/jli_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,16 +100,7 @@ JLI_CmdToArgs(char *cmdline); #define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2)) #define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3)) #define JLI_Open open -#ifdef __linux__ -#define _LARGFILE64_SOURCE -#define JLI_Lseek lseek64 -#endif -#ifdef MACOSX #define JLI_Lseek lseek -#endif -#ifdef _AIX -#define JLI_Lseek lseek -#endif #endif /* _WIN32 */ /* diff --git a/src/java.base/share/native/libjli/wildcard.c b/src/java.base/share/native/libjli/wildcard.c index 5cb413d39d9..8aebc69cbef 100644 --- a/src/java.base/share/native/libjli/wildcard.c +++ b/src/java.base/share/native/libjli/wildcard.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,14 +100,6 @@ #include #endif /* Unix */ -#if defined(_AIX) - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 -#endif - static int exists(const char* filename) { diff --git a/src/java.base/share/native/libzip/zip_util.c b/src/java.base/share/native/libzip/zip_util.c index e4daedbe873..a996b450ad4 100644 --- a/src/java.base/share/native/libzip/zip_util.c +++ b/src/java.base/share/native/libzip/zip_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,11 +46,6 @@ #include "zip_util.h" #include -#ifdef _ALLBSD_SOURCE -#define off64_t off_t -#define mmap64 mmap -#endif - /* USE_MMAP means mmap the CEN & ENDHDR part of the zip file. */ #ifdef USE_MMAP #include @@ -656,7 +651,7 @@ readCEN(jzfile *zip, jint knownTotal) */ zip->mlen = cenpos - offset + cenlen + endhdrlen; zip->offset = offset; - mappedAddr = mmap64(0, zip->mlen, PROT_READ, MAP_SHARED, zip->zfd, (off64_t) offset); + mappedAddr = mmap(0, zip->mlen, PROT_READ, MAP_SHARED, zip->zfd, (off_t) offset); zip->maddr = (mappedAddr == (void*) MAP_FAILED) ? NULL : (unsigned char*)mappedAddr; diff --git a/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c b/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c index a54d5782547..c13f7334526 100644 --- a/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c +++ b/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,11 +49,6 @@ #if defined(_AIX) #include - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 #endif /** diff --git a/src/java.base/unix/native/libjava/TimeZone_md.c b/src/java.base/unix/native/libjava/TimeZone_md.c index eaf00fa1027..8124f3c0a9c 100644 --- a/src/java.base/unix/native/libjava/TimeZone_md.c +++ b/src/java.base/unix/native/libjava/TimeZone_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,12 +54,6 @@ static char *isFileIdentical(char* buf, size_t size, char *pathname); #define filegets fgets #define fileclose fclose -#if defined(_ALLBSD_SOURCE) -#define stat64 stat -#define lstat64 lstat -#define fstat64 fstat -#endif - #if defined(__linux__) || defined(_ALLBSD_SOURCE) static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; @@ -219,12 +213,12 @@ static char * isFileIdentical(char *buf, size_t size, char *pathname) { char *possibleMatch = NULL; - struct stat64 statbuf; + struct stat statbuf; char *dbuf = NULL; int fd = -1; int res; - RESTARTABLE(stat64(pathname, &statbuf), res); + RESTARTABLE(stat(pathname, &statbuf), res); if (res == -1) { return NULL; } @@ -264,7 +258,7 @@ isFileIdentical(char *buf, size_t size, char *pathname) static char * getPlatformTimeZoneID() { - struct stat64 statbuf; + struct stat statbuf; char *tz = NULL; FILE *fp; int fd; @@ -301,7 +295,7 @@ getPlatformTimeZoneID() /* * Next, try /etc/localtime to find the zone ID. */ - RESTARTABLE(lstat64(DEFAULT_ZONEINFO_FILE, &statbuf), res); + RESTARTABLE(lstat(DEFAULT_ZONEINFO_FILE, &statbuf), res); if (res == -1) { return NULL; } @@ -343,7 +337,7 @@ getPlatformTimeZoneID() return NULL; } - RESTARTABLE(fstat64(fd, &statbuf), res); + RESTARTABLE(fstat(fd, &statbuf), res); if (res == -1) { (void) close(fd); return NULL; diff --git a/src/java.base/unix/native/libjava/UnixFileSystem_md.c b/src/java.base/unix/native/libjava/UnixFileSystem_md.c index e275bc55f97..ffda8320d48 100644 --- a/src/java.base/unix/native/libjava/UnixFileSystem_md.c +++ b/src/java.base/unix/native/libjava/UnixFileSystem_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,21 +55,8 @@ #if !defined(NAME_MAX) #define NAME_MAX MAXNAMLEN #endif - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 - #define stat stat64 + #define statvfs statvfs64 #endif - -#if defined(_ALLBSD_SOURCE) - #ifndef MACOSX - #define statvfs64 statvfs - #define stat64 stat - #endif -#endif - /* -- Field IDs -- */ static struct { @@ -117,8 +104,8 @@ Java_java_io_UnixFileSystem_canonicalize0(JNIEnv *env, jobject this, static jboolean statMode(const char *path, int *mode) { - struct stat64 sb; - if (stat64(path, &sb) == 0) { + struct stat sb; + if (stat(path, &sb) == 0) { *mode = sb.st_mode; return JNI_TRUE; } @@ -229,8 +216,8 @@ Java_java_io_UnixFileSystem_getLastModifiedTime0(JNIEnv *env, jobject this, jlong rv = 0; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { - struct stat64 sb; - if (stat64(path, &sb) == 0) { + struct stat sb; + if (stat(path, &sb) == 0) { #if defined(_AIX) rv = (jlong)sb.st_mtime * 1000; rv += (jlong)sb.st_mtime_n / 1000000; @@ -254,8 +241,8 @@ Java_java_io_UnixFileSystem_getLength0(JNIEnv *env, jobject this, jlong rv = 0; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { - struct stat64 sb; - if (stat64(path, &sb) == 0) { + struct stat sb; + if (stat(path, &sb) == 0) { rv = sb.st_size; } } END_PLATFORM_STRING(env, path); @@ -409,9 +396,9 @@ Java_java_io_UnixFileSystem_setLastModifiedTime0(JNIEnv *env, jobject this, jboolean rv = JNI_FALSE; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { - struct stat64 sb; + struct stat sb; - if (stat64(path, &sb) == 0) { + if (stat(path, &sb) == 0) { struct timeval tv[2]; /* Preserve access time */ @@ -467,7 +454,7 @@ Java_java_io_UnixFileSystem_getSpace0(JNIEnv *env, jobject this, #ifdef MACOSX struct statfs fsstat; #else - struct statvfs64 fsstat; + struct statvfs fsstat; int res; #endif memset(&fsstat, 0, sizeof(fsstat)); @@ -491,7 +478,7 @@ Java_java_io_UnixFileSystem_getSpace0(JNIEnv *env, jobject this, } } #else - RESTARTABLE(statvfs64(path, &fsstat), res); + RESTARTABLE(statvfs(path, &fsstat), res); if (res == 0) { switch(t) { case java_io_FileSystem_SPACE_TOTAL: diff --git a/src/java.base/unix/native/libjava/childproc.c b/src/java.base/unix/native/libjava/childproc.c index c5dc6d31029..175128e4f63 100644 --- a/src/java.base/unix/native/libjava/childproc.c +++ b/src/java.base/unix/native/libjava/childproc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,11 +59,6 @@ isAsciiDigit(char c) #if defined(_AIX) /* AIX does not understand '/proc/self' - it requires the real process ID */ #define FD_DIR aix_fd_dir - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 #elif defined(_ALLBSD_SOURCE) #define FD_DIR "/dev/fd" #else diff --git a/src/java.base/unix/native/libjava/io_util_md.c b/src/java.base/unix/native/libjava/io_util_md.c index 1151fa7286c..28659b3a1c2 100644 --- a/src/java.base/unix/native/libjava/io_util_md.c +++ b/src/java.base/unix/native/libjava/io_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,13 +74,13 @@ jstring newStringPlatform(JNIEnv *env, const char* str) FD handleOpen(const char *path, int oflag, int mode) { FD fd; - RESTARTABLE(open64(path, oflag, mode), fd); + RESTARTABLE(open(path, oflag, mode), fd); if (fd != -1) { - struct stat64 buf64; + struct stat buf; int result; - RESTARTABLE(fstat64(fd, &buf64), result); + RESTARTABLE(fstat(fd, &buf), result); if (result != -1) { - if (S_ISDIR(buf64.st_mode)) { + if (S_ISDIR(buf.st_mode)) { close(fd); errno = EISDIR; fd = -1; @@ -201,13 +201,13 @@ jint handleAvailable(FD fd, jlong *pbytes) { int mode; - struct stat64 buf64; + struct stat buf; jlong size = -1, current = -1; int result; - RESTARTABLE(fstat64(fd, &buf64), result); + RESTARTABLE(fstat(fd, &buf), result); if (result != -1) { - mode = buf64.st_mode; + mode = buf.st_mode; if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { int n; int result; @@ -217,18 +217,18 @@ handleAvailable(FD fd, jlong *pbytes) return 1; } } else if (S_ISREG(mode)) { - size = buf64.st_size; + size = buf.st_size; } } - if ((current = lseek64(fd, 0, SEEK_CUR)) == -1) { + if ((current = lseek(fd, 0, SEEK_CUR)) == -1) { return 0; } if (size < current) { - if ((size = lseek64(fd, 0, SEEK_END)) == -1) + if ((size = lseek(fd, 0, SEEK_END)) == -1) return 0; - else if (lseek64(fd, current, SEEK_SET) == -1) + else if (lseek(fd, current, SEEK_SET) == -1) return 0; } @@ -240,16 +240,16 @@ jint handleSetLength(FD fd, jlong length) { int result; - RESTARTABLE(ftruncate64(fd, length), result); + RESTARTABLE(ftruncate(fd, length), result); return result; } jlong handleGetLength(FD fd) { - struct stat64 sb; + struct stat sb; int result; - RESTARTABLE(fstat64(fd, &sb), result); + RESTARTABLE(fstat(fd, &sb), result); if (result < 0) { return -1; } diff --git a/src/java.base/unix/native/libjava/io_util_md.h b/src/java.base/unix/native/libjava/io_util_md.h index 3dccf64f41f..d6b4d40f3d2 100644 --- a/src/java.base/unix/native/libjava/io_util_md.h +++ b/src/java.base/unix/native/libjava/io_util_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,6 +59,7 @@ FD getFD(JNIEnv *env, jobject cur, jfieldID fid); * Route the routines */ #define IO_Sync fsync +#define IO_Lseek lseek #define IO_Read handleRead #define IO_Write handleWrite #define IO_Append handleWrite @@ -66,17 +67,6 @@ FD getFD(JNIEnv *env, jobject cur, jfieldID fid); #define IO_SetLength handleSetLength #define IO_GetLength handleGetLength -#ifdef _ALLBSD_SOURCE -#define open64 open -#define fstat64 fstat -#define stat64 stat -#define lseek64 lseek -#define ftruncate64 ftruncate -#define IO_Lseek lseek -#else -#define IO_Lseek lseek64 -#endif - /* * On Solaris, the handle field is unused */ diff --git a/src/java.base/unix/native/libnio/ch/FileKey.c b/src/java.base/unix/native/libnio/ch/FileKey.c index bdb42a6324b..c3817003b5b 100644 --- a/src/java.base/unix/native/libnio/ch/FileKey.c +++ b/src/java.base/unix/native/libnio/ch/FileKey.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,12 +30,6 @@ #include "nio_util.h" #include "sun_nio_ch_FileKey.h" -#ifdef _ALLBSD_SOURCE -#define stat64 stat - -#define fstat64 fstat -#endif - static jfieldID key_st_dev; /* id for FileKey.st_dev */ static jfieldID key_st_ino; /* id for FileKey.st_ino */ @@ -51,12 +45,12 @@ Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz) JNIEXPORT void JNICALL Java_sun_nio_ch_FileKey_init(JNIEnv *env, jobject this, jobject fdo) { - struct stat64 fbuf; + struct stat fbuf; int res; - RESTARTABLE(fstat64(fdval(env, fdo), &fbuf), res); + RESTARTABLE(fstat(fdval(env, fdo), &fbuf), res); if (res < 0) { - JNU_ThrowIOExceptionWithLastError(env, "fstat64 failed"); + JNU_ThrowIOExceptionWithLastError(env, "fstat failed"); } else { (*env)->SetLongField(env, this, key_st_dev, (jlong)fbuf.st_dev); (*env)->SetLongField(env, this, key_st_ino, (jlong)fbuf.st_ino); diff --git a/src/java.base/unix/native/libnio/ch/UnixFileDispatcherImpl.c b/src/java.base/unix/native/libnio/ch/UnixFileDispatcherImpl.c index a24f0503e55..918d76bfc53 100644 --- a/src/java.base/unix/native/libnio/ch/UnixFileDispatcherImpl.c +++ b/src/java.base/unix/native/libnio/ch/UnixFileDispatcherImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,20 +29,7 @@ #include #if defined(_ALLBSD_SOURCE) -#define lseek64 lseek -#define stat64 stat -#define flock64 flock -#define off64_t off_t -#define F_SETLKW64 F_SETLKW -#define F_SETLK64 F_SETLK -#define pread64 pread -#define pwrite64 pwrite -#define ftruncate64 ftruncate -#define fstat64 fstat #define fdatasync fsync -#define mmap64 mmap -#define statvfs64 statvfs -#define fstatvfs64 fstatvfs #endif #if defined(__linux__) @@ -57,6 +44,11 @@ #include "java_lang_Long.h" #include +#if defined(_AIX) + #define statvfs statvfs64 + #define fstatvfs fstatvfs64 +#endif + JNIEXPORT jint JNICALL Java_sun_nio_ch_UnixFileDispatcherImpl_read0(JNIEnv *env, jclass clazz, jobject fdo, jlong address, jint len) @@ -74,7 +66,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_pread0(JNIEnv *env, jclass clazz, jobject jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); - return convertReturnVal(env, pread64(fd, buf, len, offset), JNI_TRUE); + return convertReturnVal(env, pread(fd, buf, len, offset), JNI_TRUE); } JNIEXPORT jlong JNICALL @@ -103,7 +95,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_pwrite0(JNIEnv *env, jclass clazz, jobjec jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); - return convertReturnVal(env, pwrite64(fd, buf, len, offset), JNI_FALSE); + return convertReturnVal(env, pwrite(fd, buf, len, offset), JNI_FALSE); } JNIEXPORT jlong JNICALL @@ -131,13 +123,13 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_seek0(JNIEnv *env, jclass clazz, jobject fdo, jlong offset) { jint fd = fdval(env, fdo); - off64_t result; + off_t result; if (offset < 0) { - result = lseek64(fd, 0, SEEK_CUR); + result = lseek(fd, 0, SEEK_CUR); } else { - result = lseek64(fd, offset, SEEK_SET); + result = lseek(fd, offset, SEEK_SET); } - return handle(env, (jlong)result, "lseek64 failed"); + return handle(env, (jlong)result, "lseek failed"); } JNIEXPORT jint JNICALL @@ -161,7 +153,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_truncate0(JNIEnv *env, jobject this, jobject fdo, jlong size) { return handle(env, - ftruncate64(fdval(env, fdo), size), + ftruncate(fdval(env, fdo), size), "Truncation failed"); } @@ -169,9 +161,9 @@ JNIEXPORT jlong JNICALL Java_sun_nio_ch_UnixFileDispatcherImpl_size0(JNIEnv *env, jobject this, jobject fdo) { jint fd = fdval(env, fdo); - struct stat64 fbuf; + struct stat fbuf; - if (fstat64(fd, &fbuf) < 0) + if (fstat(fd, &fbuf) < 0) return handle(env, -1, "Size failed"); #if defined(__linux__) @@ -194,28 +186,28 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_lock0(JNIEnv *env, jobject this, jobject jint fd = fdval(env, fdo); jint lockResult = 0; int cmd = 0; - struct flock64 fl; + struct flock fl; fl.l_whence = SEEK_SET; if (size == (jlong)java_lang_Long_MAX_VALUE) { - fl.l_len = (off64_t)0; + fl.l_len = (off_t)0; } else { - fl.l_len = (off64_t)size; + fl.l_len = (off_t)size; } - fl.l_start = (off64_t)pos; + fl.l_start = (off_t)pos; if (shared == JNI_TRUE) { fl.l_type = F_RDLCK; } else { fl.l_type = F_WRLCK; } if (block == JNI_TRUE) { - cmd = F_SETLKW64; + cmd = F_SETLKW; } else { - cmd = F_SETLK64; + cmd = F_SETLK; } lockResult = fcntl(fd, cmd, &fl); if (lockResult < 0) { - if ((cmd == F_SETLK64) && (errno == EAGAIN || errno == EACCES)) + if ((cmd == F_SETLK) && (errno == EAGAIN || errno == EACCES)) return sun_nio_ch_UnixFileDispatcherImpl_NO_LOCK; if (errno == EINTR) return sun_nio_ch_UnixFileDispatcherImpl_INTERRUPTED; @@ -230,16 +222,16 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_release0(JNIEnv *env, jobject this, { jint fd = fdval(env, fdo); jint lockResult = 0; - struct flock64 fl; - int cmd = F_SETLK64; + struct flock fl; + int cmd = F_SETLK; fl.l_whence = SEEK_SET; if (size == (jlong)java_lang_Long_MAX_VALUE) { - fl.l_len = (off64_t)0; + fl.l_len = (off_t)0; } else { - fl.l_len = (off64_t)size; + fl.l_len = (off_t)size; } - fl.l_start = (off64_t)pos; + fl.l_start = (off_t)pos; fl.l_type = F_UNLCK; lockResult = fcntl(fd, cmd, &fl); if (lockResult < 0) { @@ -319,7 +311,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_map0(JNIEnv *env, jclass klass, jobject f #endif } - mapAddress = mmap64( + mapAddress = mmap( 0, /* Let OS decide location */ len, /* Number of bytes to map */ protections, /* File permissions */ @@ -359,7 +351,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_setDirect0(JNIEnv *env, jclass clazz, { jint fd = fdval(env, fdo); jint result; - struct statvfs64 file_stat; + struct statvfs file_stat; #if defined(O_DIRECT) || defined(F_NOCACHE) || defined(DIRECTIO_ON) #ifdef O_DIRECT @@ -387,7 +379,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_setDirect0(JNIEnv *env, jclass clazz, return result; } #endif - result = fstatvfs64(fd, &file_stat); + result = fstatvfs(fd, &file_stat); if(result == -1) { JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed"); return result; diff --git a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c index f04a6a396e4..79143b45a50 100644 --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -54,22 +55,8 @@ #include // makedev macros #endif -#if defined(__linux__) || defined(_AIX) -#include -#endif - -#ifdef _ALLBSD_SOURCE -#include - -#define stat64 stat -#ifndef MACOSX -#define statvfs64 statvfs -#endif - -#define open64 open -#define fstat64 fstat -#define lstat64 lstat -#define readdir64 readdir +#if defined(_AIX) + #define statvfs statvfs64 #endif #if defined(__linux__) @@ -170,14 +157,6 @@ struct my_statx #include "sun_nio_fs_UnixNativeDispatcher.h" -#if defined(_AIX) - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 -#endif - /** * Size of password or group entry when not available via sysconf */ @@ -231,8 +210,8 @@ static jfieldID entry_dev; /** * System calls that may not be available at run time. */ -typedef int openat64_func(int, const char *, int, ...); -typedef int fstatat64_func(int, const char *, struct stat64 *, int); +typedef int openat_func(int, const char *, int, ...); +typedef int fstatat_func(int, const char *, struct stat *, int); typedef int unlinkat_func(int, const char*, int); typedef int renameat_func(int, const char*, int, const char*); typedef int futimesat_func(int, const char *, const struct timeval *); @@ -244,8 +223,8 @@ typedef int statx_func(int dirfd, const char *restrict pathname, int flags, unsigned int mask, struct my_statx *restrict statxbuf); #endif -static openat64_func* my_openat64_func = NULL; -static fstatat64_func* my_fstatat64_func = NULL; +static openat_func* my_openat_func = NULL; +static fstatat_func* my_fstatat_func = NULL; static unlinkat_func* my_unlinkat_func = NULL; static renameat_func* my_renameat_func = NULL; static futimesat_func* my_futimesat_func = NULL; @@ -261,8 +240,8 @@ static statx_func* my_statx_func = NULL; */ #if defined(__linux__) && (defined(__i386) || defined(__arm__)) #define FSTATAT64_SYSCALL_AVAILABLE -static int fstatat64_wrapper(int dfd, const char *path, - struct stat64 *statbuf, int flag) +static int fstatat_wrapper(int dfd, const char *path, + struct stat *statbuf, int flag) { #ifndef __NR_fstatat64 #define __NR_fstatat64 300 @@ -273,8 +252,8 @@ static int fstatat64_wrapper(int dfd, const char *path, #if defined(__linux__) && defined(_LP64) && defined(__NR_newfstatat) #define FSTATAT64_SYSCALL_AVAILABLE -static int fstatat64_wrapper(int dfd, const char *path, - struct stat64 *statbuf, int flag) +static int fstatat_wrapper(int dfd, const char *path, + struct stat *statbuf, int flag) { return syscall(__NR_newfstatat, dfd, path, statbuf, flag); } @@ -375,11 +354,12 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) /* system calls that might not be available at run time */ #if defined(_ALLBSD_SOURCE) - my_openat64_func = (openat64_func*)dlsym(RTLD_DEFAULT, "openat"); - my_fstatat64_func = (fstatat64_func*)dlsym(RTLD_DEFAULT, "fstatat"); + my_openat_func = (openat_func*)dlsym(RTLD_DEFAULT, "openat"); + my_fstatat_func = (fstatat_func*)dlsym(RTLD_DEFAULT, "fstatat"); #else - my_openat64_func = (openat64_func*) dlsym(RTLD_DEFAULT, "openat64"); - my_fstatat64_func = (fstatat64_func*) dlsym(RTLD_DEFAULT, "fstatat64"); + // Make sure we link to the 64-bit version of the functions + my_openat_func = (openat_func*) dlsym(RTLD_DEFAULT, "openat64"); + my_fstatat_func = (fstatat_func*) dlsym(RTLD_DEFAULT, "fstatat64"); #endif my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat"); my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat"); @@ -389,6 +369,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) #endif my_futimens_func = (futimens_func*) dlsym(RTLD_DEFAULT, "futimens"); #if defined(_AIX) + // Make sure we link to the 64-bit version of the function my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir64"); #else my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir"); @@ -396,8 +377,8 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) #if defined(FSTATAT64_SYSCALL_AVAILABLE) /* fstatat64 missing from glibc */ - if (my_fstatat64_func == NULL) - my_fstatat64_func = (fstatat64_func*)&fstatat64_wrapper; + if (my_fstatat_func == NULL) + my_fstatat_func = (fstatat_func*)&fstatat_wrapper; #endif /* supports futimes or futimesat, futimens, and/or lutimes */ @@ -416,7 +397,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) /* supports openat, etc. */ - if (my_openat64_func != NULL && my_fstatat64_func != NULL && + if (my_openat_func != NULL && my_fstatat_func != NULL && my_unlinkat_func != NULL && my_renameat_func != NULL && my_futimesat_func != NULL && my_fdopendir_func != NULL) { @@ -543,7 +524,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_open0(JNIEnv* env, jclass this, jint fd; const char* path = (const char*)jlong_to_ptr(pathAddress); - RESTARTABLE(open64(path, (int)oflags, (mode_t)mode), fd); + RESTARTABLE(open(path, (int)oflags, (mode_t)mode), fd); if (fd == -1) { throwUnixException(env, errno); } @@ -557,12 +538,12 @@ Java_sun_nio_fs_UnixNativeDispatcher_openat0(JNIEnv* env, jclass this, jint dfd, jint fd; const char* path = (const char*)jlong_to_ptr(pathAddress); - if (my_openat64_func == NULL) { + if (my_openat_func == NULL) { JNU_ThrowInternalError(env, "should not reach here"); return -1; } - RESTARTABLE((*my_openat64_func)(dfd, path, (int)oflags, (mode_t)mode), fd); + RESTARTABLE((*my_openat_func)(dfd, path, (int)oflags, (mode_t)mode), fd); if (fd == -1) { throwUnixException(env, errno); } @@ -638,9 +619,9 @@ static void copy_statx_attributes(JNIEnv* env, struct my_statx* buf, jobject att #endif /** - * Copy stat64 members into sun.nio.fs.UnixFileAttributes + * Copy stat members into sun.nio.fs.UnixFileAttributes */ -static void copy_stat64_attributes(JNIEnv* env, struct stat64* buf, jobject attrs) { +static void copy_stat_attributes(JNIEnv* env, struct stat* buf, jobject attrs) { (*env)->SetIntField(env, attrs, attrs_st_mode, (jint)buf->st_mode); (*env)->SetLongField(env, attrs, attrs_st_ino, (jlong)buf->st_ino); (*env)->SetLongField(env, attrs, attrs_st_dev, (jlong)buf->st_dev); @@ -674,7 +655,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_stat0(JNIEnv* env, jclass this, jlong pathAddress, jobject attrs) { int err; - struct stat64 buf; + struct stat buf; const char* path = (const char*)jlong_to_ptr(pathAddress); #if defined(__linux__) struct my_statx statx_buf; @@ -682,7 +663,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_stat0(JNIEnv* env, jclass this, unsigned int mask = STATX_ALL; if (my_statx_func != NULL) { - // Prefer statx over stat64 on Linux if it's available + // Prefer statx over stat on Linux if it's available RESTARTABLE(statx_wrapper(AT_FDCWD, path, flags, mask, &statx_buf), err); if (err == 0) { copy_statx_attributes(env, &statx_buf, attrs); @@ -692,9 +673,9 @@ Java_sun_nio_fs_UnixNativeDispatcher_stat0(JNIEnv* env, jclass this, } } #endif - RESTARTABLE(stat64(path, &buf), err); + RESTARTABLE(stat(path, &buf), err); if (err == 0) { - copy_stat64_attributes(env, &buf, attrs); + copy_stat_attributes(env, &buf, attrs); return 0; } else { return errno; @@ -706,7 +687,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_lstat0(JNIEnv* env, jclass this, jlong pathAddress, jobject attrs) { int err; - struct stat64 buf; + struct stat buf; const char* path = (const char*)jlong_to_ptr(pathAddress); #if defined(__linux__) struct my_statx statx_buf; @@ -714,7 +695,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_lstat0(JNIEnv* env, jclass this, unsigned int mask = STATX_ALL; if (my_statx_func != NULL) { - // Prefer statx over stat64 on Linux if it's available + // Prefer statx over stat on Linux if it's available RESTARTABLE(statx_wrapper(AT_FDCWD, path, flags, mask, &statx_buf), err); if (err == 0) { copy_statx_attributes(env, &statx_buf, attrs); @@ -725,11 +706,11 @@ Java_sun_nio_fs_UnixNativeDispatcher_lstat0(JNIEnv* env, jclass this, return; } #endif - RESTARTABLE(lstat64(path, &buf), err); + RESTARTABLE(lstat(path, &buf), err); if (err == -1) { throwUnixException(env, errno); } else { - copy_stat64_attributes(env, &buf, attrs); + copy_stat_attributes(env, &buf, attrs); } } @@ -738,7 +719,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstat0(JNIEnv* env, jclass this, jint fd, jobject attrs) { int err; - struct stat64 buf; + struct stat buf; #if defined(__linux__) struct my_statx statx_buf; int flags = AT_EMPTY_PATH | AT_STATX_SYNC_AS_STAT; @@ -757,11 +738,11 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstat0(JNIEnv* env, jclass this, jint fd, return; } #endif - RESTARTABLE(fstat64((int)fd, &buf), err); + RESTARTABLE(fstat((int)fd, &buf), err); if (err == -1) { throwUnixException(env, errno); } else { - copy_stat64_attributes(env, &buf, attrs); + copy_stat_attributes(env, &buf, attrs); } } @@ -770,7 +751,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstatat0(JNIEnv* env, jclass this, jint dfd jlong pathAddress, jint flag, jobject attrs) { int err; - struct stat64 buf; + struct stat buf; const char* path = (const char*)jlong_to_ptr(pathAddress); #if defined(__linux__) struct my_statx statx_buf; @@ -778,7 +759,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstatat0(JNIEnv* env, jclass this, jint dfd unsigned int mask = STATX_ALL; if (my_statx_func != NULL) { - // Prefer statx over stat64 on Linux if it's available + // Prefer statx over stat on Linux if it's available if (((int)flag & AT_SYMLINK_NOFOLLOW) > 0) { // flag set in java code flags |= AT_SYMLINK_NOFOLLOW; } @@ -793,15 +774,15 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstatat0(JNIEnv* env, jclass this, jint dfd } #endif - if (my_fstatat64_func == NULL) { + if (my_fstatat_func == NULL) { JNU_ThrowInternalError(env, "should not reach here"); return; } - RESTARTABLE((*my_fstatat64_func)((int)dfd, path, &buf, (int)flag), err); + RESTARTABLE((*my_fstatat_func)((int)dfd, path, &buf, (int)flag), err); if (err == -1) { throwUnixException(env, errno); } else { - copy_stat64_attributes(env, &buf, attrs); + copy_stat_attributes(env, &buf, attrs); } } @@ -1210,14 +1191,14 @@ Java_sun_nio_fs_UnixNativeDispatcher_statvfs0(JNIEnv* env, jclass this, #ifdef MACOSX struct statfs buf; #else - struct statvfs64 buf; + struct statvfs buf; #endif const char* path = (const char*)jlong_to_ptr(pathAddress); #ifdef MACOSX RESTARTABLE(statfs(path, &buf), err); #else - RESTARTABLE(statvfs64(path, &buf), err); + RESTARTABLE(statvfs(path, &buf), err); #endif if (err == -1) { throwUnixException(env, errno); diff --git a/src/java.desktop/share/native/common/awt/debug/debug_assert.c b/src/java.desktop/share/native/common/awt/debug/debug_assert.c index 573c19f0870..eb3e380c8e9 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_assert.c +++ b/src/java.desktop/share/native/common/awt/debug/debug_assert.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ #if defined(DEBUG) +#include +#include + #include "debug_util.h" enum { diff --git a/src/java.desktop/share/native/common/awt/debug/debug_mem.c b/src/java.desktop/share/native/common/awt/debug/debug_mem.c index dce59783c03..311476695dd 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_mem.c +++ b/src/java.desktop/share/native/common/awt/debug/debug_mem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ #if defined(DEBUG) +#include +#include + #include "debug_util.h" #define DMEM_MIN(a,b) (a) < (b) ? (a) : (b) diff --git a/src/java.desktop/share/native/common/awt/debug/debug_trace.c b/src/java.desktop/share/native/common/awt/debug/debug_trace.c index 97abe77044b..8ea8eafb223 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_trace.c +++ b/src/java.desktop/share/native/common/awt/debug/debug_trace.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ * questions. */ +#include + #include "debug_util.h" #if defined(DEBUG) diff --git a/src/java.desktop/share/native/common/awt/debug/debug_util.h b/src/java.desktop/share/native/common/awt/debug/debug_util.h index 117305613f5..48533626cfa 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_util.h +++ b/src/java.desktop/share/native/common/awt/debug/debug_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,12 +45,6 @@ typedef void * dmutex_t; #include "jni.h" #include "jni_util.h" #include "jvm.h" -#include -#include -#include -#include -#include -#include /* keep these after the other headers */ #include "debug_mem.h" diff --git a/src/java.desktop/share/native/libawt/java2d/pipe/BufferedRenderPipe.c b/src/java.desktop/share/native/libawt/java2d/pipe/BufferedRenderPipe.c index 823475b0a23..ac55c38f932 100644 --- a/src/java.desktop/share/native/libawt/java2d/pipe/BufferedRenderPipe.c +++ b/src/java.desktop/share/native/libawt/java2d/pipe/BufferedRenderPipe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,10 @@ #include "SpanIterator.h" #include "Trace.h" +#if defined(_AIX) && defined(open) +#undef open +#endif + /* The "header" consists of a jint opcode and a jint span count value */ #define INTS_PER_HEADER 2 #define BYTES_PER_HEADER 8 diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c b/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c index 0700f545eb1..d778c0bf6d6 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c b/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c index 4e15ddd6e01..4dc4137da2a 100644 --- a/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c +++ b/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,12 +55,6 @@ Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, return (jint) result; } -#if defined(_ALLBSD_SOURCE) -typedef struct flock FLOCK; -#else -typedef struct flock64 FLOCK; -#endif - /** * Try to open a named lock file. * The result is a cookie that can be used later to unlock the file. @@ -74,7 +68,7 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, int result[2] = {0, 0}; jintArray javaResult = NULL; int old_umask; - FLOCK fl; + struct flock fl; if (!fname) return javaResult; @@ -101,11 +95,7 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, if (fd < 0) { result[0] = 0; } else { -#if defined(_ALLBSD_SOURCE) rc = fcntl(fd, F_SETLK, &fl); -#else - rc = fcntl(fd, F_SETLK64, &fl); -#endif result[1] = errno; if (rc < 0) { result[0]= 0; @@ -130,18 +120,13 @@ Java_java_util_prefs_FileSystemPreferences_unlockFile0(JNIEnv *env, jclass thisclass, jint fd) { int rc; - FLOCK fl; + struct flock fl; fl.l_whence = SEEK_SET; fl.l_len = 0; fl.l_start = 0; fl.l_type = F_UNLCK; -#if defined(_ALLBSD_SOURCE) rc = fcntl(fd, F_SETLK, &fl); -#else - rc = fcntl(fd, F_SETLK64, &fl); -#endif - if (rc < 0) { close(fd); return (jint)errno; diff --git a/src/jdk.attach/aix/native/libattach/VirtualMachineImpl.c b/src/jdk.attach/aix/native/libattach/VirtualMachineImpl.c index ec789f0f26d..d0e943398e1 100644 --- a/src/jdk.attach/aix/native/libattach/VirtualMachineImpl.c +++ b/src/jdk.attach/aix/native/libattach/VirtualMachineImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -133,11 +133,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions jboolean isCopy; const char* p = GetStringPlatformChars(env, path, &isCopy); if (p != NULL) { - struct stat64 sb; + struct stat sb; uid_t uid, gid; int res; - memset(&sb, 0, sizeof(struct stat64)); + memset(&sb, 0, sizeof(struct stat)); /* * Check that the path is owned by the effective uid/gid of this @@ -146,7 +146,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions uid = geteuid(); gid = getegid(); - res = stat64(p, &sb); + res = stat(p, &sb); if (res != 0) { /* save errno */ res = errno; diff --git a/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c b/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c index c96a45d8fd7..56339ed0932 100644 --- a/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c +++ b/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -136,11 +136,11 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions jboolean isCopy; const char* p = GetStringPlatformChars(env, path, &isCopy); if (p != NULL) { - struct stat64 sb; + struct stat sb; uid_t uid, gid; int res; - memset(&sb, 0, sizeof(struct stat64)); + memset(&sb, 0, sizeof(struct stat)); /* * Check that the path is owned by the effective uid/gid of this @@ -149,7 +149,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions uid = geteuid(); gid = getegid(); - res = stat64(p, &sb); + res = stat(p, &sb); if (res != 0) { /* save errno */ res = errno; diff --git a/src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c b/src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c index b43d4de80fc..be868ba0687 100644 --- a/src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c +++ b/src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c @@ -51,11 +51,6 @@ static char *skipNonWhitespace(char *p) { #if defined(_AIX) /* AIX does not understand '/proc/self' - it requires the real process ID */ #define FD_DIR aix_fd_dir - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 #elif defined(_ALLBSD_SOURCE) #define FD_DIR "/dev/fd" #else diff --git a/src/jdk.management.agent/unix/native/libmanagement_agent/FileSystemImpl.c b/src/jdk.management.agent/unix/native/libmanagement_agent/FileSystemImpl.c index cabb73461df..be7a0209957 100644 --- a/src/jdk.management.agent/unix/native/libmanagement_agent/FileSystemImpl.c +++ b/src/jdk.management.agent/unix/native/libmanagement_agent/FileSystemImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,6 @@ #include "jni_util.h" #include "jdk_internal_agent_FileSystemImpl.h" -#ifdef _ALLBSD_SOURCE -#define stat64 stat -#endif - /* * JNI_OnLoad */ @@ -60,11 +56,11 @@ JNIEXPORT jboolean JNICALL Java_jdk_internal_agent_FileSystemImpl_isAccessUserOn jboolean isCopy; const char *path = JNU_GetStringPlatformChars(env, str, &isCopy); if (path != NULL) { - struct stat64 sb; - if (stat64(path, &sb) == 0) { + struct stat sb; + if (stat(path, &sb) == 0) { res = ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) == 0) ? JNI_TRUE : JNI_FALSE; } else { - JNU_ThrowIOExceptionWithLastError(env, "stat64 failed"); + JNU_ThrowIOExceptionWithLastError(env, "stat failed"); } if (isCopy) { JNU_ReleaseStringPlatformChars(env, str, path); diff --git a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c index 5b978ba38e1..81a972999ed 100644 --- a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c +++ b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c @@ -74,14 +74,6 @@ static jlong page_size = 0; #endif /* _ALLBSD_SOURCE */ -#if defined(_AIX) - #define DIR DIR64 - #define dirent dirent64 - #define opendir opendir64 - #define readdir readdir64 - #define closedir closedir64 -#endif - // true = get available swap in bytes // false = get total swap in bytes static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean available) {