From 76ca0c91314f74492d7be31fc434bb26a4331fed Mon Sep 17 00:00:00 2001 From: thetek Date: Tue, 25 Apr 2023 20:00:43 +0200 Subject: [PATCH] fix(vec): actually undefine helper macros --- lib/inc/vec.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/inc/vec.h b/lib/inc/vec.h index 7d7e16d..d91cc77 100644 --- a/lib/inc/vec.h +++ b/lib/inc/vec.h @@ -5,38 +5,37 @@ // helper macros -#define GET_FUNCTION_NAME(PREFIX, TYPE) _Generic((TYPE), \ +#define __VEC_GET_FUNCTION_NAME(PREFIX, TYPE) _Generic((TYPE), \ u8*: PREFIX##_##u8, u16*: PREFIX##_##u16, \ u32*: PREFIX##_##u32, u64*: PREFIX##_##u64, \ i8*: PREFIX##_##i8, i16*: PREFIX##_##i16, \ i32*: PREFIX##_##i32, i64*: PREFIX##_##i64, \ f32*: PREFIX##_##f32, f64*: PREFIX##_##f64) -#define DECLARE_FUNCTIONS(MACRO) \ +#define _DECLARE_FUNCTIONS(MACRO) \ MACRO(u8); MACRO(u16); MACRO(u32); MACRO(u64); \ MACRO(i8); MACRO(i16); MACRO(i32); MACRO(i64); \ MACRO(f32); MACRO(f64) -#define DECLARE_VEC_ADD(TYPE) void vec_add_##TYPE (usize n, TYPE a[restrict n], const TYPE b[restrict n]) -#define DECLARE_VEC_SUB(TYPE) void vec_sub_##TYPE (usize n, TYPE a[restrict n], const TYPE b[restrict n]) -#define DECLARE_VEC_FMA(TYPE) void vec_fma_##TYPE (usize n, TYPE a[restrict n], const TYPE b[restrict n], const TYPE c[restrict n]) +#define _DECLARE_VEC_ADD(TYPE) void vec_add_##TYPE (usize n, TYPE a[restrict n], const TYPE b[restrict n]) +#define _DECLARE_VEC_SUB(TYPE) void vec_sub_##TYPE (usize n, TYPE a[restrict n], const TYPE b[restrict n]) +#define _DECLARE_VEC_FMA(TYPE) void vec_fma_##TYPE (usize n, TYPE a[restrict n], const TYPE b[restrict n], const TYPE c[restrict n]) // exported macros -#define vec_add(n, a, b) GET_FUNCTION_NAME(vec_add, a)(n, a, b) /* vectorized addition - void vec_add(usize n, T a[restrict n], const T b[restrict n]) */ -#define vec_sub(n, a, b) GET_FUNCTION_NAME(vec_sub, a)(n, a, b) /* vectorized subtraction - void vec_sub(usize n, T a[restrict n], const T b[restrict n]) */ -#define vec_fma(n, a, b, c) GET_FUNCTION_NAME(vec_fma, a)(n, a, b, c) /* vectorized fused multiply-add - void vec_fma(usize n, T a[restrict n], const T b[restrict n], const T c[restrict n]) */ +#define vec_add(n, a, b) __VEC_GET_FUNCTION_NAME(vec_add, a)(n, a, b) /* vectorized addition - void vec_add(usize n, T a[restrict n], const T b[restrict n]) */ +#define vec_sub(n, a, b) __VEC_GET_FUNCTION_NAME(vec_sub, a)(n, a, b) /* vectorized subtraction - void vec_sub(usize n, T a[restrict n], const T b[restrict n]) */ +#define vec_fma(n, a, b, c) __VEC_GET_FUNCTION_NAME(vec_fma, a)(n, a, b, c) /* vectorized fused multiply-add - void vec_fma(usize n, T a[restrict n], const T b[restrict n], const T c[restrict n]) */ // function declarations -DECLARE_FUNCTIONS(DECLARE_VEC_ADD); -DECLARE_FUNCTIONS(DECLARE_VEC_SUB); -DECLARE_FUNCTIONS(DECLARE_VEC_FMA); +_DECLARE_FUNCTIONS(_DECLARE_VEC_ADD); +_DECLARE_FUNCTIONS(_DECLARE_VEC_SUB); +_DECLARE_FUNCTIONS(_DECLARE_VEC_FMA); // undefine helper macros -#undef __GET_FUNCTION_NAME -#undef __DECLARE_FUNCTIONS -#undef __DECLARE_VEC_ADD -#undef __DECLARE_VEC_SUB -#undef __DECLARE_VEC_FMA +#undef _DECLARE_FUNCTIONS +#undef _DECLARE_VEC_ADD +#undef _DECLARE_VEC_SUB +#undef _DECLARE_VEC_FMA #endif // VEC_H_