Skip to content

Commit f4d08cc

Browse files
thesamesamKim Barrett
authored and
Kim Barrett
committedJan 20, 2024
8318696: Do not use LFS64 symbols on Linux
Reviewed-by: ihse, dholmes, kbarrett, mbaesken
1 parent 9049402 commit f4d08cc

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed
 

‎make/autoconf/flags-cflags.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
479479
[
480480
#### OS DEFINES, these should be independent on toolchain
481481
if test "x$OPENJDK_TARGET_OS" = xlinux; then
482-
CFLAGS_OS_DEF_JVM="-DLINUX"
482+
CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64"
483483
CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
484484
elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
485485
CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"

‎src/hotspot/os/linux/attachListener_linux.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -184,6 +184,8 @@ int LinuxAttachListener::init() {
184184
char initial_path[UNIX_PATH_MAX]; // socket file during setup
185185
int listener; // listener socket (file descriptor)
186186

187+
static_assert(sizeof(off_t) == 8, "Expected Large File Support in this file");
188+
187189
// register function to cleanup
188190
if (!_atexit_registered) {
189191
_atexit_registered = true;
@@ -446,14 +448,14 @@ AttachOperation* AttachListener::dequeue() {
446448

447449
void AttachListener::vm_start() {
448450
char fn[UNIX_PATH_MAX];
449-
struct stat64 st;
451+
struct stat st;
450452
int ret;
451453

452454
int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
453455
os::get_temp_directory(), os::current_process_id());
454456
assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");
455457

456-
RESTARTABLE(::stat64(fn, &st), ret);
458+
RESTARTABLE(::stat(fn, &st), ret);
457459
if (ret == 0) {
458460
ret = ::unlink(fn);
459461
if (ret == -1) {
@@ -473,8 +475,8 @@ int AttachListener::pd_init() {
473475

474476
bool AttachListener::check_socket_file() {
475477
int ret;
476-
struct stat64 st;
477-
ret = stat64(LinuxAttachListener::path(), &st);
478+
struct stat st;
479+
ret = stat(LinuxAttachListener::path(), &st);
478480
if (ret == -1) { // need to restart attach listener.
479481
log_debug(attach)("Socket file %s does not exist - Restart Attach Listener",
480482
LinuxAttachListener::path());
@@ -513,14 +515,14 @@ bool AttachListener::is_init_trigger() {
513515
}
514516
char fn[PATH_MAX + 1];
515517
int ret;
516-
struct stat64 st;
518+
struct stat st;
517519
os::snprintf_checked(fn, sizeof(fn), ".attach_pid%d", os::current_process_id());
518-
RESTARTABLE(::stat64(fn, &st), ret);
520+
RESTARTABLE(::stat(fn, &st), ret);
519521
if (ret == -1) {
520522
log_trace(attach)("Failed to find attach file: %s, trying alternate", fn);
521523
snprintf(fn, sizeof(fn), "%s/.attach_pid%d",
522524
os::get_temp_directory(), os::current_process_id());
523-
RESTARTABLE(::stat64(fn, &st), ret);
525+
RESTARTABLE(::stat(fn, &st), ret);
524526
if (ret == -1) {
525527
log_debug(attach)("Failed to find attach file: %s", fn);
526528
}

‎src/hotspot/os/linux/os_linux.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,8 @@ void os::jvm_path(char *buf, jint buflen) {
27722772
void linux_wrap_code(char* base, size_t size) {
27732773
static volatile jint cnt = 0;
27742774

2775+
static_assert(sizeof(off_t) == 8, "Expected Large File Support in this file");
2776+
27752777
if (!UseOprofile) {
27762778
return;
27772779
}
@@ -4262,7 +4264,7 @@ jlong os::Linux::fast_thread_cpu_time(clockid_t clockid) {
42624264
// the number of bytes written to out_fd is returned if transfer was successful
42634265
// otherwise, returns -1 that implies an error
42644266
jlong os::Linux::sendfile(int out_fd, int in_fd, jlong* offset, jlong count) {
4265-
return ::sendfile64(out_fd, in_fd, (off64_t*)offset, (size_t)count);
4267+
return ::sendfile(out_fd, in_fd, (off_t*)offset, (size_t)count);
42664268
}
42674269

42684270
// Determine if the vmid is the parent pid for a child in a PID namespace.
@@ -4940,14 +4942,14 @@ int os::open(const char *path, int oflag, int mode) {
49404942
oflag |= O_CLOEXEC;
49414943
#endif
49424944

4943-
int fd = ::open64(path, oflag, mode);
4945+
int fd = ::open(path, oflag, mode);
49444946
if (fd == -1) return -1;
49454947

49464948
//If the open succeeded, the file might still be a directory
49474949
{
4948-
struct stat64 buf64;
4949-
int ret = ::fstat64(fd, &buf64);
4950-
int st_mode = buf64.st_mode;
4950+
struct stat buf;
4951+
int ret = ::fstat(fd, &buf);
4952+
int st_mode = buf.st_mode;
49514953

49524954
if (ret != -1) {
49534955
if ((st_mode & S_IFMT) == S_IFDIR) {
@@ -4984,17 +4986,17 @@ int os::open(const char *path, int oflag, int mode) {
49844986
int os::create_binary_file(const char* path, bool rewrite_existing) {
49854987
int oflags = O_WRONLY | O_CREAT;
49864988
oflags |= rewrite_existing ? O_TRUNC : O_EXCL;
4987-
return ::open64(path, oflags, S_IREAD | S_IWRITE);
4989+
return ::open(path, oflags, S_IREAD | S_IWRITE);
49884990
}
49894991

49904992
// return current position of file pointer
49914993
jlong os::current_file_offset(int fd) {
4992-
return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR);
4994+
return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
49934995
}
49944996

49954997
// move file pointer to the specified offset
49964998
jlong os::seek_to_file_offset(int fd, jlong offset) {
4997-
return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET);
4999+
return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
49985000
}
49995001

50005002
// Map a block of memory.

‎src/hotspot/os/posix/os_posix.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -287,6 +287,7 @@ static char* reserve_mmapped_memory(size_t bytes, char* requested_addr) {
287287
}
288288

289289
static int util_posix_fallocate(int fd, off_t offset, off_t len) {
290+
static_assert(sizeof(off_t) == 8, "Expected Large File Support in this file");
290291
#ifdef __APPLE__
291292
fstore_t store = { F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, len };
292293
// First we try to get a continuous chunk of disk space
@@ -752,11 +753,11 @@ void os::dll_unload(void *lib) {
752753
}
753754

754755
jlong os::lseek(int fd, jlong offset, int whence) {
755-
return (jlong) BSD_ONLY(::lseek) NOT_BSD(::lseek64)(fd, offset, whence);
756+
return (jlong) ::lseek(fd, offset, whence);
756757
}
757758

758759
int os::ftruncate(int fd, jlong length) {
759-
return BSD_ONLY(::ftruncate) NOT_BSD(::ftruncate64)(fd, length);
760+
return ::ftruncate(fd, length);
760761
}
761762

762763
const char* os::get_current_directory(char *buf, size_t buflen) {

‎src/hotspot/os/posix/os_posix.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
// Note: the Posix API aims to capture functionality available on all Posix
3333
// compliant platforms, but in practice the implementations may depend on
34-
// non-Posix functionality. For example, the use of lseek64 and ftruncate64.
34+
// non-Posix functionality.
3535
// This use of non-Posix API's is made possible by compiling/linking in a mode
3636
// that is not restricted to being fully Posix complaint, such as by declaring
3737
// -D_GNU_SOURCE. But be aware that in doing so we may enable non-Posix

0 commit comments

Comments
 (0)
Please sign in to comment.