J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1994-2002 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | #ifndef _JAVASOFT_TYPEDEFS_H_ |
| 27 | #define _JAVASOFT_TYPEDEFS_H_ |
| 28 | |
| 29 | #include "typedefs_md.h" /* for int64_t */ |
| 30 | |
| 31 | /* |
| 32 | * Macros to deal with the JavaVM's stack alignment. Many machines |
| 33 | * require doublewords to be double aligned. This union is used by |
| 34 | * code in math.h as a more portable way do alingnment on machines |
| 35 | * that require it. This union and the macros that use it came from |
| 36 | * Netscape. |
| 37 | */ |
| 38 | |
| 39 | #ifdef HAVE_ALIGNED_LONGLONGS |
| 40 | #define GET_INT64(_t,_addr) \ |
| 41 | ((((int32_t*) &(_t))[0] = ((int32_t*)(_addr))[0]), \ |
| 42 | (((int32_t*) &(_t))[1] = ((int32_t*)(_addr))[1]), \ |
| 43 | (_t).j ) |
| 44 | #define SET_INT64(_t, _addr, _v) \ |
| 45 | ( (_t).j = (_v), \ |
| 46 | ((int32_t*)(_addr))[0] = ((int32_t*) &(_t))[0], \ |
| 47 | ((int32_t*)(_addr))[1] = ((int32_t*) &(_t))[1] ) |
| 48 | #else |
| 49 | #define GET_INT64(_t,_addr) (*(int64_t*)(_addr)) |
| 50 | #define SET_INT64(_t, _addr, _v) (*(int64_t*)(_addr) = (_v)) |
| 51 | #endif |
| 52 | |
| 53 | /* If double's must be aligned on doubleword boundaries then define this */ |
| 54 | #ifdef HAVE_ALIGNED_DOUBLES |
| 55 | #define GET_DOUBLE(_t,_addr) \ |
| 56 | ((((int32_t*) &(_t))[0] = ((int32_t*)(_addr))[0]), \ |
| 57 | (((int32_t*) &(_t))[1] = ((int32_t*)(_addr))[1]), \ |
| 58 | (_t).d ) |
| 59 | #define SET_DOUBLE(_t, _addr, _v) \ |
| 60 | ( (_t).d = (_v), \ |
| 61 | ((int32_t*)(_addr))[0] = ((int32_t*) &(_t))[0], \ |
| 62 | ((int32_t*)(_addr))[1] = ((int32_t*) &(_t))[1] ) |
| 63 | #else |
| 64 | #define GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr)) |
| 65 | #define SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v)) |
| 66 | #endif |
| 67 | |
| 68 | /* If pointers are 64bits then define this */ |
| 69 | #ifdef HAVE_64BIT_POINTERS |
| 70 | #define GET_HANDLE(_t,_addr) \ |
| 71 | ( ((int32_t*) &(_t))[0] = ((int32_t*)(_addr))[0]), \ |
| 72 | ((int32_t*) &(_t))[1] = ((int32_t*)(_addr))[1]), \ |
| 73 | (void*) (_t).l ) |
| 74 | #define SET_HANDLE(_t, _addr, _v) \ |
| 75 | ( *(void**) &((_t).l) = (_v), \ |
| 76 | ((int32_t*)(_addr))[0] = ((int32_t*) &(_t))[0], \ |
| 77 | ((int32_t*)(_addr))[1] = ((int32_t*) &(_t))[1] ) |
| 78 | #else |
| 79 | #define GET_HANDLE(_t,_addr) (*(JHandle*)(_addr)) |
| 80 | #define SET_HANDLE(_t, _addr, _v) (*(JHandle*)(_addr) = (_v)) |
| 81 | #endif |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | * Printf-style formatters for fixed- and variable-width types as pointers and |
| 86 | * integers. |
| 87 | * |
| 88 | * Each platform-specific definitions file "typedefs_md.h" |
| 89 | * must define the macro FORMAT64_MODIFIER, which is the modifier for '%x' or |
| 90 | * '%d' formats to indicate a 64-bit quantity; commonly "l" (in LP64) or "ll" |
| 91 | * (in ILP32). |
| 92 | */ |
| 93 | |
| 94 | /* Format 32-bit quantities. */ |
| 95 | #define INT32_FORMAT "%d" |
| 96 | #define UINT32_FORMAT "%u" |
| 97 | #define PTR32_FORMAT "0x%08x" |
| 98 | |
| 99 | /* Format 64-bit quantities. */ |
| 100 | #define INT64_FORMAT "%" FORMAT64_MODIFIER "d" |
| 101 | #define UINT64_FORMAT "%" FORMAT64_MODIFIER "u" |
| 102 | #define PTR64_FORMAT "0x%016" FORMAT64_MODIFIER "x" |
| 103 | |
| 104 | /* Format pointers and size_t (or size_t-like integer types) which change size |
| 105 | * between 32- and 64-bit. |
| 106 | */ |
| 107 | #if defined(_LP64) || defined(_WIN64) |
| 108 | #define PTR_FORMAT PTR64_FORMAT |
| 109 | #define SIZE_FORMAT UINT64_FORMAT |
| 110 | #define SSIZE_FORMAT INT64_FORMAT |
| 111 | #else |
| 112 | #define PTR_FORMAT PTR32_FORMAT |
| 113 | #define SIZE_FORMAT UINT32_FORMAT |
| 114 | #define SSIZE_FORMAT INT32_FORMAT |
| 115 | #endif |
| 116 | |
| 117 | #define INTPTR_FORMAT PTR_FORMAT |
| 118 | |
| 119 | |
| 120 | #endif /* !_JAVASOFT_TYPEDEFS_H_ */ |