1 --- sysconf.c.orig 2007-04-03 12:19:23.000000000 -0700
2 +++ sysconf.c 2007-04-05 11:33:36.000000000 -0700
4 #include <sys/sysctl.h>
5 #include <sys/resource.h>
6 #include <sys/socket.h>
8 +#include <sys/semaphore.h>
16 + quad_t qdvalue; /* for kern.sysv.shmmin */
18 - int mib[2], sverrno, value;
19 + int mib[3], sverrno, value;
24 return (_POSIX_TIMERS);
26 case _SC_AIO_LISTIO_MAX:
27 - mib[0] = CTL_P1003_1B;
28 - mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX;
31 - mib[0] = CTL_P1003_1B;
32 - mib[1] = CTL_P1003_1B_AIO_MAX;
34 + mib[1] = KERN_AIOMAX;
37 case _SC_AIO_PRIO_DELTA_MAX:
38 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_AIO_PRIO_DELTA_MAX)
39 mib[0] = CTL_P1003_1B;
40 mib[1] = CTL_P1003_1B_AIO_PRIO_DELTA_MAX;
45 case _SC_DELAYTIMER_MAX:
46 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_DELAYTIMER_MAX)
47 mib[0] = CTL_P1003_1B;
48 mib[1] = CTL_P1003_1B_DELAYTIMER_MAX;
54 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_MQ_OPEN_MAX)
55 mib[0] = CTL_P1003_1B;
56 mib[1] = CTL_P1003_1B_MQ_OPEN_MAX;
62 defaultresult = getpagesize();
63 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_PAGESIZE)
64 mib[0] = CTL_P1003_1B;
65 mib[1] = CTL_P1003_1B_PAGESIZE;
68 + return defaultresult;
71 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_RTSIG_MAX)
72 mib[0] = CTL_P1003_1B;
73 mib[1] = CTL_P1003_1B_RTSIG_MAX;
78 case _SC_SEM_NSEMS_MAX:
79 - mib[0] = CTL_P1003_1B;
80 - mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX;
82 + return (sysctlbyname("kern.sysv.semmns", &value, &len, NULL, 0) == -1 ? -1 : value);
84 case _SC_SEM_VALUE_MAX:
85 +#if SEM_VALUE_MAX == 0
86 mib[0] = CTL_P1003_1B;
87 mib[1] = CTL_P1003_1B_SEM_VALUE_MAX;
90 + return (SEM_VALUE_MAX);
92 case _SC_SIGQUEUE_MAX:
93 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_SIGQUEUE_MAX)
94 mib[0] = CTL_P1003_1B;
95 mib[1] = CTL_P1003_1B_SIGQUEUE_MAX;
101 +#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_TIMER_MAX)
102 mib[0] = CTL_P1003_1B;
103 mib[1] = CTL_P1003_1B_TIMER_MAX;
108 yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
111 return (defaultresult);
115 case _SC_2_PBS_ACCOUNTING:
116 case _SC_2_PBS_CHECKPOINT:
117 case _SC_2_PBS_LOCATE:
118 case _SC_2_PBS_MESSAGE:
119 case _SC_2_PBS_TRACK:
120 -#if _POSIX2_PBS == 0
121 -#error "don't know how to determine _SC_2_PBS"
123 - * This probably requires digging through the filesystem
124 - * to see if the appropriate package has been installed.
125 - * Since we don't currently support this option at all,
126 - * it's not worth the effort to write the code now.
127 - * Figuring out which of the sub-options are supported
128 - * would be even more difficult, so it's probably easier
129 - * to always say ``no''.
132 - return (_POSIX2_PBS);
135 case _SC_ADVISORY_INFO:
136 #if _POSIX_ADVISORY_INFO == 0
137 #error "_POSIX_ADVISORY_INFO"
138 @@ -348,18 +366,12 @@
140 return (_POSIX_CPUTIME);
143 case _SC_FILE_LOCKING:
145 - * XXX - The standard doesn't tell us how to define
146 - * _POSIX_FILE_LOCKING, so we can't answer this one.
149 -#if _POSIX_THREAD_SAFE_FUNCTIONS > -1
150 case _SC_GETGR_R_SIZE_MAX:
151 +/* return sizeof(group) + group_name_max + group_passwd_max + max_group_member*(MAXLOGNAME+1); */
152 + return 4096; /* INT_MAX is too big for Perl */
153 case _SC_GETPW_R_SIZE_MAX:
154 -#error "somebody needs to implement this"
157 case _SC_HOST_NAME_MAX:
158 return (MAXHOSTNAMELEN - 1); /* does not include \0 */
159 case _SC_LOGIN_NAME_MAX:
162 return (_POSIX_MONOTONIC_CLOCK);
164 -#if _POSIX_MESSAGE_PASSING > -1
165 case _SC_MQ_PRIO_MAX:
166 - return (MQ_PRIO_MAX);
169 case _SC_READER_WRITER_LOCKS:
170 return (_POSIX_READER_WRITER_LOCKS);
172 @@ -410,10 +420,16 @@
173 return (_POSIX_THREAD_PROCESS_SHARED);
174 case _SC_THREAD_SAFE_FUNCTIONS:
175 return (_POSIX_THREAD_SAFE_FUNCTIONS);
176 + case _SC_THREAD_SPORADIC_SERVER:
177 + return (_POSIX_THREAD_SPORADIC_SERVER);
178 case _SC_THREAD_STACK_MIN:
179 return (PTHREAD_STACK_MIN);
180 case _SC_THREAD_THREADS_MAX:
181 +#ifdef PTHREAD_THREADS_MAX
182 return (PTHREAD_THREADS_MAX); /* XXX wrong type! */
187 return (_POSIX_TIMEOUTS);
189 @@ -425,16 +441,14 @@
191 return (_POSIX_TRACE);
193 -#if _POSIX_TRACE > -1
194 case _SC_TRACE_EVENT_FILTER:
195 return (_POSIX_TRACE_EVENT_FILTER);
196 case _SC_TRACE_INHERIT:
197 return (_POSIX_TRACE_INHERIT);
199 return (_POSIX_TRACE_LOG);
201 case _SC_TTY_NAME_MAX:
203 + path = "/"; // should be _PATH_DEV (PR-3624562)
205 case _SC_TYPED_MEMORY_OBJECTS:
206 #if _POSIX_TYPED_MEMORY_OBJECTS == 0
207 @@ -491,11 +505,15 @@
208 return (_V6_LPBIG_OFFBIG);
211 - return (ATEXIT_SIZE);
212 + return (INT_MAX); /* unlimited */
216 mib[1] = KERN_IOV_MAX;
221 case _SC_XOPEN_CRYPT:
222 return (_XOPEN_CRYPT);
223 case _SC_XOPEN_ENH_I18N:
228 - if (sysctlbyname("kern.ipc.shmmin", &value, &len, NULL,
229 + len = sizeof(qdvalue);
230 + if (sysctlbyname("kern.sysv.shmmin", &qdvalue, &len, NULL,
234 @@ -568,11 +587,37 @@
235 return (_POSIX_IPV6);
238 +#ifdef _SC_NPROCESSORS_CONF
239 case _SC_NPROCESSORS_CONF:
241 +#ifdef _SC_NPROCESSORS_ONLN
242 case _SC_NPROCESSORS_ONLN:
244 +#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
249 + case _SC_XBS5_ILP32_OFF32:
250 + return (_XBS5_ILP32_OFF32);
251 + case _SC_XBS5_ILP32_OFFBIG:
252 + return (_XBS5_ILP32_OFFBIG);
253 + case _SC_XBS5_LP64_OFF64:
254 + return (_XBS5_LP64_OFF64);
255 + case _SC_XBS5_LPBIG_OFFBIG:
256 + return (_XBS5_LPBIG_OFFBIG);
257 + case _SC_SS_REPL_MAX:
258 + return (_POSIX_SS_REPL_MAX);
259 + case _SC_TRACE_EVENT_NAME_MAX:
260 + return (_POSIX_TRACE_EVENT_NAME_MAX);
261 + case _SC_TRACE_NAME_MAX:
262 + return (_POSIX_TRACE_NAME_MAX);
263 + case _SC_TRACE_SYS_MAX:
264 + return (_POSIX_TRACE_SYS_MAX);
265 + case _SC_TRACE_USER_EVENT_MAX:
266 + return (_POSIX_TRACE_USER_EVENT_MAX);