summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-11-08 16:37:57 +0800
committerJSDurand <mmemmew@gmail.com>2021-11-08 16:37:57 +0800
commit9594210f02572681ed581c5197ace4c207db0917 (patch)
tree08bf1bf079d111c64cf3128dd68323abdce78228 /src/util.h
initial commit
Now the rough framework is established and the grammar class is sort of ready. It remains to write a general input reading mechanism.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..d657f0e
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,34 @@
+#ifndef UTIL_H
+#define UTIL_H
+#include <stdlib.h>
+
+/* This is commonly used, so put here for easy access. */
+#define MYALLOC(TYPE, LEN) (TYPE*)malloc(sizeof(TYPE) * (LEN))
+
+
+typedef long DATA;
+typedef long NUM;
+typedef unsigned long long UNUM; /* definitely bigger than size_t */
+
+
+#define HC_ATTR __attribute__((__hot__, __const__))
+#define H_ATTR __attribute__((__hot__))
+#define P_ATTR __attribute__((__pure__))
+#define UNUSED __attribute__((__unused__))
+#define U_ATTR UNUSED
+
+#define D_ATTR(X) __attribute__((__unused__, __deprecated__("This is deprecated.\n" \
+ "Please use " X \
+ " instead")))
+
+#define UD_ATTR __attribute__((__unused__, __deprecated__))
+#define UC_ATTR __attribute__((__unused__, __const__))
+#define UH_ATTR __attribute__((__unused__, __hot__))
+#define UHP_ATTR __attribute__((__unused__, __hot__, __pure__))
+
+
+#define eprintf(...) fprintf(stderr, __VA_ARGS__)
+
+
+
+#endif