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 | /* |
| 27 | * Solaris-dependent types for Green threads |
| 28 | */ |
| 29 | |
| 30 | #ifndef _JAVASOFT_SOLARIS_TYPES_MD_H_ |
| 31 | #define _JAVASOFT_SOLARIS_TYPES_MD_H_ |
| 32 | |
| 33 | #include <sys/types.h> |
| 34 | #include <sys/stat.h> |
| 35 | |
| 36 | #ifdef __linux__ |
| 37 | #include <stdint.h> |
| 38 | #define HAVE_INTPTR_T |
| 39 | #define _UINT64_T |
| 40 | #endif |
| 41 | |
| 42 | #define int8_t char |
| 43 | |
| 44 | /* Fix for varargs differences on PowerPC */ |
| 45 | #if defined(__powerpc__) |
| 46 | #define VARGS(x) (x) |
| 47 | #else |
| 48 | #define VARGS(x) (&x) |
| 49 | #endif /* __powerpc__ */ |
| 50 | |
| 51 | |
| 52 | #if defined(__alpha__) |
| 53 | #define PTR_IS_64 1 |
| 54 | #define LONG_IS_64 1 |
| 55 | #else |
| 56 | #define PTR_IS_32 1 |
| 57 | #endif |
| 58 | |
| 59 | /* don't redefine typedef's on Solaris 2.6 or Later */ |
| 60 | |
| 61 | #if !defined(_ILP32) && !defined(_LP64) |
| 62 | |
| 63 | #ifndef HAVE_INTPTR_T |
| 64 | #ifdef LONG_IS_64 |
| 65 | typedef long intptr_t; |
| 66 | typedef unsigned long uintptr_t; |
| 67 | #else |
| 68 | typedef int intptr_t; |
| 69 | typedef unsigned int uintptr_t; |
| 70 | #endif /* LONG_IS_64 */ |
| 71 | #endif /* don't HAVE_INTPTR_T */ |
| 72 | |
| 73 | #ifndef _UINT64_T |
| 74 | #define _UINT64_T |
| 75 | #ifdef LONG_IS_64 |
| 76 | typedef unsigned long uint64_t; |
| 77 | #else |
| 78 | typedef unsigned long long uint64_t; |
| 79 | #endif |
| 80 | #define _UINT32_T |
| 81 | #ifndef uint32_t /* [sbb] scaffolding */ |
| 82 | typedef unsigned int uint32_t; |
| 83 | #endif /* [sbb] scaffolding */ |
| 84 | #if defined(__linux__) |
| 85 | typedef unsigned int uint_t; |
| 86 | #endif |
| 87 | #endif |
| 88 | |
| 89 | #ifndef __BIT_TYPES_DEFINED__ |
| 90 | /* that should get Linux, at least */ |
| 91 | #ifndef _INT64_T |
| 92 | #define _INT64_T |
| 93 | #ifdef LONG_IS_64 |
| 94 | typedef long int64_t; |
| 95 | #else |
| 96 | typedef long long int64_t; |
| 97 | #endif |
| 98 | #define _INT32_T |
| 99 | #ifndef int32_t /* [sbb] scaffolding */ |
| 100 | typedef int int32_t; |
| 101 | #endif /* [sbb] scaffolding */ |
| 102 | #if defined(__linux__) |
| 103 | typedef int int_t; |
| 104 | #endif |
| 105 | #endif |
| 106 | #endif /* __BIT_TYPES_DEFINED__ */ |
| 107 | |
| 108 | #endif /* !defined(_ILP32) && !defined(_LP64) */ |
| 109 | |
| 110 | /* use these macros when the compiler supports the long long type */ |
| 111 | |
| 112 | #define ll_high(a) ((uint32_t)(((uint64_t)(a))>>32)) |
| 113 | #define ll_low(a) ((uint32_t)(a)) |
| 114 | #define int2ll(a) ((int64_t)(a)) |
| 115 | #define ll2int(a) ((int)(a)) |
| 116 | #define ll_add(a, b) ((int64_t)(a) + (int64_t)(b)) |
| 117 | #define ll_and(a, b) ((int64_t)(a) & (int64_t)(b)) |
| 118 | #define ll_div(a, b) ((int64_t)(a) / (int64_t)(b)) |
| 119 | #define ll_mul(a, b) ((int64_t)(a) * (int64_t)(b)) |
| 120 | #define ll_neg(a) (-(a)) |
| 121 | #define ll_not(a) (~(uint64_t)(a)) |
| 122 | #define ll_or(a, b) ((uint64_t)(a) | (b)) |
| 123 | #define ll_shl(a, n) ((uint64_t)(a) << (n)) |
| 124 | #define ll_shr(a, n) ((int64_t)(a) >> (n)) |
| 125 | #define ll_sub(a, b) ((uint64_t)(a) - (b)) |
| 126 | #define ll_ushr(a, n) ((uint64_t)(a) >>(n)) |
| 127 | #define ll_xor(a, b) ((int64_t)(a) ^ (int64_t)(b)) |
| 128 | #define uint2ll(a) ((uint64_t)(a)) |
| 129 | #define ll_rem(a,b) ((int64_t)(a) % (int64_t)(b)) |
| 130 | |
| 131 | extern int32_t float2l(float f); |
| 132 | extern int32_t double2l(double d); |
| 133 | extern int64_t float2ll(float f); |
| 134 | extern int64_t double2ll(double d); |
| 135 | |
| 136 | #define ll2float(a) ((float) (a)) |
| 137 | #define ll2double(a) ((double) (a)) |
| 138 | |
| 139 | /* Useful on machines where jlong and jdouble have different endianness. */ |
| 140 | #define ll2double_bits(a) ((void) 0) |
| 141 | |
| 142 | /* comparison operators */ |
| 143 | #define ll_ltz(ll) ((ll)<0) |
| 144 | #define ll_gez(ll) ((ll)>=0) |
| 145 | #define ll_eqz(a) ((a) == 0) |
| 146 | #define ll_nez(a) ((a) != 0) |
| 147 | #define ll_eq(a, b) ((a) == (b)) |
| 148 | #define ll_ne(a,b) ((a) != (b)) |
| 149 | #define ll_ge(a,b) ((a) >= (b)) |
| 150 | #define ll_le(a,b) ((a) <= (b)) |
| 151 | #define ll_lt(a,b) ((a) < (b)) |
| 152 | #define ll_gt(a,b) ((a) > (b)) |
| 153 | |
| 154 | #define ll_zero_const ((int64_t) 0) |
| 155 | #define ll_one_const ((int64_t) 1) |
| 156 | |
| 157 | extern void ll2str(int64_t a, char *s, char *limit); |
| 158 | |
| 159 | #define ll2ptr(a) ((void*)(uintptr_t)(a)) |
| 160 | #define ptr2ll(a) ((int64_t)(uintptr_t)(a)) |
| 161 | |
| 162 | #ifdef ppc |
| 163 | #define HAVE_ALIGNED_DOUBLES |
| 164 | #define HAVE_ALIGNED_LONGLONGS |
| 165 | #endif |
| 166 | |
| 167 | /* printf format modifier for printing pointers */ |
| 168 | #ifdef _LP64 |
| 169 | #define FORMAT64_MODIFIER "l" |
| 170 | #else |
| 171 | #define FORMAT64_MODIFIER "ll" |
| 172 | #endif |
| 173 | |
| 174 | #endif /* !_JAVASOFT_SOLARIS_TYPES_MD_H_ */ |