From: Dale Weiler Date: Wed, 14 Jan 2015 02:43:48 +0000 (-0500) Subject: More cleanup X-Git-Tag: xonotic-v0.8.2~58 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9d89a059aa6d2a03d3a08de4db295e08e45458d9;p=xonotic%2Fgmqcc.git More cleanup --- diff --git a/gmqcc.h b/gmqcc.h index 18b9098..07cdddd 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -163,23 +163,9 @@ char *stat_mem_strdup(const char *, bool); #define mem_d(PTRN) free((void*)PTRN) #define mem_r(PTRN, SIZE) realloc((void*)PTRN, SIZE) -/* TODO: rename to mem variations */ #define util_strdup(SRC) stat_mem_strdup((char*)(SRC), false) #define util_strdupe(SRC) stat_mem_strdup((char*)(SRC), true) -/* util.c */ - -/* - * Microsoft implements against the spec versions of ctype.h. Which - * means what ever the current set locale is will render the actual - * results of say isalpha('A') wrong for what ever retarded locale - * is used. Simalerly these are also implemented inefficently on - * some toolchains and end up becoming actual library calls. Perhaps - * this is why tools like yacc provide their own? Regardless implementing - * these as functions is equally as silly, the call overhead is not - * justified when this could happen on every character from an input - * stream. We provide our own as macros for absolute inlinability. - */ #define util_isalpha(a) ((((unsigned)(a)|32)-'a') < 26) #define util_isdigit(a) (((unsigned)(a)-'0') < 10) #define util_islower(a) (((unsigned)(a)-'a') < 26) @@ -256,36 +242,6 @@ typedef struct hash_table_s { struct hash_node_t **table; } hash_table_t, *ht; -/* - * hashtable implementation: - * - * Note: - * This was designed for pointers: you manage the life of the object yourself - * if you do use this for non-pointers please be warned that the object may not - * be valid if the duration of it exceeds (i.e on stack). So you need to allocate - * yourself, or put those in global scope to ensure duration is for the whole - * runtime. - * - * util_htnew(size) -- to make a new hashtable - * util_htset(table, key, value, sizeof(value)) -- to set something in the table - * util_htget(table, key) -- to get something from the table - * util_htdel(table) -- to delete the table - * - * example of use: - * - * ht foo = util_htnew(1024); - * int data = 100; - * char *test = "hello world\n"; - * util_htset(foo, "foo", (void*)&data); - * util_gtset(foo, "bar", (void*)test); - * - * printf("foo: %d, bar %s", - * *((int *)util_htget(foo, "foo")), - * ((char*)util_htget(foo, "bar")) - * ); - * - * util_htdel(foo); - */ hash_table_t *util_htnew (size_t size); void util_htrem(hash_table_t *ht, void (*callback)(void *data)); void util_htset(hash_table_t *ht, const char *key, void *value); @@ -378,34 +334,16 @@ typedef struct { #define OFS_PARM6 (OFS_PARM5 +3) #define OFS_PARM7 (OFS_PARM6 +3) +typedef union { + int16_t s1; + uint16_t u1; +} operand_t; + typedef struct { uint16_t opcode; - - /* operand 1 */ - union { - int16_t s1; /* signed */ - uint16_t u1; /* unsigned */ - } o1; - /* operand 2 */ - union { - int16_t s1; /* signed */ - uint16_t u1; /* unsigned */ - } o2; - /* operand 3 */ - union { - int16_t s1; /* signed */ - uint16_t u1; /* unsigned */ - } o3; - - /* - * This is the same as the structure in darkplaces - * { - * unsigned short op; - * short a,b,c; - * } - * But this one is more sane to work with, and the - * type sizes are guranteed. - */ + operand_t o1; + operand_t o2; + operand_t o3; } prog_section_statement_t; typedef struct { diff --git a/intrin.c b/intrin.c index 15788fa..9ef0207 100644 --- a/intrin.c +++ b/intrin.c @@ -1,15 +1,6 @@ #include #include "parser.h" -/* - * Provides all the "intrinsics" / "builtins" for GMQCC. These can do - * a few things, they can provide fall back implementations for math - * functions if the definitions don't exist for some given engine. Or - * then can determine definitions for existing builtins, and simply - * wrap back to them instead. This is like a "portable" intrface that - * is entered when -fintrin is used (causing all existing builtins to - * be ignored by the compiler and instead interface through here. - */ #define intrin_ctx(I) parser_ctx((I)->parser) static GMQCC_INLINE ast_function *intrin_value(intrin_t *intrin, ast_value **out, const char *name, qcint_t vtype) {