]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/bug23-4.c
[powerpc] No need to enter "Ignore Exceptions Mode"
[thirdparty/glibc.git] / stdio-common / bug23-4.c
CommitLineData
a5357b7c
JL
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <sys/resource.h>
5
6#define LIMIT 1000000
7
8int
9main (void)
10{
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;
31}