aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c_type.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-21 17:55:01 +0100
committerlemon <lsof@mailbox.org>2026-03-21 17:55:01 +0100
commit0e75fc383becccd113416677b7e26e0caf21e28b (patch)
tree356cf6c271ea8e0b2ca0211ac0c9efe776cc2118 /src/c_type.c
parent8b846d0245744f4eefc32f3c98b6359a3d21e659 (diff)
Rework handling of predefined macros.
And add some GCC predefs like __SIZE_TYPE__, __LONG_SIZE__, etc
Diffstat (limited to 'src/c_type.c')
-rw-r--r--src/c_type.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/c_type.c b/src/c_type.c
index 5fed20e..bf24653 100644
--- a/src/c_type.c
+++ b/src/c_type.c
@@ -2,7 +2,28 @@
#include "u_hash.h"
TypeData typedata[1<<13];
-internstr ttypenames[1<<10];
+internstr tagtypetags[1<<10];
+const char *const primtypenames[] = {
+ [TYBOOL] = "bool",
+ [TYCHAR] = "char",
+ [TYSCHAR] = "signed char",
+ [TYUCHAR] = "unsigned char",
+ [TYSHORT] = "short",
+ [TYUSHORT] = "unsigned short",
+ [TYINT] = "int",
+ [TYUINT] = "unsigned int",
+ [TYLONG] = "long",
+ [TYULONG] = "unsigned long",
+ [TYVLONG] = "long long",
+ [TYUVLONG] = "unsigned long long",
+ [TYFLOAT] = "float",
+ [TYDOUBLE] = "double",
+ [TYLDOUBLE] = "long double",
+ [TYCOMPLEXF] = "float complex",
+ [TYCOMPLEX] = "double complex",
+ [TYCOMPLEXL] = "long double complex",
+ [TYVOID] = "void",
+};
static ushort
hashtd(const TypeData *td)
@@ -188,11 +209,11 @@ completetype(internstr name, int id, TypeData *td)
{
assert(td->t == TYENUM || td->t == TYSTRUCT || td->t == TYUNION);
td->id = id;
- assert(id < countof(ttypenames) && "too many tag types");
- if (ttypenames[id])
- assert(ttypenames[id] == name && "bad redefn");
+ assert(id < countof(tagtypetags) && "too many tag types");
+ if (tagtypetags[id])
+ assert(tagtypetags[id] == name && "bad redefn");
else
- ttypenames[id] = name;
+ tagtypetags[id] = name;
return mktype(td->t, .dat = interntd(td), .backing = td->t == TYENUM ? td->backing : 0);
}