sysconf(3C)


sysconf -- get configurable system variables

Synopsis

   #include <unistd.h>
   

long sysconf(int name);

Description

The sysconf function provides a method for the application to determine the current value of a configurable system limit or option (variable). The name argument represents the system variable to be queried.

The sysinfo(2) and confstr(3C) routines provide a similar class of configuration information.

The following table lists the minimal set of system variables from limits.h and unistd.h that can be returned by sysconf, and the symbolic constants, defined in unistd.h that are the corresponding values used for name.

Name Return value (minimum)
_SC_ARG_MAX ARG_MAX
_SC_BC_BASE_MAX BC_BASE_MAX
_SC_BC_DIM_MAX BC_DIM_MAX
_SC_BC_SCALE_MAX BC_SCALE_MAX
_SC_BC_STRING_MAX BC_STRING_MAX
_SC_CHILD_MAX CHILD_MAX
_SC_CACHE_LINE The worst-case (largest) cache line size of the various levels of memory cache that are present on the machine, as reported by the Platform Support Module via the topology. A default value of 32 is assigned if the topology provides no information.
_SC_CLK_TCK CLK_TCK
_SC_COLL_WEIGHTS_MAX COLL_WEIGHTS_MAX
_SC_EXPR_NEST_MAX EXPR_NEST_MAX
_SC_IOV_MAX IOV_MAX
_SC_LINE_MAX LINE_MAX
_SC_JOB_CONTROL _POSIX_JOB_CONTROL
_SC_LOGNAME_MAX LOGNAME_MAX
_SC_NACLS_MAX _CONFIG_NACLS_MAX
_SC_NGROUPS_MAX NGROUPS_MAX
_SC_OPEN_MAX OPEN_MAX
_SC_PAGESIZE PAGESIZE
_SC_PASS_MAX PASS_MAX
_SC_SAVED_IDS _POSIX_SAVED_IDS
_SC_VERSION _POSIX_VERSION
_SC_XOPEN_VERSION _XOPEN_VERSION
_SC_XOPEN_XCU_VERSION _XOPEN_XCU_VERSION
_SC_BC_BASE_MAX _POSIX2_BC_BASE_MAX
_SC_BD_DIM_MAX _POSIX2_BC_DIM_MAX
_SC_BC_SCALE_MAX _POSIX2_BC_SCALE_MAX
_SC_BC_STRING_MAX _POSIX2_BC_STRING_MAX
_SC_COLL_WEIGHTS_MAX _POSIX2_COLL_WEIGHTS_MAX
_SC_EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX
_SC_STREAM_MAX _POSIX2_STREAM_MAX
_SC_RE_DUP_MAX _RE_DUP_MAX
_SC_LINE_MAX _POSIX2_LINE_MAX
_SC_TZNAME_MAX TZNAME_MAX
_SC_LINE_MAX 1
_SC_XOPEN_CRYPT 1
_SC_2_C_VERSION _POSIX2_C_VERSION
_SC_2_CHAR_TERM _POSIX2_CHAR_TERM
_SC_2_FORT_RUN _POSIX2_FORT_RUN
_SC_2_UPE _POSIX2_UPE
_SC_XOPEN_ENH_I18N _POSIX2_XOPEN_ENH_I18N
_SC_2_LOCALEDEF _POSIX2_LOCALEDEF
_SC_2_VERSION _POSIX2_VERSION
_SC_NCGS_CONF Number of configured CPU-Groups
_SC_NCGS_ONLN Number of online CPU-Groups
_SC_MAX_CPUS_PER_CG Maximum number of processors on a CPU-Group (which may be greater than the maximum number of processors on a specific CPU-Group if the CPU-Groups are not all symmetric).
_SC_CG_SIMPLE_IMPL _CG_SIMPLE_IMPL

 Name                    Return value (minimum)
 _SC_ARG_MAX             ARG_MAX
 _SC_BC_BASE_MAX         BC_BASE_MAX
 _SC_BC_DIM_MAX          BC_DIM_MAX
 _SC_BC_SCALE_MAX        BC_SCALE_MAX
 _SC_BC_STRING_MAX       BC_STRING_MAX
 _SC_CHILD_MAX           CHILD_MAX
 _SC_CACHE_LINE          The worst-case (largest) cache
                         line size of the various levels
                         of memory cache that are present
                         on the machine, as reported by
                         the Platform Support Module via
                         the topology.  A default value
                         of 32 is assigned if the
                         topology provides no
                         information.
 _SC_CLK_TCK             CLK_TCK
 _SC_COLL_WEIGHTS_MAX    COLL_WEIGHTS_MAX
 _SC_EXPR_NEST_MAX       EXPR_NEST_MAX
 _SC_IOV_MAX             IOV_MAX
 _SC_LINE_MAX            LINE_MAX
 _SC_JOB_CONTROL         _POSIX_JOB_CONTROL
 _SC_LOGNAME_MAX         LOGNAME_MAX
 _SC_NACLS_MAX           _CONFIG_NACLS_MAX
 _SC_NGROUPS_MAX         NGROUPS_MAX
 _SC_OPEN_MAX            OPEN_MAX
 _SC_PAGESIZE            PAGESIZE
 _SC_PASS_MAX            PASS_MAX
 _SC_SAVED_IDS           _POSIX_SAVED_IDS
 _SC_VERSION             _POSIX_VERSION
 _SC_XOPEN_VERSION       _XOPEN_VERSION
 _SC_XOPEN_XCU_VERSION   _XOPEN_XCU_VERSION
 _SC_BC_BASE_MAX         _POSIX2_BC_BASE_MAX
 _SC_BD_DIM_MAX          _POSIX2_BC_DIM_MAX
 _SC_BC_SCALE_MAX        _POSIX2_BC_SCALE_MAX
 _SC_BC_STRING_MAX       _POSIX2_BC_STRING_MAX
 _SC_COLL_WEIGHTS_MAX    _POSIX2_COLL_WEIGHTS_MAX
 _SC_EXPR_NEST_MAX       _POSIX2_EXPR_NEST_MAX
 _SC_STREAM_MAX          _POSIX2_STREAM_MAX
 _SC_RE_DUP_MAX          _RE_DUP_MAX
 _SC_LINE_MAX            _POSIX2_LINE_MAX
 _SC_TZNAME_MAX          TZNAME_MAX
 _SC_LINE_MAX            1
 _SC_XOPEN_CRYPT         1
 _SC_2_C_VERSION         _POSIX2_C_VERSION
 _SC_2_CHAR_TERM         _POSIX2_CHAR_TERM
 _SC_2_FORT_RUN          _POSIX2_FORT_RUN
 _SC_2_UPE               _POSIX2_UPE
 _SC_XOPEN_ENH_I18N      _POSIX2_XOPEN_ENH_I18N
 _SC_2_LOCALEDEF         _POSIX2_LOCALEDEF
 _SC_2_VERSION           _POSIX2_VERSION
 _SC_NCGS_CONF           Number of configured CPU-Groups
 _SC_NCGS_ONLN           Number of online CPU-Groups
 _SC_MAX_CPUS_PER_CG     Maximum number of processors on
                         a CPU-Group (which may be
                         greater than the maximum number
                         of processors on a specific CPU-
                         Group if the CPU-Groups are not
                         all symmetric).
 _SC_CG_SIMPLE_IMPL      _CG_SIMPLE_IMPL

