From 88a8e87418f0f0460a1d37695dedde309f894094 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Tue, 2 May 2023 13:20:07 +0200 Subject: [PATCH] thiersort compile errors --- thiersort.h | 33 +++++++++++++++++---------------- ypsu.cpp | 1 + 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/thiersort.h b/thiersort.h index 5738872..9c3960b 100644 --- a/thiersort.h +++ b/thiersort.h @@ -282,7 +282,7 @@ static inline void thiersort8_internal( void *reent_data); /** The '<' operation used for int32 */ -static inline const int ts_lt_int( +static inline const TSBOOL ts_lt_int( const union tskey ak, const union tskey bk, const TSU32 ai, @@ -290,7 +290,7 @@ static inline const int ts_lt_int( void *reent_data) { return (ak.i < bk.i); } /** The '<' operation used for unsigned int32 */ -static inline const int ts_lt_uint( +static inline const TSBOOL ts_lt_uint( const union tskey ak, const union tskey bk, const TSU32 ai, @@ -298,7 +298,7 @@ static inline const int ts_lt_uint( void *reent_data) { return (ak.u < bk.u); } /** The '<' operation used for float */ -static inline const int ts_lt_float( +static inline const TSBOOL ts_lt_float( const union tskey ak, const union tskey bk, const TSU32 ai, @@ -361,7 +361,8 @@ static inline void thiersort8_floatkey( ts_lt_float, TSFALSE, TSFALSE, - TSTRUE); + TSTRUE, + NULL); } /** @@ -388,7 +389,7 @@ static inline struct tselem *thiersort_prepare_array( TSU32 length, void* (*malloc)(size_t size)) { /* Allocate */ - tselem *out = malloc(length * sizeof(tselem)); + tselem *out = (tselem *)malloc(length * sizeof(tselem)); /* Fill */ TSU32 j = 0; @@ -431,12 +432,12 @@ static inline void thiersort_apply( // This also solves "already at right place" originals. while(ni != j) { // xchg j and ni - memcpy(tmp, arr[(size_t)j * elemsize], elemsize); + memcpy(tmp, &((TSU8*)arr)[(size_t)j * elemsize], elemsize); memcpy( - arr[(size_t)j * elemsize], - arr[(size_t)ni * elemsize], + &((TSU8*)arr)[(size_t)j * elemsize], + &((TSU8*)arr)[(size_t)ni * elemsize], elemsize); - memcpy(arr[(size_t)ni * elemsize], tmp, elemsize); + memcpy(&((TSU8*)arr)[(size_t)ni * elemsize], tmp, elemsize); // Mark j index as done in sortres for outer loop. // This is necessary for inner loop stopping early @@ -486,7 +487,7 @@ static inline TSU8 ts_radixi( union tskey k; if(isint) { /* Sign bit can be 1! */ - k.f = (float)(arr[i].i); + k.f = (float)(key.i); /* 8 bit float */ k.u >> 24; @@ -496,7 +497,7 @@ static inline TSU8 ts_radixi( } if(isunsigned) { /* Sign bit CANNOT be 1! */ - k.f = (float)(arr[i].u); + k.f = (float)(key.u); /* 8 bit float */ /* top bit always zero so ignore it and use 8 useful bits */ @@ -508,7 +509,7 @@ static inline TSU8 ts_radixi( } if(isfloat) { /* Sign bit can be 1! */ - k.f = arr[i].f; + k.f = key.f; /* 8 bit float */ k.u >> 24; @@ -540,7 +541,7 @@ static inline void ts_quicksort_inplace( TSU32 right = to - 1; while(left < right) { // Step over rightly positioned elems from left - const union tskey leftkey = arr[left].key; + union tskey leftkey = arr[left].key; TSU32 lefti = arr[left].i; while((left < right) && lt(leftkey, pivotkey, lefti, pivoti, reent_data)) { ++left; @@ -549,7 +550,7 @@ static inline void ts_quicksort_inplace( } // Step over rightly positioned elems from right - const union tskey rightkey = arr[right].key; + union tskey rightkey = arr[right].key; TSU32 righti = arr[right].i; while((left < right) && lt(pivotkey, rightkey, pivoti, righti, reent_data)) { --right; @@ -639,7 +640,7 @@ static inline void thiersort8_internal( TSU32 radics[256] = {0}; /* [from, to) index: only where prefix sums change - usually nonfull */ TSU32 real_radics[256 * 2] = {0}; - struct tselem *arr2 = malloc((sizeof struct tselem) * length); + struct tselem *arr2 = (tselem *)malloc((sizeof(struct tselem)) * length); /* Step 1) Bucketing */ #ifdef TS_SSE2 @@ -691,7 +692,7 @@ static inline void thiersort8_internal( TSU32 to = real_radics[i + 1]; /* Quicksort this bucket in O(mlogm), where m << n usually */ - ts_quicksort_fromto(arr2, arr1, from, to, lt, reent_data); + ts_quicksort_fromto(arr2, arr, from, to, lt, reent_data); } /* Cleanup */ diff --git a/ypsu.cpp b/ypsu.cpp index d070adf..019cdcf 100644 --- a/ypsu.cpp +++ b/ypsu.cpp @@ -14,6 +14,7 @@ #include // mlock & munlock #include "ska_sort.hpp" #include "gptsort.h" +#include "thiersort.h" #define MAGYAR_SORT_DEFAULT_REUSE #include "magyarsort.h"