Fix sys/ucontext.h namespace from signal.h etc. inclusion (bug 21457).
[glibc.git] / stdio-common / bug23-4.c
bloba4785640dee04ae385f44b34ff2acba240d6ec3a
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <sys/resource.h>
6 #define LIMIT 1000000
8 int
9 main (void)
11 struct rlimit lim;
12 getrlimit (RLIMIT_STACK, &lim);
13 lim.rlim_cur = 1048576;
14 setrlimit (RLIMIT_STACK, &lim);
15 char *fmtstr = malloc (4 * LIMIT + 1);
16 if (fmtstr == NULL)
17 abort ();
18 char *output = malloc (LIMIT + 1);
19 if (output == NULL)
20 abort ();
21 for (size_t i = 0; i < LIMIT; i++)
22 memcpy (fmtstr + 4 * i, "%1$d", 4);
23 fmtstr[4 * LIMIT] = '\0';
24 int ret = snprintf (output, LIMIT + 1, fmtstr, 0);
25 if (ret != LIMIT)
26 abort ();
27 for (size_t i = 0; i < LIMIT; i++)
28 if (output[i] != '0')
29 abort ();
30 return 0;