1 /* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 27 #ifndef MLIB_TYPES_H 28 #define MLIB_TYPES_H 29 30 #include <limits.h> 31 #if defined(_MSC_VER) 32 #include <float.h> /* for FLT_MAX and DBL_MAX */ 33 #endif 34 35 #ifndef DBL_MAX 36 #define DBL_MAX 1.7976931348623157E+308 /* max decimal value of a "double" */ 37 #endif 38 39 #ifndef FLT_MAX 40 #define FLT_MAX 3.402823466E+38F /* max decimal value of a "float" */ 41 #endif 42 43 #ifndef FLT_MIN 44 #define FLT_MIN 1.175494351e-38F /* min normalised value of a "float" */ 45 #endif 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 typedef char mlib_s8; 52 typedef unsigned char mlib_u8; 53 typedef short mlib_s16; 54 typedef unsigned short mlib_u16; 55 typedef int mlib_s32; 56 typedef unsigned int mlib_u32; 57 typedef float mlib_f32; 58 typedef double mlib_d64; 59 60 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__GNUC__) || defined(_AIX) 61 62 #include <stdint.h> 63 #include <stddef.h> 64 65 #if defined(MLIB_OS64BIT) || (defined(MACOSX) && defined(_LP64)) 66 67 typedef long mlib_s64; 68 typedef unsigned long mlib_u64; 69 70 #define MLIB_S64_MIN LONG_MIN 71 #define MLIB_S64_MAX LONG_MAX 72 73 #define MLIB_S64_CONST(x) x##L 74 #define MLIB_U64_CONST(x) x##UL 75 76 #elif (__STDC__ - 0 == 0) || defined(__GNUC__) 77 78 #if defined(_NO_LONGLONG) 79 80 typedef union { 81 mlib_d64 d64; 82 mlib_s32 s32[2]; 83 } mlib_s64; 84 85 typedef union { 86 mlib_d64 d64; 87 mlib_u32 u32[2]; 88 } mlib_u64; 89 90 #else 91 92 typedef long long mlib_s64; 93 typedef unsigned long long mlib_u64; 94 95 #define MLIB_S64_MIN LLONG_MIN 96 #define MLIB_S64_MAX LLONG_MAX 97 98 #define MLIB_S64_CONST(x) x##LL 99 #define MLIB_U64_CONST(x) x##ULL 100 101 #endif /* !defined(_NO_LONGLONG) */ 102 103 #endif /* MLIB_OS64BIT */ 104 105 #elif defined(_MSC_VER) 106 107 #if defined(_NO_LONGLONG) 108 109 typedef union { 110 mlib_d64 d64; 111 mlib_s32 s32[2]; 112 } mlib_s64; 113 114 typedef union { 115 mlib_d64 d64; 116 mlib_u32 u32[2]; 117 } mlib_u64; 118 119 #else 120 121 typedef __int64 mlib_s64; 122 typedef unsigned __int64 mlib_u64; 123 124 #define MLIB_S64_MIN _I64_MIN 125 #define MLIB_S64_MAX _I64_MAX 126 127 #define MLIB_S64_CONST(x) x##I64 128 #define MLIB_U64_CONST(x) x##UI64 129 130 #endif /* !defined(_NO_LONGLONG) */ 131 132 #include <stddef.h> 133 #if !defined(_WIN64) 134 typedef int intptr_t; 135 typedef unsigned int uintptr_t; 136 #endif /* _WIN64 */ 137 138 #else 139 140 #error "unknown platform" 141 142 #endif 143 144 typedef uintptr_t mlib_addr; 145 typedef void* mlib_ras; 146 147 #define MLIB_S8_MIN SCHAR_MIN 148 #define MLIB_S8_MAX SCHAR_MAX 149 #define MLIB_U8_MIN 0 150 #define MLIB_U8_MAX UCHAR_MAX 151 #define MLIB_S16_MIN SHRT_MIN 152 #define MLIB_S16_MAX SHRT_MAX 153 #define MLIB_U16_MIN 0 154 #define MLIB_U16_MAX USHRT_MAX 155 #define MLIB_S32_MIN INT_MIN 156 #define MLIB_S32_MAX INT_MAX 157 #define MLIB_U32_MIN 0 158 #define MLIB_U32_MAX UINT_MAX 159 #define MLIB_F32_MIN -FLT_MAX 160 #define MLIB_F32_MAX FLT_MAX 161 #define MLIB_D64_MIN -DBL_MAX 162 #define MLIB_D64_MAX DBL_MAX 163 164 #ifdef __cplusplus 165 } 166 #endif 167 168 #endif /* MLIB_TYPES_H */