diff options
| author | 2025-10-15 10:44:06 +0200 | |
|---|---|---|
| committer | 2025-10-15 10:44:06 +0200 | |
| commit | 66ffc2ae07941e00406493020579a0b695b535ee (patch) | |
| tree | 705422eed8562683fdaa15b32b0ba55f2c44c3a0 | |
| parent | e9896f1db183fefc0392273c2579c3481510f624 (diff) | |
implement long double (as double synonym). wchar_t placeholder
| -rw-r--r-- | c.c | 6 | ||||
| -rw-r--r-- | embedfilesdir.c | 1 | ||||
| -rw-r--r-- | ir.c | 1 | ||||
| -rw-r--r-- | lex.c | 3 | ||||
| -rw-r--r-- | targ.c | 11 | ||||
| -rw-r--r-- | type.c | 1 |
6 files changed, 14 insertions, 9 deletions
@@ -2047,9 +2047,7 @@ End: else if (arith == KDOUBLE) t = TYDOUBLE; else if (arith == (KLONG | KDOUBLE)) { - /* t = TYLDOUBLE; */ - warn(&span, "`long double' is unsupported"); - t = TYDOUBLE; + t = TYLDOUBLE; } else if (arith == KBOOL) t = TYBOOL; else if (arith == KCHAR) @@ -2697,7 +2695,7 @@ narrow(struct function *fn, enum irclass to, enum typetag tt, union ref ref, uin if (targ_primsizes[tt] < cls2siz[to]) { ins.cls = to; if (isfltt(tt)) { - assert(to == KF4 && tt == TYDOUBLE); + assert(to == KF4 && tt >= TYDOUBLE); ins.op = Ocvtf8f4; } else { static const enum op ext[5][2] = { diff --git a/embedfilesdir.c b/embedfilesdir.c index e2f223b..434e2e8 100644 --- a/embedfilesdir.c +++ b/embedfilesdir.c @@ -13,6 +13,7 @@ struct embedfile embedfilesdir[] = { typedef __typeof__((char*)0 - (char*)0) ptrdiff_t;\n\ typedef __typeof__(sizeof 0) size_t;\n\ /*typedef __typeof__(L'a') wchar_t;*/\n\ +typedef int wchar_t;\n\ #define NULL ((void *)0)\n\ #define offsetof(_Type, _Memb) ((size_t)(&((_Type *)0)->_Memb - (_Type *)0))\n\ ")}, @@ -58,6 +58,7 @@ irinit(struct function *fn) } type2cls[TYFLOAT] = KF4; type2cls[TYDOUBLE] = KF8; + type2cls[TYLDOUBLE] = KF8; type2cls[TYPTR] = KPTR; type2cls[TYARRAY] = KPTR; cls2siz[KI4] = cls2siz[KF4] = 4; @@ -178,6 +178,9 @@ parsenumlit(uvlong *outi, double *outf, const struct token *tk, bool ispp) } else if ((suffix[0]|0x20) == 'f' && !suffix[1]) { if (outf) *outf = f; return TYFLOAT; + } else if ((suffix[0]|0x20) == 'l' && !suffix[1]) { + if (outf) *outf = f; + return TYLDOUBLE; } return 0; } else { /* int literal */ @@ -6,16 +6,16 @@ static const struct targ { struct { uchar longsize, vlongsize, ptrsize, valistsize; }; struct { uchar longalign, vlongalign, doublealign, ptralign; }; bool charsigned; - uchar sizetype, ptrdifftype; + uchar sizetype, ptrdifftype, wchartype; const struct mctarg *mctarg; } targs[] = { - { "amd64-sysv", {8, 8, 8, 24}, {8, 8, 8, 8}, 1, TYULONG, TYLONG, &t_amd64_sysv }, - { "i686-sysv", {4, 8, 4, 8}, {4, 4, 4, 4}, 1, TYUINT, TYINT } + { "amd64-sysv", {8, 8, 8, 24}, {8, 8, 8, 8}, 1, TYULONG, TYLONG, TYUINT, &t_amd64_sysv }, + { "i686-sysv", {4, 8, 4, 8}, {4, 4, 4, 4}, 1, TYUINT, TYINT, TYUINT } }; uchar targ_primsizes[TYPTR+1]; uchar targ_primalign[TYPTR+1]; -enum typetag targ_sizetype, targ_ptrdifftype; +enum typetag targ_sizetype, targ_ptrdifftype, targ_wchartype; bool targ_charsigned, targ_bigendian, targ_64bit; const struct mctarg *mctarg; @@ -30,6 +30,7 @@ targ_init(const char *starg) sizes[TYUINT] = sizes[TYINT] = 4; sizes[TYFLOAT] = 4; sizes[TYDOUBLE] = 8; + sizes[TYLDOUBLE] = 8; memcpy(align, sizes, sizeof targ_primalign); sizes[TYULONG] = sizes[TYLONG] = t->longsize; sizes[TYUVLONG] = sizes[TYVLONG] = t->vlongsize; @@ -38,9 +39,11 @@ targ_init(const char *starg) align[TYULONG] = align[TYLONG] = t->longalign; align[TYUVLONG] = align[TYVLONG] = t->vlongalign; align[TYDOUBLE] = t->doublealign; + align[TYLDOUBLE] = t->doublealign; align[TYVALIST] = align[TYPTR] = t->ptralign; targ_sizetype = t->sizetype; targ_ptrdifftype = t->ptrdifftype; + targ_wchartype = t->wchartype; targ_charsigned = t->charsigned; targ_bigendian = 0; targ_64bit = t->ptrsize == 8; @@ -1,5 +1,4 @@ #include "common.h" -#include <string.h> struct typedata typedata[1<<13]; const char *ttypenames[1<<10]; |