The value of CLK_TCK may be variable and it should not be assumed that CLK_TCK is a compile-time constant. The value of CLK_TCK is the same as the value of sysconf(_SC_CLK_TCK).

sysconf can also return the following values:

Name Return value
_SC_ATEXIT_MAX Maximum number of atexit functions that can be registered
_SC_NPROCESSORS_CONF Number of configured processors
_SC_NPROCESSORS_ONLN Number of online processors
_SC_NPROCESSES Number of processes per real user id
_SC_PAGE_SIZE Size in bytes of physical page
_SC_PAGESIZE Size in bytes of physical page
_SC_SYSTEM_ID Persistent, system-generated identifier

 Name                   Return value
 _SC_ATEXIT_MAX         Maximum number of atexit functions that
                        can be registered
 _SC_NPROCESSORS_CONF   Number of configured processors
 _SC_NPROCESSORS_ONLN   Number of online processors
 _SC_NPROCESSES         Number of processes per real user id
 _SC_PAGE_SIZE          Size in bytes of physical page
 _SC_PAGESIZE           Size in bytes of physical page
 _SC_SYSTEM_ID          Persistent, system-generated identifier

Errors

If name is an invalid value, sysconf will return -1 and set errno to EINVAL. If sysconf fails due to a value of name that is not defined on the system, the function will return a value of -1 without changing the value of errno.

The following variables return 1, that is, the feature is supported:


_SC_XOPEN_SHM

_SC_XOPEN_CRYPT

_SC_2_C_BIND

_SC_CG_SIMPLE_IMPL

The following variables return -1 if the feature is not supported.


_SC_2_C_DEV

_SC_2_FORT_DEV

_SC_2_SW_DEV

_SC_CG_SIMPLE_IMPL

References

fpathconf(2), getrlimit(2), sysinfo(2), confstr(3C)

Notices

A call to setrlimit (see getrlimit(2)) may cause the value of OPEN_MAX to change.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004