summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/enum.h
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2012-01-20 13:41:10 +0000
committerkr.angelov <kr.angelov@gmail.com>2012-01-20 13:41:10 +0000
commit2eee382a62a909d5a3f2f5eda94f30fe68fd5335 (patch)
treeb0b0d513535895f244214aebf6358e172b8dce6d /src/runtime/c/gu/enum.h
parentb9728357126f8b9a6311cca17d9f0dcc2a7bfb9b (diff)
initial import of the C runtime
Diffstat (limited to 'src/runtime/c/gu/enum.h')
-rw-r--r--src/runtime/c/gu/enum.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/runtime/c/gu/enum.h b/src/runtime/c/gu/enum.h
new file mode 100644
index 000000000..88cd5ba6a
--- /dev/null
+++ b/src/runtime/c/gu/enum.h
@@ -0,0 +1,35 @@
+#ifndef GU_ENUM_H_
+#define GU_ENUM_H_
+
+#include <gu/mem.h>
+
+typedef struct GuEnum GuEnum;
+
+struct GuEnum {
+ void (*next)(GuEnum* self, void* to, GuPool* pool);
+};
+
+void
+gu_enum_next(GuEnum* en, void* to, GuPool* pool);
+
+#ifdef GU_GNUC
+
+#define gu_next(ENUM, T, POOL) \
+ ({ \
+ T gu_next_tmp_; \
+ gu_enum_next((ENUM), &gu_next_tmp_, (POOL)); \
+ gu_next_tmp_; \
+ })
+#else
+static inline void*
+gu_enum_next_(GuEnum* en, void* to, GuPool* pool)
+{
+ gu_enum_next(en, to, pool);
+ return to;
+}
+#define gu_next(ENUM, T, POOL) \
+ (*(T*)gu_enum_next_((ENUM), &(T){0}, (POOL)))
+
+#endif
+
+#endif /* GU_ENUM_H_ */