diff options
author | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
commit | 5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch) | |
tree | 4470480d904b65cf14ca524f96f79eca818c3eaf /stdlib/tst-qsort2.c | |
parent | 199fc19d3aaaf57944ef036e15904febe877fc93 (diff) | |
download | glibc-zack/build-layout-experiment.tar glibc-zack/build-layout-experiment.tar.gz glibc-zack/build-layout-experiment.tar.bz2 glibc-zack/build-layout-experiment.zip |
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'stdlib/tst-qsort2.c')
-rw-r--r-- | stdlib/tst-qsort2.c | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/stdlib/tst-qsort2.c b/stdlib/tst-qsort2.c deleted file mode 100644 index 10d16852b0..0000000000 --- a/stdlib/tst-qsort2.c +++ /dev/null @@ -1,89 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -char *array; -char *array_end; -size_t member_size; - -int -compare (const void *a1, const void *b1) -{ - const char *a = a1; - const char *b = b1; - - if (! (array <= a && a < array_end - && array <= b && b < array_end)) - { - puts ("compare arguments not inside of the array"); - exit (EXIT_FAILURE); - } - int ret = b[0] - a[0]; - if (ret) - return ret; - if (member_size > 1) - return b[1] - a[1]; - return 0; -} - -int -test (size_t nmemb, size_t size) -{ - array = malloc (nmemb * size); - if (array == NULL) - { - printf ("%zd x %zd: no memory", nmemb, size); - return 1; - } - - array_end = array + nmemb * size; - member_size = size; - - char *p; - size_t i; - size_t bias = random (); - for (i = 0, p = array; i < nmemb; i++, p += size) - { - p[0] = (char) (i + bias); - if (size > 1) - p[1] = (char) ((i + bias) >> 8); - } - - qsort (array, nmemb, size, compare); - - for (i = 0, p = array; i < nmemb - 1; i++, p += size) - { - if (p[0] < p[size] - || (size > 1 && p[0] == p[size] && p[1] < p[size + 1])) - { - printf ("%zd x %zd: failure at offset %zd\n", nmemb, - size, i); - free (array); - return 1; - } - } - - free (array); - return 0; -} - -int -main (int argc, char **argv) -{ - int ret = 0; - if (argc >= 3) - ret |= test (atoi (argv[1]), atoi (argv[2])); - else - { - ret |= test (10000, 1); - ret |= test (200000, 2); - ret |= test (2000000, 3); - ret |= test (2132310, 4); - ret |= test (1202730, 7); - ret |= test (1184710, 8); - ret |= test (272710, 12); - ret |= test (14170, 32); - ret |= test (4170, 320); - } - - return ret; -} |