Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in |
| 12 | * the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | * SUCH DAMAGE. |
| 27 | */ |
| 28 | |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 29 | #include <errno.h> |
| 30 | #include <fcntl.h> |
| 31 | #include <limits.h> |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 32 | #include <linux/uio.h> // For UIO_MAXIOV. |
Elliott Hughes | c03e1e7 | 2013-07-29 16:51:45 -0700 | [diff] [blame] | 33 | #include <pthread.h> |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 34 | #include <stdio.h> // For FOPEN_MAX. |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 35 | #include <sys/auxv.h> |
Elliott Hughes | be6a445 | 2015-02-17 09:55:58 -0800 | [diff] [blame^] | 36 | #include <sys/resource.h> |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 37 | #include <sys/sysconf.h> |
Yabin Cui | 9d93986 | 2014-11-14 15:51:58 -0800 | [diff] [blame] | 38 | #include <sys/sysinfo.h> |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 39 | #include <time.h> |
| 40 | #include <unistd.h> |
| 41 | |
Elliott Hughes | eb847bc | 2013-10-09 15:50:50 -0700 | [diff] [blame] | 42 | #include "private/bionic_tls.h" |
Elliott Hughes | 701bec2 | 2013-02-25 13:14:31 -0800 | [diff] [blame] | 43 | |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 44 | static int __sysconf_monotonic_clock() { |
| 45 | timespec t; |
| 46 | int rc = clock_getres(CLOCK_MONOTONIC, &t); |
| 47 | return (rc == -1) ? -1 : _POSIX_VERSION; |
| 48 | } |
| 49 | |
Yabin Cui | 7257560 | 2014-12-08 11:54:12 -0800 | [diff] [blame] | 50 | static bool __sysconf_has_clock(clockid_t clock_id) { |
| 51 | return clock_getres(clock_id, NULL) == 0; |
| 52 | } |
| 53 | |
Elliott Hughes | be6a445 | 2015-02-17 09:55:58 -0800 | [diff] [blame^] | 54 | static long __sysconf_rlimit(int resource) { |
| 55 | rlimit rl; |
| 56 | getrlimit(resource, &rl); |
| 57 | return rl.rlim_cur; |
| 58 | } |
| 59 | |
Elliott Hughes | 60d84af | 2014-11-14 15:14:44 -0800 | [diff] [blame] | 60 | long sysconf(int name) { |
Elliott Hughes | 04303f5 | 2014-09-18 16:11:59 -0700 | [diff] [blame] | 61 | switch (name) { |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 62 | case _SC_ARG_MAX: return ARG_MAX; |
| 63 | case _SC_BC_BASE_MAX: return _POSIX2_BC_BASE_MAX; // Minimum requirement. |
| 64 | case _SC_BC_DIM_MAX: return _POSIX2_BC_DIM_MAX; // Minimum requirement. |
| 65 | case _SC_BC_SCALE_MAX: return _POSIX2_BC_SCALE_MAX; // Minimum requirement. |
| 66 | case _SC_BC_STRING_MAX: return _POSIX2_BC_STRING_MAX; // Minimum requirement. |
Elliott Hughes | be6a445 | 2015-02-17 09:55:58 -0800 | [diff] [blame^] | 67 | case _SC_CHILD_MAX: return __sysconf_rlimit(RLIMIT_NPROC); |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 68 | case _SC_CLK_TCK: return static_cast<long>(getauxval(AT_CLKTCK)); |
| 69 | case _SC_COLL_WEIGHTS_MAX: return _POSIX2_COLL_WEIGHTS_MAX; // Minimum requirement. |
| 70 | case _SC_EXPR_NEST_MAX: return _POSIX2_EXPR_NEST_MAX; // Minimum requirement. |
| 71 | case _SC_LINE_MAX: return _POSIX2_LINE_MAX; // Minimum requirement. |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 72 | case _SC_NGROUPS_MAX: return NGROUPS_MAX; |
Elliott Hughes | be6a445 | 2015-02-17 09:55:58 -0800 | [diff] [blame^] | 73 | case _SC_OPEN_MAX: return __sysconf_rlimit(RLIMIT_NOFILE); |
Elliott Hughes | a186b2e | 2014-09-22 14:49:07 -0700 | [diff] [blame] | 74 | case _SC_PASS_MAX: return PASS_MAX; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 75 | case _SC_2_C_BIND: return _POSIX2_C_BIND; |
| 76 | case _SC_2_C_DEV: return _POSIX2_C_DEV; |
| 77 | case _SC_2_CHAR_TERM: return _POSIX2_CHAR_TERM; |
| 78 | case _SC_2_FORT_DEV: return -1; |
| 79 | case _SC_2_FORT_RUN: return -1; |
| 80 | case _SC_2_LOCALEDEF: return _POSIX2_LOCALEDEF; |
| 81 | case _SC_2_SW_DEV: return _POSIX2_SW_DEV; |
| 82 | case _SC_2_UPE: return _POSIX2_UPE; |
| 83 | case _SC_2_VERSION: return _POSIX2_VERSION; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 84 | case _SC_JOB_CONTROL: return _POSIX_JOB_CONTROL; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 85 | case _SC_SAVED_IDS: return _POSIX_SAVED_IDS; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 86 | case _SC_VERSION: return _POSIX_VERSION; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 87 | case _SC_RE_DUP_MAX: return _POSIX_RE_DUP_MAX; // Minimum requirement. |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 88 | case _SC_STREAM_MAX: return FOPEN_MAX; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 89 | case _SC_TZNAME_MAX: return _POSIX_TZNAME_MAX; // Minimum requirement. |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 90 | case _SC_XOPEN_CRYPT: return _XOPEN_CRYPT; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 91 | case _SC_XOPEN_ENH_I18N: return _XOPEN_ENH_I18N; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 92 | case _SC_XOPEN_SHM: return _XOPEN_SHM; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 93 | case _SC_XOPEN_VERSION: return _XOPEN_VERSION; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 94 | case _SC_XOPEN_REALTIME: return _XOPEN_REALTIME; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 95 | case _SC_XOPEN_REALTIME_THREADS: return _XOPEN_REALTIME_THREADS; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 96 | case _SC_XOPEN_LEGACY: return _XOPEN_LEGACY; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 97 | case _SC_ATEXIT_MAX: return LONG_MAX; // Unlimited. |
| 98 | case _SC_IOV_MAX: return UIO_MAXIOV; |
Elliott Hughes | 0e44bc3 | 2014-02-24 15:55:31 -0800 | [diff] [blame] | 99 | |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 100 | case _SC_PAGESIZE: // Fall through, PAGESIZE and PAGE_SIZE always hold the same value. |
| 101 | case _SC_PAGE_SIZE: return PAGE_SIZE; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 102 | case _SC_XOPEN_UNIX: return _XOPEN_UNIX; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 103 | case _SC_AIO_LISTIO_MAX: return _POSIX_AIO_LISTIO_MAX; // Minimum requirement. |
| 104 | case _SC_AIO_MAX: return _POSIX_AIO_MAX; // Minimum requirement. |
| 105 | case _SC_AIO_PRIO_DELTA_MAX:return 0; // Minimum requirement. |
| 106 | case _SC_DELAYTIMER_MAX: return INT_MAX; |
| 107 | case _SC_MQ_OPEN_MAX: return _POSIX_MQ_OPEN_MAX; // Minimum requirement. |
| 108 | case _SC_MQ_PRIO_MAX: return _POSIX_MQ_PRIO_MAX; // Minimum requirement. |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 109 | case _SC_RTSIG_MAX: return RTSIG_MAX; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 110 | case _SC_SEM_NSEMS_MAX: return _POSIX_SEM_NSEMS_MAX; // Minimum requirement. |
Elliott Hughes | 04303f5 | 2014-09-18 16:11:59 -0700 | [diff] [blame] | 111 | case _SC_SEM_VALUE_MAX: return SEM_VALUE_MAX; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 112 | case _SC_SIGQUEUE_MAX: return _POSIX_SIGQUEUE_MAX; // Minimum requirement. |
| 113 | case _SC_TIMER_MAX: return _POSIX_TIMER_MAX; // Minimum requirement. |
| 114 | case _SC_ASYNCHRONOUS_IO: return _POSIX_ASYNCHRONOUS_IO; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 115 | case _SC_FSYNC: return _POSIX_FSYNC; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 116 | case _SC_MAPPED_FILES: return _POSIX_MAPPED_FILES; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 117 | case _SC_MEMLOCK: return _POSIX_MEMLOCK; |
| 118 | case _SC_MEMLOCK_RANGE: return _POSIX_MEMLOCK_RANGE; |
| 119 | case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION; |
| 120 | case _SC_MESSAGE_PASSING: return _POSIX_MESSAGE_PASSING; |
| 121 | case _SC_PRIORITIZED_IO: return _POSIX_PRIORITIZED_IO; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 122 | case _SC_PRIORITY_SCHEDULING: return _POSIX_PRIORITY_SCHEDULING; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 123 | case _SC_REALTIME_SIGNALS: return _POSIX_REALTIME_SIGNALS; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 124 | case _SC_SEMAPHORES: return _POSIX_SEMAPHORES; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 125 | case _SC_SHARED_MEMORY_OBJECTS: return _POSIX_SHARED_MEMORY_OBJECTS; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 126 | case _SC_SYNCHRONIZED_IO: return _POSIX_SYNCHRONIZED_IO; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 127 | case _SC_TIMERS: return _POSIX_TIMERS; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 128 | case _SC_GETGR_R_SIZE_MAX: return 1024; |
| 129 | case _SC_GETPW_R_SIZE_MAX: return 1024; |
| 130 | case _SC_LOGIN_NAME_MAX: return 256; // Seems default on linux. |
| 131 | case _SC_THREAD_DESTRUCTOR_ITERATIONS: return PTHREAD_DESTRUCTOR_ITERATIONS; |
| 132 | case _SC_THREAD_KEYS_MAX: return PTHREAD_KEYS_MAX; |
Elliott Hughes | c03e1e7 | 2013-07-29 16:51:45 -0700 | [diff] [blame] | 133 | case _SC_THREAD_STACK_MIN: return PTHREAD_STACK_MIN; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 134 | case _SC_THREAD_THREADS_MAX: return PTHREAD_THREADS_MAX; |
| 135 | case _SC_TTY_NAME_MAX: return 32; // Seems default on linux. |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 136 | case _SC_THREADS: return _POSIX_THREADS; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 137 | case _SC_THREAD_ATTR_STACKADDR: return _POSIX_THREAD_ATTR_STACKADDR; |
| 138 | case _SC_THREAD_ATTR_STACKSIZE: return _POSIX_THREAD_ATTR_STACKSIZE; |
| 139 | case _SC_THREAD_PRIORITY_SCHEDULING: return _POSIX_THREAD_PRIORITY_SCHEDULING; |
| 140 | case _SC_THREAD_PRIO_INHERIT: return _POSIX_THREAD_PRIO_INHERIT; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 141 | case _SC_THREAD_PRIO_PROTECT: return _POSIX_THREAD_PRIO_PROTECT; |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 142 | case _SC_THREAD_SAFE_FUNCTIONS: return _POSIX_THREAD_SAFE_FUNCTIONS; |
Yabin Cui | 9d93986 | 2014-11-14 15:51:58 -0800 | [diff] [blame] | 143 | case _SC_NPROCESSORS_CONF: return get_nprocs_conf(); |
| 144 | case _SC_NPROCESSORS_ONLN: return get_nprocs(); |
| 145 | case _SC_PHYS_PAGES: return get_phys_pages(); |
| 146 | case _SC_AVPHYS_PAGES: return get_avphys_pages(); |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 147 | case _SC_MONOTONIC_CLOCK: return __sysconf_monotonic_clock(); |
| 148 | |
| 149 | case _SC_2_PBS: return -1; // Obsolescent in POSIX.1-2008. |
| 150 | case _SC_2_PBS_ACCOUNTING: return -1; // Obsolescent in POSIX.1-2008. |
| 151 | case _SC_2_PBS_CHECKPOINT: return -1; // Obsolescent in POSIX.1-2008. |
| 152 | case _SC_2_PBS_LOCATE: return -1; // Obsolescent in POSIX.1-2008. |
| 153 | case _SC_2_PBS_MESSAGE: return -1; // Obsolescent in POSIX.1-2008. |
| 154 | case _SC_2_PBS_TRACK: return -1; // Obsolescent in POSIX.1-2008. |
| 155 | case _SC_ADVISORY_INFO: return _POSIX_ADVISORY_INFO; |
| 156 | case _SC_BARRIERS: return _POSIX_BARRIERS; |
| 157 | case _SC_CLOCK_SELECTION: return _POSIX_CLOCK_SELECTION; |
Yabin Cui | 7257560 | 2014-12-08 11:54:12 -0800 | [diff] [blame] | 158 | case _SC_CPUTIME: |
| 159 | return __sysconf_has_clock(CLOCK_PROCESS_CPUTIME_ID) ?_POSIX_VERSION : -1; |
| 160 | |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 161 | case _SC_HOST_NAME_MAX: return _POSIX_HOST_NAME_MAX; // Minimum requirement. |
| 162 | case _SC_IPV6: return _POSIX_IPV6; |
| 163 | case _SC_RAW_SOCKETS: return _POSIX_RAW_SOCKETS; |
| 164 | case _SC_READER_WRITER_LOCKS: return _POSIX_READER_WRITER_LOCKS; |
| 165 | case _SC_REGEXP: return _POSIX_REGEXP; |
| 166 | case _SC_SHELL: return _POSIX_SHELL; |
| 167 | case _SC_SPAWN: return _POSIX_SPAWN; |
| 168 | case _SC_SPIN_LOCKS: return _POSIX_SPIN_LOCKS; |
| 169 | case _SC_SPORADIC_SERVER: return _POSIX_SPORADIC_SERVER; |
| 170 | case _SC_SS_REPL_MAX: return -1; |
| 171 | case _SC_SYMLOOP_MAX: return _POSIX_SYMLOOP_MAX; // Minimum requirement. |
Yabin Cui | 7257560 | 2014-12-08 11:54:12 -0800 | [diff] [blame] | 172 | case _SC_THREAD_CPUTIME: |
| 173 | return __sysconf_has_clock(CLOCK_THREAD_CPUTIME_ID) ? _POSIX_VERSION : -1; |
| 174 | |
Yabin Cui | 1c19194 | 2014-11-19 19:49:14 -0800 | [diff] [blame] | 175 | case _SC_THREAD_PROCESS_SHARED: return _POSIX_THREAD_PROCESS_SHARED; |
| 176 | case _SC_THREAD_ROBUST_PRIO_INHERIT: return _POSIX_THREAD_ROBUST_PRIO_INHERIT; |
| 177 | case _SC_THREAD_ROBUST_PRIO_PROTECT: return _POSIX_THREAD_ROBUST_PRIO_PROTECT; |
| 178 | case _SC_THREAD_SPORADIC_SERVER: return _POSIX_THREAD_SPORADIC_SERVER; |
| 179 | case _SC_TIMEOUTS: return _POSIX_TIMEOUTS; |
| 180 | case _SC_TRACE: return -1; // Obsolescent in POSIX.1-2008. |
| 181 | case _SC_TRACE_EVENT_FILTER: return -1; // Obsolescent in POSIX.1-2008. |
| 182 | case _SC_TRACE_EVENT_NAME_MAX: return -1; |
| 183 | case _SC_TRACE_INHERIT: return -1; // Obsolescent in POSIX.1-2008. |
| 184 | case _SC_TRACE_LOG: return -1; // Obsolescent in POSIX.1-2008. |
| 185 | case _SC_TRACE_NAME_MAX: return -1; |
| 186 | case _SC_TRACE_SYS_MAX: return -1; |
| 187 | case _SC_TRACE_USER_EVENT_MAX: return -1; |
| 188 | case _SC_TYPED_MEMORY_OBJECTS: return _POSIX_TYPED_MEMORY_OBJECTS; |
| 189 | case _SC_V7_ILP32_OFF32: return _POSIX_V7_ILP32_OFF32; |
| 190 | case _SC_V7_ILP32_OFFBIG: return _POSIX_V7_ILP32_OFFBIG; |
| 191 | case _SC_V7_LP64_OFF64: return _POSIX_V7_LP64_OFF64; |
| 192 | case _SC_V7_LPBIG_OFFBIG: return _POSIX_V7_LPBIG_OFFBIG; |
| 193 | case _SC_XOPEN_STREAMS: return -1; // Obsolescent in POSIX.1-2008. |
| 194 | case _SC_XOPEN_UUCP: return -1; |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 195 | |
Tao Bao | 1f40be9 | 2014-12-04 15:24:28 -0800 | [diff] [blame] | 196 | // We do not have actual implementations for cache queries. |
| 197 | // It's valid to return 0 as the result is unknown. |
| 198 | case _SC_LEVEL1_ICACHE_SIZE: return 0; |
| 199 | case _SC_LEVEL1_ICACHE_ASSOC: return 0; |
| 200 | case _SC_LEVEL1_ICACHE_LINESIZE: return 0; |
| 201 | case _SC_LEVEL1_DCACHE_SIZE: return 0; |
| 202 | case _SC_LEVEL1_DCACHE_ASSOC: return 0; |
| 203 | case _SC_LEVEL1_DCACHE_LINESIZE: return 0; |
| 204 | case _SC_LEVEL2_CACHE_SIZE: return 0; |
| 205 | case _SC_LEVEL2_CACHE_ASSOC: return 0; |
| 206 | case _SC_LEVEL2_CACHE_LINESIZE: return 0; |
| 207 | case _SC_LEVEL3_CACHE_SIZE: return 0; |
| 208 | case _SC_LEVEL3_CACHE_ASSOC: return 0; |
| 209 | case _SC_LEVEL3_CACHE_LINESIZE: return 0; |
| 210 | case _SC_LEVEL4_CACHE_SIZE: return 0; |
| 211 | case _SC_LEVEL4_CACHE_ASSOC: return 0; |
| 212 | case _SC_LEVEL4_CACHE_LINESIZE: return 0; |
| 213 | |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 214 | default: |
Elliott Hughes | 04303f5 | 2014-09-18 16:11:59 -0700 | [diff] [blame] | 215 | // Posix says EINVAL is the only error that shall be returned, |
| 216 | // but glibc uses ENOSYS. |
| 217 | errno = ENOSYS; |
| 218 | return -1; |
| 219 | } |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 220 | } |