]> git.saurik.com Git - apple/libc.git/blob - gen/FreeBSD/sysconf.c.patch
Libc-339.tar.gz
[apple/libc.git] / gen / FreeBSD / sysconf.c.patch
1 --- sysconf.c.orig Sun Nov 17 00:54:29 2002
2 +++ sysconf.c Wed Apr 14 17:09:36 2004
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
23 @@ -76,7 +78,7 @@
24 {
25 struct rlimit rl;
26 size_t len;
27 - int mib[2], sverrno, value;
28 + int mib[3], sverrno, value;
29 long defaultresult;
30 const char *path;
31
32 @@ -254,76 +256,94 @@
33 return (_POSIX_TIMERS);
34 #endif
35 case _SC_AIO_LISTIO_MAX:
36 - mib[0] = CTL_P1003_1B;
37 - mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX;
38 - break;
39 case _SC_AIO_MAX:
40 - mib[0] = CTL_P1003_1B;
41 - mib[1] = CTL_P1003_1B_AIO_MAX;
42 + mib[0] = CTL_KERN;;
43 + mib[1] = KERN_AIOMAX;
44 break;
45 +
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;
50 break;
51 +#else
52 + return (-1);
53 +#endif
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;
58 goto yesno;
59 +#else
60 + return (-1);
61 +#endif
62 case _SC_MQ_OPEN_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;
66 goto yesno;
67 +#else
68 + return (-1);
69 +#endif
70 case _SC_PAGESIZE:
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;
75 goto yesno;
76 +#else
77 + return defaultresult;
78 +#endif
79 case _SC_RTSIG_MAX:
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;
83 goto yesno;
84 +#else
85 + return (-1);
86 +#endif
87 case _SC_SEM_NSEMS_MAX:
88 - mib[0] = CTL_P1003_1B;
89 - mib[1] = CTL_P1003_1B_SEM_NSEMS_MAX;
90 - goto yesno;
91 + mib[0] = CTL_KERN;
92 + mib[1] = KERN_SYSV;
93 + mib[2] = KSYSV_SEMMNS;
94 + return (sysctl(mib, 3, &value, &len, NULL, 0) == -1 ? -1 : value);
95 +
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;
100 goto yesno;
101 +#else
102 + return (SEM_VALUE_MAX);
103 +#endif
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;
108 goto yesno;
109 +#else
110 + return (-1);
111 +#endif
112 case _SC_TIMER_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;
116 +#else
117 + return (-1);
118 +#endif
119
120 yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
121 return (-1);
122 if (value == 0)
123 return (defaultresult);
124 return (value);
125 -
126 case _SC_2_PBS:
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"
134 - /*
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''.
142 - */
143 -#else
144 - return (_POSIX2_PBS);
145 -#endif
146 + return -1;
147 case _SC_ADVISORY_INFO:
148 #if _POSIX_ADVISORY_INFO == 0
149 #error "_POSIX_ADVISORY_INFO"
150 @@ -348,18 +368,10 @@
151 #else
152 return (_POSIX_CPUTIME);
153 #endif
154 -#ifdef notdef
155 case _SC_FILE_LOCKING:
156 - /*
157 - * XXX - The standard doesn't tell us how to define
158 - * _POSIX_FILE_LOCKING, so we can't answer this one.
159 - */
160 -#endif
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"
165 -#endif
166 + return (-1);
167 case _SC_HOST_NAME_MAX:
168 return (MAXHOSTNAMELEN - 1); /* does not include \0 */
169 case _SC_LOGIN_NAME_MAX:
170 @@ -370,10 +382,8 @@
171 #else
172 return (_POSIX_MONOTONIC_CLOCK);
173 #endif
174 -#if _POSIX_MESSAGE_PASSING > -1
175 case _SC_MQ_PRIO_MAX:
176 - return (MQ_PRIO_MAX);
177 -#endif
178 + return (-1);
179 case _SC_READER_WRITER_LOCKS:
180 return (_POSIX_READER_WRITER_LOCKS);
181 case _SC_REGEXP:
182 @@ -413,7 +423,11 @@
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! */
188 +#else
189 + return (-1);
190 +#endif
191 case _SC_TIMEOUTS:
192 return (_POSIX_TIMEOUTS);
193 case _SC_THREADS:
194 @@ -493,9 +507,13 @@
195 case _SC_ATEXIT_MAX:
196 return (ATEXIT_SIZE);
197 case _SC_IOV_MAX:
198 +#ifdef KERN_IOV_MAX
199 mib[0] = CTL_KERN;
200 mib[1] = KERN_IOV_MAX;
201 break;
202 +#else
203 + return (-1);
204 +#endif
205 case _SC_XOPEN_CRYPT:
206 return (_XOPEN_CRYPT);
207 case _SC_XOPEN_ENH_I18N:
208 @@ -568,11 +586,25 @@
209 return (_POSIX_IPV6);
210 #endif
211
212 +#ifdef _SC_NPROCESSORS_CONF
213 case _SC_NPROCESSORS_CONF:
214 +#endif
215 +#ifdef _SC_NPROCESSORS_ONLN
216 case _SC_NPROCESSORS_ONLN:
217 +#endif
218 +#if defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
219 mib[0] = CTL_HW;
220 mib[1] = HW_NCPU;
221 break;
222 +#endif
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);
231
232 default:
233 errno = EINVAL;