]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
fold_binary now used instead of ast_binary_new, which calls fold_superfluous
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 9d00687c8daf7c57c9048af9f62c2059863a8cf0..6e0d3ac05ecfca2f7bc858212dc56b8751f539d2 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -25,7 +25,7 @@
 #define GMQCC_HDR
 #include <stdarg.h>
 #include <stddef.h>
-#include <time.h>   /* TODO remove?*/
+#include <time.h>   /* TODO: remove?*/
 
 /*
  * Disable some over protective warnings in visual studio because fixing them is a waste
@@ -256,14 +256,14 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
 /* stat.c */
 void  stat_info          (void);
 char *stat_mem_strdup    (const char *, size_t,         const char *, bool);
-void *stat_mem_reallocate(void *,       size_t, size_t, const char *);
+void *stat_mem_reallocate(void *,       size_t, size_t, const char *, const char *);
 void  stat_mem_deallocate(void *);
-void *stat_mem_allocate  (size_t, size_t, const char *);
+void *stat_mem_allocate  (size_t, size_t, const char *, const char *);
 
-#define mem_a(SIZE)              stat_mem_allocate  ((SIZE), __LINE__, __FILE__)
+#define mem_a(SIZE)              stat_mem_allocate  ((SIZE), __LINE__, __FILE__, #SIZE)
 #define mem_d(PTRN)              stat_mem_deallocate((void*)(PTRN))
-#define mem_r(PTRN, SIZE)        stat_mem_reallocate((void*)(PTRN), (SIZE), __LINE__, __FILE__)
-#define mem_af(SIZE, FILE, LINE) stat_mem_allocate  ((SIZE), (LINE), (FILE))
+#define mem_r(PTRN, SIZE)        stat_mem_reallocate((void*)(PTRN), (SIZE), __LINE__, __FILE__, #SIZE)
+#define mem_af(SIZE, FILE, LINE) stat_mem_allocate  ((SIZE), (LINE), (FILE), #SIZE)
 
 /* TODO: rename to mem variations */
 #define util_strdup(SRC)         stat_mem_strdup((char*)(SRC), __LINE__, __FILE__, false)
@@ -313,7 +313,8 @@ const struct tm *util_localtime(const time_t *timer);
 const char      *util_ctime    (const time_t *timer);
 
 typedef struct fs_file_s fs_file_t;
-int              util_isatty   (fs_file_t *);
+
+bool             util_isatty(fs_file_t *);
 
 /*
  * A flexible vector implementation: all vector pointers contain some
@@ -1010,11 +1011,19 @@ typedef enum {
     COMPILER_GMQCC    /* this   QuakeC */
 } opts_std_t;
 
-typedef union {
-    bool     B;
-    uint16_t U16;
-    uint32_t U32;
-    char    *STR;
+typedef struct {
+    union {
+        bool     b;
+        uint16_t u16;
+        uint32_t u32;
+
+        union {
+            char       *p;
+            const char *c;
+        } str;
+    } data;
+
+    bool allocated;
 } opt_value_t;
 
 
@@ -1036,9 +1045,11 @@ extern opts_cmd_t opts;
 #define OPTS_WARN(i)         OPTS_GENERIC(opts.warn,         (i))
 #define OPTS_WERROR(i)       OPTS_GENERIC(opts.werror,       (i))
 #define OPTS_OPTIMIZATION(i) OPTS_GENERIC(opts.optimization, (i))
-#define OPTS_OPTION_BOOL(X) (opts.options[X].B)
-#define OPTS_OPTION_U16(X)  (opts.options[X].U16)
-#define OPTS_OPTION_U32(X)  (opts.options[X].U32)
-#define OPTS_OPTION_STR(X)  (opts.options[X].STR)
+#define OPTS_OPTION_DUPED(X) (opts.options[X].allocated)
+#define OPTS_OPTION_BOOL(X) (opts.options[X].data.b)
+#define OPTS_OPTION_U16(X)  (opts.options[X].data.u16)
+#define OPTS_OPTION_U32(X)  (opts.options[X].data.u32)
+#define OPTS_OPTION_DUP(X) *(OPTS_OPTION_DUPED(X)=true, &(opts.options[X].data.str.p))
+#define OPTS_OPTION_STR(X)  (opts.options[X].data.str.c)
 
 #endif /*! GMQCC_HDR */