diff options
| author | Tyge Løvset <[email protected]> | 2021-03-26 07:11:32 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-03-26 07:11:32 +0100 |
| commit | fb25143685df32ed91b84da9fb7f2e821ed7daaf (patch) | |
| tree | 7fcb97dfc473a3aa90e1bb1a15d869c937f80e2d /stc/ccommon.h | |
| parent | 99bb129812e6fb830a05dd7f789987ba11f69b96 (diff) | |
| download | STC-modified-fb25143685df32ed91b84da9fb7f2e821ed7daaf.tar.gz STC-modified-fb25143685df32ed91b84da9fb7f2e821ed7daaf.zip | |
Changed cpque declaration to using_cpque(X, Value, valueCompare), and valueCompare optional: more consistent with STC conventions.
Diffstat (limited to 'stc/ccommon.h')
| -rw-r--r-- | stc/ccommon.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/stc/ccommon.h b/stc/ccommon.h index 29790333..ec01d731 100644 --- a/stc/ccommon.h +++ b/stc/ccommon.h @@ -65,6 +65,7 @@ #define c_container_of(ptr, type, member) \
((type *)((char *)(ptr) - offsetof(type, member)))
+#define c_struct(S) typedef struct S S; struct S
#define c_new(...) c_MACRO_OVERLOAD(c_new, __VA_ARGS__)
#define c_new_1(T) ((T *) c_malloc(sizeof(T)))
#define c_new_2(T, n) ((T *) c_malloc(sizeof(T)*(n)))
@@ -78,9 +79,10 @@ #define c_swap(T, x, y) do { T _c_t = x; x = y; y = _c_t; } while (0)
#define c_arraylen(a) (sizeof (a)/sizeof (a)[0])
-#define c_default_compare(x, y) (c_default_less(y, x) - c_default_less(x, y))
+#define c_default_compare(x, y) c_less_compare(c_default_less, x, y)
#define c_default_less(x, y) (*(x) < *(y))
#define c_no_compare(x, y) (assert(!"c_no_compare() called"), 0)
+#define c_less_compare(less, x, y) (less(y, x) - less(x, y))
#define c_default_equals(x, y) (*(x) == *(y))
#define c_trivial_equals(x, y) (memcmp(x, y, sizeof *(x)) == 0)
|
