#include <unistd.h>
long sysconf(int name);
The name argument represents the system variable to be queried. 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 on the SPARC, x86 and PowerPC platforms.
Name | Return Value | Meaning |
_SC_ARG_MAX | ARG_MAX | Max size of argv[] plus envp[]. |
_SC_CHILD_MAX | CHILD_MAX | Max processes allowed to a UID . |
_SC_CLK_TCK | CLK_TCK | Ticks per second (clock_t). |
_SC_NGROUPS_MAX | NGROUPS_MAX | Max simultaneous groups |
to which one may belong. | ||
_SC_OPEN_MAX | OPEN_MAX | Max open files per process. |
_SC_PASS_MAX | PASS_MAX | |
_SC_PAGESIZE | PAGESIZE | System memory page size. |
_SC_JOB_CONTROL | _POSIX_JOB_CONTROL | Job control supported? |
_SC_SAVED_IDS | _POSIX_SAVED_IDS | Saved IDs (seteuid()) supported? |
_SC_VERSION | _POSIX_VERSION | POSIX.1 version supported. |
_SC_XOPEN_VERSION | _XOPEN_VERSION | |
_SC_LOGNAME_MAX | LOGNAME_MAX | |
_SC_NPROCESSORS_CONF | Number of processors configured. | |
_SC_NPROCESSORS_ONLN | Number of processors online. | |
_SC_PHYS_PAGES | Total number of pages of | |
physical memory in system. | ||
_SC_AVPHYS_PAGES | Number physical memory pages | |
not currently in use by system. | ||
_SC_AIO_LISTIO_MAX | AIO_LISTIO_MAX | Max number of I/O operations |
in a single list I/O call | ||
supported by implementation. | ||
_SC_AIO_MAX | AIO_MAX | Max number of outstanding |
asynchronous I/O operations | ||
supported by implementation. | ||
_SC_AIO_PRIO_DELTA_MAX | AIO_PRIO_DELTA_MAX | Max amount by which a process |
can decrease its asynchronous | ||
/O priority level from its own | ||
scheduling priority. | ||
_SC_DELAYTIMER_MAX | DELAYTIMER_MAX | Max number of timer |
expiration overruns. | ||
_SC_GETGR_R_SIZE_MAX | NSS_BUFLEN_GROUP | Max size of group entry buffer. |
_SC_GETPW_R_SIZE_MAX | NSS_BUFLEN_PASSWD | Max size of password entry buffer. |
_SC_LOGIN_NAME_MAX | LOGNAME_MAX + 1 | Max length of login name. |
_SC_MQ_OPEN_MAX | MQ_OPEN_MAX | Max number of open message |
queues a process may hold. | ||
_SC_MQ_PRIO_MAX | MQ_PRIO_MAX | Max number of message priorities |
supported by implementation. | ||
_SC_RTSIG_MAX | RTSIG_MAX | Max number of realtime signals |
reserved for application use | ||
in this implementation. | ||
_SC_SEM_NSEMS_MAX | SEM_NSEMS_MAX | Max number of semaphores |
that a process may have. | ||
_SC_SEM_VALUE_MAX | SEM_VALUE_MAX | Max value a semaphore may have. |
_SC_SIGQUEUE_MAX | SIGQUEUE_MAX | Max number of queued signals |
that a process may send and have | ||
pending at receiver(s) at a time. | ||
_SC_TIMER_MAX | TIMER_MAX | Max number of timers per process |
supported by implementation. | ||
_SC_ASYNCHRONOUS_IO | _POSIX_ASYNCHRONOUS_IO | Supports Asynchronous I/O. |
_SC_FSYNC | _POSIX_FSYNC | Supports File Synchronization. |
_SC_MAPPED_FILES | _POSIX_MAPPED_FILES | Supports Memory Mapped Files. |
_SC_MEMLOCK | _POSIX_MEMLOCK | Supports Process Memory Locking. |
_SC_MEMLOCK_RANGE | _POSIX_MEMLOCK_RANGE | Supports Range Memory Locking. |
_SC_MEMORY_PROTECTION | _POSIX_MEMORY_PROTECTION | Supports Memory Protection. |
_SC_MESSAGE_PASSING | _POSIX_MESSAGE_PASSING | Supports Message Passing. |
_SC_PRIORITIZED_IO | _POSIX_PRIORITIZED_IO | Supports Prioritized I/O. |
_SC_PRIORITY_SCHEDULING | _POSIX_PRIORITY_SCHEDULING | Supports Process Scheduling |
_SC_REALTIME_SIGNALS | _POSIX_REALTIME_SIGNALS | Supports Realtime Signals. |
_SC_SEMAPHORES | _POSIX_SEMAPHORES | Supports Semaphores. |
_SC_SHARED_MEMORY_ | _POSIX_SHARED_MEMORY_ | Supports Shared Memory |
OBJECTS | OBJECTS | Objects. |
_SC_SYNCHRONIZED_IO | _POSIX_SYNCHRONIZED_IO | Supports Synchronized I/O. |
_SC_TIMERS | _POSIX_TIMERS | Supports Timers. |
_SC_THREAD_DESTRUCTOR_ | PTHREAD_DESTRUCTOR_ | Number attempts made to destroy |
ITERATIONS | ITERATIONS | thread-specific data on thread exit. |
_SC_THREAD_KEYS_MAX | PTHREAD_KEYS_MAX | Max number of data keys |
per process. | ||
_SC_THREAD_STACK_MIN | PTHREAD_STACK_MIN | Min byte size of thread |
stack storage. | ||
_SC_THREAD_THREADS_MAX | PTHREAD_THREADS_MAX | Max number of threads per process. |
_SC_TTY_NAME_MAX | TTYNAME_MAX | Max length of tty device name. |
_SC_THREADS | _POSIX_THREADS | Supports Threads option. |
_SC_THREAD_ATTR_STACKADDR | _POSIX_THREAD_ATTR_STACKADDR |
Supports Thread Stack Address Attribute option. | |
_SC_THREAD_ATTR_STACKSIZE | _POSIX_THREAD_ATTR_STACKSIZE |
Supports Thread Stack Size Attribute option. | |
_SC_THREAD_PRIORITY_SCHEDULING | _POSIX_THREAD_PRIORITY_SCHEDULING |
Supports Thread Execution Scheduling option. | |
_SC_THREAD_PRIO_INHERIT | _POSIX_THREAD_PRIO_INHERIT |
Supports Priority Inheritance option. | |
_SC_THREAD_PRIO_PROTECT | _POSIX_THREAD_PRIO_PROTECT |
Supports Priority Protection option. | |
_SC_THREAD_PROCESS_SHARED | _POSIX_THREAD_PROCESS_SHARED |
Supports Process-Shared Synchronization option. | |
_SC_THREAD_SAFE_FUNCTIONS | _POSIX_THREAD_SAFE_FUNCTIONS |
Supports Thread-Safe Functions option. |
The following table lists the names and return values for platform-specific system variables.
Name | Return Value | |
SPARC , x86 | PowerPC | |
_SC_COHER_BLKSZ | EINVAL | Cache coherency size in bytes. |
_SC_SPLIT_CACHE | EINVAL | 0 for non-split or 1 for split. |
_SC_ICACHE_SZ | EINVAL | Size of icache in bytes. |
_SC_DCACHE_SZ | EINVAL | Size of data cache in bytes. |
_SC_ICACHE_LINESZ | EINVAL | Instruction cache line size in bytes. |
_SC_DCACHE_LINESZ | EINVAL | Data cache line size in bytes. |
_SC_ICACHE_BLKSZ | EINVAL | Block size invalidated in icache by |
icbi in bytes. | ||
_SC_DCACHE_BLKSZ | EINVAL | Block size for dcbz, dcbst, dcbf |
and dcbi in bytes. | ||
_SC_DCACHE_TBLKSZ | EINVAL | Block size for dcache prefetch by dcbt |
and dcbtst in bytes. | ||
_SC_ICACHE_ASSOC | EINVAL | Icache associativity (2 = 2-way...). |
_SC_DCACHE_ASSOC | EINVAL | Dcache associativity (2 = 2-way...). |
_SC_PPC_GRANULE_SZ | EINVAL | Granule size for reservations by lwarx |
in bytes. | ||
_SC_PPC_TB_TICKSPSECH | EINVAL | Currently returns 0 (reserved for future expansion). |
_SC_PPC_TB_TICKSPSECL | EINVAL | Returns the rate at which the timebase |
is updated. |
Multiplying sysconf(_SC_PHYS_PAGES ) or sysconf(_SC_AVPHYS_PAGES ) by sysconf(_SC_PAGESIZE ) to determine memory amount in bytes can exceed the maximum values representable in a long or unsigned long.
_SC_PHYS_PAGES and _SC_AVPHYS_PAGES are specific to Solaris 2.3 and later releases.
The value of CLK_TCK may be variable and it should not be assumed that CLK_TCK is a compile-time constant.
Calling sysconf() with _SC_THREAD_KEYS_MAX or _SC_THREAD_THREADS_MAX returns -1, because no maximum limit can be determined. The system supports at least the minimum values defined by _POSIX_THREAD_KEYS_MAX and _POSIX_THREAD_THREADS_MAX and can support higher values depending upon system resources.
_SC_THREAD_PRIO_INHERIT and _SC_THREAD_PRIO_PROTECT are currently not supported, so sysconf() with these arguments returns -1.