HPlogo HP-UX Reference Volume 3 of 5 > s

sysconf(2)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

sysconf() — get configurable system variables

SYNOPSIS

#include <unistd.h>

long sysconf(int name);

int CPU_IS_PA_RISC(long cpuvers);

DESCRIPTION

The sysconf() system call provides a way for applications to determine the current value of a configurable limit or variable.

The name argument represents the system variable being queried.

The following table lists the configuration variables whose values can be determined by calling sysconf(), and for each variable, the associated value of the name argument and the value returned:

VariableValue for nameValue Returned
AES_OS_VERSION_SC_AES_OS_VERSIONVersion number of OSF/AES OSC supported
ARG_MAX_SC_ARG_MAXMaximum total length of the arguments for exec() in bytes, including environment data (see exec(2))
ATEXIT_MAX_SC_ATEXIT_MAXMaximum number of functions that can be registered with atexit() (see atexit(2))
BC_BASE_MAX_SC_BC_BASE_MAXMaximum ibase (input number radix) and obase (output number radix) allowed by bc (see bc(1))
BC_DIM_MAX_SC_BC_DIM_MAXMaximum number of elements in an array permitted by bc (see bc(1))
BC_SCALE_MAX_SC_BC_SCALE_MAXMaximum scale factor (number of digits to the right of the decimal point) allowed by bc (see bc(1))
BC_STRING_MAX_SC_BC_STRING_MAXMaximum length of strings allowed by bc (see bc(1))
CHILD_MAX_SC_CHILD_MAXMaximum number of simultaneous processes per user ID (see fork(2))
CLK_TCK_SC_CLK_TCKNumber of clock intervals per second for times() (see times(2))
CLOCKS_PER_SEC_SC_CLOCKS_PER_SECNumber of clock ticks per second for clock() (see clock(3C))
COLL_WEIGHTS_MAX_SC_COLL_WEIGHTS_MAXMaximum number of weights that can be assigned to an entry of the LC_COLLATE order keyword in a localedef input file (see localedef(1M))
CPU_CHIP_TYPE_SC_CPU_CHIP_TYPEEncoding which indicates type of CPU chip employed in system. Bits 21-26 identify the model, bits 27-31 the revision. See "Precision I/O Architecture Specification" for encodings.
CPU_KEYBITS1_SC_CPU_KEYBITS1Processor Extensions (see below)
CPU_VERSION_SC_CPU_VERSIONVersion of CPU architecture (see below)
EXPR_NEST_MAX_SC_EXPR_NEST_MAXMaximum parenthesis nesting level for expr expressions (see expr(1))
HW_32_64_CAPABLE_SC_HW_32_64_CAPABLEReturns which kernel is supported on the hardware. The value returned is an encoding which may be interpreted using the _SYSTEM_SUPPORTS_ILP32OS() and _SYSTEM_SUPPORTS_LP64OS() macros defined in unistd.h. Example: long ret = sysconf(_SC_HW_32_64_CAPABLE); if (_SYSTEM_SUPPORTS_ILP32OS(ret) != 0) { /* system supports 32-bit OS */ } if (_SYSTEM_SUPPORTS_LP64OS(ret) != 0) { /* system supports 64-bit OS */ }
IO_TYPE_SC_IO_TYPEType of I/O drivers the kernel supports, currently, only the value IO_TYPE_CDIO
KERNEL_BITS_SC_KERNEL_BITSReturns the number of bits used by the kernel for pointer and long data types. Current values include 32 and 64.
LIBC_VERSION_SC_LIBC_VERSIONThe version of libc that is in use by the application that is requesting this information. See below for details.
LINE_MAX_SC_LINE_MAXMaximum number of bytes in an input line (including the newline) for POSIX.2 utilities
NGROUPS_MAX_SC_NGROUPS_MAXMaximum number of simultaneous supplementary group IDs per process
OPEN_MAX_SC_OPEN_MAXMaximum number of files that one process can have open at one time
PAGE_SIZE_SC_PAGE_SIZEKernel memory page size
PASS_MAX_SC_PASS_MAXMaximum number of significant bytes in a password
POSIX_FSYNC_SC_FSYNCPositive if the File Synchronization option is supported (see fsync(2))
POSIX_JOB_CONTROL_SC_JOB_CONTROLPositive if the system supports POSIX job control; -1 otherwise
POSIX_PRIORITY_ SCHEDULING _SC_PRIORITY_ SCHEDULING Positive if the system supports POSIX.4 priority scheduling; -1 otherwise
POSIX_REALTIME_SIGNALS_SC_REALTIME_SIGNALSPositive if the system supports POSIX.4 realtime signal extensions; -1 otherwise
POSIX_SAVED_IDS_SC_SAVED_IDSPositive if each process has a saved set-user-ID and a saved set-group-ID; -1 otherwise
POSIX_SYNCHRONIZED_IO_SC_SYNCHRONIZED_IOPositive if the Synchronized IO option is supported (see open(2))
POSIX_TIMERS_SC_TIMERSPositive if the system supports POSIX.4 clocks and timers; -1 otherwise
POSIX_VERSION_SC_VERSIONApproval date of the POSIX.1 Standard (such as 199009 for POSIX.1-1990) to which the system conforms. This value indicates the year (first four digits) and month (next two digits) that the standard was approved by the IEEE Standards Board.
POSIX2_C_BIND_SC_2_C_BINDEqual to 1 if the POSIX.2 C Language Bindings Option is available through the c89 utility; -1 otherwise
POSIX2_C_DEV_SC_2_C_DEVEqual to 1 if the POSIX.2 C Language Development Utilities Option is supported; -1 otherwise
POSIX2_C_VERSION_SC_2_C_VERSIONCurrent version of the POSIX.2 C Language Binding Option supported (same format as _POSIX_VERSION); -1 otherwise.
POSIX2_FORT_DEV_SC_2_FORT_DEVEqual to 1 if the POSIX.2 FORTRAN Development Utilities Option is supported; -1 otherwise
POSIX2_FORT_RUN_SC_2_FORT_RUNEqual to 1 if the POSIX.2 Fortran Runtime Utilities Option is supported; -1 otherwise
POSIX2_LOCALEDEF_SC_2_LOCALEDEFEqual to 1 if locales can be created with the POSIX.2 localedef utility; -1 otherwise
POSIX2_SW_DEV_SC_2_SW_DEVEqual to 1 if the POSIX.2 Software Development Utilities Option is supported; -1 otherwise
POSIX2_UPE_SC_2_UPEEqual to 1 if the POSIX.2 User Portability Utilities Option is supported; -1 otherwise
POSIX2_VERSION_SC_2_VERSIONCurrent version of POSIX.2 (same format as _POSIX_VERSION)
POSIX_THREADS_SC_THREADSPositive if the implementation supports POSIX threads; -1 otherwise.
POSIX_THREAD_ ATTR_STACKADDR _SC_THREAD_ ATTR_STACKADDR Positive if the implementation supports the POSIX Thread Stack Address Attribute option; -1 otherwise.
POSIX_THREAD_ ATTR_STACKSIZE _SC_THREAD_ ATTR_STACKSIZE Positive if the implementation supports the POSIX Thread Stack Size Attribute option; -1 otherwise.

