Skip to content

Commit

Permalink
Add patch to fix GCC 5.x build on modern linux distributions.
Browse files Browse the repository at this point in the history
	new file:   patches/001-IncorrectTestForIsNaN.patch
  • Loading branch information
jmatt committed May 17, 2016
1 parent b6cc49b commit dc5266d
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions patches/001-IncorrectTestForIsNaN.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/util/permutedsort.c b/util/permutedsort.c
index f329481..5cbcbf5 100644
--- a/util/permutedsort.c
+++ b/util/permutedsort.c
@@ -94,6 +94,11 @@ int* permuted_sort(const void* realarray, int array_stride,

//printf("d1=%g, d2=%g\n", d1, d2);

+#define INTCOMPARE(i1, i2, op1, op2) \
+ if (i1 op1 i2) return -1; \
+ if (i1 op2 i2) return 1; \
+ return 0;
+
int compare_doubles_asc(const void* v1, const void* v2) {
const double d1 = *(double*)v1;
const double d2 = *(double*)v2;
@@ -120,15 +125,15 @@ int compare_floats_desc(const void* v1, const void* v2) {
}

int compare_int64_asc(const void* v1, const void* v2) {
- int64_t f1 = *(int64_t*)v1;
- int64_t f2 = *(int64_t*)v2;
- COMPARE(f1, f2, <, >);
+ int64_t i1 = *(int64_t*)v1;
+ int64_t i2 = *(int64_t*)v2;
+ INTCOMPARE(i1, i2, <, >);
}

int compare_int64_desc(const void* v1, const void* v2) {
- int64_t f1 = *(int64_t*)v1;
- int64_t f2 = *(int64_t*)v2;
- COMPARE(f1, f2, >, <);
+ int64_t i1 = *(int64_t*)v1;
+ int64_t i2 = *(int64_t*)v2;
+ INTCOMPARE(i1, i2, >, <);
}

// Versions for use with QSORT_R
@@ -139,6 +144,7 @@ int QSORT_COMPARISON_FUNCTION(compare_floats_asc_r,


#undef COMPARE
+#undef INTCOMPARE

int compare_ints_asc(const void* v1, const void* v2) {
const int d1 = *(int*)v1;

0 comments on commit dc5266d

Please sign in to comment.