diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-08-23 22:07:34 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-08-27 11:46:25 +0200 |
| commit | 37516080db6878bef6fb1e6c5542165f3f982792 (patch) | |
| tree | d6d37921249b52b53df7166aaf67db510469f3c4 /include | |
| parent | b22b59adb72371d6ca7072eca2c166f4c2534677 (diff) | |
code upgrade
Diffstat (limited to 'include')
| -rw-r--r-- | include/assert.h | 17 | ||||
| -rw-r--r-- | include/testing.h | 10 | ||||
| -rw-r--r-- | include/types.h | 4 |
3 files changed, 21 insertions, 10 deletions
diff --git a/include/assert.h b/include/assert.h index ad9c2fd..aa62bd1 100644 --- a/include/assert.h +++ b/include/assert.h @@ -3,12 +3,13 @@ #include <stdio.h> #include <stdlib.h> -#define assert(condition, ...) \ - do { \ - if (!(condition)) { \ - fprintf(stderr, "Assertion failed: %s:%d in %s(): ", __FILE__, __LINE__, __func__); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - abort(); \ - } \ +#define assert(condition, ...) \ + do { \ + if (!(condition)) { \ + fprintf(stderr, "Assertion failed: %s:%d in %s(): ", __FILE__, \ + __LINE__, __func__); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + abort(); \ + } \ } while (0) diff --git a/include/testing.h b/include/testing.h index 9e0c022..dc070d3 100644 --- a/include/testing.h +++ b/include/testing.h @@ -1,4 +1,6 @@ +#pragma once #include <stdio.h> +#include <string.h> #define t_assert(fact) \ if (!(fact)) { \ @@ -22,3 +24,11 @@ #a, b, #b, __FILE__, __LINE__, __func__); \ return 1; \ } + +#define t_assert_strequal(a, b) \ + if ((a.len != b.len) || (a.len && memcmp(a.data, b.data, a.len))) { \ + fprintf(stderr, \ + "Assertion failed: %.*s (%s) != %.*s (%s) at %s:%d in %s()\n", (i32)a.len, a.data, \ + #a, (i32)b.len, b.data, #b, __FILE__, __LINE__, __func__); \ + return 1; \ + } diff --git a/include/types.h b/include/types.h index da3a093..6df9510 100644 --- a/include/types.h +++ b/include/types.h @@ -1,7 +1,7 @@ +#include <immintrin.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <immintrin.h> typedef ptrdiff_t size; typedef char byte; @@ -9,7 +9,7 @@ typedef uintptr_t uptr; typedef int32_t i32; typedef uint64_t u64; typedef float f32; -typedef __m256i byte_32; +typedef __m256i bytex32; #define sizeof(x) (size)sizeof(x) #define countof(a) (sizeof(a) / sizeof(*(a))) |
