From caa3aecaad7285755c4212bfcead46a7e84c91f8 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Sun, 9 Apr 2023 20:21:51 +0200 Subject: [PATCH] thier progress --- thiersort.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/thiersort.h b/thiersort.h index 59c2f02..776912c 100644 --- a/thiersort.h +++ b/thiersort.h @@ -233,4 +233,59 @@ * the float conversions AND shifts vectorized with SSE somewhat... */ + +#include +#define TS_BOOL uint8_t +#define TS_TRUE 1 +#define TS_FALSE 0 + +/* Nearly same alg for all these keys */ +union thier_key { + int32_t i; + uint32_t u; + float f; +}; + +struct thier_elem { + union thier_key key; + uint32_t i; +}; + +/* Forward decl of internal code */ +static inline void thiersort8_internal( + const thier_elem *arr, + uint32_t length, + const int (*compar)( + const union thier_key ak, + const union thier_key bk, + const void *aiptr, + const void *biptr, + void *reent_data), + const TS_BOOL isint, + const TS_BOOL isunsigned, + const TS_BOOL isfloat); + +/** + * Sort {key, index32} elements where key is 32 bit integer. + */ +static inline void thiersort8_intkey( + const thier_elem *arr, + uint32_t length) { +} + +/** Internal code reuse (branches shoul be optimized out) */ +static inline void thiersort8_internal( + thier_elem *arr, + const uint32_t length, + const int (*compar)( + const union thier_key ak, + const union thier_key bk, + const void *aiptr, + const void *biptr, + void *reent_data), + const TS_BOOL isint, + const TS_BOOL isunsigned, + const TS_BOOL isfloat) { + // TODO: implement +} #endif /* THIER_SORT_H */