diff options
author | David Schleef <ds@schleef.org> | 2010-09-16 12:35:30 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-09-16 12:35:30 -0700 |
commit | e07b6388eb32f9fc4d21aaa0431615ebd2c2c995 (patch) | |
tree | 3afa881e32533072bdf9104fd88b7d01f93a9780 | |
parent | b89d53403f9aa61d8796fba2da77e07c049b1e44 (diff) |
Convert usage of ULL to ORC_UINT64_C()
-rw-r--r-- | orc/opcodes.h | 6 | ||||
-rw-r--r-- | orc/orcemulateopcodes.c | 16 | ||||
-rw-r--r-- | orc/orcfunctions.c | 12 | ||||
-rw-r--r-- | orc/orcfunctions.h | 6 | ||||
-rw-r--r-- | orc/orcopcodes.c | 2 | ||||
-rw-r--r-- | orc/orcprogram-c.c | 16 | ||||
-rw-r--r-- | orc/orcutils.c | 6 | ||||
-rw-r--r-- | orc/orcutils.h | 4 |
8 files changed, 42 insertions, 26 deletions
diff --git a/orc/opcodes.h b/orc/opcodes.h index 350e949..9581e1f 100644 --- a/orc/opcodes.h +++ b/orc/opcodes.h @@ -150,6 +150,6 @@ BINARY_D(subd, "%s - %s") BINARY_D(muld, "%s * %s") BINARY_D(divd, "%s / %s") UNARY_D(sqrtd, "sqrt(%s)") -BINARY_DQ(cmpeqd, "(%s == %s) ? (~0ULL) : 0") -BINARY_DQ(cmpltd, "(%s < %s) ? (~0ULL) : 0") -BINARY_DQ(cmpled, "(%s <= %s) ? (~0ULL) : 0") +BINARY_DQ(cmpeqd, "(%s == %s) ? ORC_UINT64_C(~0) : 0") +BINARY_DQ(cmpltd, "(%s < %s) ? ORC_UINT64_C(~0) : 0") +BINARY_DQ(cmpled, "(%s <= %s) ? ORC_UINT64_C(~0) : 0") diff --git a/orc/orcemulateopcodes.c b/orc/orcemulateopcodes.c index fcc1e14..f88bddc 100644 --- a/orc/orcemulateopcodes.c +++ b/orc/orcemulateopcodes.c @@ -33,12 +33,12 @@ #define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX) #define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8)) #define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24)) -#define ORC_SWAP_Q(x) ((((x)&0xffULL)<<56) | (((x)&0xff00ULL)<<40) | (((x)&0xff0000ULL)<<24) | (((x)&0xff000000ULL)<<8) | (((x)&0xff00000000ULL)>>8) | (((x)&0xff0000000000ULL)>>24) | (((x)&0xff000000000000ULL)>>40) | (((x)&0xff00000000000000ULL)>>56)) +#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56)) #define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) #define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff)) #define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0)) -#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&0x7ff0000000000000ULL) == 0) ? 0xfff0000000000000ULL : 0xffffffffffffffffULL)) -#define ORC_ISNAN_DOUBLE(x) ((((x)&0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) && (((x)&0x000fffffffffffffULL) != 0)) +#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff))) +#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0)) #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define ORC_RESTRICT restrict #elif defined(__GNUC__) && __GNUC__ >= 4 @@ -4054,7 +4054,7 @@ emulate_swaplq (OrcOpcodeExecutor *ex, int offset, int n) /* 0: loadq */ var32 = ptr4[i]; /* 1: swaplq */ - var33.i = ((var32.i&0x00000000ffffffffULL) << 32) | ((var32.i&0xffffffff00000000ULL) >> 32); + var33.i = (ORC_UINT64_C(var32.i&0x00000000ffffffff) << 32) | (ORC_UINT64_C(var32.i&0xffffffff00000000) >> 32); /* 2: storeq */ ptr0[i] = var33; } @@ -4994,7 +4994,7 @@ emulate_cmpeqd (OrcOpcodeExecutor *ex, int offset, int n) orc_union64 _src2; _src1.i = ORC_DENORMAL_DOUBLE(var32.i); _src2.i = ORC_DENORMAL_DOUBLE(var33.i); - var34.i = (_src1.f == _src2.f) ? (~0ULL) : 0; + var34.i = (_src1.f == _src2.f) ? ORC_UINT64_C(~0) : 0; } /* 3: storeq */ ptr0[i] = var34; @@ -5029,7 +5029,7 @@ emulate_cmpltd (OrcOpcodeExecutor *ex, int offset, int n) orc_union64 _src2; _src1.i = ORC_DENORMAL_DOUBLE(var32.i); _src2.i = ORC_DENORMAL_DOUBLE(var33.i); - var34.i = (_src1.f < _src2.f) ? (~0ULL) : 0; + var34.i = (_src1.f < _src2.f) ? ORC_UINT64_C(~0) : 0; } /* 3: storeq */ ptr0[i] = var34; @@ -5064,7 +5064,7 @@ emulate_cmpled (OrcOpcodeExecutor *ex, int offset, int n) orc_union64 _src2; _src1.i = ORC_DENORMAL_DOUBLE(var32.i); _src2.i = ORC_DENORMAL_DOUBLE(var33.i); - var34.i = (_src1.f <= _src2.f) ? (~0ULL) : 0; + var34.i = (_src1.f <= _src2.f) ? ORC_UINT64_C(~0) : 0; } /* 3: storeq */ ptr0[i] = var34; @@ -5092,7 +5092,7 @@ emulate_convdl (OrcOpcodeExecutor *ex, int offset, int n) { int tmp; tmp = var32.f; - if (tmp == 0x80000000 && !(var32.i&0x8000000000000000ULL)) tmp = 0x7fffffff; + if (tmp == 0x80000000 && !(var32.i & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff; var33.i = tmp; } /* 2: storel */ diff --git a/orc/orcfunctions.c b/orc/orcfunctions.c index 187e8a9..1151756 100644 --- a/orc/orcfunctions.c +++ b/orc/orcfunctions.c @@ -20,6 +20,7 @@ typedef uint8_t orc_uint8; typedef uint16_t orc_uint16; typedef uint32_t orc_uint32; typedef uint64_t orc_uint64; +#define ORC_UINT64_C(x) UINT64_C(x) #elif defined(_MSC_VER) typedef signed __int8 orc_int8; typedef signed __int16 orc_int16; @@ -29,6 +30,7 @@ typedef unsigned __int8 orc_uint8; typedef unsigned __int16 orc_uint16; typedef unsigned __int32 orc_uint32; typedef unsigned __int64 orc_uint64; +#define ORC_UINT64_C(x) (x##Ui64) #else #include <limits.h> typedef signed char orc_int8; @@ -40,14 +42,16 @@ typedef unsigned int orc_uint32; #if INT_MAX == LONG_MAX typedef long long orc_int64; typedef unsigned long long orc_uint64; +#define ORC_UINT64_C(x) (x##ULL) #else typedef long orc_int64; typedef unsigned long orc_uint64; +#define ORC_UINT64_C(x) (x##UL) #endif #endif typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16; typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32; -typedef union { orc_int64 i; double f; orc_int32 x2[2]; orc_int16 x4[4]; } orc_union64; +typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64; #endif void orc_memcpy (void * d1, const void * s1, int n); @@ -79,12 +83,12 @@ void orc_memset (void * d1, int p1, int n); #define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX) #define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8)) #define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24)) -#define ORC_SWAP_Q(x) ((((x)&0xffULL)<<56) | (((x)&0xff00ULL)<<40) | (((x)&0xff0000ULL)<<24) | (((x)&0xff000000ULL)<<8) | (((x)&0xff00000000ULL)>>8) | (((x)&0xff0000000000ULL)>>24) | (((x)&0xff000000000000ULL)>>40) | (((x)&0xff00000000000000ULL)>>56)) +#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56)) #define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) #define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff)) #define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0)) -#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&0x7ff0000000000000ULL) == 0) ? 0xfff0000000000000ULL : 0xffffffffffffffffULL)) -#define ORC_ISNAN_DOUBLE(x) ((((x)&0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) && (((x)&0x000fffffffffffffULL) != 0)) +#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff))) +#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0)) #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define ORC_RESTRICT restrict #elif defined(__GNUC__) && __GNUC__ >= 4 diff --git a/orc/orcfunctions.h b/orc/orcfunctions.h index e73895d..07f5265 100644 --- a/orc/orcfunctions.h +++ b/orc/orcfunctions.h @@ -23,6 +23,7 @@ typedef uint8_t orc_uint8; typedef uint16_t orc_uint16; typedef uint32_t orc_uint32; typedef uint64_t orc_uint64; +#define ORC_UINT64_C(x) UINT64_C(x) #elif defined(_MSC_VER) typedef signed __int8 orc_int8; typedef signed __int16 orc_int16; @@ -32,6 +33,7 @@ typedef unsigned __int8 orc_uint8; typedef unsigned __int16 orc_uint16; typedef unsigned __int32 orc_uint32; typedef unsigned __int64 orc_uint64; +#define ORC_UINT64_C(x) (x##Ui64) #else #include <limits.h> typedef signed char orc_int8; @@ -43,14 +45,16 @@ typedef unsigned int orc_uint32; #if INT_MAX == LONG_MAX typedef long long orc_int64; typedef unsigned long long orc_uint64; +#define ORC_UINT64_C(x) (x##ULL) #else typedef long orc_int64; typedef unsigned long orc_uint64; +#define ORC_UINT64_C(x) (x##UL) #endif #endif typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16; typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32; -typedef union { orc_int64 i; double f; orc_int32 x2[2]; orc_int16 x4[4]; } orc_union64; +typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64; #endif void orc_memcpy (void * d1, const void * s1, int n); void orc_memset (void * d1, int p1, int n); diff --git a/orc/orcopcodes.c b/orc/orcopcodes.c index f6a2fdf..8201083 100644 --- a/orc/orcopcodes.c +++ b/orc/orcopcodes.c @@ -34,7 +34,7 @@ static OrcTarget *default_target; #define ORC_UW_MIN 0 #define ORC_SL_MAX 2147483647 #define ORC_SL_MIN (-1-ORC_SL_MAX) -#define ORC_UL_MAX 4294967295ULL +#define ORC_UL_MAX ORC_UINT64_C(4294967295) #define ORC_UL_MIN 0 #define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX) diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c index 855fa2f..8358cd7 100644 --- a/orc/orcprogram-c.c +++ b/orc/orcprogram-c.c @@ -41,6 +41,7 @@ orc_target_c_get_typedefs (void) "typedef uint16_t orc_uint16;\n" "typedef uint32_t orc_uint32;\n" "typedef uint64_t orc_uint64;\n" + "#define ORC_UINT64_C(x) UINT64_C(x)\n" "#elif defined(_MSC_VER)\n" "typedef signed __int8 orc_int8;\n" "typedef signed __int16 orc_int16;\n" @@ -50,6 +51,7 @@ orc_target_c_get_typedefs (void) "typedef unsigned __int16 orc_uint16;\n" "typedef unsigned __int32 orc_uint32;\n" "typedef unsigned __int64 orc_uint64;\n" + "#define ORC_UINT64_C(x) (x##Ui64)\n" "#else\n" "#include <limits.h>\n" "typedef signed char orc_int8;\n" @@ -61,9 +63,11 @@ orc_target_c_get_typedefs (void) "#if INT_MAX == LONG_MAX\n" "typedef long long orc_int64;\n" "typedef unsigned long long orc_uint64;\n" + "#define ORC_UINT64_C(x) (x##ULL)\n" "#else\n" "typedef long orc_int64;\n" "typedef unsigned long orc_uint64;\n" + "#define ORC_UINT64_C(x) (x##UL)\n" "#endif\n" "#endif\n" "typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;\n" @@ -101,12 +105,12 @@ orc_target_c_get_asm_preamble (void) "#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)\n" "#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))\n" "#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))\n" - "#define ORC_SWAP_Q(x) ((((x)&0xffULL)<<56) | (((x)&0xff00ULL)<<40) | (((x)&0xff0000ULL)<<24) | (((x)&0xff000000ULL)<<8) | (((x)&0xff00000000ULL)>>8) | (((x)&0xff0000000000ULL)>>24) | (((x)&0xff000000000000ULL)>>40) | (((x)&0xff00000000000000ULL)>>56))\n" + "#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56))\n" "#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))\n" "#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))\n" "#define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))\n" - "#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&0x7ff0000000000000ULL) == 0) ? 0xfff0000000000000ULL : 0xffffffffffffffffULL))\n" - "#define ORC_ISNAN_DOUBLE(x) ((((x)&0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) && (((x)&0x000fffffffffffffULL) != 0))\n" + "#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff)))\n" + "#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0))\n" "#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n" "#define ORC_RESTRICT restrict\n" "#elif defined(__GNUC__) && __GNUC__ >= 4\n" @@ -799,7 +803,7 @@ c_rule_loadpX (OrcCompiler *p, void *user, OrcInstruction *insn) (int)p->vars[insn->src_args[0]].value.i, p->vars[insn->src_args[0]].value.f); } else { - ORC_ASM_CODE(p," %s = 0x%08x%08xULL; /* %gf */\n", dest, + ORC_ASM_CODE(p," %s = ORC_UINT64_C(0x%08x%08x); /* %gf */\n", dest, (orc_uint32)(((orc_uint64)p->vars[insn->src_args[0]].value.i)>>32), ((orc_uint32)p->vars[insn->src_args[0]].value.i), p->vars[insn->src_args[0]].value.f); @@ -1189,7 +1193,7 @@ c_rule_convdl (OrcCompiler *p, void *user, OrcInstruction *insn) ORC_ASM_CODE(p, " {\n"); ORC_ASM_CODE(p," int tmp;\n"); ORC_ASM_CODE(p," tmp = %s;\n", src); - ORC_ASM_CODE(p," if (tmp == 0x80000000 && !(%s&0x8000000000000000ULL)) tmp = 0x7fffffff;\n", src_i); + ORC_ASM_CODE(p," if (tmp == 0x80000000 && !(%s & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff;\n", src_i); ORC_ASM_CODE(p," %s = tmp;\n", dest); ORC_ASM_CODE(p, " }\n"); } @@ -1294,7 +1298,7 @@ c_rule_swaplq (OrcCompiler *p, void *user, OrcInstruction *insn) c_get_name_int (dest, p, insn, insn->dest_args[0]); c_get_name_int (src, p, insn, insn->src_args[0]); - ORC_ASM_CODE(p," %s = ((%s&0x00000000ffffffffULL) << 32) | ((%s&0xffffffff00000000ULL) >> 32);\n", + ORC_ASM_CODE(p," %s = (ORC_UINT64_C(%s&0x00000000ffffffff) << 32) | (ORC_UINT64_C(%s&0xffffffff00000000) >> 32);\n", dest, src, src); } diff --git a/orc/orcutils.c b/orc/orcutils.c index 0f1f2a4..a37129d 100644 --- a/orc/orcutils.c +++ b/orc/orcutils.c @@ -155,9 +155,9 @@ _strtoll (const char *nptr, char **endptr, int base) if (c >= base) break; - if ((orc_uint64) val > 0xffffffffffffffffULL / base || - (orc_uint64) (val * base) > 0xffffffffffffffffULL - c) { - val = 0xffffffffffffffffULL; + if ((orc_uint64) val > ORC_UINT64_C(0xffffffffffffffff) / base || + (orc_uint64) (val * base) > ORC_UINT64_C(0xffffffffffffffff) - c) { + val = ORC_UINT64_C(0xffffffffffffffff); break; } diff --git a/orc/orcutils.h b/orc/orcutils.h index 8c1c793..750f80a 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -40,6 +40,7 @@ typedef uint8_t orc_uint8; typedef uint16_t orc_uint16; typedef uint32_t orc_uint32; typedef uint64_t orc_uint64; +#define ORC_UINT64_C(x) UINT64_C(x) #elif defined(_MSC_VER) typedef signed __int8 orc_int8; typedef signed __int16 orc_int16; @@ -49,6 +50,7 @@ typedef unsigned __int8 orc_uint8; typedef unsigned __int16 orc_uint16; typedef unsigned __int32 orc_uint32; typedef unsigned __int64 orc_uint64; +#define ORC_UINT64_C(x) (x##Ui64) #else #include <limits.h> typedef signed char orc_int8; @@ -60,9 +62,11 @@ typedef unsigned int orc_uint32; #if INT_MAX == LONG_MAX typedef long long orc_int64; typedef unsigned long long orc_uint64; +#define ORC_UINT64_C(x) (x##ULL) #else typedef long orc_int64; typedef unsigned long orc_uint64; +#define ORC_UINT64_C(x) (x##UL) #endif #endif typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16; |