diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-10-05 18:07:15 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-10-05 18:07:15 -0700 |
commit | c78555838110764860ea1684eb8dccc406a4dcb0 (patch) | |
tree | 2991d5b081dd9ee1479c538ab5da955aef94de19 | |
parent | 850affffaff1e4cbf1df771da498bd6494d704ff (diff) |
fix test_sysconf
-rw-r--r-- | src/library.js | 245 | ||||
-rw-r--r-- | system/include/libc/sys/unistd.h | 2 |
2 files changed, 123 insertions, 124 deletions
diff --git a/src/library.js b/src/library.js index 9b48a1a2..c164e767 100644 --- a/src/library.js +++ b/src/library.js @@ -1958,140 +1958,137 @@ LibraryManager.library = { sysconf: function(name) { // long sysconf(int name); // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html - // WARNING: Except for PAGE_SIZE, this is generated by a C program using - // glibc. All the constants depend on values provided by glibc, and - // code compiled with other C libraries is not guaranteed to work. switch(name) { - case 30: return PAGE_SIZE; // _SC_PAGE_SIZE / _SC_PAGESIZE - case 132: // _SC_ADVISORY_INFO - case 133: // _SC_BARRIERS - case 12: // _SC_ASYNCHRONOUS_IO - case 137: // _SC_CLOCK_SELECTION - case 138: // _SC_CPUTIME - case 15: // _SC_FSYNC - case 235: // _SC_IPV6 - case 16: // _SC_MAPPED_FILES - case 17: // _SC_MEMLOCK - case 18: // _SC_MEMLOCK_RANGE - case 19: // _SC_MEMORY_PROTECTION - case 20: // _SC_MESSAGE_PASSING - case 149: // _SC_MONOTONIC_CLOCK - case 13: // _SC_PRIORITIZED_IO - case 10: // _SC_PRIORITY_SCHEDULING - case 236: // _SC_RAW_SOCKETS - case 153: // _SC_READER_WRITER_LOCKS - case 9: // _SC_REALTIME_SIGNALS - case 21: // _SC_SEMAPHORES - case 22: // _SC_SHARED_MEMORY_OBJECTS - case 159: // _SC_SPAWN - case 154: // _SC_SPIN_LOCKS - case 14: // _SC_SYNCHRONIZED_IO - case 77: // _SC_THREAD_ATTR_STACKADDR - case 78: // _SC_THREAD_ATTR_STACKSIZE - case 139: // _SC_THREAD_CPUTIME - case 80: // _SC_THREAD_PRIO_INHERIT - case 81: // _SC_THREAD_PRIO_PROTECT - case 79: // _SC_THREAD_PRIORITY_SCHEDULING - case 82: // _SC_THREAD_PROCESS_SHARED - case 68: // _SC_THREAD_SAFE_FUNCTIONS - case 67: // _SC_THREADS - case 164: // _SC_TIMEOUTS - case 11: // _SC_TIMERS - case 29: // _SC_VERSION - case 47: // _SC_2_C_BIND - case 48: // _SC_2_C_DEV - case 95: // _SC_2_CHAR_TERM - case 52: // _SC_2_LOCALEDEF - case 51: // _SC_2_SW_DEV - case 46: // _SC_2_VERSION + case {{{ cDefine('_SC_PAGE_SIZE') }}}: return PAGE_SIZE; + case {{{ cDefine('_SC_ADVISORY_INFO') }}}: + case {{{ cDefine('_SC_BARRIERS') }}}: + case {{{ cDefine('_SC_ASYNCHRONOUS_IO') }}}: + case {{{ cDefine('_SC_CLOCK_SELECTION') }}}: + case {{{ cDefine('_SC_CPUTIME') }}}: + case {{{ cDefine('_SC_FSYNC') }}}: + case {{{ cDefine('_SC_IPV6') }}}: + case {{{ cDefine('_SC_MAPPED_FILES') }}}: + case {{{ cDefine('_SC_MEMLOCK') }}}: + case {{{ cDefine('_SC_MEMLOCK_RANGE') }}}: + case {{{ cDefine('_SC_MEMORY_PROTECTION') }}}: + case {{{ cDefine('_SC_MESSAGE_PASSING') }}}: + case {{{ cDefine('_SC_MONOTONIC_CLOCK') }}}: + case {{{ cDefine('_SC_PRIORITIZED_IO') }}}: + case {{{ cDefine('_SC_PRIORITY_SCHEDULING') }}}: + case {{{ cDefine('_SC_RAW_SOCKETS') }}}: + case {{{ cDefine('_SC_READER_WRITER_LOCKS') }}}: + case {{{ cDefine('_SC_REALTIME_SIGNALS') }}}: + case {{{ cDefine('_SC_SEMAPHORES') }}}: + case {{{ cDefine('_SC_SHARED_MEMORY_OBJECTS') }}}: + case {{{ cDefine('_SC_SPAWN') }}}: + case {{{ cDefine('_SC_SPIN_LOCKS') }}}: + case {{{ cDefine('_SC_SYNCHRONIZED_IO') }}}: + case {{{ cDefine('_SC_THREAD_ATTR_STACKADDR') }}}: + case {{{ cDefine('_SC_THREAD_ATTR_STACKSIZE') }}}: + case {{{ cDefine('_SC_THREAD_CPUTIME') }}}: + case {{{ cDefine('_SC_THREAD_PRIO_INHERIT') }}}: + case {{{ cDefine('_SC_THREAD_PRIO_PROTECT') }}}: + case {{{ cDefine('_SC_THREAD_PRIORITY_SCHEDULING') }}}: + case {{{ cDefine('_SC_THREAD_PROCESS_SHARED') }}}: + case {{{ cDefine('_SC_THREAD_SAFE_FUNCTIONS') }}}: + case {{{ cDefine('_SC_THREADS') }}}: + case {{{ cDefine('_SC_TIMEOUTS') }}}: + case {{{ cDefine('_SC_TIMERS') }}}: + case {{{ cDefine('_SC_VERSION') }}}: + case {{{ cDefine('_SC_2_C_BIND') }}}: + case {{{ cDefine('_SC_2_C_DEV') }}}: + case {{{ cDefine('_SC_2_CHAR_TERM') }}}: + case {{{ cDefine('_SC_2_LOCALEDEF') }}}: + case {{{ cDefine('_SC_2_SW_DEV') }}}: + case {{{ cDefine('_SC_2_VERSION') }}}: return 200809; - case 27: // _SC_MQ_OPEN_MAX - case 246: // _SC_XOPEN_STREAMS - case 127: // _SC_XBS5_LP64_OFF64 - case 128: // _SC_XBS5_LPBIG_OFFBIG - case 23: // _SC_AIO_LISTIO_MAX - case 24: // _SC_AIO_MAX - case 160: // _SC_SPORADIC_SERVER - case 161: // _SC_THREAD_SPORADIC_SERVER - case 181: // _SC_TRACE - case 182: // _SC_TRACE_EVENT_FILTER - case 242: // _SC_TRACE_EVENT_NAME_MAX - case 183: // _SC_TRACE_INHERIT - case 184: // _SC_TRACE_LOG - case 243: // _SC_TRACE_NAME_MAX - case 244: // _SC_TRACE_SYS_MAX - case 245: // _SC_TRACE_USER_EVENT_MAX - case 165: // _SC_TYPED_MEMORY_OBJECTS - case 178: // _SC_V6_LP64_OFF64 - case 179: // _SC_V6_LPBIG_OFFBIG - case 49: // _SC_2_FORT_DEV - case 50: // _SC_2_FORT_RUN - case 168: // _SC_2_PBS - case 169: // _SC_2_PBS_ACCOUNTING - case 175: // _SC_2_PBS_CHECKPOINT - case 170: // _SC_2_PBS_LOCATE - case 171: // _SC_2_PBS_MESSAGE - case 172: // _SC_2_PBS_TRACK - case 97: // _SC_2_UPE - case 76: // _SC_THREAD_THREADS_MAX - case 32: // _SC_SEM_NSEMS_MAX - case 173: // _SC_SYMLOOP_MAX - case 35: // _SC_TIMER_MAX + case {{{ cDefine('_SC_MQ_OPEN_MAX') }}}: + case {{{ cDefine('_SC_XOPEN_STREAMS') }}}: + case {{{ cDefine('_SC_XBS5_LP64_OFF64') }}}: + case {{{ cDefine('_SC_XBS5_LPBIG_OFFBIG') }}}: + case {{{ cDefine('_SC_AIO_LISTIO_MAX') }}}: + case {{{ cDefine('_SC_AIO_MAX') }}}: + case {{{ cDefine('_SC_SPORADIC_SERVER') }}}: + case {{{ cDefine('_SC_THREAD_SPORADIC_SERVER') }}}: + case {{{ cDefine('_SC_TRACE') }}}: + case {{{ cDefine('_SC_TRACE_EVENT_FILTER') }}}: + case {{{ cDefine('_SC_TRACE_EVENT_NAME_MAX') }}}: + case {{{ cDefine('_SC_TRACE_INHERIT') }}}: + case {{{ cDefine('_SC_TRACE_LOG') }}}: + case {{{ cDefine('_SC_TRACE_NAME_MAX') }}}: + case {{{ cDefine('_SC_TRACE_SYS_MAX') }}}: + case {{{ cDefine('_SC_TRACE_USER_EVENT_MAX') }}}: + case {{{ cDefine('_SC_TYPED_MEMORY_OBJECTS') }}}: + case {{{ cDefine('_SC_V6_LP64_OFF64') }}}: + case {{{ cDefine('_SC_V6_LPBIG_OFFBIG') }}}: + case {{{ cDefine('_SC_2_FORT_DEV') }}}: + case {{{ cDefine('_SC_2_FORT_RUN') }}}: + case {{{ cDefine('_SC_2_PBS') }}}: + case {{{ cDefine('_SC_2_PBS_ACCOUNTING') }}}: + case {{{ cDefine('_SC_2_PBS_CHECKPOINT') }}}: + case {{{ cDefine('_SC_2_PBS_LOCATE') }}}: + case {{{ cDefine('_SC_2_PBS_MESSAGE') }}}: + case {{{ cDefine('_SC_2_PBS_TRACK') }}}: + case {{{ cDefine('_SC_2_UPE') }}}: + case {{{ cDefine('_SC_THREAD_THREADS_MAX') }}}: + case {{{ cDefine('_SC_SEM_NSEMS_MAX') }}}: + case {{{ cDefine('_SC_SYMLOOP_MAX') }}}: + case {{{ cDefine('_SC_TIMER_MAX') }}}: return -1; - case 176: // _SC_V6_ILP32_OFF32 - case 177: // _SC_V6_ILP32_OFFBIG - case 7: // _SC_JOB_CONTROL - case 155: // _SC_REGEXP - case 8: // _SC_SAVED_IDS - case 157: // _SC_SHELL - case 125: // _SC_XBS5_ILP32_OFF32 - case 126: // _SC_XBS5_ILP32_OFFBIG - case 92: // _SC_XOPEN_CRYPT - case 93: // _SC_XOPEN_ENH_I18N - case 129: // _SC_XOPEN_LEGACY - case 130: // _SC_XOPEN_REALTIME - case 131: // _SC_XOPEN_REALTIME_THREADS - case 94: // _SC_XOPEN_SHM - case 91: // _SC_XOPEN_UNIX + case {{{ cDefine('_SC_V6_ILP32_OFF32') }}}: + case {{{ cDefine('_SC_V6_ILP32_OFFBIG') }}}: + case {{{ cDefine('_SC_JOB_CONTROL') }}}: + case {{{ cDefine('_SC_REGEXP') }}}: + case {{{ cDefine('_SC_SAVED_IDS') }}}: + case {{{ cDefine('_SC_SHELL') }}}: + case {{{ cDefine('_SC_XBS5_ILP32_OFF32') }}}: + case {{{ cDefine('_SC_XBS5_ILP32_OFFBIG') }}}: + case {{{ cDefine('_SC_XOPEN_CRYPT') }}}: + case {{{ cDefine('_SC_XOPEN_ENH_I18N') }}}: + case {{{ cDefine('_SC_XOPEN_LEGACY') }}}: + case {{{ cDefine('_SC_XOPEN_REALTIME') }}}: + case {{{ cDefine('_SC_XOPEN_REALTIME_THREADS') }}}: + case {{{ cDefine('_SC_XOPEN_SHM') }}}: + case {{{ cDefine('_SC_XOPEN_UNIX') }}}: return 1; - case 74: // _SC_THREAD_KEYS_MAX - case 60: // _SC_IOV_MAX - case 69: // _SC_GETGR_R_SIZE_MAX - case 70: // _SC_GETPW_R_SIZE_MAX - case 4: // _SC_OPEN_MAX + case {{{ cDefine('_SC_THREAD_KEYS_MAX') }}}: + case {{{ cDefine('_SC_IOV_MAX') }}}: + case {{{ cDefine('_SC_GETGR_R_SIZE_MAX') }}}: + case {{{ cDefine('_SC_GETPW_R_SIZE_MAX') }}}: + case {{{ cDefine('_SC_OPEN_MAX') }}}: return 1024; - case 31: // _SC_RTSIG_MAX - case 42: // _SC_EXPR_NEST_MAX - case 72: // _SC_TTY_NAME_MAX + case {{{ cDefine('_SC_RTSIG_MAX') }}}: + case {{{ cDefine('_SC_EXPR_NEST_MAX') }}}: + case {{{ cDefine('_SC_TTY_NAME_MAX') }}}: return 32; - case 87: // _SC_ATEXIT_MAX - case 26: // _SC_DELAYTIMER_MAX - case 33: // _SC_SEM_VALUE_MAX + case {{{ cDefine('_SC_ATEXIT_MAX') }}}: + case {{{ cDefine('_SC_DELAYTIMER_MAX') }}}: + case {{{ cDefine('_SC_SEM_VALUE_MAX') }}}: return 2147483647; - case 34: // _SC_SIGQUEUE_MAX - case 1: // _SC_CHILD_MAX + case {{{ cDefine('_SC_SIGQUEUE_MAX') }}}: + case {{{ cDefine('_SC_CHILD_MAX') }}}: return 47839; - case 38: // _SC_BC_SCALE_MAX - case 36: // _SC_BC_BASE_MAX + case {{{ cDefine('_SC_BC_SCALE_MAX') }}}: + case {{{ cDefine('_SC_BC_BASE_MAX') }}}: return 99; - case 43: // _SC_LINE_MAX - case 37: // _SC_BC_DIM_MAX + case {{{ cDefine('_SC_LINE_MAX') }}}: + case {{{ cDefine('_SC_BC_DIM_MAX') }}}: return 2048; - case 0: return 2097152; // _SC_ARG_MAX - case 3: return 65536; // _SC_NGROUPS_MAX - case 28: return 32768; // _SC_MQ_PRIO_MAX - case 44: return 32767; // _SC_RE_DUP_MAX - case 75: return 16384; // _SC_THREAD_STACK_MIN - case 39: return 1000; // _SC_BC_STRING_MAX - case 89: return 700; // _SC_XOPEN_VERSION - case 71: return 256; // _SC_LOGIN_NAME_MAX - case 40: return 255; // _SC_COLL_WEIGHTS_MAX - case 2: return 100; // _SC_CLK_TCK - case 180: return 64; // _SC_HOST_NAME_MAX - case 25: return 20; // _SC_AIO_PRIO_DELTA_MAX - case 5: return 16; // _SC_STREAM_MAX - case 6: return 6; // _SC_TZNAME_MAX - case 73: return 4; // _SC_THREAD_DESTRUCTOR_ITERATIONS + case {{{ cDefine('_SC_ARG_MAX') }}}: return 2097152; + case {{{ cDefine('_SC_NGROUPS_MAX') }}}: return 65536; + case {{{ cDefine('_SC_MQ_PRIO_MAX') }}}: return 32768; + case {{{ cDefine('_SC_RE_DUP_MAX') }}}: return 32767; + case {{{ cDefine('_SC_THREAD_STACK_MIN') }}}: return 16384; + case {{{ cDefine('_SC_BC_STRING_MAX') }}}: return 1000; + case {{{ cDefine('_SC_XOPEN_VERSION') }}}: return 700; + case {{{ cDefine('_SC_LOGIN_NAME_MAX') }}}: return 256; + case {{{ cDefine('_SC_COLL_WEIGHTS_MAX') }}}: return 255; + case {{{ cDefine('_SC_CLK_TCK') }}}: return 100; + case {{{ cDefine('_SC_HOST_NAME_MAX') }}}: return 64; + case {{{ cDefine('_SC_AIO_PRIO_DELTA_MAX') }}}: return 20; + case {{{ cDefine('_SC_STREAM_MAX') }}}: return 16; + case {{{ cDefine('_SC_TZNAME_MAX') }}}: return 6; + case {{{ cDefine('_SC_THREAD_DESTRUCTOR_ITERATIONS') }}}: return 4; } ___setErrNo(ERRNO_CODES.EINVAL); return -1; diff --git a/system/include/libc/sys/unistd.h b/system/include/libc/sys/unistd.h index a285d8d1..57be7421 100644 --- a/system/include/libc/sys/unistd.h +++ b/system/include/libc/sys/unistd.h @@ -406,6 +406,8 @@ int _EXFUN(unlinkat, (int, const char *, int)); #define _SC_THREAD_ROBUST_PRIO_INHERIT 122 #define _SC_THREAD_ROBUST_PRIO_PROTECT 123 #define _SC_XOPEN_UUCP 124 +/* XXX Emscripten */ +#define _SC_SHARED_MEMORY_OBJECTS 199 /* * pathconf values per IEEE Std 1003.1, 2008 Edition |