From b20c5c79def1ef2cc4b587b7688f8f1d4c81d699 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Mon, 14 Oct 2024 10:34:19 +0000 Subject: [PATCH] 8341967: Unify os::current_file_offset and os::seek_to_file_offset across posix platforms Reviewed-by: jsjolen, mdoerr --- src/hotspot/os/aix/os_aix.cpp | 10 ---------- src/hotspot/os/bsd/os_bsd.cpp | 10 ---------- src/hotspot/os/linux/os_linux.cpp | 10 ---------- src/hotspot/os/posix/os_posix.cpp | 10 ++++++++++ 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index fd16a7984a6f3..63aa53f0a2350 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -2483,16 +2483,6 @@ int os::open(const char *path, int oflag, int mode) { return fd; } -// return current position of file pointer -jlong os::current_file_offset(int fd) { - return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); -} - -// move file pointer to the specified offset -jlong os::seek_to_file_offset(int fd, jlong offset) { - return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); -} - // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) // are used by JVM M&M and JVMTI to get user+sys or user CPU time // of a thread. diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 9ad7c35e6bdef..18818268c1f9a 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -2400,16 +2400,6 @@ int os::open(const char *path, int oflag, int mode) { return fd; } -// return current position of file pointer -jlong os::current_file_offset(int fd) { - return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); -} - -// move file pointer to the specified offset -jlong os::seek_to_file_offset(int fd, jlong offset) { - return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); -} - // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) // are used by JVM M&M and JVMTI to get user+sys or user CPU time // of a thread. diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index c9968fc9f3580..c80663fec3d3a 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -5053,16 +5053,6 @@ int os::open(const char *path, int oflag, int mode) { return fd; } -// return current position of file pointer -jlong os::current_file_offset(int fd) { - return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); -} - -// move file pointer to the specified offset -jlong os::seek_to_file_offset(int fd, jlong offset) { - return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); -} - static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time); static jlong fast_cpu_time(Thread *thread) { diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 60efdeb2ef59a..cc29f209160ee 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -348,6 +348,16 @@ int os::create_file_for_heap(const char* dir) { return fd; } +// return current position of file pointer +jlong os::current_file_offset(int fd) { + return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); +} + +// move file pointer to the specified offset +jlong os::seek_to_file_offset(int fd, jlong offset) { + return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); +} + // Is a (classpath) directory empty? bool os::dir_is_empty(const char* path) { DIR *dir = nullptr;