diff --git a/src/builtins/radix.h b/src/builtins/radix.h index c400cef6..bcd68f7f 100644 --- a/src/builtins/radix.h +++ b/src/builtins/radix.h @@ -2,12 +2,10 @@ // Radix sorting utilities // These are leaky macros and assume counts are c0, c1,... -// which must be adjacent in memory +// which must be adjacent in memory. Search functions will also need +// #define GRADE_UD(U,D) U +// to do the appropriate sums for an ascending radix sort. -#ifndef GRADE_UD - // Search functions need this: they always sort up - #define GRADE_UD(U,D) U -#endif #define RDX_PRE(K) s##K=c##K[j]+=s##K #define RDX_SUM_1(T) T s0=0; for(usz j=0;j<256;j++) { RDX_PRE(0); } #define RDX_SUM_2(T) GRADE_UD(c1[0]=0;,) T s0=0, s1=0; for(usz j=0;j<256;j++) { RDX_PRE(0); RDX_PRE(1); } diff --git a/src/builtins/selfsearch.c b/src/builtins/selfsearch.c index dcbb07dd..5bf2ada2 100644 --- a/src/builtins/selfsearch.c +++ b/src/builtins/selfsearch.c @@ -6,6 +6,7 @@ B not_c1(B t, B x); B shape_c1(B t, B x); +#define GRADE_UD(U,D) U #include "radix.h" u8 radix_offsets_2_u32(usz* c0, u32* v0, usz n) { usz rx = 256; @@ -19,6 +20,7 @@ u8 radix_offsets_2_u32(usz* c0, u32* v0, usz n) { if ((c0+1)[(u8)(v>>16)] < n) { RADIX_SUM_1_u32; return 1; } return 0; } +#undef GRADE_UD #define RADIX_LOOKUP_32(INIT, SETTAB) \ u8 bytes = radix_offsets_2_u32(c0, v0, n); \ usz tim = tn/(64/sizeof(*tab)); /* sparse table init max */ \