OSDN Git Service

da37941c7bdf169238a6e662a8d1cc4bcb973719
[nxt-jsp/lejos_nxj.git] / nxtOSEK / lejos_nxj / src / nxtvm / javavm / types.h
1 #ifndef _TYPES_H
2 #define _TYPES_H
3
4 #include "platform_config.h"
5
6 typedef byte boolean;
7
8 /*
9  * The following types must be defined in platform_config.h:
10  * JBYTE
11  * JSHORT
12  * JINT
13  * TWOBYTES
14  * FOURBYTES
15  */
16
17
18 typedef float        JFLOAT;
19 typedef JBYTE        JBOOLEAN;
20 typedef JSHORT       JCHAR;
21 typedef FOURBYTES    REFERENCE;
22 typedef FOURBYTES    STACKWORD;
23
24 typedef union
25 {
26   JFLOAT fnum;
27   STACKWORD sword;
28 } AuxConvUnion1;
29
30 typedef struct
31 {
32   STACKWORD hi;
33   STACKWORD lo;
34 } JLONG;
35
36
37 #ifndef LITTLE_ENDIAN
38 #error LITTLE_ENDIAN not defined in platform_config.h
39 #endif
40
41 #define jfloat2word(FLOAT_) (((AuxConvUnion1) (FLOAT_)).sword)
42 #define word2jfloat(WORD_)  (((AuxConvUnion1) (WORD_)).fnum)
43 #define byte2jint(BYTE_)    ((JINT) (signed char) (BYTE_))
44 #define word2jint(WORD_)    ((JINT) (WORD_))
45 #define word2jshort(WORD_)  ((JSHORT) (WORD_))
46 #define word2obj(WORD_)     ((Object *) word2ptr(WORD_))
47 #define obj2word(OBJ_)      ptr2word(OBJ_)
48 #define obj2ref(OBJ_)       ptr2ref(OBJ_)
49 #define obj2ptr(OBJ_)       ((void *) (OBJ_))
50 #define ptr2ref(PTR_)       ((REFERENCE) ptr2word(PTR_))
51 #define ref2ptr(REF_)       word2ptr((STACKWORD) (REF_))
52 #define ref2obj(REF_)       ((Object *) ref2ptr(REF_))
53
54 #if 0
55 static inline JINT jlong_compare (JLONG a1, JLONG a2)
56 {
57   if (a1.hi == a2.hi)
58     return a1.lo - a2.lo;
59   return a1.hi - a2.hi;
60 }
61 #endif
62
63 #endif // _TYPES_H
64
65