]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/sysconf.c.patch
Libc-391.2.3.tar.gz
[apple/libc.git] / gen / FreeBSD / sysconf.c.patch
CommitLineData
3d9156a7
A
1--- sysconf.c 2004-04-15 16:50:28.000000000 -0700
2+++ /Volumes/dee/Len/Build/Libc-3845788.roots/Libc-3845788.sym/sysconf-fbsd.c 2004-11-30 18:08:26.000000000 -0800
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>
12@@ -53,8 +55,8 @@
13 #include <time.h>
14 #include <unistd.h>
15
16-#include "../stdlib/atexit.h"
17-#include "../stdtime/tzfile.h"
18+#include "atexit.h"
19+#include "tzfile.h"
20
21 #define _PATH_ZONEINFO TZDIR /* from tzfile.h */
22
3d9156a7
A
23@@ -75,8 +77,9 @@
24 int name;
59e0d9fe
A
25 {
26 struct rlimit rl;
3d9156a7 27+ quad_t qdvalue; /* for kern.sysv.shmmin */
59e0d9fe
A
28 size_t len;
29- int mib[2], sverrno, value;
30+ int mib[3], sverrno, value;
31 long defaultresult;
32 const char *path;
33
3d9156a7 34@@ -254,76 +257,94 @@
59e0d9fe
A
35 return (_POSIX_TIMERS);
36 #endif
37 case _SC_AIO_LISTIO_MAX:
38- mib[0] = CTL_P1003_1B;
39- mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX;
40- break;
41 case _SC_AIO_MAX:
42- mib[0] = CTL_P1003_1B;
43- mib[1] = CTL_P1003_1B_AIO_MAX;
44+ mib[0] = CTL_KERN;;
45+ mib[1] = KERN_AIOMAX;
46 break;
47+
48 case _SC_AIO_PRIO_DELTA_MAX:
49+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_AIO_PRIO_DELTA_MAX)
50 mib[0] = CTL_P1003_1B;
51 mib[1] = CTL_P1003_1B_AIO_PRIO_DELTA_MAX;
52 break;
53+#else
54+ return (-1);
55+#endif
56 case _SC_DELAYTIMER_MAX:
57+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_DELAYTIMER_MAX)
58 mib[0] = CTL_P1003_1B;
59 mib[1] = CTL_P1003_1B_DELAYTIMER_MAX;
60 goto yesno;
61+#else
62+ return (-1);
63+#endif
64 case _SC_MQ_OPEN_MAX:
65+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_MQ_OPEN_MAX)
66 mib[0] = CTL_P1003_1B;
67 mib[1] = CTL_P1003_1B_MQ_OPEN_MAX;
68 goto yesno;
69+#else
70+ return (-1);
71+#endif
72 case _SC_PAGESIZE:
73 defaultresult = getpagesize();
74+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_PAGESIZE)
75 mib[0] = CTL_P1003_1B;
76 mib[1] = CTL_P1003_1B_PAGESIZE;
77 goto yesno;
78+#else
79+ return defaultresult;
80+#endif
81 case _SC_RTSIG_MAX:
82+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_RTSIG_MAX)
83 mib[0] = CTL_P1003_1B;
84 mib[1] = CTL_P1003_1B_RTSIG_MAX;
85 goto yesno;
86+#else
87+ return (-1);
88+#endif
89 case _SC_SEM_NSEMS_MAX:
90- mib[0] = CTL_P1003_1B;
91- mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX;
92- goto yesno;
93+ mib[0] = CTL_KERN;
94+ mib[1] = KERN_SYSV;
95+ mib[2] = KSYSV_SEMMNS;
96+ return (sysctl(mib, 3, &value, &len, NULL, 0) == -1 ? -1 : value);
97+
98 case _SC_SEM_VALUE_MAX:
99+#if SEM_VALUE_MAX == 0
100 mib[0] = CTL_P1003_1B;
101 mib[1] = CTL_P1003_1B_SEM_VALUE_MAX;
102 goto yesno;
103+#else
104+ return (SEM_VALUE_MAX);
105+#endif
106 case _SC_SIGQUEUE_MAX:
107+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_SIGQUEUE_MAX)
108 mib[0] = CTL_P1003_1B;
109 mib[1] = CTL_P1003_1B_SIGQUEUE_MAX;
110 goto yesno;
111+#else
112+ return (-1);
113+#endif
114 case _SC_TIMER_MAX:
115+#if defined(CTL_P1003_1B) && defined(CTL_P1003_1B_TIMER_MAX)
116 mib[0] = CTL_P1003_1B;
117 mib[1] = CTL_P1003_1B_TIMER_MAX;
118+#else
119+ return (-1);
120+#endif
121
122 yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
123 return (-1);
124 if (value == 0)
125 return (defaultresult);
126 return (value);
127-
128 case _SC_2_PBS:
129 case _SC_2_PBS_ACCOUNTING:
130 case _SC_2_PBS_CHECKPOINT:
131 case _SC_2_PBS_LOCATE:
132 case _SC_2_PBS_MESSAGE:
133 case _SC_2_PBS_TRACK:
134-#if _POSIX2_PBS == 0
135-#error "don't know how to determine _SC_2_PBS"
136- /*
137- * This probably requires digging through the filesystem
138- * to see if the appropriate package has been installed.
139- * Since we don't currently support this option at all,
140- * it's not worth the effort to write the code now.
141- * Figuring out which of the sub-options are supported
142- * would be even more difficult, so it's probably easier
143- * to always say ``no''.
144- */
145-#else
146- return (_POSIX2_PBS);
147-#endif
148+ return -1;
149 case _SC_ADVISORY_INFO:
150 #if _POSIX_ADVISORY_INFO == 0
151 #error "_POSIX_ADVISORY_INFO"
3d9156a7 152@@ -348,18 +369,10 @@
59e0d9fe
A
153 #else
154 return (_POSIX_CPUTIME);
155 #endif
156-#ifdef notdef
157 case _SC_FILE_LOCKING:
158- /*
159- * XXX - The standard doesn't tell us how to define
160- * _POSIX_FILE_LOCKING, so we can't answer this one.
161- */
162-#endif
163-#if _POSIX_THREAD_SAFE_FUNCTIONS > -1
164 case _SC_GETGR_R_SIZE_MAX:
165 case _SC_GETPW_R_SIZE_MAX:
166-#error "somebody needs to implement this"
167-#endif
168+ return (-1);
169 case _SC_HOST_NAME_MAX:
170 return (MAXHOSTNAMELEN - 1); /* does not include \0 */
171 case _SC_LOGIN_NAME_MAX:
3d9156a7 172@@ -370,10 +383,8 @@
59e0d9fe
A
173 #else
174 return (_POSIX_MONOTONIC_CLOCK);
175 #endif
176-#if _POSIX_MESSAGE_PASSING > -1
177 case _SC_MQ_PRIO_MAX:
178- return (MQ_PRIO_MAX);
179-#endif
180+ return (-1);
181 case _SC_READER_WRITER_LOCKS:
182 return (_POSIX_READER_WRITER_LOCKS);
183 case _SC_REGEXP:
3d9156a7
A
184@@ -410,10 +421,16 @@
185 return (_POSIX_THREAD_PROCESS_SHARED);
186 case _SC_THREAD_SAFE_FUNCTIONS:
187 return (_POSIX_THREAD_SAFE_FUNCTIONS);
188+ case _SC_THREAD_SPORADIC_SERVER:
189+ return (_POSIX_THREAD_SPORADIC_SERVER);
59e0d9fe
A
190 case _SC_THREAD_STACK_MIN:
191 return (PTHREAD_STACK_MIN);
192 case _SC_THREAD_THREADS_MAX:
193+#ifdef PTHREAD_THREADS_MAX
194 return (PTHREAD_THREADS_MAX); /* XXX wrong type! */
195+#else
196+ return (-1);
197+#endif
198 case _SC_TIMEOUTS:
199 return (_POSIX_TIMEOUTS);
200 case _SC_THREADS:
3d9156a7
A
201@@ -425,16 +442,14 @@
202 #else
203 return (_POSIX_TRACE);
204 #endif
205-#if _POSIX_TRACE > -1
206 case _SC_TRACE_EVENT_FILTER:
207 return (_POSIX_TRACE_EVENT_FILTER);
208 case _SC_TRACE_INHERIT:
209 return (_POSIX_TRACE_INHERIT);
210 case _SC_TRACE_LOG:
211 return (_POSIX_TRACE_LOG);
212-#endif
213 case _SC_TTY_NAME_MAX:
214- path = _PATH_DEV;
215+ path = "/"; // should be _PATH_DEV (PR-3624562)
216 goto do_NAME_MAX;
217 case _SC_TYPED_MEMORY_OBJECTS:
218 #if _POSIX_TYPED_MEMORY_OBJECTS == 0
219@@ -493,9 +508,13 @@
59e0d9fe
A
220 case _SC_ATEXIT_MAX:
221 return (ATEXIT_SIZE);
222 case _SC_IOV_MAX:
223+#ifdef KERN_IOV_MAX
224 mib[0] = CTL_KERN;
225 mib[1] = KERN_IOV_MAX;
226 break;
227+#else
3d9156a7 228+ return (IOV_MAX);
59e0d9fe
A
229+#endif
230 case _SC_XOPEN_CRYPT:
231 return (_XOPEN_CRYPT);
232 case _SC_XOPEN_ENH_I18N:
3d9156a7
A
233@@ -531,7 +550,8 @@
234 #endif
235 case _SC_XOPEN_SHM:
236 sverrno = errno;
237- if (sysctlbyname("kern.ipc.shmmin", &value, &len, NULL,
238+ len = sizeof(qdvalue);
239+ if (sysctlbyname("kern.sysv.shmmin", &qdvalue, &len, NULL,
240 0) == -1) {
241 errno = sverrno;
242 return (-1);
243@@ -568,11 +588,25 @@
59e0d9fe
A
244 return (_POSIX_IPV6);
245 #endif
246
247+#ifdef _SC_NPROCESSORS_CONF
248 case _SC_NPROCESSORS_CONF:
249+#endif
250+#ifdef _SC_NPROCESSORS_ONLN
251 case _SC_NPROCESSORS_ONLN:
252+#endif
253+#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
254 mib[0] = CTL_HW;
255 mib[1] = HW_NCPU;
256 break;
257+#endif
258+ case _SC_XBS5_ILP32_OFF32:
259+ return (_XBS5_ILP32_OFF32);
260+ case _SC_XBS5_ILP32_OFFBIG:
261+ return (_XBS5_ILP32_OFFBIG);
262+ case _SC_XBS5_LP64_OFF64:
263+ return (_XBS5_LP64_OFF64);
264+ case _SC_XBS5_LPBIG_OFFBIG:
265+ return (_XBS5_LPBIG_OFFBIG);
266
267 default:
268 errno = EINVAL;