summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/al/array_typed.h5
-rw-r--r--include/al/lib.h13
-rw-r--r--include/al/test.h13
3 files changed, 22 insertions, 9 deletions
diff --git a/include/al/array_typed.h b/include/al/array_typed.h
index 156dbcb..a48b230 100644
--- a/include/al/array_typed.h
+++ b/include/al/array_typed.h
@@ -5,6 +5,11 @@
#error "missing required GNU C extensions"
#endif
+#define AL_EMPTY_DEFAULT(...) AL_EMPTY_DEFAULT_0(__VA_ARGS__, , )
+#define AL_EMPTY_DEFAULT_0(FUNC, T, S, ...) FUNC(T, S)
+#define AL_PASTER_EVALUATOR(X, Y) X##_##Y
+#define AL_PASTER(X, Y) AL_PASTER_EVALUATOR(X, Y)
+
#define _array(N, ...) AL_PASTER(array, AL_PASTER(N, __VA_ARGS__))
#define _al_array_init(N, ...) AL_PASTER(_array_init, AL_PASTER(N, __VA_ARGS__))
#define _al_array_data(N, ...) AL_PASTER(_array_data, AL_PASTER(N, __VA_ARGS__))
diff --git a/include/al/lib.h b/include/al/lib.h
index 71e0672..32b91ad 100644
--- a/include/al/lib.h
+++ b/include/al/lib.h
@@ -143,13 +143,6 @@ AL_UNUSED_FUNCTION_POP
#define AL_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#ifndef _MSVC_
-#define AL_EMPTY_DEFAULT(...) AL_EMPTY_DEFAULT_0(__VA_ARGS__, , )
-#define AL_EMPTY_DEFAULT_0(FUNC, T, S, ...) FUNC(T, S)
-#define AL_PASTER_EVALUATOR(X, Y) X##_##Y
-#define AL_PASTER(X, Y) AL_PASTER_EVALUATOR(X, Y)
-#endif
-
#define AL_BOOLSTR(b) ((b) ? "true" : "false")
#ifndef _MSVC_
@@ -158,6 +151,8 @@ AL_UNUSED_FUNCTION_POP
#define __al_thread __declspec(thread)
#endif
+#define __al_fallthrough __attribute__((fallthrough))
+
#if __has_attribute(__counted_by__)
#define __al_counted_by(member) __attribute__((__counted_by__(member)))
#else
@@ -199,12 +194,12 @@ static inline u16 al_u16_inc_wrap(u16 v)
static inline u32 al_u32_add_wrap(u32 v, u32 add)
{
- return (((u64)v + add) > UINT32_MAX) ? (add - (UINT32_MAX - v)) : v + add;
+ return (v > UINT32_MAX - add) ? (add - (UINT32_MAX - v)) : v + add;
}
static inline u16 al_u16_add_wrap(u16 v, u16 add)
{
- return (((u32)v + add) > UINT16_MAX) ? (add - (UINT16_MAX - v)) : v + add;
+ return (v > UINT16_MAX - add) ? (add - (UINT16_MAX - v)) : v + add;
}
AL_UNUSED_FUNCTION_POP
diff --git a/include/al/test.h b/include/al/test.h
index 532c839..aa4d28b 100644
--- a/include/al/test.h
+++ b/include/al/test.h
@@ -73,6 +73,19 @@ static inline s32 al_test_bool_cmp(bool a, bool b)
#define AL_TEST_FMT_bool "%s"
#define AL_TEST_PRINTF_bool(b) (b ? "true" : "false")
+static inline s32 al_test_u16_cmp(u16 a, u16 b)
+{
+ if (a == b) return 0;
+ else if (a < b) return -1;
+ else return 1;
+}
+
+#define AL_TEST_CMP_u16 al_test_u16_cmp
+#define AL_TEST_TYPE_u16 u16
+
+#define AL_TEST_FMT_u16 "%hu"
+#define AL_TEST_PRINTF_u16(i) i
+
static inline s32 al_test_u32_cmp(u32 a, u32 b)
{
if (a == b) return 0;