1%{ 2/* 3 * Copyright is disclaimed as to the contents of this file. 4 * 5 * $FreeBSD$ 6 */ 7 8#include <sys/types.h> 9 10#include <limits.h> 11#include <string.h> 12#include <unistd.h> 13 14#include "getconf.h" 15 16/* 17 * Stuff that isn't defined right now -- we want this file to work 18 * unmodified once it is defined. 19 */ 20#ifndef _SC_ATEXIT_MAX 21#define _SC_ATEXIT_MAX -1 22#endif 23#ifndef _SC_TTY_NAME_MAX 24#define _SC_TTY_NAME_MAX -1 25#endif 26#ifndef _SC_MQ_PRIO_MAX 27#define _SC_MQ_PRIO_MAX -1 28#endif 29#ifndef _SC_IOV_MAX 30#define _SC_IOV_MAX -1 31#endif 32#ifndef _SC_XOPEN_REALTIME 33#define _SC_XOPEN_REALTIME -1 34#endif 35#ifndef _SC_XOPEN_LEGACY 36#define _SC_XOPEN_LEGACY -1 37#endif 38#ifndef _SC_XCU_VERSION 39#define _SC_XCU_VERSION -1 40#endif 41#ifndef _SC_PASS_MAX 42#define _SC_PASS_MAX -1 43#endif 44#ifndef _SC_XOPEN_REALTIME_THREADS 45#define _SC_XOPEN_REALTIME_THREADS -1 46#endif 47#ifndef _SC_LOGIN_NAME_MAX 48#define _SC_LOGIN_NAME_MAX -1 49#endif 50#ifndef _SC_XBS5_LP64_OFF64 51#define _SC_XBS5_LP64_OFF64 -1 52#endif 53#ifndef _SC_XOPEN_SHM 54#define _SC_XOPEN_SHM -1 55#endif 56#ifndef _SC_XOPEN_CRYPT 57#define _SC_XOPEN_CRYPT -1 58#endif 59#ifndef _SC_XOPEN_UNIX 60#define _SC_XOPEN_UNIX -1 61#endif 62#ifndef _SC_XOPEN_VERSION 63#define _SC_XOPEN_VERSION -1 64#endif 65#ifndef _SC_THREAD_DESTRUCTOR_ITERATIONS 66#define _SC_THREAD_DESTRUCTOR_ITERATIONS -1 67#endif 68#ifndef _SC_THREAD_KEYS_MAX 69#define _SC_THREAD_KEYS_MAX -1 70#endif 71#ifndef _SC_2_C_VERSION 72#define _SC_2_C_VERSION -1 73#endif 74#ifndef _SC_XBS5_LPBIG_OFFBIG 75#define _SC_XBS5_LPBIG_OFFBIG -1 76#endif 77#ifndef _SC_THREAD_THREADS_MAX 78#define _SC_THREAD_THREADS_MAX -1 79#endif 80#ifndef _SC_XBS5_ILP32_OFF32 81#define _SC_XBS5_ILP32_OFF32 -1 82#endif 83#ifndef _SC_XBS5_ILP32_OFFBIG 84#define _SC_XBS5_ILP32_OFFBIG -1 85#endif 86#ifndef _SC_THREAD_STACK_MIN 87#define _SC_THREAD_STACK_MIN -1 88#endif 89#ifndef _SC_XOPEN_ENH_I18N 90#define _SC_XOPEN_ENH_I18N -1 91#endif 92#ifndef _SC_THREAD_ATTR_STACKSIZE 93#define _SC_THREAD_ATTR_STACKSIZE -1 94#endif 95#ifndef _SC_THREAD_PRIORITY_SCHEDULING 96#define _SC_THREAD_PRIORITY_SCHEDULING -1 97#endif 98#ifndef _SC_THREADS 99#define _SC_THREADS -1 100#endif 101#ifndef _SC_THREAD_PROCESS_SHARED 102#define _SC_THREAD_PROCESS_SHARED -1 103#endif 104#ifndef _SC_THREAD_SAFE_FUNCTIONS 105#define _SC_THREAD_SAFE_FUNCTIONS -1 106#endif 107#ifndef _SC_THREAD_PRIO_PROTECT 108#define _SC_THREAD_PRIO_PROTECT -1 109#endif 110#ifndef _SC_THREAD_ATTR_STACKADDR 111#define _SC_THREAD_ATTR_STACKADDR -1 112#endif 113#ifndef _SC_THREAD_PRIO_INHERIT 114#define _SC_THREAD_PRIO_INHERIT -1 115#endif 116 117/* 118 * Override gperf's built-in external scope. 119 */ 120static const struct map *in_word_set(const char *str, unsigned int len); 121 122%} 123struct map { char *name; int key; }; 124%% 125AIO_LISTIO_MAX, _SC_AIO_LISTIO_MAX 126AIO_MAX, _SC_AIO_MAX 127AIO_PRIO_DELTA_MAX, _SC_AIO_PRIO_DELTA_MAX 128ARG_MAX, _SC_ARG_MAX 129ATEXIT_MAX, _SC_ATEXIT_MAX 130BC_BASE_MAX, _SC_BC_BASE_MAX 131BC_DIM_MAX, _SC_BC_DIM_MAX 132BC_SCALE_MAX, _SC_BC_SCALE_MAX 133BC_STRING_MAX, _SC_BC_STRING_MAX 134CHILD_MAX, _SC_CHILD_MAX 135CLK_TCK, _SC_CLK_TCK 136COLL_WEIGHTS_MAX, _SC_COLL_WEIGHTS_MAX 137DELAYTIMER_MAX, _SC_DELAYTIMER_MAX 138EXPR_NEST_MAX, _SC_EXPR_NEST_MAX 139IOV_MAX, _SC_IOV_MAX 140LINE_MAX, _SC_LINE_MAX 141LOGIN_NAME_MAX, _SC_LOGIN_NAME_MAX 142MQ_OPEN_MAX, _SC_MQ_OPEN_MAX 143MQ_PRIO_MAX, _SC_MQ_PRIO_MAX 144NGROUPS_MAX, _SC_NGROUPS_MAX 145OPEN_MAX, _SC_OPEN_MAX 146PAGESIZE, _SC_PAGESIZE 147PAGE_SIZE, _SC_PAGESIZE 148PASS_MAX, _SC_PASS_MAX 149PTHREAD_DESTRUCTOR_ITERATIONS, _SC_THREAD_DESTRUCTOR_ITERATIONS 150PTHREAD_KEYS_MAX, _SC_THREAD_KEYS_MAX 151PTHREAD_STACK_MIN, _SC_THREAD_STACK_MIN 152PTHREAD_THREADS_MAX, _SC_THREAD_THREADS_MAX 153RE_DUP_MAX, _SC_RE_DUP_MAX 154RTSIG_MAX, _SC_RTSIG_MAX 155SEM_NSEMS_MAX, _SC_SEM_NSEMS_MAX 156SEM_VALUE_MAX, _SC_SEM_VALUE_MAX 157SIGQUEUE_MAX, _SC_SIGQUEUE_MAX 158STREAM_MAX, _SC_STREAM_MAX 159TIMER_MAX, _SC_TIMER_MAX 160TTY_NAME_MAX, _SC_TTY_NAME_MAX 161TZNAME_MAX, _SC_TZNAME_MAX 162_POSIX2_CHAR_TERM, _SC_2_CHAR_TERM 163_POSIX2_C_BIND, _SC_2_C_BIND 164_POSIX2_C_DEV, _SC_2_C_DEV 165_POSIX2_C_VERSION, _SC_2_C_VERSION 166_POSIX2_FORT_DEV, _SC_2_FORT_DEV 167_POSIX2_FORT_RUN, _SC_2_FORT_RUN 168_POSIX2_LOCALEDEF, _SC_2_LOCALEDEF 169_POSIX2_SW_DEV, _SC_2_SW_DEV 170_POSIX2_UPE, _SC_2_UPE 171_POSIX2_VERSION, _SC_2_VERSION 172_POSIX_ASYNCHRONOUS_IO, _SC_ASYNCHRONOUS_IO 173_POSIX_FSYNC, _SC_FSYNC 174_POSIX_JOB_CONTROL, _SC_JOB_CONTROL 175_POSIX_MAPPED_FILES, _SC_MAPPED_FILES 176_POSIX_MEMLOCK, _SC_MEMLOCK 177_POSIX_MEMLOCK_RANGE, _SC_MEMLOCK_RANGE 178_POSIX_MEMORY_PROTECTION, _SC_MEMORY_PROTECTION 179_POSIX_MESSAGE_PASSING, _SC_MESSAGE_PASSING 180_POSIX_PRIORITIZED_IO, _SC_PRIORITIZED_IO 181_POSIX_PRIORITY_SCHEDULING, _SC_PRIORITY_SCHEDULING 182_POSIX_REALTIME_SIGNALS, _SC_REALTIME_SIGNALS 183_POSIX_SAVED_IDS, _SC_SAVED_IDS 184_POSIX_SEMAPHORES, _SC_SEMAPHORES 185_POSIX_SHARED_MEMORY_OBJECTS, _SC_SHARED_MEMORY_OBJECTS 186_POSIX_SYNCHRONIZED_IO, _SC_SYNCHRONIZED_IO 187_POSIX_THREADS, _SC_THREADS 188_POSIX_THREAD_ATTR_STACKADDR, _SC_THREAD_ATTR_STACKADDR 189_POSIX_THREAD_ATTR_STACKSIZE, _SC_THREAD_ATTR_STACKSIZE 190_POSIX_THREAD_PRIORITY_SCHEDULING, _SC_THREAD_PRIORITY_SCHEDULING 191_POSIX_THREAD_PRIO_INHERIT, _SC_THREAD_PRIO_INHERIT 192_POSIX_THREAD_PRIO_PROTECT, _SC_THREAD_PRIO_PROTECT 193_POSIX_THREAD_PROCESS_SHARED, _SC_THREAD_PROCESS_SHARED 194_POSIX_THREAD_SAFE_FUNCTIONS, _SC_THREAD_SAFE_FUNCTIONS 195_POSIX_TIMERS, _SC_TIMERS 196_POSIX_VERSION, _SC_VERSION 197_XBS5_ILP32_OFF32, _SC_XBS5_ILP32_OFF32 198_XBS5_ILP32_OFFBIG, _SC_XBS5_ILP32_OFFBIG 199_XBS5_LP64_OFF64, _SC_XBS5_LP64_OFF64 200_XBS5_LPBIG_OFFBIG, _SC_XBS5_LPBIG_OFFBIG 201_XOPEN_CRYPT, _SC_XOPEN_CRYPT 202_XOPEN_ENH_I18N, _SC_XOPEN_ENH_I18N 203_XOPEN_LEGACY, _SC_XOPEN_LEGACY 204_XOPEN_REALTIME, _SC_XOPEN_REALTIME 205_XOPEN_REALTIME_THREADS, _SC_XOPEN_REALTIME_THREADS 206_XOPEN_SHM, _SC_XOPEN_SHM 207_XOPEN_UNIX, _SC_XOPEN_UNIX 208_XOPEN_VERSION, _SC_XOPEN_VERSION 209_XOPEN_XCU_VERSION, _SC_XCU_VERSION 210%% 211int 212find_sysconf(const char *name) 213{ 214 const struct map *rv; 215 216 rv = in_word_set(name, strlen(name)); 217 if (rv != 0) 218 return rv->key; 219 else 220 return -1; 221} 222