Consolidate off_t/off64_t syscall argument passing
[glibc.git] / nptl / tst-oddstacklimit.c
bloba2a92747468fc6952f7d8fc9cd86b8015f920726
1 /* Test NPTL with stack limit that is not a multiple of the page size.
2 Copyright (C) 2012-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <sys/resource.h>
23 #include <sys/wait.h>
24 #include <stdlib.h>
26 /* This sets the stack resource limit to 1023kb, which is not a multiple
27 of the page size since every architecture's page size is > 1k. */
28 #ifndef ODD_STACK_LIMIT
29 # define ODD_STACK_LIMIT (1023 * 1024)
30 #endif
32 static const char *command;
34 static int
35 do_test (void)
37 int ret;
38 struct rlimit rlim;
40 ret = getrlimit (RLIMIT_STACK, &rlim);
41 if (ret != 0)
43 printf ("getrlimit failed: %s\n", strerror (errno));
44 return 1;
46 rlim.rlim_cur = ODD_STACK_LIMIT;
47 ret = setrlimit (RLIMIT_STACK, &rlim);
48 if (ret != 0)
50 printf ("setrlimit failed: %s\n", strerror (errno));
51 return 1;
53 ret = system (command);
54 if (ret == -1)
56 printf ("system failed: %s\n", strerror (errno));
57 return 1;
59 if (WIFEXITED (ret))
60 return WEXITSTATUS (ret);
61 else
62 return 1;
65 #define OPT_COMMAND 10000
66 #define CMDLINE_OPTIONS \
67 { "command", required_argument, NULL, OPT_COMMAND },
68 #define CMDLINE_PROCESS \
69 case OPT_COMMAND: \
70 command = optarg; \
71 break;
72 #define TEST_FUNCTION do_test ()
73 #include "../test-skeleton.c"