ia64: atomic.h: fix atomic_exchange_and_add 64bit handling
[glibc.git] / stdio-common / bug23-3.c
blob57c8cef195a841e13ce7f37d028537359c83c0f6
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
5 int
6 do_test (void)
8 size_t instances = 16384;
9 #define X0 "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
10 const char *item = "\na\nabbcd55";
11 #define X3 X0 X0 X0 X0 X0 X0 X0 X0
12 #define X6 X3 X3 X3 X3 X3 X3 X3 X3
13 #define X9 X6 X6 X6 X6 X6 X6 X6 X6
14 #define X12 X9 X9 X9 X9 X9 X9 X9 X9
15 #define X14 X12 X12 X12 X12
16 #define TRAILER "%%%%%%%%%%%%%%%%%%%%%%%%%%"
17 #define TRAILER2 TRAILER TRAILER
18 size_t length = instances * strlen (item) + strlen (TRAILER) + 1;
20 char *buf = malloc (length + 1);
21 snprintf (buf, length + 1,
22 X14 TRAILER2 "\n",
23 "a", "b", "c", "d", 5);
25 const char *p = buf;
26 size_t i;
27 for (i = 0; i < instances; ++i)
29 const char *expected;
30 for (expected = item; *expected; ++expected)
32 if (*p != *expected)
34 printf ("mismatch at offset %zu (%zu): expected %d, got %d\n",
35 (size_t) (p - buf), i, *expected & 0xFF, *p & 0xFF);
36 return 1;
38 ++p;
41 if (strcmp (p, TRAILER "\n") != 0)
43 printf ("mismatch at trailer: [%s]\n", p);
44 return 1;
46 free (buf);
47 return 0;
49 #define TEST_FUNCTION do_test ()
50 #include "../test-skeleton.c"