开发者

source for native sun.misc.Unsafe operations in java

开发者 https://www.devze.com 2023-03-21 16:48 出处:网络
i\'ve downloaded \"openjdk-6-src-b23-05_jul_2011\" to have a look at the native implementations for the methods in sun.misc.Unsafe. e.g. compareAndSwapInt(...) but i am not able find anything in the d

i've downloaded "openjdk-6-src-b23-05_jul_2011" to have a look at the native implementations for the methods in sun.misc.Unsafe. e.g. compareAndSwapInt(...) but i am not able find anything in the do开发者_StackOverflowwnloaded sources of openjdk. i want to get an idea how these methods look like (i was interested in the atomic stuff the jdk provides).

could anybody point me to the right location(s)?

$ ls jdk/src/
linux  share  solaris  windows

$ ls hotspot/src/os/
linux  posix  solaris  windows

any help appreciated

marcel


Implementation of unsafe methods itself is not OS-specific, therefore it can be found in hotspot/src/share/vm/prims/unsafe.cpp. It delegates to hotspot/src/share/vm/runtime/atomic.cpp, which includes OS and CPU specific files, such as hotspot/src/os_cpu/windows_x86/atomic_windows_x86.inline.hpp.


Gcc atomic builtins as provided like java

http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html

But problem is there is no standard, as you move to solaris, you will need something else. So you have to use different system call as you change your platform.

0

精彩评论

暂无评论...
验证码 换一张
取 消