summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libc/qsort/Makefile4
-rw-r--r--src/regress/lib/libc/qsort/qsort_test.c14
2 files changed, 8 insertions, 10 deletions
diff --git a/src/regress/lib/libc/qsort/Makefile b/src/regress/lib/libc/qsort/Makefile
index d3c4e2baa2..9062e26f95 100644
--- a/src/regress/lib/libc/qsort/Makefile
+++ b/src/regress/lib/libc/qsort/Makefile
@@ -1,9 +1,7 @@
1# $OpenBSD: Makefile,v 1.1 2017/05/17 14:47:06 millert Exp $ 1# $OpenBSD: Makefile,v 1.2 2017/05/17 20:28:35 millert Exp $
2 2
3PROG= qsort_test 3PROG= qsort_test
4CFLAGS+=-Wall 4CFLAGS+=-Wall
5LDADD+= -lm
6DPADD+= ${LIBM}
7 5
8qsort-regress: ${PROG} 6qsort-regress: ${PROG}
9 ./${PROG} 7 ./${PROG}
diff --git a/src/regress/lib/libc/qsort/qsort_test.c b/src/regress/lib/libc/qsort/qsort_test.c
index b23f3e6190..3b36eb06b4 100644
--- a/src/regress/lib/libc/qsort/qsort_test.c
+++ b/src/regress/lib/libc/qsort/qsort_test.c
@@ -18,7 +18,6 @@
18#include <stdlib.h> 18#include <stdlib.h>
19#include <string.h> 19#include <string.h>
20#include <setjmp.h> 20#include <setjmp.h>
21#include <math.h>
22#include <err.h> 21#include <err.h>
23 22
24/* 23/*
@@ -235,16 +234,17 @@ run_tests(int m, int n)
235{ 234{
236 int *x, *y, *z; 235 int *x, *y, *z;
237 int ret = 0; 236 int ret = 0;
238 double nlgn; 237 int idx, nlgn = 0;
239 enum distribution dist; 238 enum distribution dist;
240 239
241 /* 240 /*
242 * The expected number of compares is A * n * log2(n) 241 * We expect A*n*lg(n) compares where A is between 1 and 2.
243 * where A is between 1 and 2. If A is greater than 1.5 242 * For A > 1.5, print a warning.
244 * we'll print a warning. If A is greater than 10 we 243 * For A > 10 abort the test since qsort has probably gone quadratic.
245 * abort the test since qsort has probably gone quadratic.
246 */ 244 */
247 nlgn = n * log2(n); 245 for (idx = n - 1; idx > 0; idx >>= 1)
246 nlgn++;
247 nlgn *= n;
248 max_compares = nlgn * 1.5; 248 max_compares = nlgn * 1.5;
249 abrt_compares = nlgn * 10; 249 abrt_compares = nlgn * 10;
250 250