POSIX_THREAD_ PRIORITY_SCHEDULING _SC_THREAD_ PRIORITY_SCHEDULING Positive if the implementation supports the POSIX Thread Priority Scheduling option; -l otherwise.
POSIX_THREAD_ PRIO_INHERIT _SC_THREAD_ PRIO_INHERIT Positive if the implementation supports the POSIX Thread Priority Inheritance option; -l otherwise.
POSIX_THREAD_ PRIO_PROTECT _SC_THREAD_ PRIO_PROTECT Positive if the implementation supports the POSIX Thread Priority Protection option; -l otherwise.
POSIX_THREAD_ PROCESS_SHARED _SC_THREAD_PROCESS_ SHARED Positive if the implementation supports the POSIX Thread Process-Shared Synchronization option; -l otherwise.
POSIX_THREAD_ SAFE_FUNCTIONS _SC_THREAD_SAFE_ FUNCTIONS Positive if the implementation supports the POSIX Thread Thread-Safe Functions option; -l otherwise.
PTHREAD_ DESTRUCTOR_ ITERATIONS _SC_THREAD_ DESTRUCTOR_ ITERATIONS The number of attempts made to destroy a pthread's thread-specific data values on thread exit.
PTHREAD_KEYS_MAX_SC_THREAD_ KEYS_MAX The number of pthread data keys per process.
PTHREAD_STACK_MIN_SC_THREAD_ STACK_MIN Minimum size in bytes of pthread stack storage.
PTHREAD_THREADS_MAX_SC_THREAD_ THREADS_MAX Maximum number of pthreads that can be created per process.
PROC_RSRC_MGR_SC_PROC_RSRC_MGREqual to 1 if the optional HP Process Resource Management (PRM) software is installed and configured; 0 otherwise (see prmconfig(1))
RE_DUP_MAX_SC_RE_DUP_MAXMaximum number of repeated occurrences of a regular expression permitted when using the interval notation \{m,n\} (see regcomp(3C))
RTSIG_MAX_SC_RTSIG_MAXMaximum number of realtime signals reserved for application use.
SECURITY_CLASS_SC_SECURITY_CLASSSEC_CLASS-NONE (No DoD security level supported)
SIGQUEUE_MAX_SC_SIGQUEUE_MAXMaximum number of queued signals that a process may send and have pending at the receiver(s) at any time.
STREAM_MAX_SC_STREAM_MAXMaximum number of stdio streams that one process can have open at one time
TIMER_MAX_SC_TIMER_MAXMaximum number of POSIX.4 timers per process, if POSIX.4 timers are supported; -1 otherwise
TZNAME_MAX_SC_TZNAME_MAXMaximum number of bytes in a time zone name for the TZ environment variable
XOPEN_CRYPT_SC_XOPEN_CRYPTEqual to 1 if the X/Open Encryption Feature Group is supported; -1 otherwise
XOPEN_ENH_I18N_SC_XOPEN_ENH_I18NEqual to 1 if the X/Open Enhanced Internationalization Feature Group is supported; -1 otherwise
XOPEN_SHM_SC_XOPEN_SHMEqual to 1 if the X/Open Shared Memory Feature Group is supported; -1 otherwise
XOPEN_VERSION_SC_XOPEN_VERSIONIssue number of X/Open Portability Guide supported
XBS5_ILP32_ OFF32 _SC_XBS5_ILP32_ OFF32 A flag which denotes whether _CS_XBS5_ILP32_OFF32_CFLAGS, _CS_XBS5_ILP32_OFF32_LDFLAGS, _CS_XBS5_ILP32_OFF32_LIBS and _CS_XBS5_ILP32_OFF32_LINTFLAGS are supported by confstr(3C). A return value of -1 indicates they are not supported.
XBS5_ILP32_ OFFBIG _SC_XBS5_ILP32_ OFFBIG A flag which denotes whether _CS_XBS5_ILP32_OFFBIG_CFLAGS, _CS_XBS5_ILP32_OFFBIG_LDFLAGS, _CS_XBS5_ILP32_OFFBIG_LIBS and _CS_XBS5_ILP32_OFFBIG_LINTFLAGS are supported by confstr(3C). A return value of -1 indicates they are not supported.
XBS5_LP64_ OFF64 _SC_XBS5_LP64_ OFF64 A flag which denotes whether _CS_XBS5_LP64_OFF64_CFLAGS, _CS_XBS5_LP64_OFF64_LDFLAGS, _CS_XBS5_LP64_OFF64_LIBS and _CS_XBS5_LP64_OFF64_LINTFLAGS are supported by confstr(3C). A return value of -1 indicates they are not supported.
XBS5_LPBIG_ OFFBIG _SC_XBS5_LPBIG_ OFFBIG A flag which denotes whether _CS_XBS5_LPBIG_OFFBIG_CFLAGS, _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, _CS_XBS5_LPBIG_OFFBIG_LIBS and _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS are supported by confstr(3C). A return value of -1 indicates they are not supported.

