aboutsummaryrefslogtreecommitdiff
path: root/src/mtx_qhull/entry.h
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2012-08-27 15:04:59 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2012-08-27 15:04:59 +0000
commite4f56a32d01350b09212172a509d34d9411a0d01 (patch)
treef7e5bf130a0cc181d15c368b831a71202af3c64e /src/mtx_qhull/entry.h
parentaf9edd913bbb5ef56eded61030ce46c48cf4e90b (diff)
read list 'entry' type
svn path=/trunk/externals/iem/iemmatrix/; revision=16177
Diffstat (limited to 'src/mtx_qhull/entry.h')
-rw-r--r--src/mtx_qhull/entry.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/mtx_qhull/entry.h b/src/mtx_qhull/entry.h
new file mode 100644
index 0000000..bc22f35
--- /dev/null
+++ b/src/mtx_qhull/entry.h
@@ -0,0 +1,89 @@
+#ifndef QHULL_ENTRY_H
+#define QHULL_ENTRY_H
+
+#include <sys/types.h>
+#include <stdio.h>
+
+typedef size_t index_t;
+
+typedef union {
+ index_t i;
+ void*p;
+} entryvalu_t;
+
+typedef enum {
+ INDEX,
+ POINTER,
+ INVALID
+} entrytype_t;
+
+typedef struct entry_ {
+ entrytype_t typ;
+ entryvalu_t val;
+} entry_t;
+
+static
+void entry_setIndex(entry_t*e, index_t i) {
+ e->typ=INDEX;
+ e->val.i=i;
+}
+static
+void entry_setPointer(entry_t*e, void*p) {
+ e->typ=POINTER;
+ e->val.p=p;
+}
+static
+entry_t entry_makeIndex(index_t i) {
+ entry_t result;
+ entry_setIndex(&result, i);
+ return result;
+}
+static
+entry_t entry_makePointer(void*p) {
+ entry_t result;
+ entry_setPointer(&result, p);
+ return result;
+}
+
+static
+index_t entry_getIndex(const entry_t*e) {
+ return (INDEX==e->typ)?e->val.i:0;
+}
+static
+void*entry_getPointer(const entry_t*e) {
+ return (POINTER==e->typ)?e->val.p:0;
+}
+static
+int entry_equals(const entry_t*e1, const entry_t*e2) {
+ if(e1->typ!=e2->typ)return 0;
+ switch(e1->typ) {
+ case INDEX:
+ return (e1->val.i == e2->val.i);
+ case POINTER:
+ return (e1->val.p == e2->val.p);
+ default:
+ return 0;
+ }
+ return 0;
+}
+
+static
+void print_entry(const entry_t e) {
+ switch(e.typ) {
+ case INDEX:
+ printf("%d", e.val.i);
+ return;
+ case POINTER:
+ printf("0x%p", e.val.p);
+ return;
+ default:
+ printf("<unkonwn>");
+ return;
+ }
+}
+
+
+
+
+
+#endif