diff options
author | Adrian Thurston <thurston@colm.net> | 2021-10-30 09:45:15 -0700 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2021-11-06 12:14:07 -0700 |
commit | d9ec5ca9cdc5015c93c11f195db49c511a71f298 (patch) | |
tree | fea96575bc06fb3ac250426c49a15dd01f9eb55c | |
parent | 159c9a44359291ce5954d4779988b79f6cef0341 (diff) | |
download | ragel-d9ec5ca9cdc5015c93c11f195db49c511a71f298.tar.gz |
C char type: decide signedness of char based on CHAR_MIN
Previously had char fixed to signed char, this is not useful on ARM as it does
not align with the host type. Instead, decide at runtime (or probably compile
time) if char is signed or not.
-rw-r--r-- | src/common.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/common.cc b/src/common.cc index 6c789d77..eafaab68 100644 --- a/src/common.cc +++ b/src/common.cc @@ -42,18 +42,18 @@ const char *defaultOutFnC( const char *inputFileName ) HostType hostTypesC[] = { - { "char", 0, "char", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, sizeof(char) }, - { "signed", "char", "char", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, sizeof(char) }, - { "unsigned", "char", "uchar", false, true, false, 0, 0, 0, UCHAR_MAX, sizeof(unsigned char) }, - { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, - { "signed", "short", "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, - { "unsigned", "short", "ushort", false, true, false, 0, 0, 0, USHRT_MAX, sizeof(unsigned short) }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, - { "signed", "int", "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, - { "unsigned", "int", "uint", false, true, false, 0, 0, 0, UINT_MAX, sizeof(unsigned int) }, - { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, - { "signed", "long", "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, - { "unsigned", "long", "ulong", false, true, false, 0, 0, 0, ULONG_MAX, sizeof(unsigned long) }, + { "char", 0, "char", (CHAR_MIN != 0), true, false, SCHAR_MIN, SCHAR_MAX, 0, UCHAR_MAX, sizeof(char) }, + { "signed", "char", "char", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, sizeof(char) }, + { "unsigned", "char", "uchar", false, true, false, 0, 0, 0, UCHAR_MAX, sizeof(unsigned char) }, + { "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, + { "signed", "short", "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) }, + { "unsigned", "short", "ushort", false, true, false, 0, 0, 0, USHRT_MAX, sizeof(unsigned short) }, + { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, + { "signed", "int", "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, + { "unsigned", "int", "uint", false, true, false, 0, 0, 0, UINT_MAX, sizeof(unsigned int) }, + { "long", 0, "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, + { "signed", "long", "long", true, true, false, LONG_MIN, LONG_MAX, 0, 0, sizeof(long) }, + { "unsigned", "long", "ulong", false, true, false, 0, 0, 0, ULONG_MAX, sizeof(unsigned long) }, }; const HostLang hostLangC = { |