Some of the variables in the table are defined as constants in <limits.h> (see limits(5)). The associated values of the name argument are defined in <unistd.h>.

The possible values of the CPU_VERSION variable returned by sysconf(_SC_CPU_VERSION) and their meanings are:

ValueMeaning
CPU_PA_RISC1_0HP Precision Architecture RISC Version 1.0
CPU_PA_RISC1_1HP Precision Architecture RISC Version 1.1

The CPU_IS_PA_RISC() function classifies cpuvers, a value of the CPU_VERSION variable, as to its processor family.

The availability of architecture specific instructions is indicated by the key bit data returned by sysconf(_SC_CPU_KEYBITS1). Upon successful completion, the data returned will be the logical OR of the defined values for the features supported.

The possible values returned by sysconf(_SC_CPU_KEYBITS1) and their meanings are shown in the following table.

Return ValueInstruction Supported
HARITHHalfword parallel add, subtract, and average
HSHIFTHalfword parallel shift-and-add

The format of the value returned by sysconf(_SC_LIBC_VERSION) is as follows:

XXyyZZZZqN

where

XX

HP-UX major release number

yy

HP-UX minor release number

ZZZZ

Library specific number

q

0=32PA 1=64PA 2=32EM 3=64EM 4-9=Reserved

N

0 = archive library

