19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef CPU_ZERO_VM_BYTES_ZERO_HPP
27 #define CPU_ZERO_VM_BYTES_ZERO_HPP
28
29 #include "memory/allocation.hpp"
30
31 typedef union unaligned {
32 u4 u;
33 u2 us;
34 u8 ul;
35 } __attribute__((packed)) unaligned;
36
37 class Bytes: AllStatic {
38 public:
39 // Returns true if the byte ordering used by Java is different
40 // from the native byte ordering of the underlying machine.
41 static inline bool is_Java_byte_ordering_different() {
42 #ifdef VM_LITTLE_ENDIAN
43 return true;
44 #else
45 return false;
46 #endif
47 }
48
49 // Efficient reading and writing of unaligned unsigned data in
50 // platform-specific byte ordering.
51 static inline u2 get_native_u2(address p){
52 unaligned *up = (unaligned *) p;
53 return up->us;
54 }
55
56 static inline u4 get_native_u4(address p) {
57 unaligned *up = (unaligned *) p;
58 return up->u;
59 }
60
61 static inline u8 get_native_u8(address p) {
62 unaligned *up = (unaligned *) p;
63 return up->ul;
64 }
65
66 static inline void put_native_u2(address p, u2 x) {
67 unaligned *up = (unaligned *) p;
68 up->us = x;
|
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef CPU_ZERO_VM_BYTES_ZERO_HPP
27 #define CPU_ZERO_VM_BYTES_ZERO_HPP
28
29 #include "memory/allocation.hpp"
30
31 typedef union unaligned {
32 u4 u;
33 u2 us;
34 u8 ul;
35 } __attribute__((packed)) unaligned;
36
37 class Bytes: AllStatic {
38 public:
39 // Efficient reading and writing of unaligned unsigned data in
40 // platform-specific byte ordering.
41 static inline u2 get_native_u2(address p){
42 unaligned *up = (unaligned *) p;
43 return up->us;
44 }
45
46 static inline u4 get_native_u4(address p) {
47 unaligned *up = (unaligned *) p;
48 return up->u;
49 }
50
51 static inline u8 get_native_u8(address p) {
52 unaligned *up = (unaligned *) p;
53 return up->ul;
54 }
55
56 static inline void put_native_u2(address p, u2 x) {
57 unaligned *up = (unaligned *) p;
58 up->us = x;
|