summaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-11-30 06:33:11 +0000
committerJakub Jelinek <jakub@redhat.com>2004-11-30 06:33:11 +0000
commitc1f8ef75d3ddf687efc5ee23e16075c256fa77be (patch)
treea3ea2de6f93ff7c1abd4190b14414cf458474436 /posix
parentf94203900a978cda33df395c36827a17d171f98e (diff)
Updated to fedora-glibc-20041130T0624
Diffstat (limited to 'posix')
-rw-r--r--posix/Makefile2
-rw-r--r--posix/confstr.c12
-rw-r--r--posix/getconf.c6
-rw-r--r--posix/tst-sysconf.c114
4 files changed, 127 insertions, 7 deletions
diff --git a/posix/Makefile b/posix/Makefile
index 5a3534a6ad..7f2bcb9d01 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -83,7 +83,7 @@ tests := tstgetopt testfnm runtests runptests \
tst-nice tst-nanosleep tst-regex2 \
transbug tst-rxspencer tst-pcre tst-boost \
bug-ga1 tst-vfork1 tst-vfork2 tst-waitid \
- tst-getaddrinfo2 bug-glob1 bug-glob2
+ tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf
xtests := bug-ga2
ifeq (yes,$(build-shared))
test-srcs := globtest
diff --git a/posix/confstr.c b/posix/confstr.c
index 6b0dcf0c20..da929c25df 100644
--- a/posix/confstr.c
+++ b/posix/confstr.c
@@ -113,7 +113,7 @@ confstr (name, buf, len)
case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
#ifdef __ILP32_OFF32_CFLAGS
# if _POSIX_V6_ILP32_OFF32 == -1
-# error __ILP32_OFF32_CFLAGS shouldn't be defined
+# error __ILP32_OFF32_CFLAGS should not be defined
# elif !defined _POSIX_V6_ILP32_OFF32
if (__sysconf (_SC_V6_ILP32_OFF32) < 0)
break;
@@ -127,7 +127,7 @@ confstr (name, buf, len)
case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
#ifdef __ILP32_OFFBIG_CFLAGS
# if _POSIX_V6_ILP32_OFFBIG == -1
-# error __ILP32_OFFBIG_CFLAGS shouldn't be defined
+# error __ILP32_OFFBIG_CFLAGS should not be defined
# elif !defined _POSIX_V6_ILP32_OFFBIG
if (__sysconf (_SC_V6_ILP32_OFFBIG) < 0)
break;
@@ -141,7 +141,7 @@ confstr (name, buf, len)
case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
#ifdef __LP64_OFF64_CFLAGS
# if _POSIX_V6_LP64_OFF64 == -1
-# error __LP64_OFF64_CFLAGS shouldn't be defined
+# error __LP64_OFF64_CFLAGS should not be defined
# elif !defined _POSIX_V6_LP64_OFF64
if (__sysconf (_SC_V6_LP64_OFF64) < 0)
break;
@@ -155,7 +155,7 @@ confstr (name, buf, len)
case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
#ifdef __ILP32_OFF32_LDFLAGS
# if _POSIX_V6_ILP32_OFF32 == -1
-# error __ILP32_OFF32_LDFLAGS shouldn't be defined
+# error __ILP32_OFF32_LDFLAGS should not be defined
# elif !defined _POSIX_V6_ILP32_OFF32
if (__sysconf (_SC_V6_ILP32_OFF32) < 0)
break;
@@ -169,7 +169,7 @@ confstr (name, buf, len)
case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
#ifdef __ILP32_OFFBIG_LDFLAGS
# if _POSIX_V6_ILP32_OFFBIG == -1
-# error __ILP32_OFFBIG_LDFLAGS shouldn't be defined
+# error __ILP32_OFFBIG_LDFLAGS should not be defined
# elif !defined _POSIX_V6_ILP32_OFFBIG
if (__sysconf (_SC_V6_ILP32_OFFBIG) < 0)
break;
@@ -183,7 +183,7 @@ confstr (name, buf, len)
case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
#ifdef __LP64_OFF64_LDFLAGS
# if _POSIX_V6_LP64_OFF64 == -1
-# error __LP64_OFF64_LDFLAGS shouldn't be defined
+# error __LP64_OFF64_LDFLAGS should not be defined
# elif !defined _POSIX_V6_LP64_OFF64
if (__sysconf (_SC_V6_LP64_OFF64) < 0)
break;
diff --git a/posix/getconf.c b/posix/getconf.c
index 6175dfec26..5aac25e4ca 100644
--- a/posix/getconf.c
+++ b/posix/getconf.c
@@ -912,6 +912,12 @@ static const struct conf vars[] =
{ "LEVEL4_CACHE_ASSOC", _SC_LEVEL4_CACHE_ASSOC, SYSCONF },
#endif
+#ifdef _SC_IPV6
+ { "IPV6", _SC_IPV6, SYSCONF },
+#endif
+#ifdef _SC_RAW_SOCKETS
+ { "RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF },
+#endif
{ NULL, 0, SYSCONF }
};
diff --git a/posix/tst-sysconf.c b/posix/tst-sysconf.c
new file mode 100644
index 0000000000..e9ff06a8da
--- /dev/null
+++ b/posix/tst-sysconf.c
@@ -0,0 +1,114 @@
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static struct
+{
+ long int _P_val;
+ const char *name;
+ int _SC_val;
+ bool positive;
+ bool posix2;
+} posix_options[] =
+ {
+#define N_(name, pos) { _POSIX_##name, #name, _SC_##name, pos, false }
+#define NP(name) N_ (name, true)
+#define N(name) N_ (name, false)
+#define N2(name) { _POSIX2_##name, #name, _SC_2_##name, false, true }
+ N (ADVISORY_INFO),
+ N (ASYNCHRONOUS_IO),
+ N (BARRIERS),
+ N (CLOCK_SELECTION),
+ N (CPUTIME),
+ N (FSYNC),
+ N (IPV6),
+ NP (JOB_CONTROL),
+ N (MAPPED_FILES),
+ N (MEMLOCK),
+ N (MEMLOCK_RANGE),
+ N (MEMORY_PROTECTION),
+ N (MESSAGE_PASSING),
+ N (MONOTONIC_CLOCK),
+ N (PRIORITIZED_IO),
+ N (PRIORITY_SCHEDULING),
+ N (RAW_SOCKETS),
+ N (READER_WRITER_LOCKS),
+ N (REALTIME_SIGNALS),
+ NP (REGEXP),
+ NP (SAVED_IDS),
+ N (SEMAPHORES),
+ N (SHARED_MEMORY_OBJECTS),
+ NP (SHELL),
+ N (SPAWN),
+ N (SPIN_LOCKS),
+ N (SPORADIC_SERVER),
+ N (SYNCHRONIZED_IO),
+ N (THREAD_ATTR_STACKADDR),
+ N (THREAD_ATTR_STACKSIZE),
+ N (THREAD_CPUTIME),
+ N (THREAD_PRIO_INHERIT),
+ N (THREAD_PRIO_PROTECT),
+ N (THREAD_PRIORITY_SCHEDULING),
+ N (THREAD_PROCESS_SHARED),
+ N (THREAD_SAFE_FUNCTIONS),
+ N (THREAD_SPORADIC_SERVER),
+ N (THREADS),
+ N (TIMEOUTS),
+ N (TIMERS),
+ N (TRACE),
+ N (TRACE_EVENT_FILTER),
+ N (TRACE_INHERIT),
+ N (TRACE_LOG),
+ N (TYPED_MEMORY_OBJECTS),
+ N2 (C_BIND),
+ N2 (C_DEV),
+ N2 (CHAR_TERM)
+ };
+#define nposix_options (sizeof (posix_options) / sizeof (posix_options[0]))
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+ for (int i = 0; i < nposix_options; ++i)
+ {
+ long int scret = sysconf (posix_options[i]._SC_val);
+
+ if (scret == 0)
+ {
+ printf ("sysconf(_SC_%s%s) returned zero\n",
+ posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
+ result = 1;
+ }
+ if (posix_options[i]._P_val != 0 && posix_options[i]._P_val != scret)
+ {
+ printf ("sysconf(_SC_%s%s) = %ld does not match _POSIX%s_%s = %ld\n",
+ posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
+ scret,
+ posix_options[i].posix2 ? "2" : "", posix_options[i].name,
+ posix_options[i]._P_val);
+ result = 1;
+ }
+ else if (posix_options[i].positive && scret < 0)
+ {
+ printf ("sysconf(_SC_%s%s) must be > 0\n",
+ posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
+ result = 1;
+ }
+
+#define STDVER 200112L
+ if (scret > 0 && scret != STDVER && !posix_options[i].positive)
+ {
+ printf ("sysconf(_SC_%s%s) must be %ldL\n",
+ posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
+ STDVER);
+ result = 1;
+ }
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"