1-9 = System V version of shared library

RETURN VALUE

Upon successful completion, sysconf() returns the value of the named variable. If the value of name is not valid, sysconf() returns -1 and sets errno to indicate the error. If the variable corresponding to name is not defined, sysconf() returns -1, but does not change errno.

CPU_IS_PA_RISC() returns positive nonzero if cpuvers is an HP PA-RISC processor; zero if not.

ERRORS

If sysconf() fails, the value of errno (see errno(2)) is set to:

[EINVAL]

The value of name is not valid.

EXAMPLES

The following example determines the number of times the system clock ticks each second:

#include <unistd.h> long ticks; ... ticks = sysconf(_SC_CLK_TCK);

The following example determines if the current processor is an HP PA-RISC machine:

#include <unistd.h> if (CPU_IS_PA_RISC(sysconf(_SC_CPU_VERSION))) ...

WARNINGS

CPU_IS_PA_RISC() is implemented as a macro.

Normally, the values returned from sysconf() do not change during the lifetime of the calling process. However, the value of the symbolic constant _POSIX_VERSION and thus the value of sysconf(_SC_VERSION) can vary under certain circumstances. If either of the feature test macros _POSIX1_1988 or _XPG3 is defined by the programmer prior to including <unistd.h>, the value of _POSIX_VERSION is defined as 198808, in conformance with POSIX.1-1988, FIPS 151-1, and XPG3. Otherwise, the value of _POSIX_VERSION is defined as 199009, in conformance with POSIX.1-1990.

Similarly, the value of the symbolic constant _XOPEN_VERSION and thus the value of sysconf(_SC_XOPEN_VERSION) can vary under certain circumstances. If the feature test macro _XPG3 is defined by the programmer prior to including <unistd.h>, the value of _XOPEN_VERSION is defined as 3, in conformance with XPG3. Otherwise, the value of _XOPEN_VERSION is defined as 4, in conformance with XPG4.

See stdsyms(5) for more information about these feature test macros.

Any application that has a dependency on libdld.sl is a potential user of both archived and shared libc. Applications that comprise both archived and shared components where sysconf(_SC_LIBC_VERSION) may be invoked from both the archived and shared components may get inconsistent return values from sysconf().

AUTHOR

sysconf() was developed by HP and POSIX.

CPU_IS_PA_RISC() was developed by HP.

SEE ALSO

getconf(1), atexit(2), exec(2), fork(2), getrlimit(2), pathconf(2), times(2), clock(3C), regcomp(3C), limits(5), stdsyms(5), unistd(5), x_open(5).

HP Process Resource Manager: prmconfig(1) in HP Process Resource Manager User's Guide.

STANDARDS CONFORMANCE

sysconf(): AES, SVID3, XPG3, XPG4, FIPS 151-2, POSIX.1, POSIX.2, POSIX.4

© Hewlett-Packard Development Company, L.P.