| @@ -324,12 +324,6 @@ · 323 unmodified lines |
| 324 | 324 | #define TOK_HASH_SIZE 16384 /* must be a power of two */ |
| 325 | 325 | #define TOK_ALLOC_INCR 512 /* must be a power of two */ |
| 326 | 326 | #define TOK_MAX_SIZE 4 /* token max size in int unit when stored in string */ |
| 327 | | −#define TOKSYM_TAL_SIZE (768 * 1024) /* allocator for tiny TokenSym in table_ident */ |
| 328 | | −#define TOKSTR_TAL_SIZE (768 * 1024) /* allocator for tiny TokenString instances */ |
| 329 | | −#define CSTR_TAL_SIZE (256 * 1024) /* allocator for tiny CString instances */ |
| 330 | | −#define TOKSYM_TAL_LIMIT 256 /* prefer unique limits to distinguish allocators debug msgs */ |
| 331 | | −#define TOKSTR_TAL_LIMIT 128 /* 32 * sizeof(int) */ |
| 332 | | −#define CSTR_TAL_LIMIT 1024 |
| 333 | 327 | |
| 334 | 328 | /* token symbol management */ |
| 335 | 329 | typedef struct TokenSym { |
| @@ -1021,42 +1015,15 @@ enum tcc_token { · 685 unmodified lines |
| 1021 | 1015 | #undef DEF |
| 1022 | 1016 | }; |
| 1023 | 1017 | |
| 1018 | +/* keywords: tok >= TOK_IDENT && tok < TOK_UIDENT */ |
| 1024 | 1019 | #define TOK_UIDENT TOK_DEFINE |
| 1025 | 1020 | |
| 1026 | | −/* space exlcuding newline */ |
| 1027 | | −static inline int is_space(int ch) |
| 1028 | | −{ |
| 1029 | | − return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r'; |
| 1030 | | −} |
| 1031 | | − |
| 1032 | | −static inline int isid(int c) |
| 1033 | | −{ |
| 1034 | | − return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; |
| 1035 | | −} |
| 1036 | | − |
| 1037 | | −static inline int isnum(int c) |
| 1038 | | −{ |
| 1039 | | − return c >= '0' && c <= '9'; |
| 1040 | | −} |
| 1041 | | − |
| 1042 | | −static inline int isoct(int c) |
| 1043 | | −{ |
| 1044 | | − return c >= '0' && c <= '7'; |
| 1045 | | −} |
| 1046 | | − |
| 1047 | | −static inline int toup(int c) |
| 1048 | | −{ |
| 1049 | | − return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; |
| 1050 | | −} |
| 1021 | +/* -------------------------------------------- */ |
| 1051 | 1022 | |
| 1052 | | −#ifndef PUB_FUNC |
| 1023 | +#ifndef PUB_FUNC /* functions used by tcc.c but not in libtcc.h */ |
| 1053 | 1024 | # define PUB_FUNC |
| 1054 | 1025 | #endif |
| 1055 | 1026 | |
| 1056 | | −#ifdef TCC_PROFILE /* profile all functions */ |
| 1057 | | −# define static |
| 1058 | | −#endif |
| 1059 | | − |
| 1060 | 1027 | #ifdef ONE_SOURCE |
| 1061 | 1028 | #define ST_INLN static inline |
| 1062 | 1029 | #define ST_FUNC static |
| @@ -1067,6 +1034,10 @@ static inline int toup(int c) · 4 unmodified lines |
| 1067 | 1034 | #define ST_DATA extern |
| 1068 | 1035 | #endif |
| 1069 | 1036 | |
| 1037 | +#ifdef TCC_PROFILE /* profile all functions */ |
| 1038 | +# define static |
| 1039 | +#endif |
| 1040 | + |
| 1070 | 1041 | /* ------------ libtcc.c ------------ */ |
| 1071 | 1042 | |
| 1072 | 1043 | /* use GNU C extensions */ |
| @@ -1240,6 +1211,23 @@ ST_FUNC int tcc_preprocess(TCCState *s1); · 167 unmodified lines |
| 1240 | 1211 | ST_FUNC void skip(int c); |
| 1241 | 1212 | ST_FUNC NORETURN void expect(const char *msg); |
| 1242 | 1213 | |
| 1214 | +/* space exlcuding newline */ |
| 1215 | +static inline int is_space(int ch) { |
| 1216 | + return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r'; |
| 1217 | +} |
| 1218 | +static inline int isid(int c) { |
| 1219 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; |
| 1220 | +} |
| 1221 | +static inline int isnum(int c) { |
| 1222 | + return c >= '0' && c <= '9'; |
| 1223 | +} |
| 1224 | +static inline int isoct(int c) { |
| 1225 | + return c >= '0' && c <= '7'; |
| 1226 | +} |
| 1227 | +static inline int toup(int c) { |
| 1228 | + return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; |
| 1229 | +} |
| 1230 | + |
| 1243 | 1231 | /* ------------ tccgen.c ------------ */ |
| 1244 | 1232 | |
| 1245 | 1233 | ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */ |
| @@ -1422,49 +1410,23 @@ ST_FUNC void gen_vla_sp_save(int addr); · 176 unmodified lines |
| 1422 | 1410 | ST_FUNC void gen_vla_sp_restore(int addr); |
| 1423 | 1411 | ST_FUNC void gen_vla_alloc(CType *type, int align); |
| 1424 | 1412 | |
| 1425 | | −static inline uint16_t read16le(unsigned char *p) |
| 1426 | | −{ |
| 1413 | +static inline uint16_t read16le(unsigned char *p) { |
| 1427 | 1414 | return p[0] | (uint16_t)p[1] << 8; |
| 1428 | 1415 | } |
| 1429 | | − |
| 1430 | | −static inline void write16le(unsigned char *p, uint16_t x) |
| 1431 | | −{ |
| 1432 | | − p[0] = x & 255; |
| 1433 | | − p[1] = x >> 8 & 255; |
| 1416 | +static inline void write16le(unsigned char *p, uint16_t x) { |
| 1417 | + p[0] = x & 255, p[1] = x >> 8 & 255; |
| 1434 | 1418 | } |
| 1435 | | − |
| 1436 | | −static inline uint32_t read32le(unsigned char *p) |
| 1437 | | −{ |
| 1438 | | − return (p[0] | (uint32_t)p[1] << 8 | |
| 1439 | | − (uint32_t)p[2] << 16 | (uint32_t)p[3] << 24); |
| 1419 | +static inline uint32_t read32le(unsigned char *p) { |
| 1420 | + return read16le(p) | (uint32_t)read16le(p + 2) << 16; |
| 1440 | 1421 | } |
| 1441 | | − |
| 1442 | | −static inline void write32le(unsigned char *p, uint32_t x) |
| 1443 | | −{ |
| 1444 | | − p[0] = x & 255; |
| 1445 | | − p[1] = x >> 8 & 255; |
| 1446 | | − p[2] = x >> 16 & 255; |
| 1447 | | − p[3] = x >> 24 & 255; |
| 1422 | +static inline void write32le(unsigned char *p, uint32_t x) { |
| 1423 | + write16le(p, x), write16le(p + 2, x >> 16); |
| 1448 | 1424 | } |
| 1449 | | − |
| 1450 | | −static inline uint64_t read64le(unsigned char *p) |
| 1451 | | −{ |
| 1452 | | − return (p[0] | (uint64_t)p[1] << 8 | |
| 1453 | | − (uint64_t)p[2] << 16 | (uint64_t)p[3] << 24 | |
| 1454 | | − (uint64_t)p[4] << 32 | (uint64_t)p[5] << 40 | |
| 1455 | | − (uint64_t)p[6] << 48 | (uint64_t)p[7] << 56); |
| 1425 | +static inline uint64_t read64le(unsigned char *p) { |
| 1426 | + return read32le(p) | (uint64_t)read32le(p + 4) << 32; |
| 1456 | 1427 | } |
| 1457 | | − |
| 1458 | | −static inline void write64le(unsigned char *p, uint64_t x) |
| 1459 | | −{ |
| 1460 | | − p[0] = x & 255; |
| 1461 | | − p[1] = x >> 8 & 255; |
| 1462 | | − p[2] = x >> 16 & 255; |
| 1463 | | − p[3] = x >> 24 & 255; |
| 1464 | | − p[4] = x >> 32 & 255; |
| 1465 | | − p[5] = x >> 40 & 255; |
| 1466 | | − p[6] = x >> 48 & 255; |
| 1467 | | − p[7] = x >> 56 & 255; |
| 1428 | +static inline void write64le(unsigned char *p, uint64_t x) { |
| 1429 | + write32le(p, x), write32le(p + 4, x >> 32); |
| 1468 | 1430 | } |
| 1469 | 1431 | |
| 1470 | 1432 | /* ------------ i386-gen.c ------------ */ |