-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglthreads.h
39 lines (28 loc) · 1.11 KB
/
glthreads.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
#ifndef __GLTHREADS__
#define __GLTHREADS__
#include <stddef.h>
typedef struct gl_thread_ {
struct gl_thread_ *left;
struct gl_thread_ *right;
}gl_thread_t;
void glthread_add_next(gl_thread_t *list, gl_thread_t *glnode);
void glthread_node_init(gl_thread_t *glthread);
void remove_glthread(gl_thread_t *glnode);
#define BASE(start) ((start)->right)
#define IS_GLTHREAD_LIST_EMPTY(glthreadptr) \
((glthreadptr)->left == 0 && (glthreadptr)->right == 0)
#define ITERATE_GLTHREAD_BEGIN(start, curr) \
{ \
gl_thread_t* temp = NULL; \
curr = BASE(start); \
for(;curr != NULL; curr = temp) { \
temp = (curr)->right; \
#define ITERATE_GLTHREAD_END(start, curr) \
}}
#define offsetof(struct_name, field_name) \
(char*)&(((struct_name*)NULL)->field_name)
#define GLTHREAD_TO_STRUCT(fn_name, structure_name, field_name) \
static inline structure_name * fn_name(gl_thread_t *glthreadptr){ \
return (structure_name *)((char *)(glthreadptr) - (char *)&(((structure_name *)0)->field_name)); \
}
#endif /*__GL_THREADS__*/