• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #include <unistd.h>
30 
31 #include "header_checks.h"
32 
unistd_h()33 static void unistd_h() {
34   MACRO(_POSIX_VERSION);
35   MACRO(_POSIX2_VERSION);
36   MACRO(_XOPEN_VERSION);
37 
38   MACRO(_POSIX_ADVISORY_INFO);
39   MACRO(_POSIX_ASYNCHRONOUS_IO);
40   MACRO(_POSIX_BARRIERS);
41   MACRO(_POSIX_CHOWN_RESTRICTED);
42   MACRO(_POSIX_CLOCK_SELECTION);
43   MACRO(_POSIX_CPUTIME);
44   MACRO(_POSIX_FSYNC);
45   MACRO(_POSIX_IPV6);
46   MACRO(_POSIX_JOB_CONTROL);
47   MACRO(_POSIX_MAPPED_FILES);
48   MACRO(_POSIX_MEMLOCK);
49   MACRO(_POSIX_MEMLOCK_RANGE);
50   MACRO(_POSIX_MEMORY_PROTECTION);
51   MACRO(_POSIX_MESSAGE_PASSING);
52   MACRO(_POSIX_MONOTONIC_CLOCK);
53   MACRO(_POSIX_NO_TRUNC);
54 #if !defined(ANDROID_HOST_MUSL)
55   MACRO(_POSIX_PRIORITIZED_IO);
56   MACRO(_POSIX_PRIORITY_SCHEDULING);
57 #endif
58   MACRO(_POSIX_RAW_SOCKETS);
59   MACRO(_POSIX_READER_WRITER_LOCKS);
60   MACRO(_POSIX_REALTIME_SIGNALS);
61   MACRO(_POSIX_REGEXP);
62   MACRO(_POSIX_SAVED_IDS);
63   MACRO(_POSIX_SEMAPHORES);
64   MACRO(_POSIX_SHARED_MEMORY_OBJECTS);
65   MACRO(_POSIX_SHELL);
66   MACRO(_POSIX_SPAWN);
67   MACRO(_POSIX_SPIN_LOCKS);
68 #if !defined(ANDROID_HOST_MUSL)
69   MACRO(_POSIX_SPORADIC_SERVER);
70   MACRO(_POSIX_SYNCHRONIZED_IO);
71 #endif
72   MACRO(_POSIX_THREAD_ATTR_STACKADDR);
73   MACRO(_POSIX_THREAD_ATTR_STACKSIZE);
74   MACRO(_POSIX_THREAD_CPUTIME);
75 #if !defined(ANDROID_HOST_MUSL)
76   MACRO(_POSIX_THREAD_PRIO_INHERIT);
77   MACRO(_POSIX_THREAD_PRIO_PROTECT);
78 #endif
79   MACRO(_POSIX_THREAD_PRIORITY_SCHEDULING);
80   MACRO(_POSIX_THREAD_PROCESS_SHARED);
81 #if !defined(ANDROID_HOST_MUSL)
82   MACRO(_POSIX_THREAD_ROBUST_PRIO_INHERIT);
83   MACRO(_POSIX_THREAD_ROBUST_PRIO_PROTECT);
84 #endif
85   MACRO(_POSIX_THREAD_SAFE_FUNCTIONS);
86 #if !defined(ANDROID_HOST_MUSL)
87   MACRO(_POSIX_THREAD_SPORADIC_SERVER);
88 #endif
89   MACRO(_POSIX_THREADS);
90   MACRO(_POSIX_TIMEOUTS);
91   MACRO(_POSIX_TIMERS);
92 #if !defined(ANDROID_HOST_MUSL)
93   MACRO(_POSIX_TYPED_MEMORY_OBJECTS);
94 #endif
95   MACRO(_POSIX2_C_BIND);
96 #if !defined(ANDROID_HOST_MUSL)
97   MACRO(_POSIX2_CHAR_TERM);
98   MACRO(_POSIX2_LOCALEDEF);
99   MACRO(_POSIX2_SW_DEV);
100 #endif
101 #if 0 // No libc I can find actually has this.
102   MACRO(_POSIX2_UPE);
103 #endif
104 #if !defined(ANDROID_HOST_MUSL)
105   MACRO(_XOPEN_CRYPT);
106 #endif
107   MACRO(_XOPEN_ENH_I18N);
108 #if !defined(ANDROID_HOST_MUSL)
109   MACRO(_XOPEN_REALTIME);
110   MACRO(_XOPEN_REALTIME_THREADS);
111   MACRO(_XOPEN_SHM);
112 #endif
113   MACRO(_XOPEN_UNIX);
114 #if defined(_XOPEN_UUCP)
115 #if _XOPEN_UUCP != -1 && _XOPEN_UUCP != 0 && _XOPEN_UUCP != 200809L
116 #error _XOPEN_UUCP
117 #endif
118 #endif
119 
120   MACRO(NULL);
121 
122   MACRO(F_OK);
123   MACRO(R_OK);
124   MACRO(W_OK);
125   MACRO(X_OK);
126 
127 #if !defined(__BIONIC__) // No confstr on Android.
128   MACRO(_CS_PATH);
129   MACRO(_CS_POSIX_V7_ILP32_OFF32_CFLAGS);
130   MACRO(_CS_POSIX_V7_ILP32_OFF32_LDFLAGS);
131   MACRO(_CS_POSIX_V7_ILP32_OFF32_LIBS);
132   MACRO(_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS);
133   MACRO(_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS);
134   MACRO(_CS_POSIX_V7_ILP32_OFFBIG_LIBS);
135   MACRO(_CS_POSIX_V7_LP64_OFF64_CFLAGS);
136   MACRO(_CS_POSIX_V7_LP64_OFF64_LDFLAGS);
137   MACRO(_CS_POSIX_V7_LP64_OFF64_LIBS);
138   MACRO(_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS);
139   MACRO(_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS);
140   MACRO(_CS_POSIX_V7_LPBIG_OFFBIG_LIBS);
141   MACRO(_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS);
142   MACRO(_CS_V7_ENV);
143 #endif
144 
145   MACRO(SEEK_CUR);
146   MACRO(SEEK_END);
147   MACRO(SEEK_SET);
148 
149   MACRO(F_LOCK);
150   MACRO(F_TEST);
151   MACRO(F_TLOCK);
152   MACRO(F_ULOCK);
153 
154   MACRO(_PC_2_SYMLINKS);
155   MACRO(_PC_ALLOC_SIZE_MIN);
156   MACRO(_PC_ASYNC_IO);
157   MACRO(_PC_CHOWN_RESTRICTED);
158   MACRO(_PC_FILESIZEBITS);
159   MACRO(_PC_LINK_MAX);
160   MACRO(_PC_MAX_CANON);
161   MACRO(_PC_MAX_INPUT);
162   MACRO(_PC_NAME_MAX);
163   MACRO(_PC_NO_TRUNC);
164   MACRO(_PC_PATH_MAX);
165   MACRO(_PC_PIPE_BUF);
166   MACRO(_PC_PRIO_IO);
167   MACRO(_PC_REC_INCR_XFER_SIZE);
168   MACRO(_PC_REC_MAX_XFER_SIZE);
169   MACRO(_PC_REC_MIN_XFER_SIZE);
170   MACRO(_PC_REC_XFER_ALIGN);
171   MACRO(_PC_SYMLINK_MAX);
172   MACRO(_PC_SYNC_IO);
173 #if 0 // No libc I can find actually has this.
174   MACRO(_PC_TIMESTAMP_RESOLUTION);
175 #endif
176   MACRO(_PC_VDISABLE);
177 
178   MACRO(_SC_2_C_BIND);
179   MACRO(_SC_2_C_DEV);
180   MACRO(_SC_2_CHAR_TERM);
181   MACRO(_SC_2_FORT_DEV);
182   MACRO(_SC_2_FORT_RUN);
183   MACRO(_SC_2_LOCALEDEF);
184   MACRO(_SC_2_SW_DEV);
185   MACRO(_SC_2_UPE);
186   MACRO(_SC_2_VERSION);
187   MACRO(_SC_ADVISORY_INFO);
188   MACRO(_SC_AIO_LISTIO_MAX);
189   MACRO(_SC_AIO_MAX);
190   MACRO(_SC_AIO_PRIO_DELTA_MAX);
191   MACRO(_SC_ARG_MAX);
192   MACRO(_SC_ASYNCHRONOUS_IO);
193   MACRO(_SC_ATEXIT_MAX);
194   MACRO(_SC_BARRIERS);
195   MACRO(_SC_BC_BASE_MAX);
196   MACRO(_SC_BC_DIM_MAX);
197   MACRO(_SC_BC_SCALE_MAX);
198   MACRO(_SC_BC_STRING_MAX);
199   MACRO(_SC_CHILD_MAX);
200   MACRO(_SC_CLK_TCK);
201   MACRO(_SC_CLOCK_SELECTION);
202   MACRO(_SC_COLL_WEIGHTS_MAX);
203   MACRO(_SC_CPUTIME);
204   MACRO(_SC_DELAYTIMER_MAX);
205   MACRO(_SC_EXPR_NEST_MAX);
206   MACRO(_SC_FSYNC);
207   MACRO(_SC_GETGR_R_SIZE_MAX);
208   MACRO(_SC_GETPW_R_SIZE_MAX);
209   MACRO(_SC_HOST_NAME_MAX);
210   MACRO(_SC_IOV_MAX);
211   MACRO(_SC_IPV6);
212   MACRO(_SC_JOB_CONTROL);
213   MACRO(_SC_LINE_MAX);
214   MACRO(_SC_LOGIN_NAME_MAX);
215   MACRO(_SC_MAPPED_FILES);
216   MACRO(_SC_MEMLOCK);
217   MACRO(_SC_MEMLOCK_RANGE);
218   MACRO(_SC_MEMORY_PROTECTION);
219   MACRO(_SC_MESSAGE_PASSING);
220   MACRO(_SC_MONOTONIC_CLOCK);
221   MACRO(_SC_MQ_OPEN_MAX);
222   MACRO(_SC_MQ_PRIO_MAX);
223   MACRO(_SC_NGROUPS_MAX);
224   MACRO(_SC_OPEN_MAX);
225   MACRO(_SC_PAGE_SIZE);
226   MACRO(_SC_PAGESIZE);
227   MACRO(_SC_PRIORITIZED_IO);
228   MACRO(_SC_PRIORITY_SCHEDULING);
229   MACRO(_SC_RAW_SOCKETS);
230   MACRO(_SC_RE_DUP_MAX);
231   MACRO(_SC_READER_WRITER_LOCKS);
232   MACRO(_SC_REALTIME_SIGNALS);
233   MACRO(_SC_REGEXP);
234   MACRO(_SC_RTSIG_MAX);
235   MACRO(_SC_SAVED_IDS);
236   MACRO(_SC_SEM_NSEMS_MAX);
237   MACRO(_SC_SEM_VALUE_MAX);
238   MACRO(_SC_SEMAPHORES);
239   MACRO(_SC_SHARED_MEMORY_OBJECTS);
240   MACRO(_SC_SHELL);
241   MACRO(_SC_SIGQUEUE_MAX);
242   MACRO(_SC_SPAWN);
243   MACRO(_SC_SPIN_LOCKS);
244   MACRO(_SC_SPORADIC_SERVER);
245   MACRO(_SC_SS_REPL_MAX);
246   MACRO(_SC_STREAM_MAX);
247   MACRO(_SC_SYMLOOP_MAX);
248   MACRO(_SC_SYNCHRONIZED_IO);
249   MACRO(_SC_THREAD_ATTR_STACKADDR);
250   MACRO(_SC_THREAD_ATTR_STACKSIZE);
251   MACRO(_SC_THREAD_CPUTIME);
252   MACRO(_SC_THREAD_DESTRUCTOR_ITERATIONS);
253   MACRO(_SC_THREAD_KEYS_MAX);
254   MACRO(_SC_THREAD_PRIO_INHERIT);
255   MACRO(_SC_THREAD_PRIO_PROTECT);
256   MACRO(_SC_THREAD_PRIORITY_SCHEDULING);
257   MACRO(_SC_THREAD_PROCESS_SHARED);
258   MACRO(_SC_THREAD_ROBUST_PRIO_INHERIT);
259   MACRO(_SC_THREAD_ROBUST_PRIO_PROTECT);
260   MACRO(_SC_THREAD_SAFE_FUNCTIONS);
261   MACRO(_SC_THREAD_SPORADIC_SERVER);
262   MACRO(_SC_THREAD_STACK_MIN);
263   MACRO(_SC_THREAD_THREADS_MAX);
264   MACRO(_SC_THREADS);
265   MACRO(_SC_TIMEOUTS);
266   MACRO(_SC_TIMER_MAX);
267   MACRO(_SC_TIMERS);
268   MACRO(_SC_TRACE);
269   MACRO(_SC_TRACE_EVENT_FILTER);
270   MACRO(_SC_TRACE_EVENT_NAME_MAX);
271   MACRO(_SC_TRACE_INHERIT);
272   MACRO(_SC_TRACE_LOG);
273   MACRO(_SC_TRACE_NAME_MAX);
274   MACRO(_SC_TRACE_SYS_MAX);
275   MACRO(_SC_TRACE_USER_EVENT_MAX);
276   MACRO(_SC_TYPED_MEMORY_OBJECTS);
277   MACRO(_SC_TZNAME_MAX);
278   MACRO(_SC_V7_ILP32_OFF32);
279   MACRO(_SC_VERSION);
280   MACRO(_SC_XOPEN_CRYPT);
281   MACRO(_SC_XOPEN_ENH_I18N);
282   MACRO(_SC_XOPEN_REALTIME);
283   MACRO(_SC_XOPEN_REALTIME_THREADS);
284   MACRO(_SC_XOPEN_SHM);
285   MACRO(_SC_XOPEN_STREAMS);
286   MACRO(_SC_XOPEN_UNIX);
287 #if 0 // No libc I can find actually has this.
288   MACRO(_SC_XOPEN_UUCP);
289 #endif
290   MACRO(_SC_XOPEN_VERSION);
291 
292   MACRO_VALUE(STDERR_FILENO, 2);
293   MACRO_VALUE(STDIN_FILENO, 0);
294   MACRO_VALUE(STDOUT_FILENO, 1);
295 
296   MACRO(_POSIX_VDISABLE);
297 
298   TYPE(size_t);
299   TYPE(ssize_t);
300   TYPE(uid_t);
301   TYPE(gid_t);
302   TYPE(off_t);
303   TYPE(pid_t);
304   TYPE(intptr_t);
305 
306   FUNCTION(access, int (*f)(const char*, int));
307   FUNCTION(alarm, unsigned (*f)(unsigned));
308   FUNCTION(chdir, int (*f)(const char*));
309   FUNCTION(chown, int (*f)(const char*, uid_t, gid_t));
310   FUNCTION(close, int (*f)(int));
311 #if !defined(__BIONIC__)
312   FUNCTION(confstr, size_t (*f)(int, char*, size_t));
313   FUNCTION(crypt, char* (*f)(const char*, const char*));
314 #endif
315   FUNCTION(dup, int (*f)(int));
316   FUNCTION(dup2, int (*f)(int, int));
317   FUNCTION(_exit, void (*f)(int));
318 #if !defined(__BIONIC__)
319   FUNCTION(encrypt, void (*f)(char[64], int));
320 #endif
321   FUNCTION(execl, int (*f)(const char*, const char*, ...));
322   FUNCTION(execle, int (*f)(const char*, const char*, ...));
323   FUNCTION(execlp, int (*f)(const char*, const char*, ...));
324   FUNCTION(execv, int (*f)(const char*, char* const[]));
325   FUNCTION(execve, int (*f)(const char*, char* const[], char* const[]));
326   FUNCTION(execvp, int (*f)(const char*, char* const[]));
327   FUNCTION(faccessat, int (*f)(int, const char*, int, int));
328   FUNCTION(fchdir, int (*f)(int));
329   FUNCTION(fchown, int (*f)(int, uid_t, gid_t));
330   FUNCTION(fchownat, int (*f)(int, const char*, uid_t, gid_t, int));
331   FUNCTION(fdatasync, int (*f)(int));
332   FUNCTION(fexecve, int (*f)(int, char* const[], char* const[]));
333   FUNCTION(fork, pid_t (*f)(void));
334   FUNCTION(fpathconf, long (*f)(int, int));
335   FUNCTION(fsync, int (*f)(int));
336   FUNCTION(ftruncate, int (*f)(int, off_t));
337   FUNCTION(getcwd, char* (*f)(char*, size_t));
338   FUNCTION(getegid, gid_t (*f)(void));
339   FUNCTION(geteuid, uid_t (*f)(void));
340   FUNCTION(getgid, gid_t (*f)(void));
341   FUNCTION(getgroups, int (*f)(int, gid_t[]));
342 #if !defined(__BIONIC__)
343   FUNCTION(gethostid, long (*f)(void));
344 #endif
345   FUNCTION(gethostname, int (*f)(char*, size_t));
346   FUNCTION(getlogin, char* (*f)(void));
347   FUNCTION(getlogin_r, int (*f)(char*, size_t));
348   FUNCTION(getopt, int (*f)(int, char* const[], const char*));
349   FUNCTION(getpgid, pid_t (*f)(pid_t));
350   FUNCTION(getpgrp, pid_t (*f)(void));
351   FUNCTION(getpid, pid_t (*f)(void));
352   FUNCTION(getppid, pid_t (*f)(void));
353   FUNCTION(getsid, pid_t (*f)(pid_t));
354   FUNCTION(getuid, uid_t (*f)(void));
355   FUNCTION(isatty, int (*f)(int));
356   FUNCTION(lchown, int (*f)(const char*, uid_t, gid_t));
357   FUNCTION(link, int (*f)(const char*, const char*));
358   FUNCTION(linkat, int (*f)(int, const char*, int, const char*, int));
359   FUNCTION(lockf, int (*f)(int, int, off_t));
360   FUNCTION(lseek, off_t (*f)(int, off_t, int));
361   FUNCTION(nice, int (*f)(int));
362   FUNCTION(pathconf, long (*f)(const char*, int));
363   FUNCTION(pause, int (*f)(void));
364   FUNCTION(pipe, int (*f)(int[2]));
365   FUNCTION(pread, ssize_t (*f)(int, void*, size_t, off_t));
366   FUNCTION(pwrite, ssize_t (*f)(int, const void*, size_t, off_t));
367   FUNCTION(read, ssize_t (*f)(int, void*, size_t));
368   FUNCTION(readlink, ssize_t (*f)(const char*, char*, size_t));
369   FUNCTION(readlinkat, ssize_t (*f)(int, const char*, char*, size_t));
370   FUNCTION(rmdir, int (*f)(const char*));
371   FUNCTION(setegid, int (*f)(gid_t));
372   FUNCTION(seteuid, int (*f)(uid_t));
373   FUNCTION(setgid, int (*f)(gid_t));
374   FUNCTION(setpgid, int (*f)(pid_t, pid_t));
375   FUNCTION(setpgrp, pid_t (*f)(void));
376   FUNCTION(setregid, int (*f)(gid_t, gid_t));
377   FUNCTION(setreuid, int (*f)(uid_t, uid_t));
378   FUNCTION(setsid, pid_t (*f)(void));
379   FUNCTION(setuid, int (*f)(uid_t));
380   FUNCTION(sleep, unsigned (*f)(unsigned));
381   FUNCTION(swab, void (*f)(const void*, void*, ssize_t));
382   FUNCTION(symlink, int (*f)(const char*, const char*));
383   FUNCTION(symlinkat, int (*f)(const char*, int, const char*));
384   FUNCTION(sync, void (*f)(void));
385   FUNCTION(sysconf, long (*f)(int));
386   FUNCTION(tcgetpgrp, pid_t (*f)(int));
387   FUNCTION(tcsetpgrp, int (*f)(int, pid_t));
388   FUNCTION(truncate, int (*f)(const char*, off_t));
389   FUNCTION(ttyname, char* (*f)(int));
390   FUNCTION(ttyname_r, int (*f)(int, char*, size_t));
391   FUNCTION(unlink, int (*f)(const char*));
392   FUNCTION(unlinkat, int (*f)(int, const char*, int));
393   FUNCTION(write, ssize_t (*f)(int, const void*, size_t));
394 
395   char* cp;
396   cp = optarg;
397   int i;
398   i = opterr;
399   i = optind;
400   i = optopt;
401 }
402