1 --- sysconf.c.orig Sun Nov 17 00:54:29 2002
2 +++ sysconf.c Wed Apr 14 17:09:36 2004
4 #include <sys/sysctl.h>
5 #include <sys/resource.h>
6 #include <sys/socket.h>
8 +#include <sys/semaphore.h>
16 -#include "../stdlib/atexit.h"
17 -#include "../stdtime/tzfile.h"
21 #define _PATH_ZONEINFO TZDIR /* from tzfile.h */
27 - int mib[2], sverrno, value;
28 + int mib[3], sverrno, value;
33 return (_POSIX_TIMERS);
35 case _SC_AIO_LISTIO_MAX:
36 - mib[0] = CTL_P1003_1B;
37 - mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX;
40 - mib[0] = CTL_P1003_1B;
41 - mib[1] = CTL_P1003_1B_AIO_MAX;
43 + mib[1] = KERN_AIOMAX;
46 case _SC_AIO_PRIO_DELTA_MAX:
47 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_AIO_PRIO_DELTA_MAX)
48 mib[0] = CTL_P1003_1B;
49 mib[1] = CTL_P1003_1B_AIO_PRIO_DELTA_MAX;
54 case _SC_DELAYTIMER_MAX:
55 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_DELAYTIMER_MAX)
56 mib[0] = CTL_P1003_1B;
57 mib[1] = CTL_P1003_1B_DELAYTIMER_MAX;
63 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_MQ_OPEN_MAX)
64 mib[0] = CTL_P1003_1B;
65 mib[1] = CTL_P1003_1B_MQ_OPEN_MAX;
71 defaultresult = getpagesize();
72 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_PAGESIZE)
73 mib[0] = CTL_P1003_1B;
74 mib[1] = CTL_P1003_1B_PAGESIZE;
77 + return defaultresult;
80 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_RTSIG_MAX)
81 mib[0] = CTL_P1003_1B;
82 mib[1] = CTL_P1003_1B_RTSIG_MAX;
87 case _SC_SEM_NSEMS_MAX:
88 - mib[0] = CTL_P1003_1B;
89 - mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX;
93 + mib[2] = KSYSV_SEMMNS;
94 + return (sysctl(mib, 3, &value, &len, NULL, 0) == -1 ? -1 : value);
96 case _SC_SEM_VALUE_MAX:
97 +#if SEM_VALUE_MAX == 0
98 mib[0] = CTL_P1003_1B;
99 mib[1] = CTL_P1003_1B_SEM_VALUE_MAX;
102 + return (SEM_VALUE_MAX);
104 case _SC_SIGQUEUE_MAX:
105 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_SIGQUEUE_MAX)
106 mib[0] = CTL_P1003_1B;
107 mib[1] = CTL_P1003_1B_SIGQUEUE_MAX;
113 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_TIMER_MAX)
114 mib[0] = CTL_P1003_1B;
115 mib[1] = CTL_P1003_1B_TIMER_MAX;
120 yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
123 return (defaultresult);
127 case _SC_2_PBS_ACCOUNTING:
128 case _SC_2_PBS_CHECKPOINT:
129 case _SC_2_PBS_LOCATE:
130 case _SC_2_PBS_MESSAGE:
131 case _SC_2_PBS_TRACK:
132 -#if _POSIX2_PBS == 0
133 -#error "don't know how to determine _SC_2_PBS"
135 - * This probably requires digging through the filesystem
136 - * to see if the appropriate package has been installed.
137 - * Since we don't currently support this option at all,
138 - * it's not worth the effort to write the code now.
139 - * Figuring out which of the sub-options are supported
140 - * would be even more difficult, so it's probably easier
141 - * to always say ``no''.
144 - return (_POSIX2_PBS);
147 case _SC_ADVISORY_INFO:
148 #if _POSIX_ADVISORY_INFO == 0
149 #error "_POSIX_ADVISORY_INFO"
150 @@ -348,18 +368,10 @@
152 return (_POSIX_CPUTIME);
155 case _SC_FILE_LOCKING:
157 - * XXX - The standard doesn't tell us how to define
158 - * _POSIX_FILE_LOCKING, so we can't answer this one.
161 -#if _POSIX_THREAD_SAFE_FUNCTIONS > -1
162 case _SC_GETGR_R_SIZE_MAX:
163 case _SC_GETPW_R_SIZE_MAX:
164 -#error "somebody needs to implement this"
167 case _SC_HOST_NAME_MAX:
168 return (MAXHOSTNAMELEN - 1); /* does not include \0 */
169 case _SC_LOGIN_NAME_MAX:
172 return (_POSIX_MONOTONIC_CLOCK);
174 -#if _POSIX_MESSAGE_PASSING > -1
175 case _SC_MQ_PRIO_MAX:
176 - return (MQ_PRIO_MAX);
179 case _SC_READER_WRITER_LOCKS:
180 return (_POSIX_READER_WRITER_LOCKS);
183 case _SC_THREAD_STACK_MIN:
184 return (PTHREAD_STACK_MIN);
185 case _SC_THREAD_THREADS_MAX:
186 +#ifdef PTHREAD_THREADS_MAX
187 return (PTHREAD_THREADS_MAX); /* XXX wrong type! */
192 return (_POSIX_TIMEOUTS);
196 return (ATEXIT_SIZE);
200 mib[1] = KERN_IOV_MAX;
205 case _SC_XOPEN_CRYPT:
206 return (_XOPEN_CRYPT);
207 case _SC_XOPEN_ENH_I18N:
208 @@ -568,11 +586,25 @@
209 return (_POSIX_IPV6);
212 +#ifdef _SC_NPROCESSORS_CONF
213 case _SC_NPROCESSORS_CONF:
215 +#ifdef _SC_NPROCESSORS_ONLN
216 case _SC_NPROCESSORS_ONLN:
218 +#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
223 + case _SC_XBS5_ILP32_OFF32:
224 + return (_XBS5_ILP32_OFF32);
225 + case _SC_XBS5_ILP32_OFFBIG:
226 + return (_XBS5_ILP32_OFFBIG);
227 + case _SC_XBS5_LP64_OFF64:
228 + return (_XBS5_LP64_OFF64);
229 + case _SC_XBS5_LPBIG_OFFBIG:
230 + return (_XBS5_LPBIG_OFFBIG);