#ifndef GCC_JAVAOP_H
#define GCC_JAVAOP_H
typedef unsigned char uint8;
#ifndef int16
#define int16 short
#endif
typedef unsigned int16 uint16;
#ifndef int32
#define int32 long
#endif
typedef unsigned int32 uint32;
#ifndef int64
#define int64 long long
#endif
#ifndef uint64
#define uint64 unsigned int64
#endif
typedef uint16 jchar;
typedef signed char jbyte;
typedef int16 jshort;
typedef int32 jint;
typedef int64 jlong;
typedef void* jref;
typedef struct _jfloat {
unsigned int negative : 1;
unsigned int exponent : 8;
unsigned int mantissa : 23;
} jfloat;
#define JFLOAT_FINITE(f) ((f).exponent != 0xFF)
#define JFLOAT_QNAN_MASK 0x400000
#define JFLOAT_EXP_BIAS 0x7f
typedef struct _jdouble {
unsigned int negative : 1;
unsigned int exponent : 11;
unsigned int mantissa0: 20;
unsigned int mantissa1: 32;
} jdouble;
#define JDOUBLE_FINITE(f) ((f).exponent != 0x7FF)
#define JDOUBLE_QNAN_MASK 0x80000
#define JDOUBLE_EXP_BIAS 0x3ff
#ifndef jword
#define jword uint32
#endif
#ifndef IMMEDIATE_u1
#define IMMEDIATE_u1 (PC++, CHECK_PC_IN_RANGE(PC), BCODE[PC-1])
#endif
#ifndef IMMEDIATE_s1
#define IMMEDIATE_s1 (PC++, CHECK_PC_IN_RANGE(PC), (signed char)BCODE[PC-1])
#endif
#ifndef IMMEDIATE_s2
#define IMMEDIATE_s2 (PC+=2, CHECK_PC_IN_RANGE(PC), \
(signed char) BCODE[PC-2] * 256 + BCODE[PC-1])
#endif
#ifndef IMMEDIATE_u2
#define IMMEDIATE_u2 (PC+=2, CHECK_PC_IN_RANGE(PC),\
(BCODE[PC-2] * 256 + BCODE[PC-1]))
#endif
#ifndef IMMEDIATE_s4
#define IMMEDIATE_s4 (PC+=4, CHECK_PC_IN_RANGE(PC), \
(WORD_TO_INT((BCODE[PC-4] << 24) | (BCODE[PC-3] << 16) \
| (BCODE[PC-2] << 8) | (BCODE[PC-1]))))
#endif
static inline jfloat
WORD_TO_FLOAT(jword w)
{
jfloat f;
f.negative = (w & 0x80000000) >> 31;
f.exponent = (w & 0x7f800000) >> 23;
f.mantissa = (w & 0x007fffff);
return f;
}
static inline jint
WORD_TO_INT(jword w)
{
jint n = w & 0xffffffff;
n ^= (jint)1 << 31;
n -= (jint)1 << 31;
return n;
}
static inline jlong
WORDS_TO_LONG(jword hi, jword lo)
{
return ((jlong) hi << 32) | ((jlong)lo & (((jlong)1 << 32) -1));
}
static inline jdouble
WORDS_TO_DOUBLE(jword hi, jword lo)
{
jdouble d;
d.negative = (hi & 0x80000000) >> 31;
d.exponent = (hi & 0x7ff00000) >> 20;
d.mantissa0 = (hi & 0x000fffff);
d.mantissa1 = lo;
return d;
}
#define UT8_CHAR_LENGTH(PREFIX_CHAR) \
((unsigned char)(PREFIX_CHAR) < 128 ? 1 \
: ((PREFIX_CHAR) & 0x40) == 0 ? -1 \
: ((PREFIX_CHAR) & 0x20) == 0 ? 2 \
: ((PREFIX_CHAR) & 0x10) == 0 ? 3 \
: ((PREFIX_CHAR) & 0x08) == 0 ? 4 : 5)
#endif