diff options
Diffstat (limited to 'string/test-string.h')
-rw-r--r-- | string/test-string.h | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/string/test-string.h b/string/test-string.h index 728a7c226a..883878b2e9 100644 --- a/string/test-string.h +++ b/string/test-string.h @@ -1,5 +1,5 @@ /* Test and measure string and memory functions. - Copyright (C) 1999-2016 Free Software Foundation, Inc. + Copyright (C) 1999-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -40,6 +40,18 @@ extern impl_t __start_impls[], __stop_impls[]; #undef __USE_STRING_INLINES +/* We are compiled under _ISOMAC, so libc-symbols.h does not do this + for us. */ +#include "config.h" +#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL +# define inhibit_loop_to_libcall \ + __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) +#else +# define inhibit_loop_to_libcall +#endif + +#include <getopt.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,7 +67,7 @@ extern impl_t __start_impls[], __stop_impls[]; #define GLRO(x) _##x -# define TEST_FUNCTION test_main () +# define TEST_FUNCTION test_main # define TIMEOUT (4 * 60) # define OPT_ITERATIONS 10000 # define OPT_RANDOM 10001 @@ -83,23 +95,31 @@ size_t iterations = 100000; # define CMDLINE_OPTIONS ITERATIONS_OPTIONS \ { "random", no_argument, NULL, OPT_RANDOM }, \ { "seed", required_argument, NULL, OPT_SEED }, -# define CMDLINE_PROCESS ITERATIONS_PROCESS \ - case OPT_RANDOM: \ - { \ - int fdr = open ("/dev/urandom", O_RDONLY); \ - \ - if (fdr < 0 || read (fdr, &seed, sizeof(seed)) != sizeof (seed)) \ - seed = time (NULL); \ - if (fdr >= 0) \ - close (fdr); \ - do_srandom = 1; \ - break; \ - } \ - \ - case OPT_SEED: \ - seed = strtoul (optarg, NULL, 0); \ - do_srandom = 1; \ - break; + +static void __attribute__ ((used)) +cmdline_process_function (int c) +{ + switch (c) + { + ITERATIONS_PROCESS + case OPT_RANDOM: + { + int fdr = open ("/dev/urandom", O_RDONLY); + if (fdr < 0 || read (fdr, &seed, sizeof (seed)) != sizeof (seed)) + seed = time (NULL); + if (fdr >= 0) + close (fdr); + do_srandom = 1; + break; + } + + case OPT_SEED: + seed = strtoul (optarg, NULL, 0); + do_srandom = 1; + break; + } +} +# define CMDLINE_PROCESS cmdline_process_function #define CALL(impl, ...) \ (* (proto_t) (impl)->fn) (__VA_ARGS__) |