Commits

Andrew Schein committed 43a11b0

pulled in the pull request 27aa7df, fixed an endian bug for u2_sort.

Comments (0)

Files changed (6)

 
 static inline void CS_(intro_sort)(CSORT_TY *x, const long long orig_n, long intro_limit) {
     long long n = orig_n,s;
-    long long ty_sz; /* ,l,h; */ 
     CSORT_TY *p0,*pm,*p1;
     CSORT_TY *a,*b,*c,*d; /* ,*t; */ /* indices within array */
     CSORT_TY pivot;
     if (n < 0) fprintf(stderr,"sort error: n < 0: %lld\n",n),exit(1);
     if (n <= CSORT_ISORT_SWITCH) return CS_(ins_sort) (x,n); 
     if (intro_limit <= 0)        return CS_(heap_sort)(x,n);  
-    s=(n>>3), ty_sz=sizeof(CSORT_TY);
+    s=(n>>3);
     p0=x;pm=x+(n>>1);p1=x+n-1; /* pivot candidates 0,1 from calculus, m for median */
     if (n >= CSORT_NINTHER_SWITCH) {
         p0    = CSORT_NINTHER(p0    , p0+s, p0+2*s);

csort/datetime

-../../datetime
 #define SWAPCPY(x,y,sz) {memcpy((buf.c),(x),(sz)); memcpy((x),(y),(sz)); memcpy((y),(buf.c),(sz));}
 
 #define SWAPASS(ty) {*((ty*)buf.c)=*((ty*)x); *((ty*)x)=*((ty*)y); *((ty*)y)=*((ty*)buf.c);}
-#define SWAPINT32 (buf.d=*(int_fast32_t*)x, \
-                   *((int_fast32_t*)x)=*((int_fast32_t*)y), *((int_fast32_t*)y)= buf.d)
-#define SWAPINT64 (buf.f=*(int_fast64_t*)x, \
-                   *((int_fast64_t*)x)=*((int_fast64_t*)y), *((int_fast64_t*)y)= buf.f)
+#define SWAPINT16 (buf.d=*(int16_t*)x, \
+                   *((int16_t*)x)=*((int16_t*)y), *((int16_t*)y)= buf.d)
+#define SWAPINT32 (buf.d=*(int32_t*)x, \
+                   *((int32_t*)x)=*((int32_t*)y), *((int32_t*)y)= buf.d)
+#define SWAPINT64 (buf.f=*(int64_t*)x, \
+                   *((int64_t*)x)=*((int64_t*)y), *((int64_t*)y)= buf.f)
 #define SWAP_MIN(x,y)  ((x) < (y) ? (x) : (y))
 
     
     switch (sz) {
     case             0 : return NULL;
     case             sizeof(char)         :  SWAPASS(char);           return _x;
-    case             sizeof(short)        :  SWAPASS(short);          return _x;
-    case             sizeof(int32_t)      :  SWAPASS(int32_t);        return _x;
-    case             sizeof(int_fast64_t) :  SWAPASS(int_fast64_t);   return _x;
+    case             sizeof(short)        :  SWAPINT16;          return _x;
+    case             sizeof(int32_t)      :  SWAPINT32;        return _x;
+    case             sizeof(int64_t)      :  SWAPINT64;   return _x;
     default : 
         do {
             n = SWAP_MIN(sz,sizeof(int_fast64_t));

isort/datetime

-../../datetime

usort/t/small-cmp.sh

File contents unchanged.
 #  error __FILE__ ": __BYTE_ORDER is not defined!"
 # endif
 #endif
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #include <stdlib.h> /* malloc among others */
 
 #define CSORT_TY unsigned short
 #define CS_(name) u2_##name
 #include "../common/defs.c"
-#include "../isort/ufunc/u2_isort.c"
 
 #define _0(v) ((v)         & 0xFF)
 #define _1(v) (((v) >> 8)  & 0xFF)
     long n, sum0=0 , sum1=0 , tsum=0;
     unsigned short *reader, *writer, *buf;
     long *b0, *b1;
-    if (sz < 32) { return u2_isort(a,sz); }
+    if (sz < 16) { return CS_(ins_sort)(a,sz); }
     buf = (unsigned short*) malloc(sz * sizeof(unsigned short));
     b0   = calloc(HIST_SIZE * 2, sizeof(long));
     b1   = b0 + HIST_SIZE;