flesh out sysconf(3) and the _POSIX_* constants

Bug: 17571891
Change-Id: I81036615486bde65969ae5662587fcc88348474e
This commit is contained in:
Yabin Cui 2014-11-19 19:49:14 -08:00
parent 27aa9c5b50
commit 1c19194c9d
5 changed files with 530 additions and 265 deletions

View file

@ -29,8 +29,10 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <linux/uio.h> // For UIO_MAXIOV.
#include <pthread.h>
#include <stdio.h> // For FOPEN_MAX.
#include <sys/auxv.h>
#include <sys/sysconf.h>
#include <sys/sysinfo.h>
#include <time.h>
@ -38,33 +40,6 @@
#include "private/bionic_tls.h"
/* seems to be the default on Linux, per the GLibc sources and my own digging */
#define SYSTEM_CLK_TCK 100
#define SYSTEM_IOV_MAX 1024
#define SYSTEM_DELAYTIMER_MAX 2147483647
#define SYSTEM_MQ_OPEN_MAX 8
#define SYSTEM_MQ_PRIO_MAX 32768
#define SYSTEM_SEM_NSEMS_MAX 256
#define SYSTEM_SIGQUEUE_MAX 32
#define SYSTEM_TIMER_MAX 32
#define SYSTEM_LOGIN_NAME_MAX 256
#define SYSTEM_TTY_NAME_MAX 32
/* the following depends on our implementation */
#define SYSTEM_ATEXIT_MAX 65536 /* our implementation is unlimited */
#define SYSTEM_THREAD_THREADS_MAX 2048 /* really unlimited */
#define SYSTEM_2_C_BIND _POSIX_VERSION /* Posix C binding version */
#define SYSTEM_2_C_VER _POSIX2_C_VERSION
#define SYSTEM_2_C_DEV -1 /* Posix C development tools unsupported on the device */
#define SYSTEM_2_FORT_DEV -1 /* Fortran development unsupported */
#define SYSTEM_2_FORT_RUN -1 /* Fortran runtime unsupported */
#define SYSTEM_2_SW_DEV -1 /* posix software dev utilities unsupported */
#define SYSTEM_2_LOCALEDEF -1 /* localedef() unimplemented */
#define SYSTEM_2_UPE -1 /* No UPE for you ! (User Portability Utilities) */
#define SYSTEM_2_VERSION -1 /* No posix command-line tools */
static int __sysconf_monotonic_clock() {
timespec t;
int rc = clock_getres(CLOCK_MONOTONIC, &t);
@ -73,103 +48,135 @@ static int __sysconf_monotonic_clock() {
long sysconf(int name) {
switch (name) {
case _SC_ARG_MAX: return _POSIX_ARG_MAX;
case _SC_ARG_MAX: return ARG_MAX;
case _SC_BC_BASE_MAX: return _POSIX2_BC_BASE_MAX; // Minimum requirement.
case _SC_BC_DIM_MAX: return _POSIX2_BC_DIM_MAX; // Minimum requirement.
case _SC_BC_SCALE_MAX: return _POSIX2_BC_SCALE_MAX; // Minimum requirement.
case _SC_BC_STRING_MAX: return _POSIX2_BC_STRING_MAX; // Minimum requirement.
case _SC_CHILD_MAX: return CHILD_MAX;
case _SC_CLK_TCK: return SYSTEM_CLK_TCK;
case _SC_LINE_MAX: return _POSIX2_LINE_MAX;
case _SC_CLK_TCK: return static_cast<long>(getauxval(AT_CLKTCK));
case _SC_COLL_WEIGHTS_MAX: return _POSIX2_COLL_WEIGHTS_MAX; // Minimum requirement.
case _SC_EXPR_NEST_MAX: return _POSIX2_EXPR_NEST_MAX; // Minimum requirement.
case _SC_LINE_MAX: return _POSIX2_LINE_MAX; // Minimum requirement.
case _SC_NGROUPS_MAX: return NGROUPS_MAX;
case _SC_OPEN_MAX: return OPEN_MAX;
case _SC_PASS_MAX: return PASS_MAX;
case _SC_2_C_BIND: return SYSTEM_2_C_BIND;
case _SC_2_C_DEV: return SYSTEM_2_C_DEV;
case _SC_2_C_VERSION: return SYSTEM_2_C_VER;
//case _SC_2_CHAR_TERM: return ;
case _SC_2_FORT_DEV: return SYSTEM_2_FORT_DEV;
case _SC_2_FORT_RUN: return SYSTEM_2_FORT_RUN;
case _SC_2_LOCALEDEF: return SYSTEM_2_LOCALEDEF;
case _SC_2_SW_DEV: return SYSTEM_2_SW_DEV;
case _SC_2_UPE: return SYSTEM_2_UPE;
case _SC_2_VERSION: return SYSTEM_2_VERSION;
case _SC_2_C_BIND: return _POSIX2_C_BIND;
case _SC_2_C_DEV: return _POSIX2_C_DEV;
case _SC_2_CHAR_TERM: return _POSIX2_CHAR_TERM;
case _SC_2_FORT_DEV: return -1;
case _SC_2_FORT_RUN: return -1;
case _SC_2_LOCALEDEF: return _POSIX2_LOCALEDEF;
case _SC_2_SW_DEV: return _POSIX2_SW_DEV;
case _SC_2_UPE: return _POSIX2_UPE;
case _SC_2_VERSION: return _POSIX2_VERSION;
case _SC_JOB_CONTROL: return _POSIX_JOB_CONTROL;
case _SC_SAVED_IDS: return _POSIX_SAVED_IDS;
case _SC_VERSION: return _POSIX_VERSION;
case _SC_RE_DUP_MAX: return _POSIX_RE_DUP_MAX;
case _SC_RE_DUP_MAX: return _POSIX_RE_DUP_MAX; // Minimum requirement.
case _SC_STREAM_MAX: return FOPEN_MAX;
case _SC_TZNAME_MAX: return _POSIX_TZNAME_MAX;
case _SC_TZNAME_MAX: return _POSIX_TZNAME_MAX; // Minimum requirement.
case _SC_XOPEN_CRYPT: return _XOPEN_CRYPT;
case _SC_XOPEN_ENH_I18N: return _XOPEN_ENH_I18N;
//case _SC_XOPEN_SHM: return _XOPEN_SHM;
case _SC_XOPEN_SHM: return _XOPEN_SHM;
case _SC_XOPEN_VERSION: return _XOPEN_VERSION;
case _SC_XOPEN_XCU_VERSION: return _XOPEN_XCU_VERSION;
case _SC_XOPEN_REALTIME: return _XOPEN_REALTIME;
case _SC_XOPEN_REALTIME_THREADS: return _XOPEN_REALTIME_THREADS;
case _SC_XOPEN_LEGACY: return _XOPEN_LEGACY;
case _SC_ATEXIT_MAX: return SYSTEM_ATEXIT_MAX;
case _SC_IOV_MAX: return SYSTEM_IOV_MAX;
case _SC_PAGESIZE:
case _SC_PAGE_SIZE:
return PAGE_SIZE;
case _SC_ATEXIT_MAX: return LONG_MAX; // Unlimited.
case _SC_IOV_MAX: return UIO_MAXIOV;
case _SC_PAGESIZE: // Fall through, PAGESIZE and PAGE_SIZE always hold the same value.
case _SC_PAGE_SIZE: return PAGE_SIZE;
case _SC_XOPEN_UNIX: return _XOPEN_UNIX;
// XXX: TODO: XBS5 nonsense
//case _SC_AIO_LISTIO_MAX: return AIO_LISTIO_MAX;
//case _SC_AIO_MAX: return AIO_MAX;
//case _SC_AIO_PRIO_DELTA_MAX: return AIO_PRIO_DELTA_MAX;
case _SC_DELAYTIMER_MAX: return SYSTEM_DELAYTIMER_MAX;
case _SC_MQ_OPEN_MAX: return SYSTEM_MQ_OPEN_MAX;
case _SC_MQ_PRIO_MAX: return SYSTEM_MQ_PRIO_MAX;
case _SC_AIO_LISTIO_MAX: return _POSIX_AIO_LISTIO_MAX; // Minimum requirement.
case _SC_AIO_MAX: return _POSIX_AIO_MAX; // Minimum requirement.
case _SC_AIO_PRIO_DELTA_MAX:return 0; // Minimum requirement.
case _SC_DELAYTIMER_MAX: return INT_MAX;
case _SC_MQ_OPEN_MAX: return _POSIX_MQ_OPEN_MAX; // Minimum requirement.
case _SC_MQ_PRIO_MAX: return _POSIX_MQ_PRIO_MAX; // Minimum requirement.
case _SC_RTSIG_MAX: return RTSIG_MAX;
case _SC_SEM_NSEMS_MAX: return SYSTEM_SEM_NSEMS_MAX;
case _SC_SEM_NSEMS_MAX: return _POSIX_SEM_NSEMS_MAX; // Minimum requirement.
case _SC_SEM_VALUE_MAX: return SEM_VALUE_MAX;
case _SC_SIGQUEUE_MAX: return SYSTEM_SIGQUEUE_MAX;
case _SC_TIMER_MAX: return SYSTEM_TIMER_MAX;
//case _SC_ASYNCHRONOUS_IO: return _POSIX_ASYNCHRONOUS_IO;
case _SC_SIGQUEUE_MAX: return _POSIX_SIGQUEUE_MAX; // Minimum requirement.
case _SC_TIMER_MAX: return _POSIX_TIMER_MAX; // Minimum requirement.
case _SC_ASYNCHRONOUS_IO: return _POSIX_ASYNCHRONOUS_IO;
case _SC_FSYNC: return _POSIX_FSYNC;
case _SC_MAPPED_FILES: return _POSIX_MAPPED_FILES;
//case _SC_MEMLOCK: return _POSIX_MEMLOCK;
//case _SC_MEMLOCK_RANGE: return _POSIX_MEMLOCK_RANGE;
//case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION;
//case _SC_MESSAGE_PASSING: return _POSIX_MESSAGE_PASSING;
//case _SC_PRIORITIZED_IO: return _POSIX_PRIORITIZED_IO;
case _SC_MEMLOCK: return _POSIX_MEMLOCK;
case _SC_MEMLOCK_RANGE: return _POSIX_MEMLOCK_RANGE;
case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION;
case _SC_MESSAGE_PASSING: return _POSIX_MESSAGE_PASSING;
case _SC_PRIORITIZED_IO: return _POSIX_PRIORITIZED_IO;
case _SC_PRIORITY_SCHEDULING: return _POSIX_PRIORITY_SCHEDULING;
case _SC_REALTIME_SIGNALS: return _POSIX_REALTIME_SIGNALS;
case _SC_SEMAPHORES: return _POSIX_SEMAPHORES;
//case _SC_SHARED_MEMORY_OBJECTS: return _POSIX_SHARED_MEMORY_OBJECTS;
case _SC_SHARED_MEMORY_OBJECTS: return _POSIX_SHARED_MEMORY_OBJECTS;
case _SC_SYNCHRONIZED_IO: return _POSIX_SYNCHRONIZED_IO;
case _SC_TIMERS: return _POSIX_TIMERS;
case _SC_GETGR_R_SIZE_MAX: return 1024;
case _SC_GETPW_R_SIZE_MAX: return 1024;
case _SC_LOGIN_NAME_MAX: return SYSTEM_LOGIN_NAME_MAX;
case _SC_THREAD_DESTRUCTOR_ITERATIONS:
return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
case _SC_THREAD_KEYS_MAX:
return (BIONIC_TLS_SLOTS - TLS_SLOT_FIRST_USER_SLOT - BIONIC_TLS_RESERVED_SLOTS);
case _SC_LOGIN_NAME_MAX: return 256; // Seems default on linux.
case _SC_THREAD_DESTRUCTOR_ITERATIONS: return PTHREAD_DESTRUCTOR_ITERATIONS;
case _SC_THREAD_KEYS_MAX: return PTHREAD_KEYS_MAX;
case _SC_THREAD_STACK_MIN: return PTHREAD_STACK_MIN;
case _SC_THREAD_THREADS_MAX: return SYSTEM_THREAD_THREADS_MAX;
case _SC_TTY_NAME_MAX: return SYSTEM_TTY_NAME_MAX;
case _SC_THREAD_THREADS_MAX: return PTHREAD_THREADS_MAX;
case _SC_TTY_NAME_MAX: return 32; // Seems default on linux.
case _SC_THREADS: return _POSIX_THREADS;
case _SC_THREAD_ATTR_STACKADDR: return -1; // Removed in POSIX 2008
case _SC_THREAD_ATTR_STACKSIZE: return -1; // Removed in POSIX 2008
//case _SC_THREAD_PRIORITY_SCHEDULING: return _POSIX_THREAD_PRIORITY_SCHEDULING;
case _SC_THREAD_ATTR_STACKADDR: return _POSIX_THREAD_ATTR_STACKADDR;
case _SC_THREAD_ATTR_STACKSIZE: return _POSIX_THREAD_ATTR_STACKSIZE;
case _SC_THREAD_PRIORITY_SCHEDULING: return _POSIX_THREAD_PRIORITY_SCHEDULING;
case _SC_THREAD_PRIO_INHERIT: return _POSIX_THREAD_PRIO_INHERIT;
case _SC_THREAD_PRIO_PROTECT: return _POSIX_THREAD_PRIO_PROTECT;
//case _SC_THREAD_SAFE_FUNCTIONS: return _POSIX_THREAD_SAFE_FUNCTIONS
case _SC_MONOTONIC_CLOCK: return __sysconf_monotonic_clock();
case _SC_THREAD_SAFE_FUNCTIONS: return _POSIX_THREAD_SAFE_FUNCTIONS;
case _SC_NPROCESSORS_CONF: return get_nprocs_conf();
case _SC_NPROCESSORS_ONLN: return get_nprocs();
case _SC_PHYS_PAGES: return get_phys_pages();
case _SC_AVPHYS_PAGES: return get_avphys_pages();
case _SC_MONOTONIC_CLOCK: return __sysconf_monotonic_clock();
case _SC_2_PBS: return -1; // Obsolescent in POSIX.1-2008.
case _SC_2_PBS_ACCOUNTING: return -1; // Obsolescent in POSIX.1-2008.
case _SC_2_PBS_CHECKPOINT: return -1; // Obsolescent in POSIX.1-2008.
case _SC_2_PBS_LOCATE: return -1; // Obsolescent in POSIX.1-2008.
case _SC_2_PBS_MESSAGE: return -1; // Obsolescent in POSIX.1-2008.
case _SC_2_PBS_TRACK: return -1; // Obsolescent in POSIX.1-2008.
case _SC_ADVISORY_INFO: return _POSIX_ADVISORY_INFO;
case _SC_BARRIERS: return _POSIX_BARRIERS;
case _SC_CLOCK_SELECTION: return _POSIX_CLOCK_SELECTION;
case _SC_CPUTIME: return _POSIX_CPUTIME;
case _SC_HOST_NAME_MAX: return _POSIX_HOST_NAME_MAX; // Minimum requirement.
case _SC_IPV6: return _POSIX_IPV6;
case _SC_RAW_SOCKETS: return _POSIX_RAW_SOCKETS;
case _SC_READER_WRITER_LOCKS: return _POSIX_READER_WRITER_LOCKS;
case _SC_REGEXP: return _POSIX_REGEXP;
case _SC_SHELL: return _POSIX_SHELL;
case _SC_SPAWN: return _POSIX_SPAWN;
case _SC_SPIN_LOCKS: return _POSIX_SPIN_LOCKS;
case _SC_SPORADIC_SERVER: return _POSIX_SPORADIC_SERVER;
case _SC_SS_REPL_MAX: return -1;
case _SC_SYMLOOP_MAX: return _POSIX_SYMLOOP_MAX; // Minimum requirement.
case _SC_THREAD_CPUTIME: return _POSIX_THREAD_CPUTIME;
case _SC_THREAD_PROCESS_SHARED: return _POSIX_THREAD_PROCESS_SHARED;
case _SC_THREAD_ROBUST_PRIO_INHERIT: return _POSIX_THREAD_ROBUST_PRIO_INHERIT;
case _SC_THREAD_ROBUST_PRIO_PROTECT: return _POSIX_THREAD_ROBUST_PRIO_PROTECT;
case _SC_THREAD_SPORADIC_SERVER: return _POSIX_THREAD_SPORADIC_SERVER;
case _SC_TIMEOUTS: return _POSIX_TIMEOUTS;
case _SC_TRACE: return -1; // Obsolescent in POSIX.1-2008.
case _SC_TRACE_EVENT_FILTER: return -1; // Obsolescent in POSIX.1-2008.
case _SC_TRACE_EVENT_NAME_MAX: return -1;
case _SC_TRACE_INHERIT: return -1; // Obsolescent in POSIX.1-2008.
case _SC_TRACE_LOG: return -1; // Obsolescent in POSIX.1-2008.
case _SC_TRACE_NAME_MAX: return -1;
case _SC_TRACE_SYS_MAX: return -1;
case _SC_TRACE_USER_EVENT_MAX: return -1;
case _SC_TYPED_MEMORY_OBJECTS: return _POSIX_TYPED_MEMORY_OBJECTS;
case _SC_V7_ILP32_OFF32: return _POSIX_V7_ILP32_OFF32;
case _SC_V7_ILP32_OFFBIG: return _POSIX_V7_ILP32_OFFBIG;
case _SC_V7_LP64_OFF64: return _POSIX_V7_LP64_OFF64;
case _SC_V7_LPBIG_OFFBIG: return _POSIX_V7_LPBIG_OFFBIG;
case _SC_XOPEN_STREAMS: return -1; // Obsolescent in POSIX.1-2008.
case _SC_XOPEN_UUCP: return -1;
default:
// Posix says EINVAL is the only error that shall be returned,

View file

@ -29,46 +29,129 @@
#ifndef _POSIX_LIMITS_H_
#define _POSIX_LIMITS_H_
/* TODO: complete and check these. */
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
/* Any constant values here other than -1 or 200809L are explicitly specified by POSIX.1-2008. */
/* Keep it sorted. */
#define _POSIX_ADVISORY_INFO -1 /* posix_madvise() not implemented */
#define _POSIX_AIO_LISTIO_MAX 2
#define _POSIX_AIO_MAX 1
#define _POSIX_ARG_MAX 4096
#define _POSIX_ASYNCHRONOUS_IO -1 /* not implemented */
#define _POSIX_BARRIERS -1 /* not implemented */
#define _POSIX_CHILD_MAX 25
#define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */
#define _POSIX_FSYNC 1 /* fdatasync() supported */
#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
#define _POSIX_CLOCK_SELECTION 200809L
#define _POSIX_CPUTIME -1 /* clock_getcpuclockid() not implemented */
#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_FSYNC 200809L /* fdatasync() supported */
#define _POSIX_HOST_NAME_MAX 255
#define _POSIX_IPV6 200809L
#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
#define _POSIX_LINK_MAX 8
#define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */
#define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */
#define _POSIX_MAPPED_FILES 200809L /* mmap-ed files supported */
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_MEMLOCK 200809L
#define _POSIX_MEMLOCK_RANGE 200809L
#define _POSIX_MEMORY_PROTECTION 200809L
#define _POSIX_MESSAGE_PASSING -1 /* not implemented */
#define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */
#define _POSIX_MQ_OPEN_MAX 8
#define _POSIX_MQ_PRIO_MAX 32
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 0
#define _POSIX_NGROUPS_MAX 8
#define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */
#define _POSIX_OPEN_MAX 16
#define _POSIX_OPEN_MAX 20
#define _POSIX_PATH_MAX 256
#define _POSIX_PIPE_BUF 512
#define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */
#define _POSIX_PRIORITY_SCHEDULING 200809L /* priority scheduling is a Linux feature */
#define _POSIX_PRIORITIZED_IO -1 /* not implemented */
#define _POSIX_RAW_SOCKETS 200809L
#define _POSIX_READER_WRITER_LOCKS 200809L
#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */
#define _POSIX_REGEXP 1
#define _POSIX_RE_DUP_MAX 255
#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
#define _POSIX_SEMAPHORES 200809L
#define _POSIX_SEM_NSEMS_MAX 256
#define _POSIX_SEM_VALUE_MAX 32767
#define _POSIX_SHARED_MEMORY_OBJECTS -1 /* shm_open()/shm_unlink() not implemented */
#define _POSIX_SHELL 1 /* system() supported */
#define _POSIX_SIGQUEUE_MAX 32
#define _POSIX_SPAWN -1 /* not implemented */
#define _POSIX_SPIN_LOCKS -1 /* not implemented */
#define _POSIX_SPORADIC_SERVER -1 /* not implemented */
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_SYMLINK_MAX 255
#define _POSIX_SYMLOOP_MAX 8
#define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */
#define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */
#define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */
#define _POSIX_THREADS 1 /* we support threads */
#define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */
#define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */
#define _POSIX_TIMERS 1 /* Posix timers are supported */
#define _POSIX_SYNCHRONIZED_IO 200809L /* synchronized i/o supported */
#define _POSIX_THREADS 200809L /* we support threads */
#define _POSIX_THREAD_ATTR_STACKADDR 200809L
#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
#define _POSIX_THREAD_CPUTIME 200809L
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
#define _POSIX_THREAD_KEYS_MAX 128
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
#define _POSIX_THREAD_PRIO_INHERIT 200809L /* linux feature */
#define _POSIX_THREAD_PRIO_PROTECT 200809L /* linux feature */
#define _POSIX_THREAD_PROCESS_SHARED -1 /* not implemented */
#define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1 /* not implemented */
#define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1 /* not implemented */
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
#define _POSIX_THREAD_SPORADIC_SERVER -1 /* not implemented */
#define _POSIX_THREAD_THREADS_MAX 64
#define _POSIX_TIMEOUTS 200809L
#define _POSIX_TIMERS 200809L /* Posix timers are supported */
#define _POSIX_TIMER_MAX 32
#define _POSIX_TRACE -1 /* not implemented */
#define _POSIX_TRACE_EVENT_FILTER -1 /* not implemented */
#define _POSIX_TRACE_INHERIT -1 /* not implemented */
#define _POSIX_TRACE_LOG -1 /* not implemented */
#define _POSIX_TRACE_NAME_MAX 8
#define _POSIX_TRACE_SYS_MAX 8
#define _POSIX_TRACE_USER_EVENT_MAX 32
#define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */
#define _POSIX_TZNAME_MAX 3
#define _POSIX_TYPED_MEMORY_OBJECTS -1 /* not implemented */
#define _POSIX_TZNAME_MAX 6
#define _POSIX_VDISABLE '\0'
#if defined(__LP64__)
#define _POSIX_V7_ILP32_OFF32 -1
#define _POSIX_V7_ILP32_OFFBIG -1
#define _POSIX_V7_LP64_OFF64 1
#define _POSIX_V7_LPBIG_OFFBIG 1
#else
#define _POSIX_V7_ILP32_OFF32 1
#define _POSIX_V7_ILP32_OFFBIG -1
#define _POSIX_V7_LP64_OFF64 -1
#define _POSIX_V7_LPBIG_OFFBIG -1
#endif
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_CHARCLASS_NAME_MAX 14
#define _POSIX2_CHAR_TERM -1 /* not implemented */
#define _POSIX2_COLL_WEIGHTS_MAX 2
#define _POSIX2_C_BIND _POSIX_VERSION
#define _POSIX2_C_DEV -1 /* c dev utilities not implemented */
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_LOCALEDEF -1 /* localedef utilitiy not implemented */
#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
#define _POSIX2_SW_DEV -1 /* software dev utilities not implemented */
#define _POSIX2_UPE -1 /* user portability utilities not implemented */
#define _XOPEN_ENH_I18N -1 /* we don't support internationalization in the C library */
#define _XOPEN_CRYPT -1 /* don't support X/Open Encryption */
#define _XOPEN_IOV_MAX 16
#define _XOPEN_LEGACY -1 /* not support all */
#define _XOPEN_REALTIME -1 /* we don't support all these functions */
#define _XOPEN_REALTIME_THREADS -1 /* same here */
#define _XOPEN_SHM -1
#define _XOPEN_UNIX 1
#endif /* _POSIX_LIMITS_H_ */

View file

@ -115,31 +115,13 @@
/* Bionic-specific definitions */
#define _POSIX_VERSION 200112L /* Posix C language bindings version */
#define _POSIX_VERSION 200809L /* Posix C language bindings version */
#define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */
#define _POSIX2_C_VERSION _POSIX_VERSION
#define _XOPEN_VERSION 500 /* by Posix definition */
#define _XOPEN_XCU_VERSION -1 /* we don't support command-line utilities */
#define _XOPEN_VERSION 700 /* by Posix definition */
/* tell what we implement legacy stuff when appropriate */
#if _POSIX_VERSION > 0
#define _XOPEN_XPG2 1
#define _XOPEN_XPG3 1
#define _XOPEN_XPG4 1
#define _XOPEN_UNIX 1
#endif
#define _XOPEN_ENH_I18N -1 /* we don't support internationalization in the C library */
#define _XOPEN_CRYPT -1 /* don't support X/Open Encryption */
#define _XOPEN_LEGACY -1 /* don't claim we support these, we have some of them but not all */
#define _XOPEN_REALTIME -1 /* we don't support all these functions */
#define _XOPEN_REALTIME_THREADS -1 /* same here */
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define _POSIX_THREAD_KEYS_MAX 128 /* the minimum mandated by POSIX */
#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
#define PTHREAD_DESTRUCTOR_ITERATIONS 4 // >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define PTHREAD_KEYS_MAX 128 // >= _POSIX_THREAD_KEYS_MAX
#define PTHREAD_THREADS_MAX 2048 // bionic has no specific limit
#endif

View file

@ -50,7 +50,7 @@ __BEGIN_DECLS
#define _SC_PASS_MAX 0x000c
#define _SC_2_C_BIND 0x000d
#define _SC_2_C_DEV 0x000e
#define _SC_2_C_VERSION 0x000f
#define _SC_2_C_VERSION 0x000f /* Obsolescent in POSIX.1-2008, TODO: remove it. */
#define _SC_2_CHAR_TERM 0x0010
#define _SC_2_FORT_DEV 0x0011
#define _SC_2_FORT_RUN 0x0012
@ -68,7 +68,7 @@ __BEGIN_DECLS
#define _SC_XOPEN_ENH_I18N 0x001e
#define _SC_XOPEN_SHM 0x001f
#define _SC_XOPEN_VERSION 0x0020
#define _SC_XOPEN_XCU_VERSION 0x0021
#define _SC_XOPEN_XCU_VERSION 0x0021 /* Obsolescent in POSIX.1-2008, TODO: remove it. */
#define _SC_XOPEN_REALTIME 0x0022
#define _SC_XOPEN_REALTIME_THREADS 0x0023
#define _SC_XOPEN_LEGACY 0x0024
@ -77,10 +77,10 @@ __BEGIN_DECLS
#define _SC_PAGESIZE 0x0027
#define _SC_PAGE_SIZE 0x0028
#define _SC_XOPEN_UNIX 0x0029
#define _SC_XBS5_ILP32_OFF32 0x002a
#define _SC_XBS5_ILP32_OFFBIG 0x002b
#define _SC_XBS5_LP64_OFF64 0x002c
#define _SC_XBS5_LPBIG_OFFBIG 0x002d
#define _SC_XBS5_ILP32_OFF32 0x002a /* Obsolescent in POSIX.1-2008, TODO: remove it. */
#define _SC_XBS5_ILP32_OFFBIG 0x002b /* Obsolescent in POSIX.1-2008, TODO: remove it. */
#define _SC_XBS5_LP64_OFF64 0x002c /* Obsolescent in POSIX.1-2008, TODO: remove it. */
#define _SC_XBS5_LPBIG_OFFBIG 0x002d /* Obsolescent in POSIX.1-2008, TODO: remove it. */
#define _SC_AIO_LISTIO_MAX 0x002e
#define _SC_AIO_MAX 0x002f
#define _SC_AIO_PRIO_DELTA_MAX 0x0030
@ -129,6 +129,49 @@ __BEGIN_DECLS
#define _SC_AVPHYS_PAGES 0x0063
#define _SC_MONOTONIC_CLOCK 0x0064
#define _SC_2_PBS 0x0065
#define _SC_2_PBS_ACCOUNTING 0x0066
#define _SC_2_PBS_CHECKPOINT 0x0067
#define _SC_2_PBS_LOCATE 0x0068
#define _SC_2_PBS_MESSAGE 0x0069
#define _SC_2_PBS_TRACK 0x006a
#define _SC_ADVISORY_INFO 0x006b
#define _SC_BARRIERS 0x006c
#define _SC_CLOCK_SELECTION 0x006d
#define _SC_CPUTIME 0x006e
#define _SC_HOST_NAME_MAX 0x006f
#define _SC_IPV6 0x0070
#define _SC_RAW_SOCKETS 0x0071
#define _SC_READER_WRITER_LOCKS 0x0072
#define _SC_REGEXP 0x0073
#define _SC_SHELL 0x0074
#define _SC_SPAWN 0x0075
#define _SC_SPIN_LOCKS 0x0076
#define _SC_SPORADIC_SERVER 0x0077
#define _SC_SS_REPL_MAX 0x0078
#define _SC_SYMLOOP_MAX 0x0079
#define _SC_THREAD_CPUTIME 0x007a
#define _SC_THREAD_PROCESS_SHARED 0x007b
#define _SC_THREAD_ROBUST_PRIO_INHERIT 0x007c
#define _SC_THREAD_ROBUST_PRIO_PROTECT 0x007d
#define _SC_THREAD_SPORADIC_SERVER 0x007e
#define _SC_TIMEOUTS 0x007f
#define _SC_TRACE 0x0080
#define _SC_TRACE_EVENT_FILTER 0x0081
#define _SC_TRACE_EVENT_NAME_MAX 0x0082
#define _SC_TRACE_INHERIT 0x0083
#define _SC_TRACE_LOG 0x0084
#define _SC_TRACE_NAME_MAX 0x0085
#define _SC_TRACE_SYS_MAX 0x0086
#define _SC_TRACE_USER_EVENT_MAX 0x0087
#define _SC_TYPED_MEMORY_OBJECTS 0x0088
#define _SC_V7_ILP32_OFF32 0x0089
#define _SC_V7_ILP32_OFFBIG 0x008a
#define _SC_V7_LP64_OFF64 0x008b
#define _SC_V7_LPBIG_OFFBIG 0x008c
#define _SC_XOPEN_STREAMS 0x008d
#define _SC_XOPEN_UUCP 0x008e
long sysconf(int);
__END_DECLS

View file

@ -517,137 +517,287 @@ TEST(unistd, pathconf_fpathconf) {
ASSERT_TRUE(rc > 0 && powerof2(rc));
}
#define verifySysconf(name, ret) \
{\
errno = 0;\
ret = sysconf(name);\
ASSERT_TRUE((0 == errno) && (-1 != ret)) << "name=" << #name << ", ret=" << ret << ", Error Message: " << strerror(errno);\
}\
TEST(unistd, _POSIX_macros_smoke) {
// Make a tight verification of _POSIX_* / _POSIX2_* / _XOPEN_* macros, to prevent change by mistake.
// Verify according to POSIX.1-2008.
EXPECT_EQ(200809L, _POSIX_VERSION);
EXPECT_GT(_POSIX_AIO_LISTIO_MAX, 0);
EXPECT_GT(_POSIX_AIO_MAX, 0);
EXPECT_GT(_POSIX_ARG_MAX, 0);
EXPECT_GT(_POSIX_CHILD_MAX, 0);
EXPECT_NE(_POSIX_CHOWN_RESTRICTED, -1);
EXPECT_EQ(_POSIX_VERSION, _POSIX_CLOCK_SELECTION);
EXPECT_GT(_POSIX_DELAYTIMER_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_FSYNC);
EXPECT_GT(_POSIX_HOST_NAME_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_IPV6);
EXPECT_GT(_POSIX_JOB_CONTROL, 0);
EXPECT_GT(_POSIX_LINK_MAX, 0);
EXPECT_GT(_POSIX_LOGIN_NAME_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_MAPPED_FILES);
EXPECT_GT(_POSIX_MAX_CANON, 0);
EXPECT_GT(_POSIX_MAX_INPUT, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_MEMLOCK);
EXPECT_EQ(_POSIX_VERSION, _POSIX_MEMLOCK_RANGE);
EXPECT_EQ(_POSIX_VERSION, _POSIX_MEMORY_PROTECTION);
EXPECT_EQ(0, _POSIX_MONOTONIC_CLOCK);
EXPECT_GT(_POSIX_MQ_OPEN_MAX, 0);
EXPECT_GT(_POSIX_MQ_PRIO_MAX, 0);
EXPECT_GT(_POSIX_NAME_MAX, 0);
EXPECT_GT(_POSIX_NGROUPS_MAX, 0);
EXPECT_GT(_POSIX_NO_TRUNC, 0);
EXPECT_GT(_POSIX_OPEN_MAX, 0);
EXPECT_GT(_POSIX_PATH_MAX, 0);
EXPECT_GT(_POSIX_PIPE_BUF, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_PRIORITY_SCHEDULING);
EXPECT_EQ(_POSIX_VERSION, _POSIX_RAW_SOCKETS);
EXPECT_EQ(_POSIX_VERSION, _POSIX_READER_WRITER_LOCKS);
EXPECT_GT(_POSIX_REGEXP, 0);
EXPECT_GT(_POSIX_RE_DUP_MAX, 0);
EXPECT_GT(_POSIX_SAVED_IDS, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_SEMAPHORES);
EXPECT_GT(_POSIX_SEM_NSEMS_MAX, 0);
EXPECT_GT(_POSIX_SEM_VALUE_MAX, 0);
EXPECT_GT(_POSIX_SHELL, 0);
EXPECT_GT(_POSIX_SIGQUEUE_MAX, 0);
EXPECT_EQ(-1, _POSIX_SPORADIC_SERVER);
EXPECT_GT(_POSIX_SSIZE_MAX, 0);
EXPECT_GT(_POSIX_STREAM_MAX, 0);
EXPECT_GT(_POSIX_SYMLINK_MAX, 0);
EXPECT_GT(_POSIX_SYMLOOP_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_SYNCHRONIZED_IO);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREADS);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_ATTR_STACKADDR);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_ATTR_STACKSIZE);
EXPECT_TRUE(_POSIX_VERSION == _POSIX_THREAD_CPUTIME || 0 == _POSIX_THREAD_CPUTIME);
EXPECT_GT(_POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0);
EXPECT_GT(_POSIX_THREAD_KEYS_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIORITY_SCHEDULING);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIO_INHERIT);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_PRIO_PROTECT);
EXPECT_EQ(-1, _POSIX_THREAD_ROBUST_PRIO_PROTECT);
EXPECT_EQ(_POSIX_VERSION, _POSIX_THREAD_SAFE_FUNCTIONS);
EXPECT_EQ(-1, _POSIX_THREAD_SPORADIC_SERVER);
EXPECT_GT(_POSIX_THREAD_THREADS_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX_TIMEOUTS);
EXPECT_EQ(_POSIX_VERSION, _POSIX_TIMERS);
EXPECT_GT(_POSIX_TIMER_MAX, 0);
EXPECT_EQ(-1, _POSIX_TRACE);
EXPECT_EQ(-1, _POSIX_TRACE_EVENT_FILTER);
EXPECT_EQ(-1, _POSIX_TRACE_INHERIT);
EXPECT_EQ(-1, _POSIX_TRACE_LOG);
EXPECT_GT(_POSIX_TTY_NAME_MAX, 0);
EXPECT_EQ(-1, _POSIX_TYPED_MEMORY_OBJECTS);
EXPECT_GT(_POSIX_TZNAME_MAX, 0);
EXPECT_NE(-1, _POSIX_VDISABLE);
EXPECT_GT(_POSIX2_BC_BASE_MAX, 0);
EXPECT_GT(_POSIX2_BC_DIM_MAX, 0);
EXPECT_GT(_POSIX2_BC_SCALE_MAX, 0);
EXPECT_GT(_POSIX2_BC_STRING_MAX, 0);
EXPECT_GT(_POSIX2_CHARCLASS_NAME_MAX, 0);
EXPECT_GT(_POSIX2_COLL_WEIGHTS_MAX, 0);
EXPECT_EQ(_POSIX_VERSION, _POSIX2_C_BIND);
EXPECT_GT(_POSIX2_EXPR_NEST_MAX, 0);
EXPECT_GT(_POSIX2_LINE_MAX, 0);
EXPECT_GT(_POSIX2_RE_DUP_MAX, 0);
EXPECT_EQ(700, _XOPEN_VERSION);
EXPECT_GT(_XOPEN_IOV_MAX, 0);
EXPECT_GT(_XOPEN_UNIX, 0);
#if defined(__BIONIC__)
// These tests only pass on bionic, as bionic and glibc has different support on these macros.
// Macros like _POSIX_ADVISORY_INFO are not supported on bionic yet.
EXPECT_EQ(-1, _POSIX_ADVISORY_INFO);
EXPECT_EQ(-1, _POSIX_ASYNCHRONOUS_IO);
EXPECT_EQ(-1, _POSIX_BARRIERS);
EXPECT_EQ(-1, _POSIX_CPUTIME);
EXPECT_EQ(-1, _POSIX_MESSAGE_PASSING);
EXPECT_EQ(-1, _POSIX_PRIORITIZED_IO);
EXPECT_EQ(-1, _POSIX_REALTIME_SIGNALS);
EXPECT_EQ(-1, _POSIX_SHARED_MEMORY_OBJECTS);
EXPECT_EQ(-1, _POSIX_SPAWN);
EXPECT_EQ(-1, _POSIX_SPIN_LOCKS);
EXPECT_EQ(-1, _POSIX_THREAD_PROCESS_SHARED);
EXPECT_EQ(-1, _POSIX_THREAD_ROBUST_PRIO_INHERIT);
EXPECT_EQ(-1, _POSIX2_VERSION);
EXPECT_EQ(-1, _POSIX2_CHAR_TERM);
EXPECT_EQ(-1, _POSIX2_C_DEV);
EXPECT_EQ(-1, _POSIX2_LOCALEDEF);
EXPECT_EQ(-1, _POSIX2_SW_DEV);
EXPECT_EQ(-1, _POSIX2_UPE);
EXPECT_EQ(-1, _XOPEN_ENH_I18N);
EXPECT_EQ(-1, _XOPEN_CRYPT);
EXPECT_EQ(-1, _XOPEN_LEGACY);
EXPECT_EQ(-1, _XOPEN_REALTIME);
EXPECT_EQ(-1, _XOPEN_REALTIME_THREADS);
EXPECT_EQ(-1, _XOPEN_SHM);
#endif // defined(__BIONIC__)
}
#define VERIFY_SYSCONF_NOT_SUPPORT(name) VerifySysconf(name, #name, [](long v){return v == -1;})
// sysconf() means unlimited when it returns -1 with errno unchanged.
#define VERIFY_SYSCONF_POSITIVE(name) \
VerifySysconf(name, #name, [](long v){return (v > 0 || v == -1);})
#define VERIFY_SYSCONF_POSIX_VERSION(name) \
VerifySysconf(name, #name, [](long v){return v == _POSIX_VERSION;})
static void VerifySysconf(int option, const char *option_name, bool (*verify)(long)) {
errno = 0;
long ret = sysconf(option);
EXPECT_TRUE(0 == errno && verify(ret)) << "name = " << option_name << ", ret = "
<< ret <<", Error Message: " << strerror(errno);
}
TEST(unistd, sysconf) {
long ret;
VERIFY_SYSCONF_POSITIVE(_SC_ARG_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_BC_BASE_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_BC_DIM_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_BC_SCALE_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_CHILD_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_CLK_TCK);
VERIFY_SYSCONF_POSITIVE(_SC_COLL_WEIGHTS_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_EXPR_NEST_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_LINE_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_NGROUPS_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_OPEN_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_PASS_MAX);
VERIFY_SYSCONF_POSIX_VERSION(_SC_2_C_BIND);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_FORT_DEV);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_FORT_RUN);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_UPE);
VERIFY_SYSCONF_POSITIVE(_SC_JOB_CONTROL);
VERIFY_SYSCONF_POSITIVE(_SC_SAVED_IDS);
VERIFY_SYSCONF_POSIX_VERSION(_SC_VERSION);
VERIFY_SYSCONF_POSITIVE(_SC_RE_DUP_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_STREAM_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_TZNAME_MAX);
VerifySysconf(_SC_XOPEN_VERSION, "_SC_XOPEN_VERSION", [](long v){return v == _XOPEN_VERSION;});
VERIFY_SYSCONF_POSITIVE(_SC_ATEXIT_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_IOV_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_PAGESIZE);
VERIFY_SYSCONF_POSITIVE(_SC_PAGE_SIZE);
VERIFY_SYSCONF_POSITIVE(_SC_XOPEN_UNIX);
VERIFY_SYSCONF_POSITIVE(_SC_AIO_LISTIO_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_AIO_MAX);
VerifySysconf(_SC_AIO_PRIO_DELTA_MAX, "_SC_AIO_PRIO_DELTA_MAX", [](long v){return v >= 0;});
VERIFY_SYSCONF_POSITIVE(_SC_DELAYTIMER_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_MQ_OPEN_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_MQ_PRIO_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_RTSIG_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_SEM_NSEMS_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_SEM_VALUE_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_TIMER_MAX);
VERIFY_SYSCONF_POSIX_VERSION(_SC_FSYNC);
VERIFY_SYSCONF_POSIX_VERSION(_SC_MAPPED_FILES);
VERIFY_SYSCONF_POSIX_VERSION(_SC_MEMLOCK);
VERIFY_SYSCONF_POSIX_VERSION(_SC_MEMLOCK_RANGE);
VERIFY_SYSCONF_POSIX_VERSION(_SC_MEMORY_PROTECTION);
VERIFY_SYSCONF_POSIX_VERSION(_SC_PRIORITY_SCHEDULING);
VERIFY_SYSCONF_POSIX_VERSION(_SC_SEMAPHORES);
VERIFY_SYSCONF_POSIX_VERSION(_SC_SYNCHRONIZED_IO);
VERIFY_SYSCONF_POSIX_VERSION(_SC_TIMERS);
VERIFY_SYSCONF_POSITIVE(_SC_GETGR_R_SIZE_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_GETPW_R_SIZE_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_LOGIN_NAME_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_THREAD_DESTRUCTOR_ITERATIONS);
VERIFY_SYSCONF_POSITIVE(_SC_THREAD_KEYS_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_THREAD_STACK_MIN);
VERIFY_SYSCONF_POSITIVE(_SC_THREAD_THREADS_MAX);
VERIFY_SYSCONF_POSITIVE(_SC_TTY_NAME_MAX);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREADS);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_ATTR_STACKADDR);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_ATTR_STACKSIZE);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_PRIORITY_SCHEDULING);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_PRIO_INHERIT);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_PRIO_PROTECT);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_SAFE_FUNCTIONS);
VERIFY_SYSCONF_POSITIVE(_SC_NPROCESSORS_CONF);
VERIFY_SYSCONF_POSITIVE(_SC_NPROCESSORS_ONLN);
VERIFY_SYSCONF_POSITIVE(_SC_PHYS_PAGES);
VERIFY_SYSCONF_POSITIVE(_SC_AVPHYS_PAGES);
VERIFY_SYSCONF_POSIX_VERSION(_SC_MONOTONIC_CLOCK);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_ACCOUNTING);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_CHECKPOINT);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_LOCATE);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_MESSAGE);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_PBS_TRACK);
VERIFY_SYSCONF_POSIX_VERSION(_SC_CLOCK_SELECTION);
VERIFY_SYSCONF_POSITIVE(_SC_HOST_NAME_MAX);
VERIFY_SYSCONF_POSIX_VERSION(_SC_IPV6);
VERIFY_SYSCONF_POSIX_VERSION(_SC_RAW_SOCKETS);
VERIFY_SYSCONF_POSIX_VERSION(_SC_READER_WRITER_LOCKS);
VERIFY_SYSCONF_POSITIVE(_SC_REGEXP);
VERIFY_SYSCONF_POSITIVE(_SC_SHELL);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_SPORADIC_SERVER);
VERIFY_SYSCONF_POSITIVE(_SC_SYMLOOP_MAX);
VERIFY_SYSCONF_POSIX_VERSION(_SC_THREAD_CPUTIME);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_SPORADIC_SERVER);
VERIFY_SYSCONF_POSIX_VERSION(_SC_TIMEOUTS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_EVENT_FILTER);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_EVENT_NAME_MAX);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_INHERIT);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_LOG);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_NAME_MAX);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_SYS_MAX);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TRACE_USER_EVENT_MAX);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_TYPED_MEMORY_OBJECTS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_STREAMS);
verifySysconf(_SC_MONOTONIC_CLOCK, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_ARG_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_CHILD_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_CLK_TCK, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_LINE_MAX, ret);
ASSERT_GT(ret, 1);
verifySysconf(_SC_NGROUPS_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_OPEN_MAX, ret);
ASSERT_GT(ret, 1);
verifySysconf(_SC_2_C_BIND, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_2_C_VERSION, ret);
verifySysconf(_SC_JOB_CONTROL, ret);
ASSERT_EQ(1, ret);
verifySysconf(_SC_SAVED_IDS, ret);
ASSERT_EQ(1, ret);
verifySysconf(_SC_VERSION, ret);
verifySysconf(_SC_RE_DUP_MAX, ret);
verifySysconf(_SC_STREAM_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_TZNAME_MAX, ret);
verifySysconf(_SC_XOPEN_VERSION, ret);
verifySysconf(_SC_ATEXIT_MAX, ret);
ASSERT_GT(ret, 1);
verifySysconf(_SC_IOV_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_PAGESIZE, ret);
ASSERT_GE(ret, 1);
verifySysconf(_SC_PAGE_SIZE, ret);
ASSERT_GE(ret, 1);
verifySysconf(_SC_XOPEN_UNIX, ret);
verifySysconf(_SC_DELAYTIMER_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_MQ_OPEN_MAX, ret);
verifySysconf(_SC_MQ_PRIO_MAX, ret);
ASSERT_GT(ret ,0);
verifySysconf(_SC_RTSIG_MAX, ret);
verifySysconf(_SC_SEM_NSEMS_MAX, ret);
verifySysconf(_SC_SEM_VALUE_MAX, ret);
verifySysconf(_SC_SIGQUEUE_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_TIMER_MAX, ret);
verifySysconf(_SC_FSYNC, ret);
verifySysconf(_SC_MAPPED_FILES, ret);
verifySysconf(_SC_PRIORITY_SCHEDULING, ret);
verifySysconf(_SC_SEMAPHORES, ret);
verifySysconf(_SC_SYNCHRONIZED_IO, ret);
verifySysconf(_SC_TIMERS, ret);
verifySysconf(_SC_GETGR_R_SIZE_MAX, ret);
verifySysconf(_SC_GETPW_R_SIZE_MAX, ret);
verifySysconf(_SC_LOGIN_NAME_MAX, ret);
verifySysconf(_SC_THREAD_DESTRUCTOR_ITERATIONS, ret);
verifySysconf(_SC_THREAD_KEYS_MAX, ret);
verifySysconf(_SC_THREAD_STACK_MIN, ret);
verifySysconf(_SC_THREAD_THREADS_MAX, ret);
verifySysconf(_SC_TTY_NAME_MAX, ret);
ASSERT_GT(ret, 0);
verifySysconf(_SC_THREADS, ret);
verifySysconf(_SC_THREAD_PRIO_INHERIT, ret);
verifySysconf(_SC_THREAD_PRIO_PROTECT, ret);
verifySysconf(_SC_NPROCESSORS_CONF, ret);
verifySysconf(_SC_NPROCESSORS_ONLN, ret);
verifySysconf(_SC_PHYS_PAGES, ret);
verifySysconf(_SC_AVPHYS_PAGES, ret);
#if defined(__LP64__)
VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_ILP32_OFF32);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_ILP32_OFFBIG);
VERIFY_SYSCONF_POSITIVE(_SC_V7_LP64_OFF64);
VERIFY_SYSCONF_POSITIVE(_SC_V7_LPBIG_OFFBIG);
#else
VERIFY_SYSCONF_POSITIVE(_SC_V7_ILP32_OFF32);
#if defined(__BIONIC__)
// bionic does not support 64 bits off_t type on 32bit machine.
VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_ILP32_OFFBIG);
#endif
VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_LP64_OFF64);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_V7_LPBIG_OFFBIG);
#endif
// TODO: keep following names check here
// so that we can enable them when the error fixed
#if defined(__BIONIC__)
// Tests can only run on bionic, as bionic and glibc have different support for these options.
// Below options are not supported on bionic yet.
VERIFY_SYSCONF_NOT_SUPPORT(_SC_ADVISORY_INFO);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_ASYNCHRONOUS_IO);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_BARRIERS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_CPUTIME);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_MESSAGE_PASSING);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_PRIORITIZED_IO);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_REALTIME_SIGNALS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_SHARED_MEMORY_OBJECTS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_SPAWN);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_SPIN_LOCKS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_PROCESS_SHARED);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_ROBUST_PRIO_INHERIT);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_THREAD_ROBUST_PRIO_PROTECT);
/* when call sysconf with following name,
the system call will report error "Function not implemented"
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_C_DEV);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_CHAR_TERM);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_LOCALEDEF);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_SW_DEV);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_2_VERSION);
verifySysconf(_SC_BC_BASE_MAX, ret);
verifySysconf(_SC_BC_DIM_MAX, ret);
verifySysconf(_SC_BC_SCALE_MAX, ret);
verifySysconf(_SC_BC_STRING_MAX, ret);
verifySysconf(_SC_COLL_WEIGHTS_MAX, ret);
verifySysconf(_SC_EXPR_NEST_MAX, ret);
verifySysconf(_SC_XOPEN_SHM, ret);
verifySysconf(_SC_XBS5_ILP32_OFF32, ret);
verifySysconf(_SC_XBS5_ILP32_OFFBIG, ret);
verifySysconf(_SC_XBS5_LP64_OFF64, ret);
verifySysconf(_SC_XBS5_LPBIG_OFFBIG, ret);
verifySysconf(_SC_AIO_LISTIO_MAX, ret);
verifySysconf(_SC_AIO_MAX, ret);
verifySysconf(_SC_AIO_PRIO_DELTA_MAX, ret);
verifySysconf(_SC_ASYNCHRONOUS_IO, ret);
verifySysconf(_SC_MEMLOCK, ret);
verifySysconf(_SC_MEMLOCK_RANGE, ret);
verifySysconf(_SC_MEMORY_PROTECTION, ret);
verifySysconf(_SC_MESSAGE_PASSING, ret);
verifySysconf(_SC_PRIORITIZED_IO, ret);
verifySysconf(_SC_SHARED_MEMORY_OBJECTS, ret);
verifySysconf(_SC_THREAD_SAFE_FUNCTIONS, ret);
*/
/* when following names are checked,
the return value of sysconf is -1,
which means following name are invalid.
verifySysconf(_SC_2_C_DEV, ret);
verifySysconf(_SC_2_FORT_DEV, ret);
verifySysconf(_SC_2_FORT_RUN, ret);
verifySysconf(_SC_2_LOCALEDEF, ret);
verifySysconf(_SC_2_SW_DEV, ret);
verifySysconf(_SC_2_UPE, ret);
verifySysconf(_SC_2_VERSION, ret);
verifySysconf(_SC_XOPEN_CRYPT, ret);
verifySysconf(_SC_XOPEN_ENH_I18N, ret);
verifySysconf(_SC_XOPEN_XCU_VERSION, ret);
verifySysconf(_SC_XOPEN_REALTIME, ret);
verifySysconf(_SC_XOPEN_REALTIME_THREADS, ret);
verifySysconf(_SC_XOPEN_LEGACY, ret);
verifySysconf(_SC_THREAD_ATTR_STACKADDR, ret);
verifySysconf(_SC_THREAD_ATTR_STACKSIZE, ret);
verifySysconf(_SC_REALTIME_SIGNALS, ret);
*/
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_CRYPT);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_ENH_I18N);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_LEGACY);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_REALTIME);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_REALTIME_THREADS);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_SHM);
VERIFY_SYSCONF_NOT_SUPPORT(_SC_XOPEN_UUCP);
#endif // defined(__BIONIC__)
}