Preserve stack alignment in i386 makecontext.
[glibc/pb-stable.git] / posix / tst-sysconf.c
blobe2972291ae6dc1962c90f5900aa66f163289b246
1 #include <stdbool.h>
2 #include <stdio.h>
3 #include <unistd.h>
5 static struct
7 long int _P_val;
8 const char *name;
9 int _SC_val;
10 bool positive;
11 bool posix2;
12 } posix_options[] =
14 #define N_(name, pos) { _POSIX_##name, #name, _SC_##name, pos, false }
15 #define NP(name) N_ (name, true)
16 #define N(name) N_ (name, false)
17 #define N2(name) { _POSIX2_##name, #name, _SC_2_##name, false, true }
18 N (ADVISORY_INFO),
19 N (ASYNCHRONOUS_IO),
20 N (BARRIERS),
21 N (CLOCK_SELECTION),
22 N (CPUTIME),
23 N (FSYNC),
24 N (IPV6),
25 NP (JOB_CONTROL),
26 N (MAPPED_FILES),
27 N (MEMLOCK),
28 N (MEMLOCK_RANGE),
29 N (MEMORY_PROTECTION),
30 N (MESSAGE_PASSING),
31 N (MONOTONIC_CLOCK),
32 N (PRIORITIZED_IO),
33 N (PRIORITY_SCHEDULING),
34 N (RAW_SOCKETS),
35 N (READER_WRITER_LOCKS),
36 N (REALTIME_SIGNALS),
37 NP (REGEXP),
38 NP (SAVED_IDS),
39 N (SEMAPHORES),
40 N (SHARED_MEMORY_OBJECTS),
41 NP (SHELL),
42 N (SPAWN),
43 N (SPIN_LOCKS),
44 N (SPORADIC_SERVER),
45 N (SYNCHRONIZED_IO),
46 N (THREAD_ATTR_STACKADDR),
47 N (THREAD_ATTR_STACKSIZE),
48 N (THREAD_CPUTIME),
49 N (THREAD_PRIO_INHERIT),
50 N (THREAD_PRIO_PROTECT),
51 N (THREAD_PRIORITY_SCHEDULING),
52 N (THREAD_PROCESS_SHARED),
53 N (THREAD_SAFE_FUNCTIONS),
54 N (THREAD_SPORADIC_SERVER),
55 N (THREADS),
56 N (TIMEOUTS),
57 N (TIMERS),
58 N (TRACE),
59 N (TRACE_EVENT_FILTER),
60 N (TRACE_INHERIT),
61 N (TRACE_LOG),
62 N (TYPED_MEMORY_OBJECTS),
63 N2 (C_BIND),
64 N2 (C_DEV),
65 N2 (CHAR_TERM)
67 #define nposix_options (sizeof (posix_options) / sizeof (posix_options[0]))
69 static int
70 do_test (void)
72 int result = 0;
74 for (int i = 0; i < nposix_options; ++i)
76 long int scret = sysconf (posix_options[i]._SC_val);
78 if (scret == 0)
80 printf ("sysconf(_SC_%s%s) returned zero\n",
81 posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
82 result = 1;
84 if (posix_options[i]._P_val != 0 && posix_options[i]._P_val != scret)
86 printf ("sysconf(_SC_%s%s) = %ld does not match _POSIX%s_%s = %ld\n",
87 posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
88 scret,
89 posix_options[i].posix2 ? "2" : "", posix_options[i].name,
90 posix_options[i]._P_val);
91 result = 1;
93 else if (posix_options[i].positive && scret < 0)
95 printf ("sysconf(_SC_%s%s) must be > 0\n",
96 posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
97 result = 1;
100 #define STDVER 200809L
101 if (scret > 0 && scret != STDVER && !posix_options[i].positive)
103 printf ("sysconf(_SC_%s%s) must be %ldL\n",
104 posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
105 STDVER);
106 result = 1;
110 return result;
113 #define TEST_FUNCTION do_test ()
114 #include "../test-skeleton.c"