2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
#if !defined(hycomp_h)
22
* USE_PROTOTYPES: Use full ANSI prototypes.
24
* CLOCK_PRIMS: We want the timer/clock prims to be used
26
* LITTLE_ENDIAN: This is for the intel machines or other
27
* little endian processors. Defaults to big endian.
29
* NO_LVALUE_CASTING: This is for compilers that don't like the left side
30
* of assigns to be cast. It hacks around to do the
33
* ATOMIC_FLOAT_ACCESS: So that float operations will work.
35
* LINKED_USER_PRIMITIVES: Indicates that user primitives are statically linked
36
* with the VM executeable.
38
* OLD_SPACE_SIZE_DIFF: The 68k uses a different amount of old space.
39
* This "legitimizes" the change.
41
* SIMPLE_SIGNAL: For machines that don't use real signals in C.
44
* OS_NAME_LOOKUP: Use nlist to lookup user primitive addresses.
46
* VMCALL: Tag for all functions called by the VM.
48
* VMAPICALL: Tag for all functions called via the PlatformFunction
49
* callWith: mechanism.
51
* SYS_FLOAT: For some math functions where extended types (80 or 96 bits) are returned
52
* Most platforms return as a double
54
* FLOAT_EXTENDED: If defined, the type name for extended precision floats.
56
* PLATFORM_IS_ASCII: Must be defined if the platform is ASCII
58
* EXE_EXTENSION_CHAR: the executable has a delimiter that we want to stop at as part of argv[0].
62
* By default order doubles in the native (that is big/little endian) ordering.
65
#define HY_PLATFORM_DOUBLE_ORDER
68
* Define common types:
70
* <li><code>U_32 / I_32</code> - unsigned/signed 32 bits</li>
71
* <li><code>U_16 / I_16</code> - unsigned/signed 16 bits</li>
72
* <li><code>U_8 / I_8</code> - unsigned/signed 8 bits (bytes -- not to be
73
* confused with char)</li>
79
typedef signed char I_8; /* chars can be unsigned */
80
typedef unsigned int U_32;
81
typedef unsigned short U_16;
82
typedef unsigned char U_8;
85
* Define platform specific types:
87
* <li><code>U_64 / I_64</code> - unsigned/signed 64 bits</li>
91
#if defined(LINUX) || defined(FREEBSD) || defined(AIX) || defined(MACOSX) || defined(__CYGWIN32__)
93
#define DATA_TYPES_DEFINED
95
/* NOTE: Linux supports different processors -- do not assume 386 */
96
#if defined(HYX86_64) || defined(HYIA64) || defined(HYPPC64) || defined(HYS390X)
98
typedef unsigned long int U_64; /* 64bits */
99
typedef long int I_64;
100
#define TOC_UNWRAP_ADDRESS(wrappedPointer) ((void *) (wrappedPointer)[0])
101
#define TOC_STORE_TOC(dest,wrappedPointer) (dest = ((UDATA*)wrappedPointer)[1])
107
typedef long long I_64;
108
typedef unsigned long long U_64;
112
#if defined(HYS390X) || defined(HYS390) || defined(HYPPC64) || defined(HYPPC32)
113
#define HY_BIG_ENDIAN
115
#define HY_LITTLE_ENDIAN
118
#if defined(HYPPC32) && defined(LINUX)
119
#define VA_PTR(valist) (&valist[0])
122
typedef double SYS_FLOAT;
123
#define HYCONST64(x) x##LL
124
#define NO_LVALUE_CASTING
125
#define FLOAT_EXTENDED long double
126
#define PLATFORM_IS_ASCII
127
#define PLATFORM_LINE_DELIMITER "\012"
128
#define DIR_SEPARATOR '/'
129
#define DIR_SEPARATOR_STR "/"
130
#define PATH_SEPARATOR ':'
131
#define PATH_SEPARATOR_STR ":"
133
#define LIBPATH_ENV_VAR "LIBPATH"
136
#define LIBPATH_ENV_VAR "DYLD_LIBRARY_PATH"
138
#define LIBPATH_ENV_VAR "LD_LIBRARY_PATH"
142
#define PLATFORM_DLL_EXTENSION ".dylib"
144
#define PLATFORM_DLL_EXTENSION ".so"
148
* No priorities on Linux
151
#define HY_PRIORITY_MAP {0,0,0,0,0,0,0,0,0,0,0,0}
153
typedef U_32 BOOLEAN;
157
/* Win32 - Windows 3.1 & NT using Win32 */
160
#define HY_LITTLE_ENDIAN
162
/* Define 64-bit integers for Windows */
163
typedef __int64 I_64;
164
typedef unsigned __int64 U_64;
166
typedef double SYS_FLOAT;
167
#define NO_LVALUE_CASTING
168
#define VMAPICALL _stdcall
169
#define VMCALL _cdecl
170
#define EXE_EXTENSION_CHAR '.'
172
#define DIR_SEPARATOR '\\'
173
#define DIR_SEPARATOR_STR "\\"
174
#define PATH_SEPARATOR ';'
175
#define PATH_SEPARATOR_STR ";"
176
#define LIBPATH_ENV_VAR "PATH"
178
/* Modifications for the Alpha running WIN-NT */
180
#undef small /* defined as char in rpcndr.h */
181
typedef double FLOAT_EXTENDED;
184
#define HY_PRIORITY_MAP { \
185
THREAD_PRIORITY_IDLE, /* 0 */\
186
THREAD_PRIORITY_LOWEST, /* 1 */\
187
THREAD_PRIORITY_BELOW_NORMAL, /* 2 */\
188
THREAD_PRIORITY_BELOW_NORMAL, /* 3 */\
189
THREAD_PRIORITY_BELOW_NORMAL, /* 4 */\
190
THREAD_PRIORITY_NORMAL, /* 5 */\
191
THREAD_PRIORITY_ABOVE_NORMAL, /* 6 */\
192
THREAD_PRIORITY_ABOVE_NORMAL, /* 7 */\
193
THREAD_PRIORITY_ABOVE_NORMAL, /* 8 */\
194
THREAD_PRIORITY_ABOVE_NORMAL, /* 9 */\
195
THREAD_PRIORITY_HIGHEST, /*10 */\
196
THREAD_PRIORITY_TIME_CRITICAL /*11 */}
198
#endif /* defined(WIN32) */
202
#define HY_BIG_ENDIAN
204
#define DATA_TYPES_DEFINED
205
typedef unsigned int BOOLEAN;
206
#if defined (HYS390X)
207
typedef unsigned long U_64;
210
typedef signed long long I_64;
211
typedef unsigned long long U_64;
214
typedef double SYS_FLOAT;
216
#define HYCONST64(x) x##LL
218
#define NO_LVALUE_CASTING
219
#define PLATFORM_LINE_DELIMITER "\012"
220
#define DIR_SEPARATOR '/'
221
#define DIR_SEPARATOR_STR "/"
222
#define PATH_SEPARATOR ':'
223
#define PATH_SEPARATOR_STR ":"
224
#define LIBPATH_ENV_VAR "LIBPATH"
226
#define VA_PTR(valist) (&valist[0])
229
#if !defined(HYS390X)
233
void (*rawFnAddress)();
234
} HyFunctionDescriptor_T;
236
#define TOC_UNWRAP_ADDRESS(wrappedPointer) (((HyFunctionDescriptor_T *) (wrappedPointer))->rawFnAddress)
238
#define PLATFORM_DLL_EXTENSION ".so"
243
#endif /* ifndef HY_WORD64 */
253
#define PVMCALL VMCALL *
255
#define GLOBAL_DATA(symbol) ((void*)&(symbol))
256
#define GLOBAL_TABLE(symbol) GLOBAL_DATA(symbol)
259
* Define platform specific types:
261
* <li><code>UDATA</code> - unsigned data, can be used as an integer or
262
* pointer storage</li>
263
* <li><code>IDATA</code> - signed data, can be used as an integer or
264
* pointer storage</li>
267
/* FIXME: POINTER64 */
268
#if defined(HYX86_64) || defined(HYIA64) || defined(HYPPC64) || defined(HYS390X) || defined(POINTER64)
273
#else /* this is default for non-64bit systems */
278
#endif /* defined(HYX86_64) */
280
#if !defined(DATA_TYPES_DEFINED)
281
/* no generic U_64 or I_64 */
283
/* don't typedef BOOLEAN since it's already def'ed on Win32 */
284
#define BOOLEAN UDATA
286
#ifndef HY_BIG_ENDIAN
287
#define HY_LITTLE_ENDIAN
292
#if !defined(HYCONST64)
293
#define HYCONST64(x) x##L
296
#if !defined(HY_DEFAULT_SCHED)
299
* By default, pthreads platforms use the <code>SCHED_OTHER</code> thread
303
#define HY_DEFAULT_SCHED SCHED_OTHER
306
#if !defined(HY_PRIORITY_MAP)
309
* If no priority map if provided, priorities will be determined
316
#define FALSE ((BOOLEAN) 0)
318
#define TRUE ((BOOLEAN) (!FALSE))
323
#if defined(__cplusplus)
326
#define NULL ((void *)0)
329
#define USE_PROTOTYPES
330
#if defined(USE_PROTOTYPES)
331
#define PROTOTYPE(x) x
332
#define VARARGS , ...
334
#define PROTOTYPE(x) ()
339
* Assign the default line delimiter, if it was not set.
342
#if !defined(PLATFORM_LINE_DELIMITER)
343
#define PLATFORM_LINE_DELIMITER "\015\012"
347
* Set the max path length, if it was not set.
350
#if !defined(MAX_IMAGE_PATH_LENGTH)
351
#define MAX_IMAGE_PATH_LENGTH (2048)
353
typedef double ESDOUBLE;
354
typedef float ESSINGLE;
360
#define CLEAR_U64(u64) (u64 = (U_64)0)
361
#define LOW_LONG(l) (*((U_32 *) &(l)))
362
#define HIGH_LONG(l) (*(((U_32 *) &(l)) + 1))
363
#define I8(x) ((I_8) (x))
364
#define I8P(x) ((I_8 *) (x))
365
#define U16(x) ((U_16) (x))
366
#define I16(x) ((I_16) (x))
367
#define I16P(x) ((I_16 *) (x))
368
#define U32(x) ((U_32) (x))
369
#define I32(x) ((I_32) (x))
370
#define I32P(x) ((I_32 *) (x))
371
#define U16P(x) ((U_16 *) (x))
372
#define U32P(x) ((U_32 *) (x))
373
#define OBJP(x) ((HyObject *) (x))
374
#define OBJPP(x) ((HyObject **) (x))
375
#define OBJPPP(x) ((HyObject ***) (x))
376
#define CLASSP(x) ((Class *) (x))
377
#define CLASSPP(x) ((Class **) (x))
378
#define BYTEP(x) ((BYTE *) (x))
381
* Test - was conflicting with OS2.h
384
#define ESCHAR(x) ((CHARACTER) (x))
385
#define FLT(x) ((FLOAT) x)
386
#define FLTP(x) ((FLOAT *) (x))
387
#if defined(NO_LVALUE_CASTING)
388
#define LI8(x) (*((I_8 *) &(x)))
389
#define LI8P(x) (*((I_8 **) &(x)))
390
#define LU16(x) (*((U_16 *) &(x)))
391
#define LI16(x) (*((I_16 *) &(x)))
392
#define LU32(x) (*((U_32 *) &(x)))
393
#define LI32(x) (*((I_32 *) &(x)))
394
#define LI32P(x) (*((I_32 **) &(x)))
395
#define LU16P(x) (*((U_16 **) &(x)))
396
#define LU32P(x) (*((U_32 **) &(x)))
397
#define LOBJP(x) (*((HyObject **) &(x)))
398
#define LOBJPP(x) (*((HyObject ***) &(x)))
399
#define LOBJPPP(x) (*((HyObject ****) &(x))
400
#define LCLASSP(x) (*((Class **) &(x)))
401
#define LBYTEP(x) (*((BYTE **) &(x)))
402
#define LCHAR(x) (*((CHARACTER) &(x)))
403
#define LFLT(x) (*((FLOAT) &x))
404
#define LFLTP(x) (*((FLOAT *) &(x)))
406
#define LI8(x) I8((x))
407
#define LI8P(x) I8P((x))
408
#define LU16(x) U16((x))
409
#define LI16(x) I16((x))
410
#define LU32(x) U32((x))
411
#define LI32(x) I32((x))
412
#define LI32P(x) I32P((x))
413
#define LU16P(x) U16P((x))
414
#define LU32P(x) U32P((x))
415
#define LOBJP(x) OBJP((x))
416
#define LOBJPP(x) OBJPP((x))
417
#define LOBJPPP(x) OBJPPP((x))
418
#define LIOBJP(x) IOBJP((x))
419
#define LCLASSP(x) CLASSP((x))
420
#define LBYTEP(x) BYTEP((x))
421
#define LCHAR(x) CHAR((x))
422
#define LFLT(x) FLT((x))
423
#define LFLTP(x) FLTP((x))
427
* Macros for converting between words and longs and accessing bits.
430
#define HIGH_WORD(x) U16(U32((x)) >> 16)
431
#define LOW_WORD(x) U16(U32((x)) & 0xFFFF)
432
#define LOW_BIT(o) (U32((o)) & 1)
433
#define LOW_2_BITS(o) (U32((o)) & 3)
434
#define LOW_3_BITS(o) (U32((o)) & 7)
435
#define LOW_4_BITS(o) (U32((o)) & 15)
436
#define MAKE_32(h, l) ((U32((h)) << 16) | U32((l)))
437
#define MAKE_64(h, l) ((((I_64)(h)) << 32) | (l))
438
#if defined(__cplusplus)
447
* Macros for tagging functions which read/write the vm thread.
450
#define READSVMTHREAD
451
#define WRITESVMTHREAD
452
#define REQUIRESSTACKFRAME
455
* Macro for tagging functions, which never return.
458
#if defined(__GNUC__)
461
* On GCC, we can actually pass this information on to the compiler.
464
#define NORETURN __attribute__((noreturn))
470
* On some systems va_list is an array type. This is probably in
471
* violation of the ANSI C spec, but it's not entirely clear. Because of
472
* this, we end up with an undesired extra level of indirection if we take
473
* the address of a va_list argument.
475
* To get it right, always use the VA_PTR macro
479
#define VA_PTR(valist) (&valist)
481
#if !defined(TOC_UNWRAP_ADDRESS)
482
#define TOC_UNWRAP_ADDRESS(wrappedPointer) (wrappedPointer)
485
#if !defined(TOC_STORE_TOC)
486
#define TOC_STORE_TOC(dest,wrappedPointer)
489
* Macros for accessing I_64 values.
492
#if defined(ATOMIC_LONG_ACCESS)
493
#define PTR_LONG_STORE(dstPtr, aLongPtr) ((*U32P(dstPtr) = *U32P(aLongPtr)), (*(U32P(dstPtr)+1) = *(U32P(aLongPtr)+1)))
494
#define PTR_LONG_VALUE(dstPtr, aLongPtr) ((*U32P(aLongPtr) = *U32P(dstPtr)), (*(U32P(aLongPtr)+1) = *(U32P(dstPtr)+1)))
496
#define PTR_LONG_STORE(dstPtr, aLongPtr) (*(dstPtr) = *(aLongPtr))
497
#define PTR_LONG_VALUE(dstPtr, aLongPtr) (*(aLongPtr) = *(dstPtr))
501
* Macro used when declaring tables which require relocations.
504
#if !defined(HYCONST_TABLE)
505
#define HYCONST_TABLE const
509
* ANSI qsort is not always available.
512
#if !defined(HY_SORT)
513
#define HY_SORT(base, nmemb, size, compare) qsort((base), (nmemb), (size), (compare))
517
* Helper macros for storing/restoring pointers to jlong.
519
#define jlong2addr(a, x) ((a *)((IDATA)(x)))
520
#define addr2jlong(x) ((jlong)((IDATA)(x)))
522
#endif /* hycomp_h */