blob: f621960b1d53f5459fdad59741cb49664913309c [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2003 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#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
48extern "C" {
49#endif
50
51typedef char mlib_s8;
52typedef unsigned char mlib_u8;
53typedef short mlib_s16;
54typedef unsigned short mlib_u16;
55typedef int mlib_s32;
56typedef unsigned int mlib_u32;
57typedef float mlib_f32;
58typedef double mlib_d64;
59
60#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__GNUC__)
61
62#if defined(__linux__)
63#include <stdint.h> /* for uintptr_t */
64#include <malloc.h> /* for ptrdiff_t */
65#else
66#include <link.h> /* for uintptr_t */
67#include <stddef.h> /* for ptrdiff_t */
68#endif /* __linux__ */
69
70#ifdef MLIB_OS64BIT
71
72typedef long mlib_s64;
73typedef unsigned long mlib_u64;
74
75#define MLIB_S64_MIN LONG_MIN
76#define MLIB_S64_MAX LONG_MAX
77
78#define MLIB_S64_CONST(x) x##L
79#define MLIB_U64_CONST(x) x##UL
80
81#elif (__STDC__ - 0 == 0) || defined(__GNUC__)
82
83#if defined(_NO_LONGLONG)
84
85typedef union {
86 mlib_d64 d64;
87 mlib_s32 s32[2];
88} mlib_s64;
89
90typedef union {
91 mlib_d64 d64;
92 mlib_u32 u32[2];
93} mlib_u64;
94
95#else
96
97typedef long long mlib_s64;
98typedef unsigned long long mlib_u64;
99
100#define MLIB_S64_MIN LLONG_MIN
101#define MLIB_S64_MAX LLONG_MAX
102
103#define MLIB_S64_CONST(x) x##LL
104#define MLIB_U64_CONST(x) x##ULL
105
106#endif /* !defined(_NO_LONGLONG) */
107
108#endif /* MLIB_OS64BIT */
109
110#elif defined(_MSC_VER)
111
112#if defined(_NO_LONGLONG)
113
114typedef union {
115 mlib_d64 d64;
116 mlib_s32 s32[2];
117} mlib_s64;
118
119typedef union {
120 mlib_d64 d64;
121 mlib_u32 u32[2];
122} mlib_u64;
123
124#else
125
126typedef __int64 mlib_s64;
127typedef unsigned __int64 mlib_u64;
128
129#define MLIB_S64_MIN _I64_MIN
130#define MLIB_S64_MAX _I64_MAX
131
132#define MLIB_S64_CONST(x) x##I64
133#define MLIB_U64_CONST(x) x##UI64
134
135#endif /* !defined(_NO_LONGLONG) */
136
137#include <stddef.h>
138#if !defined(_WIN64)
139typedef int intptr_t;
140typedef unsigned int uintptr_t;
141#endif /* _WIN64 */
142
143#else
144
145#error "unknown platform"
146
147#endif
148
149typedef uintptr_t mlib_addr;
150typedef void* mlib_ras;
151
152#define MLIB_S8_MIN SCHAR_MIN
153#define MLIB_S8_MAX SCHAR_MAX
154#define MLIB_U8_MIN 0
155#define MLIB_U8_MAX UCHAR_MAX
156#define MLIB_S16_MIN SHRT_MIN
157#define MLIB_S16_MAX SHRT_MAX
158#define MLIB_U16_MIN 0
159#define MLIB_U16_MAX USHRT_MAX
160#define MLIB_S32_MIN INT_MIN
161#define MLIB_S32_MAX INT_MAX
162#define MLIB_U32_MIN 0
163#define MLIB_U32_MAX UINT_MAX
164#define MLIB_F32_MIN -FLT_MAX
165#define MLIB_F32_MAX FLT_MAX
166#define MLIB_D64_MIN -DBL_MAX
167#define MLIB_D64_MAX DBL_MAX
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif /* MLIB_TYPES_H */