diff options
author | wollman <wollman@FreeBSD.org> | 2002-09-19 03:39:03 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 2002-09-19 03:39:03 +0000 |
commit | cb45d14fee8f6330b3fbc791aea9eaa571b019f9 (patch) | |
tree | ab1f0dc71db78e794da3665ed9b795e82d90c7aa /usr.bin/getconf/sysconf.gperf | |
parent | a059a58a99b6e22aecf174427806403adc8d6cf6 (diff) | |
download | FreeBSD-src-cb45d14fee8f6330b3fbc791aea9eaa571b019f9.zip FreeBSD-src-cb45d14fee8f6330b3fbc791aea9eaa571b019f9.tar.gz |
Completely revamp the way getconf(1) works, for better adherence to the
intent of the Standard.
- Make getconf able to distinguish between configuration variables which
are entirely unknown and those which are merely not defined in the
compilation environment. The latter now get a more appropriate
"undefined\n" result rather than a diagnostic. This may not be
exactly right, but it's closer to the intent of the Standard than
the previous behavior.
- Support ``programming environments'' by validating that the environment
requested with the `-v' flag is the one-and-only execution environment.
(If more environments are supported for some platforms in the future,
multiple getconf(1) executables will be required, but a simple edit in
progenv.gperf will enable automatic support for it.) Document POSIX
standard programming environments.
- Add all of the 1003.1-2001 configuration variables. FreeBSD does not
support all of these (including some that are mandatory); getconf will
later be fixed to break the world should a required variable not be
defined.
As a result of all these changes, gperf is no longer adequate. Keep the
overall format and names of the files for now, to preserve revision history.
Use an awk script to process the .gperf files into C source, which does a
few things that gperf, as a more general tool, cannot do. The keyword
recognition function is no longer a perfect hash function.
This may obviate the need for gperf in the source tree.
- Add a small compile-time regression test to break the build if any of the
.gperf files declare conflicting token sets. (gperf itself would have done
this for the simple case of duplicate tokens in the same input file.)
Diffstat (limited to 'usr.bin/getconf/sysconf.gperf')
-rw-r--r-- | usr.bin/getconf/sysconf.gperf | 149 |
1 files changed, 38 insertions, 111 deletions
diff --git a/usr.bin/getconf/sysconf.gperf b/usr.bin/getconf/sysconf.gperf index b917000..5467d11 100644 --- a/usr.bin/getconf/sysconf.gperf +++ b/usr.bin/getconf/sysconf.gperf @@ -14,113 +14,12 @@ #include "getconf.h" /* - * Stuff that isn't defined right now -- we want this file to work - * unmodified once it is defined. - */ -#ifndef _SC_ATEXIT_MAX -#define _SC_ATEXIT_MAX -1 -#endif -#ifndef _SC_TTY_NAME_MAX -#define _SC_TTY_NAME_MAX -1 -#endif -#ifndef _SC_MQ_PRIO_MAX -#define _SC_MQ_PRIO_MAX -1 -#endif -#ifndef _SC_IOV_MAX -#define _SC_IOV_MAX -1 -#endif -#ifndef _SC_XOPEN_REALTIME -#define _SC_XOPEN_REALTIME -1 -#endif -#ifndef _SC_XOPEN_LEGACY -#define _SC_XOPEN_LEGACY -1 -#endif -#ifndef _SC_XCU_VERSION -#define _SC_XCU_VERSION -1 -#endif -#ifndef _SC_PASS_MAX -#define _SC_PASS_MAX -1 -#endif -#ifndef _SC_XOPEN_REALTIME_THREADS -#define _SC_XOPEN_REALTIME_THREADS -1 -#endif -#ifndef _SC_LOGIN_NAME_MAX -#define _SC_LOGIN_NAME_MAX -1 -#endif -#ifndef _SC_XBS5_LP64_OFF64 -#define _SC_XBS5_LP64_OFF64 -1 -#endif -#ifndef _SC_XOPEN_SHM -#define _SC_XOPEN_SHM -1 -#endif -#ifndef _SC_XOPEN_CRYPT -#define _SC_XOPEN_CRYPT -1 -#endif -#ifndef _SC_XOPEN_UNIX -#define _SC_XOPEN_UNIX -1 -#endif -#ifndef _SC_XOPEN_VERSION -#define _SC_XOPEN_VERSION -1 -#endif -#ifndef _SC_THREAD_DESTRUCTOR_ITERATIONS -#define _SC_THREAD_DESTRUCTOR_ITERATIONS -1 -#endif -#ifndef _SC_THREAD_KEYS_MAX -#define _SC_THREAD_KEYS_MAX -1 -#endif -#ifndef _SC_2_C_VERSION -#define _SC_2_C_VERSION -1 -#endif -#ifndef _SC_XBS5_LPBIG_OFFBIG -#define _SC_XBS5_LPBIG_OFFBIG -1 -#endif -#ifndef _SC_THREAD_THREADS_MAX -#define _SC_THREAD_THREADS_MAX -1 -#endif -#ifndef _SC_XBS5_ILP32_OFF32 -#define _SC_XBS5_ILP32_OFF32 -1 -#endif -#ifndef _SC_XBS5_ILP32_OFFBIG -#define _SC_XBS5_ILP32_OFFBIG -1 -#endif -#ifndef _SC_THREAD_STACK_MIN -#define _SC_THREAD_STACK_MIN -1 -#endif -#ifndef _SC_XOPEN_ENH_I18N -#define _SC_XOPEN_ENH_I18N -1 -#endif -#ifndef _SC_THREAD_ATTR_STACKSIZE -#define _SC_THREAD_ATTR_STACKSIZE -1 -#endif -#ifndef _SC_THREAD_PRIORITY_SCHEDULING -#define _SC_THREAD_PRIORITY_SCHEDULING -1 -#endif -#ifndef _SC_THREADS -#define _SC_THREADS -1 -#endif -#ifndef _SC_THREAD_PROCESS_SHARED -#define _SC_THREAD_PROCESS_SHARED -1 -#endif -#ifndef _SC_THREAD_SAFE_FUNCTIONS -#define _SC_THREAD_SAFE_FUNCTIONS -1 -#endif -#ifndef _SC_THREAD_PRIO_PROTECT -#define _SC_THREAD_PRIO_PROTECT -1 -#endif -#ifndef _SC_THREAD_ATTR_STACKADDR -#define _SC_THREAD_ATTR_STACKADDR -1 -#endif -#ifndef _SC_THREAD_PRIO_INHERIT -#define _SC_THREAD_PRIO_INHERIT -1 -#endif - -/* * Override gperf's built-in external scope. */ static const struct map *in_word_set(const char *str, unsigned int len); %} -struct map { const char *name; int key; }; +struct map { const char *name; int key; int valid; }; %% AIO_LISTIO_MAX, _SC_AIO_LISTIO_MAX AIO_MAX, _SC_AIO_MAX @@ -136,12 +35,17 @@ CLK_TCK, _SC_CLK_TCK COLL_WEIGHTS_MAX, _SC_COLL_WEIGHTS_MAX DELAYTIMER_MAX, _SC_DELAYTIMER_MAX EXPR_NEST_MAX, _SC_EXPR_NEST_MAX +GETGR_R_SIZE_MAX, _SC_GETGR_R_SIZE_MAX +GETPW_R_SIZE_MAX, _SC_GETPW_R_SIZE_MAX +HOST_NAME_MAX, _SC_HOST_NAME_MAX IOV_MAX, _SC_IOV_MAX LINE_MAX, _SC_LINE_MAX LOGIN_NAME_MAX, _SC_LOGIN_NAME_MAX MQ_OPEN_MAX, _SC_MQ_OPEN_MAX MQ_PRIO_MAX, _SC_MQ_PRIO_MAX NGROUPS_MAX, _SC_NGROUPS_MAX +NPROCESSORS_CONF, _SC_NPROCESSORS_CONF +NPROCESSORS_ONLN, _SC_NPROCESSORS_ONLN OPEN_MAX, _SC_OPEN_MAX PAGESIZE, _SC_PAGESIZE PAGE_SIZE, _SC_PAGESIZE @@ -170,6 +74,10 @@ _POSIX2_SW_DEV, _SC_2_SW_DEV _POSIX2_UPE, _SC_2_UPE _POSIX2_VERSION, _SC_2_VERSION _POSIX_ASYNCHRONOUS_IO, _SC_ASYNCHRONOUS_IO +_POSIX_BARRIERS, _SC_BARRIERS +_POSIX_CLOCK_SELECTION, _SC_CLOCK_SELECTION +_POSIX_CPUTIME, _SC_CPUTIME +_POSIX_FILE_LOCKING, _SC_FILE_LOCKING _POSIX_FSYNC, _SC_FSYNC _POSIX_JOB_CONTROL, _SC_JOB_CONTROL _POSIX_MAPPED_FILES, _SC_MAPPED_FILES @@ -177,27 +85,42 @@ _POSIX_MEMLOCK, _SC_MEMLOCK _POSIX_MEMLOCK_RANGE, _SC_MEMLOCK_RANGE _POSIX_MEMORY_PROTECTION, _SC_MEMORY_PROTECTION _POSIX_MESSAGE_PASSING, _SC_MESSAGE_PASSING +_POSIX_MONOTONIC_CLOCK, _SC_MONOTONIC_CLOCK _POSIX_PRIORITIZED_IO, _SC_PRIORITIZED_IO _POSIX_PRIORITY_SCHEDULING, _SC_PRIORITY_SCHEDULING +_POSIX_READER_WRITER_LOCKS, _SC_READER_WRITER_LOCKS _POSIX_REALTIME_SIGNALS, _SC_REALTIME_SIGNALS +_POSIX_REGEXP, _SC_REGEXP _POSIX_SAVED_IDS, _SC_SAVED_IDS _POSIX_SEMAPHORES, _SC_SEMAPHORES _POSIX_SHARED_MEMORY_OBJECTS, _SC_SHARED_MEMORY_OBJECTS +_POSIX_SHELL, _SC_SHELL +_POSIX_SPAWN, _SC_SPAWN +_POSIX_SPIN_LOCKS, _SC_SPIN_LOCKS +_POSIX_SPORADIC_SERVER, _SC_SPORADIC_SERVER _POSIX_SYNCHRONIZED_IO, _SC_SYNCHRONIZED_IO _POSIX_THREADS, _SC_THREADS _POSIX_THREAD_ATTR_STACKADDR, _SC_THREAD_ATTR_STACKADDR _POSIX_THREAD_ATTR_STACKSIZE, _SC_THREAD_ATTR_STACKSIZE +_POSIX_THREAD_CPUTIME, _SC_THREAD_CPUTIME _POSIX_THREAD_PRIORITY_SCHEDULING, _SC_THREAD_PRIORITY_SCHEDULING _POSIX_THREAD_PRIO_INHERIT, _SC_THREAD_PRIO_INHERIT _POSIX_THREAD_PRIO_PROTECT, _SC_THREAD_PRIO_PROTECT _POSIX_THREAD_PROCESS_SHARED, _SC_THREAD_PROCESS_SHARED -_POSIX_THREAD_SAFE_FUNCTIONS, _SC_THREAD_SAFE_FUNCTIONS +_POSIX_THREAD_SAFE_FUNCTIONS, _SC_THREAD_SAFE_FUNCTIONS +_POSIX_THREAD_SPORADIC_SERVER, _SC_THREAD_SPORADIC_SERVER +_POSIX_TIMEOUTS, _SC_TIMEOUTS +_POSIX_TRACE, _SC_TRACE +_POSIX_TRACE_EVENT_FILTER, _SC_TRACE_EVENT_FILTER +_POSIX_TRACE_INHERIT, _SC_TRACE_INHERIT +_POSIX_TRACE_LOG, _SC_TRACE_LOG _POSIX_TIMERS, _SC_TIMERS +_POSIX_TYPED_MEMORY_OBJECTS, _SC_TYPED_MEMORY_OBJECTS _POSIX_VERSION, _SC_VERSION -_XBS5_ILP32_OFF32, _SC_XBS5_ILP32_OFF32 -_XBS5_ILP32_OFFBIG, _SC_XBS5_ILP32_OFFBIG -_XBS5_LP64_OFF64, _SC_XBS5_LP64_OFF64 -_XBS5_LPBIG_OFFBIG, _SC_XBS5_LPBIG_OFFBIG +_POSIX_V6_ILP32_OFF32, _SC_V6_ILP32_OFF32 +_POSIX_V6_ILP32_OFFBIG, _SC_V6_ILP32_OFFBIG +_POSIX_V6_LP64_OFF64, _SC_V6_LP64_OFF64 +_POSIX_V6_LP64_OFFBIG, _SC_V6_LP64_OFFBIG _XOPEN_CRYPT, _SC_XOPEN_CRYPT _XOPEN_ENH_I18N, _SC_XOPEN_ENH_I18N _XOPEN_LEGACY, _SC_XOPEN_LEGACY @@ -209,13 +132,17 @@ _XOPEN_VERSION, _SC_XOPEN_VERSION _XOPEN_XCU_VERSION, _SC_XCU_VERSION %% int -find_sysconf(const char *name) +find_sysconf(const char *name, int *key) { const struct map *rv; rv = in_word_set(name, strlen(name)); - if (rv != 0) - return rv->key; - else + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } return -1; + } + return 0; } |