diff options
| author | 2024-01-27 20:41:36 -0500 | |
|---|---|---|
| committer | 2024-01-27 20:41:36 -0500 | |
| commit | 3eeb6351ea365d8eb095a3db3063b6129f73a178 (patch) | |
| tree | 57c1aa63ac6c4c0860bcc31fc7e1544180925734 | |
| parent | a1f9ffcc6eb38ad5f6f0fa750a34e14ad9cdf812 (diff) | |
| download | libalabaster-3eeb6351ea365d8eb095a3db3063b6129f73a178.tar.gz libalabaster-3eeb6351ea365d8eb095a3db3063b6129f73a178.tar.bz2 libalabaster-3eeb6351ea365d8eb095a3db3063b6129f73a178.zip | |
Switch the order of al_array_insert args, cleanup
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | include/al/array_typed.h | 2 | ||||
| -rw-r--r-- | include/al/lib.h | 2 | ||||
| -rw-r--r-- | include/al/log.h | 5 | ||||
| -rw-r--r-- | include/al/ring_buffer.h | 1 | ||||
| -rw-r--r-- | include/al/str.h | 2 | ||||
| -rw-r--r-- | include/al/test.h | 1 | ||||
| -rw-r--r-- | include/al/wstr.h | 4 | ||||
| -rw-r--r-- | src/array.c | 2 | ||||
| -rw-r--r-- | src/ring_buffer.c | 3 | ||||
| -rw-r--r-- | tests/array.c | 6 | ||||
| -rw-r--r-- | tests/array_typed.c | 6 | ||||
| -rw-r--r-- | tests/ring_buffer.c | 1 |
12 files changed, 22 insertions, 13 deletions
diff --git a/include/al/array_typed.h b/include/al/array_typed.h index 678aef4..3334026 100644 --- a/include/al/array_typed.h +++ b/include/al/array_typed.h @@ -66,7 +66,7 @@ *ret = *al_array_at(N, __VA_ARGS__)(a, i); \ al_array_remove_at(N, __VA_ARGS__)(a, i); \ } \ - static inline void al_array_insert(N, __VA_ARGS__)(array(N, __VA_ARGS__) *a, T *item, u32 i) \ + static inline void al_array_insert(N, __VA_ARGS__)(array(N, __VA_ARGS__) *a, u32 i, T *item) \ { \ if (a->size > i) { \ al_array_reserve(N, __VA_ARGS__)(a, a->size + 1); \ diff --git a/include/al/lib.h b/include/al/lib.h index b9b2318..aa0d0d2 100644 --- a/include/al/lib.h +++ b/include/al/lib.h @@ -177,7 +177,7 @@ static inline u16 al_u16_add_wrap(u16 v, u16 add) return (((u32)v + add) > UINT16_MAX) ? (add - (UINT16_MAX - v)) : v + add; } -AL_UNUSED_FUNCTION_PUSH +AL_UNUSED_FUNCTION_POP extern size_t al_page_size; extern size_t al_grow_limit; diff --git a/include/al/log.h b/include/al/log.h index 1848840..b3c57da 100644 --- a/include/al/log.h +++ b/include/al/log.h @@ -24,7 +24,10 @@ s32 _al_logv(const char *level, const char *section, const char *name, #define al_log_debug(section, fmt, ...) al_log("debug", section, fmt, ##__VA_ARGS__) #else AL_UNUSED_FUNCTION_PUSH -static s32 al_log_nop(const char *section, const char *fmt, ...) { (void)section; (void)fmt; return 0; } +static s32 al_log_nop(const char *section, const char *fmt, ...) +{ + (void)section; (void)fmt; return 0; +} AL_UNUSED_FUNCTION_POP #define al_log_debug(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__) #endif diff --git a/include/al/ring_buffer.h b/include/al/ring_buffer.h index 359d087..686f47a 100644 --- a/include/al/ring_buffer.h +++ b/include/al/ring_buffer.h @@ -2,7 +2,6 @@ #define _AL_RING_BUFFER_H #include "types.h" -#include "atomic.h" struct al_ring_buffer { u8 *start; diff --git a/include/al/str.h b/include/al/str.h index 9a3c2de..9be1394 100644 --- a/include/al/str.h +++ b/include/al/str.h @@ -160,6 +160,8 @@ static inline u32 al_str_hash(str *s) return hash; } +AL_UNUSED_FUNCTION_POP + s64 al_str_to_long(str *s, s32 base); bool al_str_get_line(str *buffer, char sep, str *line); diff --git a/include/al/test.h b/include/al/test.h index 43f6770..532c839 100644 --- a/include/al/test.h +++ b/include/al/test.h @@ -1,7 +1,6 @@ #ifndef _AL_TEST_H #define _AL_TEST_H -#include "types.h" #include "lib.h" #define AL_TEST_START_GROUP(name) \ diff --git a/include/al/wstr.h b/include/al/wstr.h index 99c0157..540ed55 100644 --- a/include/al/wstr.h +++ b/include/al/wstr.h @@ -25,6 +25,8 @@ typedef struct { #define AL_WSTR_PRINTF(w) (w)->len, (w)->data #define AL_WSTR_PRINTF_MAXLEN(w, l) AL_MIN((w)->len, (l)), (w)->data +AL_UNUSED_FUNCTION_PUSH + static inline s32 al_wchar_width(wchar_t wc) { return wcwidth(wc); @@ -84,4 +86,6 @@ static inline s32 al_wstr_width(wstr *w) return wcswidth(w->data, w->len); } +AL_UNUSED_FUNCTION_POP + #endif // _AL_WSTR_H diff --git a/src/array.c b/src/array.c index 9b61cd9..6af0f40 100644 --- a/src/array.c +++ b/src/array.c @@ -35,7 +35,7 @@ al_array_at(arr, (arr).size++) = item; \ } while (0) -#define al_array_insert(arr, item, i) \ +#define al_array_insert(arr, i, item) \ do { \ if ((arr).size > i) { \ al_array_reserve(arr, (arr).size + 1); \ diff --git a/src/ring_buffer.c b/src/ring_buffer.c index eaff139..751ea4a 100644 --- a/src/ring_buffer.c +++ b/src/ring_buffer.c @@ -1,5 +1,6 @@ -#include "../include/al/lib.h" #include "../include/al/ring_buffer.h" +#include "../include/al/atomic.h" +#include "../include/al/lib.h" // https://github.com/MusicPlayerDaemon/MPD/blob/master/src/util/RingBuffer.hxx // https://andrea.lattuada.me/blog/2019/the-design-and-implementation-of-a-lock-free-ring-buffer-with-contiguous-reservations.html diff --git a/tests/array.c b/tests/array.c index ad03c3c..722aab6 100644 --- a/tests/array.c +++ b/tests/array.c @@ -216,9 +216,9 @@ static bool array_test_insert(void) .i = 5 }; - al_array_insert(arr, x, 1); - al_array_insert(arr, y, 0); - al_array_insert(arr, z, 1); + al_array_insert(arr, 1, x); + al_array_insert(arr, 0, y); + al_array_insert(arr, 1, z); AL_TEST_EQ(al_array_at(arr, 3).i, x.i, u32); AL_TEST_EQ(al_array_at(arr, 0).i, y.i, u32); diff --git a/tests/array_typed.c b/tests/array_typed.c index 21620e5..1c401d4 100644 --- a/tests/array_typed.c +++ b/tests/array_typed.c @@ -221,9 +221,9 @@ static bool array_test_insert(void) .i = 5 }; - al_array_insert(test_t, 16)(&arr, &x, 1); - al_array_insert(test_t, 16)(&arr, &y, 0); - al_array_insert(test_t, 16)(&arr, &z, 1); + al_array_insert(test_t, 16)(&arr, 1, &x); + al_array_insert(test_t, 16)(&arr, 0, &y); + al_array_insert(test_t, 16)(&arr, 1, &z); AL_TEST_EQ(al_array_at(test_t, 16)(&arr, 3)->i, x.i, u32); AL_TEST_EQ(al_array_at(test_t, 16)(&arr, 0)->i, y.i, u32); diff --git a/tests/ring_buffer.c b/tests/ring_buffer.c index 3ed7d4d..a8e26ef 100644 --- a/tests/ring_buffer.c +++ b/tests/ring_buffer.c @@ -1,5 +1,6 @@ #include <al/test.h> #include <al/ring_buffer.h> +#include <al/atomic.h> #define TEST_BUFFER_SIZE 32 |