-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmutil.h
52 lines (33 loc) · 990 Bytes
/
dmutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _DMUTIL_H_
#define _DMUTIL_H_
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#if defined ( WIN32 )
#define __func__ __FUNCTION__
#endif
#define STATIC_ASSERT(cond) typedef int foo[(cond) ? 1 : -1]
/* check we aren't on some weird platform where a float won't fit
* in a pointer's place */
STATIC_ASSERT(sizeof(float) <= sizeof(float *));
/* simple linked list */
#define LIST_LINKS void *next, *prev
typedef struct list {
void *first;
} list;
#define LIST_ITER(list, iter) \
for (iter = (list)->first; iter; (iter) = (iter)->next)
int list_count(list *l);
void list_append(list *l, void *lldata);
void list_remove(list *l, void *lldata);
void *list_find(list *l, int index);
int list_index(list *l, void *lldata);
int list_has_entry(list *l, void *lldata);
void *list_pophead(list *l);
/* static memory description strings are wrapped in that, to reduce bin size */
#ifdef _DEBUG
#define _MD(x) x
#else
#define _MD(x) NULL
#endif
#endif _DMUTIL_H_