summaryrefslogtreecommitdiff
path: root/macros.h
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-10-12 15:24:30 +0500
committerpryazha <pryadeiniv@mail.ru>2025-10-12 15:24:30 +0500
commit223b1056273f5d48d1c0bbfee75be7b82374d4eb (patch)
tree2b2003aad9c26af7006c5a5c7e2baf1a63ad89e7 /macros.h
parent7e73843ac5873833c707687cd0ada0a3034e600c (diff)
change identation, maybe will change back, add own gl functions loading, and glx example
Diffstat (limited to 'macros.h')
-rw-r--r--macros.h51
1 files changed, 27 insertions, 24 deletions
diff --git a/macros.h b/macros.h
index eb514b5..2fa04a3 100644
--- a/macros.h
+++ b/macros.h
@@ -1,22 +1,25 @@
#ifndef macros_h
#define macros_h
+/*
#undef assert
-#define assert(expr) if (!(expr)) { *(int *)0 = 0; }
+#define assert(expr) if (!(expr)) { *(int *)0 = 0; }
+*/
+#include <assert.h>
-#define array_count(array) (sizeof(array)/sizeof(*(array)))
+#define array_count(array) (sizeof(array)/sizeof(*(array)))
#undef offsetof
-#define offsetof(type, element) ((u64)(&(((type *)0)->element)))
+#define offsetof(type, element) ((u64)(&(((type *)0)->element)))
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#define max(a, b) (((a) > (b)) ? (a) : (b))
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#define max(a, b) (((a) > (b)) ? (a) : (b))
#define clamp(a, x, b) \
- (((x) < (a)) ? (a) : \
- (((x) > (b)) ? (b) : (x)))
+ (((x) < (a)) ? (a) : \
+ (((x) > (b)) ? (b) : (x)))
-#define swap(type, a, b) { type tmp = (a); (a) = (b); (b) = tmp; }
+#define swap(type, a, b) { type tmp = (a); (a) = (b); (b) = tmp; }
#define kilobytes(n) n*1024
#define megabytes(n) kilobytes(n)*1024
@@ -24,27 +27,27 @@
/* NOTE(pryazha): Singly linked list */
#define sllpush(first, last, node) \
- ((first) == 0 ? \
- ((first) = (last) = (node), (node)->next = 0) : \
- ((last)->next = (node), (last) = (node), (node)->next = 0))
+ ((first) == 0 ? \
+ ((first) = (last) = (node), (node)->next = 0) : \
+ ((last)->next = (node), (last) = (node), (node)->next = 0))
#define sllpop(first, last) \
- ((first) == (last) ? \
- ((first) = (last) = 0) : \
- ((first) = (first)->next))
+ ((first) == (last) ? \
+ ((first) = (last) = 0) : \
+ ((first) = (first)->next))
/* NOTE(pryazha): Doubly linked list */
#define dllpush(first, last, node, next, prev) \
- ((first) == 0 ? \
- ((first) = (last) = (node), (node)->next = (node)->prev = 0) : \
- ((node)->prev = (last), (last)->next = (node), (last) = (node), (node)->next = 0))
-#define dllpushback(first, last, node) dllpush(first, last, node, next, prev)
-#define dllpushfront(first, last, node) dllpush(last, first, node, prev, next)
+ ((first) == 0 ? \
+ ((first) = (last) = (node), (node)->next = (node)->prev = 0) : \
+ ((node)->prev = (last), (last)->next = (node), (last) = (node), (node)->next = 0))
+#define dllpushback(first, last, node) dllpush(first, last, node, next, prev)
+#define dllpushfront(first, last, node) dllpush(last, first, node, prev, next)
#define dllremove(first, last, node) \
- ((first) == (node) ? \
- ((first) == (last) ? (first) = (last) = 0 : \
- ((first) = (first)->next, (first)->prev = 0)) : \
- ((last) == (node) ? ((last) = (last)->prev, (last)->next = 0) : \
- ((node)->next->prev = (node)->prev, (node)->prev->next = (node)->next)))
+ ((first) == (node) ? \
+ ((first) == (last) ? (first) = (last) = 0 : \
+ ((first) = (first)->next, (first)->prev = 0)) : \
+ ((last) == (node) ? ((last) = (last)->prev, (last)->next = 0) : \
+ ((node)->next->prev = (node)->prev, (node)->prev->next = (node)->next)))
#endif