freebsd-dev/usr.bin/getconf/limits.gperf
Garrett Wollman e9cfb9ae3a 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.)
2002-09-19 03:39:03 +00:00

119 lines
3.2 KiB
Plaintext

%{
/*
* Copyright is disclaimed as to the contents of this file.
*
* $FreeBSD$
*/
#include <sys/types.h>
#include <string.h>
#include <limits.h>
#include "getconf.h"
/*
* 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; intmax_t value; int valid; };
%%
_POSIX_CLOCKRES_MIN, _POSIX_CLOCKRES_MIN
_POSIX_AIO_LISTIO_MAX, _POSIX_AIO_LISTIO_MAX
_POSIX_AIO_MAX, _POSIX_AIO_MAX
_POSIX_ARG_MAX, _POSIX_ARG_MAX
_POSIX_CHILD_MAX, _POSIX_CHILD_MAX
_POSIX_DELAYTIMER_MAX, _POSIX_DELAYTIMER_MAX
_POSIX_HOST_NAME_MAX, _POSIX_HOST_NAME_MAX
_POSIX_LINK_MAX, _POSIX_LINK_MAX
_POSIX_LOGIN_NAME_MAX, _POSIX_LOGIN_NAME_MAX
_POSIX_MAX_CANON, _POSIX_MAX_CANON
_POSIX_MAX_INPUT, _POSIX_MAX_INPUT
_POSIX_MQ_OPEN_MAX, _POSIX_MQ_OPEN_MAX
_POSIX_MQ_PRIO_MAX, _POSIX_MQ_PRIO_MAX
_POSIX_NAME_MAX, _POSIX_NAME_MAX
_POSIX_NGROUPS_MAX, _POSIX_NGROUPS_MAX
_POSIX_OPEN_MAX, _POSIX_OPEN_MAX
_POSIX_PATH_MAX, _POSIX_PATH_MAX
_POSIX_PIPE_BUF, __POSIX_PIPE_BUF
_POSIX_RE_DUP_MAX, _POSIX_RE_DUP_MAX
_POSIX_RTSIG_MAX, _POSIX_RTSIG_MAX
_POSIX_SEM_NSEMS_MAX, _POSIX_SEM_NSEMS_MAX
_POSIX_SEM_VALUE_MAX, _POSIX_SEM_VALUE_MAX
_POSIX_SIGQUEUE_MAX, _POSIX_SIGQUEUE_MAX
_POSIX_SSIZE_MAX, _POSIX_SSIZE_MAX
_POSIX_STREAM_MAX, _POSIX_STREAM_MAX
_POSIX_SS_REPL_MAX, _POSIX_SS_REPL_MAX
_POSIX_SYMLINK_MAX, _POSIX_SYMLINK_MAX
_POSIX_SYMLOOP_MAX, _POSIX_SYMLOOP_MAX
_POSIX_THREAD_DESTRUCTOR_ITERATIONS, _POSIX_THREAD_DESTRUCTOR_ITERATIONS
_POSIX_THREAD_KEYS_MAX, _POSIX_THREAD_KEYS_MAX
_POSIX_THREAD_THREADS_MAX, _POSIX_THREAD_THREADS_MAX
_POSIX_TIMER_MAX, _POSIX_TIMER_MAX
_POSIX_TRACE_EVENT_NAME_MAX, _POSIX_TRACE_EVENT_NAME_MAX
_POSIX_TRACE_NAME_MAX, _POSIX_TRACE_NAME_MAX
_POSIX_TRACE_SYS_MAX, _POSIX_TRACE_SYS_MAX
_POSIX_TRACE_USER_EVENT_MAX, _POSIX_TRACE_USER_EVENT_MAX
_POSIX_TTY_NAME_MAX, _POSIX_TTY_NAME_MAX
_POSIX_TZNAME_MAX, _POSIX_TZNAME_MAX
_POSIX2_BC_BASE_MAX, _POSIX2_BC_BASE_MAX
_POSIX2_BC_DIM_MAX, _POSIX2_BC_DIM_MAX
_POSIX2_BC_SCALE_MAX, _POSIX2_BC_SCALE_MAX
_POSIX2_BC_STRING_MAX, _POSIX2_BC_STRING_MAX
_POSIX2_CHARCLASS_NAME_MAX, _POSIX2_CHARCLASS_NAME_MAX
_POSIX2_COLL_WEIGHTS_MAX, _POSIX2_COLL_WEIGHTS_MAX
_POSIX2_EXPR_NEXT_MAX, _POSIX2_EXPR_NEST_MAX
_POSIX2_LINE_MAX, _POSIX2_LINE_MAX
_POSIX2_RE_DUP_MAX, _POSIX2_RE_DUP_MAX
_XOPEN_IOV_MAX, _XOPEN_IOV_MAX
_XOPEN_NAME_MAX, _XOPEN_NAME_MAX
_XOPEN_PATH_MAX, _XOPEN_PATH_MAX
CHAR_BIT, CHAR_BIT
CHAR_MAX, CHAR_MAX
CHAR_MIN, CHAR_MIN
INT_MAX, INT_MAX
INT_MIN, INT_MIN
LLONG_MIN, LLONG_MIN
LLONG_MAX, LLONG_MAX
LONG_BIT, LONG_BIT
LONG_MAX, LONG_MAX
LONG_MIN, LONG_MIN
MB_LEN_MAX, MB_LEN_MAX
SCHAR_MAX, SCHAR_MAX
SCHAR_MIN, SCHAR_MIN
SHRT_MAX, SHRT_MAX
SHRT_MIN, SHRT_MIN
SSIZE_MAX, SSIZE_MAX
UCHAR_MAX, UCHAR_MAX
UINT_MAX, UINT_MAX
ULLONG_MAX, ULLONG_MAX
ULONG_MAX, ULONG_MAX
USHRT_MAX, USHRT_MAX
WORD_BIT, WORD_BIT
CHARCLASS_NAME_MAX, CHARCLASS_NAME_MAX
NL_ARGMAX, NL_ARGMAX
ML_LANGMAX, NL_LANGMAX
NL_MSGMAX, NL_MSGMAX
NL_NMAX, NL_NMAX
NL_SETMAX, NL_SETMAX
NL_TEXTMAX, NL_TEXTMAX
NZERO, NZERO
%%
int
find_limit(const char *name, intmax_t *value)
{
const struct map *rv;
rv = in_word_set(name, strlen(name));
if (rv != NULL) {
if (rv->valid) {
*value = rv->value;
return 1;
}
return -1;
}
return 0;
}