]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/sysconf.c.patch
Libc-498.1.5.tar.gz
[apple/libc.git] / gen / FreeBSD / sysconf.c.patch
CommitLineData
224c7076
A
1--- sysconf.c.orig 2007-04-03 12:19:23.000000000 -0700
2+++ sysconf.c 2007-04-05 11:33:36.000000000 -0700
59e0d9fe
A
3@@ -45,6 +45,8 @@
4 #include <sys/sysctl.h>
5 #include <sys/resource.h>
6 #include <sys/socket.h>
7+#include <sys/aio.h>
8+#include <sys/semaphore.h>
9
10 #include <errno.h>
11 #include <limits.h>
3d9156a7
A
12@@ -75,8 +77,9 @@
13 int name;
59e0d9fe
A
14 {
15 struct rlimit rl;
3d9156a7 16+ quad_t qdvalue; /* for kern.sysv.shmmin */
59e0d9fe
A
17 size_t len;
18- int mib[2], sverrno, value;
19+ int mib[3], sverrno, value;
20 long defaultresult;
21 const char *path;
22
224c7076 23@@ -254,76 +257,91 @@
59e0d9fe
A
24 return (_POSIX_TIMERS);
25 #endif
26 case _SC_AIO_LISTIO_MAX:
27- mib[0] = CTL_P1003_1B;
28- mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX;
29- break;
30 case _SC_AIO_MAX:
31- mib[0] = CTL_P1003_1B;
32- mib[1] = CTL_P1003_1B_AIO_MAX;
33+ mib[0] = CTL_KERN;;
34+ mib[1] = KERN_AIOMAX;
35 break;
36+
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;
41 break;
42+#else
43+ return (-1);
44+#endif
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;
49 goto yesno;
50+#else
51+ return (-1);
52+#endif
53 case _SC_MQ_OPEN_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;
57 goto yesno;
58+#else
59+ return (-1);
60+#endif
61 case _SC_PAGESIZE:
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;
66 goto yesno;
67+#else
68+ return defaultresult;
69+#endif
70 case _SC_RTSIG_MAX:
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;
74 goto yesno;
75+#else
76+ return (-1);
77+#endif
78 case _SC_SEM_NSEMS_MAX:
79- mib[0] = CTL_P1003_1B;
80- mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX;
81- goto yesno;
224c7076 82+ return (sysctlbyname("kern.sysv.semmns", &value, &len, NULL, 0) == -1 ? -1 : value);
59e0d9fe
A
83+
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;
88 goto yesno;
89+#else
90+ return (SEM_VALUE_MAX);
91+#endif
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;
96 goto yesno;
97+#else
98+ return (-1);
99+#endif
100 case _SC_TIMER_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;
104+#else
105+ return (-1);
106+#endif
107
108 yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
109 return (-1);
110 if (value == 0)
111 return (defaultresult);
112 return (value);
113-
114 case _SC_2_PBS:
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"
122- /*
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''.
130- */
131-#else
132- return (_POSIX2_PBS);
133-#endif
134+ return -1;
135 case _SC_ADVISORY_INFO:
136 #if _POSIX_ADVISORY_INFO == 0
137 #error "_POSIX_ADVISORY_INFO"
224c7076 138@@ -348,18 +366,12 @@
59e0d9fe
A
139 #else
140 return (_POSIX_CPUTIME);
141 #endif
142-#ifdef notdef
143 case _SC_FILE_LOCKING:
144- /*
145- * XXX - The standard doesn't tell us how to define
146- * _POSIX_FILE_LOCKING, so we can't answer this one.
147- */
148-#endif
149-#if _POSIX_THREAD_SAFE_FUNCTIONS > -1
150 case _SC_GETGR_R_SIZE_MAX:
224c7076
A
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 */
59e0d9fe
A
153 case _SC_GETPW_R_SIZE_MAX:
154-#error "somebody needs to implement this"
155-#endif
224c7076 156+ return 4096;
59e0d9fe
A
157 case _SC_HOST_NAME_MAX:
158 return (MAXHOSTNAMELEN - 1); /* does not include \0 */
159 case _SC_LOGIN_NAME_MAX:
224c7076 160@@ -370,10 +382,8 @@
59e0d9fe
A
161 #else
162 return (_POSIX_MONOTONIC_CLOCK);
163 #endif
164-#if _POSIX_MESSAGE_PASSING > -1
165 case _SC_MQ_PRIO_MAX:
166- return (MQ_PRIO_MAX);
167-#endif
168+ return (-1);
169 case _SC_READER_WRITER_LOCKS:
170 return (_POSIX_READER_WRITER_LOCKS);
171 case _SC_REGEXP:
224c7076 172@@ -410,10 +420,16 @@
3d9156a7
A
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);
59e0d9fe
A
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! */
183+#else
184+ return (-1);
185+#endif
186 case _SC_TIMEOUTS:
187 return (_POSIX_TIMEOUTS);
188 case _SC_THREADS:
224c7076 189@@ -425,16 +441,14 @@
3d9156a7
A
190 #else
191 return (_POSIX_TRACE);
192 #endif
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);
198 case _SC_TRACE_LOG:
199 return (_POSIX_TRACE_LOG);
200-#endif
201 case _SC_TTY_NAME_MAX:
202- path = _PATH_DEV;
203+ path = "/"; // should be _PATH_DEV (PR-3624562)
204 goto do_NAME_MAX;
205 case _SC_TYPED_MEMORY_OBJECTS:
206 #if _POSIX_TYPED_MEMORY_OBJECTS == 0
224c7076
A
207@@ -491,11 +505,15 @@
208 return (_V6_LPBIG_OFFBIG);
209 #endif
59e0d9fe 210 case _SC_ATEXIT_MAX:
224c7076
A
211- return (ATEXIT_SIZE);
212+ return (INT_MAX); /* unlimited */
59e0d9fe
A
213 case _SC_IOV_MAX:
214+#ifdef KERN_IOV_MAX
215 mib[0] = CTL_KERN;
216 mib[1] = KERN_IOV_MAX;
217 break;
218+#else
3d9156a7 219+ return (IOV_MAX);
59e0d9fe
A
220+#endif
221 case _SC_XOPEN_CRYPT:
222 return (_XOPEN_CRYPT);
223 case _SC_XOPEN_ENH_I18N:
224c7076 224@@ -531,7 +549,8 @@
3d9156a7
A
225 #endif
226 case _SC_XOPEN_SHM:
227 sverrno = errno;
228- if (sysctlbyname("kern.ipc.shmmin", &value, &len, NULL,
229+ len = sizeof(qdvalue);
230+ if (sysctlbyname("kern.sysv.shmmin", &qdvalue, &len, NULL,
231 0) == -1) {
232 errno = sverrno;
233 return (-1);
224c7076 234@@ -568,11 +587,37 @@
59e0d9fe
A
235 return (_POSIX_IPV6);
236 #endif
237
238+#ifdef _SC_NPROCESSORS_CONF
239 case _SC_NPROCESSORS_CONF:
240+#endif
241+#ifdef _SC_NPROCESSORS_ONLN
242 case _SC_NPROCESSORS_ONLN:
243+#endif
244+#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
245 mib[0] = CTL_HW;
246 mib[1] = HW_NCPU;
247 break;
248+#endif
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);
224c7076
A
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);
267+ case _SC_PASS_MAX:
268+ return (PASS_MAX);
59e0d9fe
A
269
270 default:
271 errno = EINVAL;