Avoid using deprecated stat64 on Mac OS X

Krystal Mok rednaxelafx at gmail.com
Sun Jul 28 22:34:16 PDT 2013


Hi David,

Thanks for taking a look. I'm not that familiar with other BSD variants,
and I'm only encountering this on Mac OS X. Looking for help here.

I think FreeBSD also uses the bsd-port in their downstream OpenJDK package.
FreeBSD uses stat instead of stat64, too.

Thanks,
Kris


On Mon, Jul 29, 2013 at 1:24 PM, David Holmes <david.holmes at oracle.com>wrote:

> Hi Kris,
>
>
> On 28/07/2013 5:59 PM, Krystal Mok wrote:
>
>> Hi all,
>>
>> I'm building a freshly cloned repo from the tip of hotspot-comp on Mac OS
>> X
>> 10.7.5, and got and error:
>>
>> llvm-g++ -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64 -DASSERT -I.
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/**share/vm/prims
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/**share/vm
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/**
>> share/vm/precompiled
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/cpu/**x86/vm
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os_**cpu/bsd_x86/vm
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os/**bsd/vm
>> -I/Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os/**posix/vm
>> -I../generated -DHOTSPOT_RELEASE_VERSION="\"**25.0-b44-internal\""
>> -DHOTSPOT_BUILD_TARGET="\"**fastdebug\""
>> -DHOTSPOT_BUILD_USER="\"**rednaxelafx\"" -DHOTSPOT_LIB_ARCH=\"amd64\"
>> -DHOTSPOT_VM_DISTRO="\"**OpenJDK\""  -DTARGET_OS_FAMILY_bsd
>> -DTARGET_ARCH_x86
>> -DTARGET_ARCH_MODEL_x86_64 -DTARGET_OS_ARCH_bsd_x86
>> -DTARGET_OS_ARCH_MODEL_bsd_**x86_64 -DTARGET_COMPILER_gcc -DCOMPILER2
>> -DCOMPILER1 -fPIC -fno-rtti -fno-exceptions -pthread -fcheck-new -m64
>>   -pipe -fno-strict-aliasing -DMAC_OS_X_VERSION_MAX_**ALLOWED=1070
>> -mmacosx-version-min=10.7.0 -Os  -DVM_LITTLE_ENDIAN -D_LP64=1
>> -fno-omit-frame-pointer -Werror -Wunused-function    -DDTRACE_ENABLED
>>   -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -DALLOW_OPERATOR_NEW_USAGE -c -MMD
>> -MP
>> -MF ../generated/dependencies/**attachListener_bsd.o.d -fpch-deps -o
>> attachListener_bsd.o
>> /Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os/**
>> bsd/vm/attachListener_bsd.cpp
>> cc1plus: warnings being treated as errors
>> /Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os/**
>> bsd/vm/attachListener_bsd.cpp:
>> In static member function ‘static void AttachListener::vm_start()’:
>> /Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os/**
>> bsd/vm/attachListener_bsd.cpp:**455:
>> warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
>> /Users/rednaxelafx/build/**hotspot-comp/hotspot/src/os/**
>> bsd/vm/attachListener_bsd.cpp:**455:
>> warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
>> make[6]: *** [attachListener_bsd.o] Error 1
>>
>> The problem came from a recent commit [1]:
>> 7162400: Intermittent java.io.IOException: Bad file number during
>> HotSpotVirtualMachine.**executeCommand
>>
>> According to [2], the *-64 variants of the stat*() functions have been
>> deprecated on Mac OS X and should be avoided.
>>
>
> So is this purely an OSX issue or also a BSD one? I'm assuming OSX.
>
> Does anybody out there actually use the BSD port seperately from OSX?
>
> David
> -----
>
>
>
>> The fix is simple:
>> diff -r d90d1b96b65b src/os/bsd/vm/attachListener_**bsd.cpp
>> --- a/src/os/bsd/vm/**attachListener_bsd.cpp Fri Jul 26 12:37:39 2013
>> -0700
>> +++ b/src/os/bsd/vm/**attachListener_bsd.cpp Sun Jul 28 15:55:54 2013
>> +0800
>> @@ -445,14 +445,14 @@
>>
>>   void AttachListener::vm_start() {
>>     char fn[UNIX_PATH_MAX];
>> -  struct stat64 st;
>> +  struct stat st;
>>     int ret;
>>
>>     int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
>>              os::get_temp_directory(), os::current_process_id());
>>     assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");
>>
>> -  RESTARTABLE(::stat64(fn, &st), ret);
>> +  RESTARTABLE(::stat(fn, &st), ret);
>>     if (ret == 0) {
>>       ret = ::unlink(fn);
>>       if (ret == -1) {
>>
>> I'm not sure if this should be done for all BSD platforms. Could anybody
>> help confirm this?
>>
>> Thanks,
>> Kris
>>
>> (P.S. recovering from bad health...)
>>
>> [1]: http://hg.openjdk.java.net/**hsx/hotspot-comp/hotspot/rev/**
>> 2e8f19c2feef<http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/2e8f19c2feef>
>> [2]:
>> https://developer.apple.com/**library/mac/documentation/**
>> Darwin/Reference/ManPages/**man2/stat64.2.html<https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat64.2.html>
>>
>>


More information about the hotspot-dev mailing list