1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Don't use nested function in test-ffs

There is no real need to use a nested function in that test, so break
it out so that it can build with clang too.
This commit is contained in:
Siddhesh Poyarekar
2020-11-12 13:16:02 +05:30
parent 7163ace331
commit b7aa84d5a5

View File

@ -20,28 +20,25 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <support/check.h>
void try (const char *name, long long int param, int value, int expected)
{
if (value != expected)
{
printf ("%s(%#llx) expected %d got %d\n",
name, param, expected, value);
support_record_failure ();
}
else
printf ("%s(%#llx) as expected %d\n", name, param, value);
}
int int
do_test (void) do_test (void)
{ {
int failures = 0;
int i; int i;
auto void try (const char *name, long long int param, int value,
int expected);
void try (const char *name, long long int param, int value, int expected)
{
if (value != expected)
{
printf ("%s(%#llx) expected %d got %d\n",
name, param, expected, value);
++failures;
}
else
printf ("%s(%#llx) as expected %d\n", name, param, value);
}
#define TEST(fct, type) \ #define TEST(fct, type) \
try (#fct, 0, fct ((type) 0), 0); \ try (#fct, 0, fct ((type) 0), 0); \
for (i=0 ; i < 8 * sizeof (type); i++) \ for (i=0 ; i < 8 * sizeof (type); i++) \
@ -54,12 +51,7 @@ do_test (void)
TEST (ffsl, long int); TEST (ffsl, long int);
TEST (ffsll, long long int); TEST (ffsll, long long int);
if (failures) return 0;
printf ("Test FAILED! %d failure%s.\n", failures, &"s"[failures == 1]);
else
puts ("Test succeeded.");
return failures;
} }
#include <support/test-driver.c> #include <support/test-driver.c>