xref: /freebsd-src/usr.bin/getconf/sysconf.gperf (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
18c6bd995SGarrett Wollman%{
28c6bd995SGarrett Wollman/*
38c6bd995SGarrett Wollman * Copyright is disclaimed as to the contents of this file.
48c6bd995SGarrett Wollman */
58c6bd995SGarrett Wollman
68c6bd995SGarrett Wollman#include <sys/types.h>
78c6bd995SGarrett Wollman
88c6bd995SGarrett Wollman#include <string.h>
98c6bd995SGarrett Wollman#include <unistd.h>
108c6bd995SGarrett Wollman
118c6bd995SGarrett Wollman#include "getconf.h"
128c6bd995SGarrett Wollman
138c6bd995SGarrett Wollman/*
148c6bd995SGarrett Wollman * Override gperf's built-in external scope.
158c6bd995SGarrett Wollman */
16a272cd3aSMark Murraystatic const struct map *in_word_set(const char *str);
178c6bd995SGarrett Wollman
188c6bd995SGarrett Wollman%}
19e9cfb9aeSGarrett Wollmanstruct map { const char *name; int key; int valid; };
208c6bd995SGarrett Wollman%%
218c6bd995SGarrett WollmanAIO_LISTIO_MAX, _SC_AIO_LISTIO_MAX
228c6bd995SGarrett WollmanAIO_MAX, _SC_AIO_MAX
238c6bd995SGarrett WollmanAIO_PRIO_DELTA_MAX, _SC_AIO_PRIO_DELTA_MAX
248c6bd995SGarrett WollmanARG_MAX, _SC_ARG_MAX
258c6bd995SGarrett WollmanATEXIT_MAX, _SC_ATEXIT_MAX
268c6bd995SGarrett WollmanBC_BASE_MAX, _SC_BC_BASE_MAX
278c6bd995SGarrett WollmanBC_DIM_MAX, _SC_BC_DIM_MAX
288c6bd995SGarrett WollmanBC_SCALE_MAX, _SC_BC_SCALE_MAX
298c6bd995SGarrett WollmanBC_STRING_MAX, _SC_BC_STRING_MAX
308c6bd995SGarrett WollmanCHILD_MAX, _SC_CHILD_MAX
318c6bd995SGarrett WollmanCLK_TCK, _SC_CLK_TCK
328c6bd995SGarrett WollmanCOLL_WEIGHTS_MAX, _SC_COLL_WEIGHTS_MAX
338c6bd995SGarrett WollmanDELAYTIMER_MAX, _SC_DELAYTIMER_MAX
348c6bd995SGarrett WollmanEXPR_NEST_MAX, _SC_EXPR_NEST_MAX
35e9cfb9aeSGarrett WollmanGETGR_R_SIZE_MAX, _SC_GETGR_R_SIZE_MAX
36e9cfb9aeSGarrett WollmanGETPW_R_SIZE_MAX, _SC_GETPW_R_SIZE_MAX
37e9cfb9aeSGarrett WollmanHOST_NAME_MAX, _SC_HOST_NAME_MAX
388c6bd995SGarrett WollmanIOV_MAX, _SC_IOV_MAX
398c6bd995SGarrett WollmanLINE_MAX, _SC_LINE_MAX
408c6bd995SGarrett WollmanLOGIN_NAME_MAX, _SC_LOGIN_NAME_MAX
418c6bd995SGarrett WollmanMQ_OPEN_MAX, _SC_MQ_OPEN_MAX
428c6bd995SGarrett WollmanMQ_PRIO_MAX, _SC_MQ_PRIO_MAX
438c6bd995SGarrett WollmanNGROUPS_MAX, _SC_NGROUPS_MAX
44e9cfb9aeSGarrett WollmanNPROCESSORS_CONF, _SC_NPROCESSORS_CONF
45e9cfb9aeSGarrett WollmanNPROCESSORS_ONLN, _SC_NPROCESSORS_ONLN
468c6bd995SGarrett WollmanOPEN_MAX, _SC_OPEN_MAX
478c6bd995SGarrett WollmanPAGESIZE, _SC_PAGESIZE
488c6bd995SGarrett WollmanPAGE_SIZE, _SC_PAGESIZE
498c6bd995SGarrett WollmanPASS_MAX, _SC_PASS_MAX
508c6bd995SGarrett WollmanPTHREAD_DESTRUCTOR_ITERATIONS, _SC_THREAD_DESTRUCTOR_ITERATIONS
518c6bd995SGarrett WollmanPTHREAD_KEYS_MAX, _SC_THREAD_KEYS_MAX
528c6bd995SGarrett WollmanPTHREAD_STACK_MIN, _SC_THREAD_STACK_MIN
538c6bd995SGarrett WollmanPTHREAD_THREADS_MAX, _SC_THREAD_THREADS_MAX
548c6bd995SGarrett WollmanRE_DUP_MAX, _SC_RE_DUP_MAX
558c6bd995SGarrett WollmanRTSIG_MAX, _SC_RTSIG_MAX
568c6bd995SGarrett WollmanSEM_NSEMS_MAX, _SC_SEM_NSEMS_MAX
578c6bd995SGarrett WollmanSEM_VALUE_MAX, _SC_SEM_VALUE_MAX
588c6bd995SGarrett WollmanSIGQUEUE_MAX, _SC_SIGQUEUE_MAX
598c6bd995SGarrett WollmanSTREAM_MAX, _SC_STREAM_MAX
6011e3dcb6SGarrett WollmanSYMLOOP_MAX, _SC_SYMLOOP_MAX
618c6bd995SGarrett WollmanTIMER_MAX, _SC_TIMER_MAX
628c6bd995SGarrett WollmanTTY_NAME_MAX, _SC_TTY_NAME_MAX
638c6bd995SGarrett WollmanTZNAME_MAX, _SC_TZNAME_MAX
64*7b973005SEnji Cooper_NPROCESSORS_CONF, _SC_NPROCESSORS_CONF
65*7b973005SEnji Cooper_NPROCESSORS_ONLN, _SC_NPROCESSORS_ONLN
668c6bd995SGarrett Wollman_POSIX2_CHAR_TERM, _SC_2_CHAR_TERM
678c6bd995SGarrett Wollman_POSIX2_C_BIND, _SC_2_C_BIND
688c6bd995SGarrett Wollman_POSIX2_C_DEV, _SC_2_C_DEV
698c6bd995SGarrett Wollman_POSIX2_C_VERSION, _SC_2_C_VERSION
708c6bd995SGarrett Wollman_POSIX2_FORT_DEV, _SC_2_FORT_DEV
718c6bd995SGarrett Wollman_POSIX2_FORT_RUN, _SC_2_FORT_RUN
728c6bd995SGarrett Wollman_POSIX2_LOCALEDEF, _SC_2_LOCALEDEF
738c6bd995SGarrett Wollman_POSIX2_SW_DEV, _SC_2_SW_DEV
748c6bd995SGarrett Wollman_POSIX2_UPE, _SC_2_UPE
758c6bd995SGarrett Wollman_POSIX2_VERSION, _SC_2_VERSION
768c6bd995SGarrett Wollman_POSIX_ASYNCHRONOUS_IO, _SC_ASYNCHRONOUS_IO
77e9cfb9aeSGarrett Wollman_POSIX_BARRIERS, _SC_BARRIERS
78e9cfb9aeSGarrett Wollman_POSIX_CLOCK_SELECTION, _SC_CLOCK_SELECTION
79e9cfb9aeSGarrett Wollman_POSIX_CPUTIME, _SC_CPUTIME
80e9cfb9aeSGarrett Wollman_POSIX_FILE_LOCKING, _SC_FILE_LOCKING
818c6bd995SGarrett Wollman_POSIX_FSYNC, _SC_FSYNC
8211e3dcb6SGarrett Wollman_POSIX_IPV6, _SC_IPV6
838c6bd995SGarrett Wollman_POSIX_JOB_CONTROL, _SC_JOB_CONTROL
848c6bd995SGarrett Wollman_POSIX_MAPPED_FILES, _SC_MAPPED_FILES
858c6bd995SGarrett Wollman_POSIX_MEMLOCK, _SC_MEMLOCK
868c6bd995SGarrett Wollman_POSIX_MEMLOCK_RANGE, _SC_MEMLOCK_RANGE
878c6bd995SGarrett Wollman_POSIX_MEMORY_PROTECTION, _SC_MEMORY_PROTECTION
888c6bd995SGarrett Wollman_POSIX_MESSAGE_PASSING, _SC_MESSAGE_PASSING
89e9cfb9aeSGarrett Wollman_POSIX_MONOTONIC_CLOCK, _SC_MONOTONIC_CLOCK
908c6bd995SGarrett Wollman_POSIX_PRIORITIZED_IO, _SC_PRIORITIZED_IO
918c6bd995SGarrett Wollman_POSIX_PRIORITY_SCHEDULING, _SC_PRIORITY_SCHEDULING
92e9cfb9aeSGarrett Wollman_POSIX_READER_WRITER_LOCKS, _SC_READER_WRITER_LOCKS
938c6bd995SGarrett Wollman_POSIX_REALTIME_SIGNALS, _SC_REALTIME_SIGNALS
94e9cfb9aeSGarrett Wollman_POSIX_REGEXP, _SC_REGEXP
958c6bd995SGarrett Wollman_POSIX_SAVED_IDS, _SC_SAVED_IDS
968c6bd995SGarrett Wollman_POSIX_SEMAPHORES, _SC_SEMAPHORES
978c6bd995SGarrett Wollman_POSIX_SHARED_MEMORY_OBJECTS, _SC_SHARED_MEMORY_OBJECTS
98e9cfb9aeSGarrett Wollman_POSIX_SHELL, _SC_SHELL
99e9cfb9aeSGarrett Wollman_POSIX_SPAWN, _SC_SPAWN
100e9cfb9aeSGarrett Wollman_POSIX_SPIN_LOCKS, _SC_SPIN_LOCKS
101e9cfb9aeSGarrett Wollman_POSIX_SPORADIC_SERVER, _SC_SPORADIC_SERVER
1028c6bd995SGarrett Wollman_POSIX_SYNCHRONIZED_IO, _SC_SYNCHRONIZED_IO
1038c6bd995SGarrett Wollman_POSIX_THREADS, _SC_THREADS
1048c6bd995SGarrett Wollman_POSIX_THREAD_ATTR_STACKADDR, _SC_THREAD_ATTR_STACKADDR
1058c6bd995SGarrett Wollman_POSIX_THREAD_ATTR_STACKSIZE, _SC_THREAD_ATTR_STACKSIZE
106e9cfb9aeSGarrett Wollman_POSIX_THREAD_CPUTIME, _SC_THREAD_CPUTIME
1078c6bd995SGarrett Wollman_POSIX_THREAD_PRIORITY_SCHEDULING, _SC_THREAD_PRIORITY_SCHEDULING
1088c6bd995SGarrett Wollman_POSIX_THREAD_PRIO_INHERIT, _SC_THREAD_PRIO_INHERIT
1098c6bd995SGarrett Wollman_POSIX_THREAD_PRIO_PROTECT, _SC_THREAD_PRIO_PROTECT
1108c6bd995SGarrett Wollman_POSIX_THREAD_PROCESS_SHARED, _SC_THREAD_PROCESS_SHARED
1118c6bd995SGarrett Wollman_POSIX_THREAD_SAFE_FUNCTIONS, _SC_THREAD_SAFE_FUNCTIONS
112e9cfb9aeSGarrett Wollman_POSIX_THREAD_SPORADIC_SERVER, _SC_THREAD_SPORADIC_SERVER
113e9cfb9aeSGarrett Wollman_POSIX_TIMEOUTS, _SC_TIMEOUTS
114e9cfb9aeSGarrett Wollman_POSIX_TRACE, _SC_TRACE
115e9cfb9aeSGarrett Wollman_POSIX_TRACE_EVENT_FILTER, _SC_TRACE_EVENT_FILTER
116e9cfb9aeSGarrett Wollman_POSIX_TRACE_INHERIT, _SC_TRACE_INHERIT
117e9cfb9aeSGarrett Wollman_POSIX_TRACE_LOG, _SC_TRACE_LOG
118b4b4b530SBaptiste Daroussin_POSIX_TIMERS, _SC_TIMERS
119e9cfb9aeSGarrett Wollman_POSIX_TYPED_MEMORY_OBJECTS, _SC_TYPED_MEMORY_OBJECTS
120b4b4b530SBaptiste Daroussin_POSIX_VERSION, _SC_VERSION
121e9cfb9aeSGarrett Wollman_POSIX_V6_ILP32_OFF32, _SC_V6_ILP32_OFF32
122e9cfb9aeSGarrett Wollman_POSIX_V6_ILP32_OFFBIG, _SC_V6_ILP32_OFFBIG
123e9cfb9aeSGarrett Wollman_POSIX_V6_LP64_OFF64, _SC_V6_LP64_OFF64
1244ec37af6SBaptiste Daroussin_POSIX_V6_LPBIG_OFFBIG, _SC_V6_LPBIG_OFFBIG
1258c6bd995SGarrett Wollman_XOPEN_CRYPT, _SC_XOPEN_CRYPT
1268c6bd995SGarrett Wollman_XOPEN_ENH_I18N, _SC_XOPEN_ENH_I18N
1278c6bd995SGarrett Wollman_XOPEN_LEGACY, _SC_XOPEN_LEGACY
1288c6bd995SGarrett Wollman_XOPEN_REALTIME, _SC_XOPEN_REALTIME
1298c6bd995SGarrett Wollman_XOPEN_REALTIME_THREADS, _SC_XOPEN_REALTIME_THREADS
1308c6bd995SGarrett Wollman_XOPEN_SHM, _SC_XOPEN_SHM
1318c6bd995SGarrett Wollman_XOPEN_UNIX, _SC_XOPEN_UNIX
1328c6bd995SGarrett Wollman_XOPEN_VERSION, _SC_XOPEN_VERSION
1338c6bd995SGarrett Wollman_XOPEN_XCU_VERSION, _SC_XCU_VERSION
1348c6bd995SGarrett Wollman%%
1358c6bd995SGarrett Wollmanint
136e9cfb9aeSGarrett Wollmanfind_sysconf(const char *name, int *key)
1378c6bd995SGarrett Wollman{
1388c6bd995SGarrett Wollman	const struct map *rv;
1398c6bd995SGarrett Wollman
140a272cd3aSMark Murray	rv = in_word_set(name);
141e9cfb9aeSGarrett Wollman	if (rv != NULL) {
142e9cfb9aeSGarrett Wollman		if (rv->valid) {
143e9cfb9aeSGarrett Wollman			*key = rv->key;
144e9cfb9aeSGarrett Wollman			return 1;
145e9cfb9aeSGarrett Wollman		}
1468c6bd995SGarrett Wollman		return -1;
1478c6bd995SGarrett Wollman	}
148e9cfb9aeSGarrett Wollman	return 0;
149e9cfb9aeSGarrett Wollman}
150dda1cfcfSJohn Baldwin
151dda1cfcfSJohn Baldwinvoid
152dda1cfcfSJohn Baldwinforeach_sysconf(void (*func)(const char *, int))
153dda1cfcfSJohn Baldwin{
154dda1cfcfSJohn Baldwin	const struct map *mp;
155dda1cfcfSJohn Baldwin
156dda1cfcfSJohn Baldwin	for (mp = wordlist; mp->name != NULL; mp++) {
157dda1cfcfSJohn Baldwin		if (mp->valid)
158dda1cfcfSJohn Baldwin			func(mp->name, mp->key);
159dda1cfcfSJohn Baldwin	}
160dda1cfcfSJohn Baldwin}
161