Rev 3 | Rev 166 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * Massimiliano Giorgi <massy@gandalf.sssup.it> |
||
11 | * Luca Abeni <luca@gandalf.sssup.it> |
||
12 | * (see the web pages for full authors list) |
||
13 | * |
||
14 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
15 | * |
||
16 | * http://www.sssup.it |
||
17 | * http://retis.sssup.it |
||
18 | * http://shark.sssup.it |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | ------------ |
||
80 | pj | 23 | CVS : $Id: unistd.h,v 1.2 2003-03-13 13:41:04 pj Exp $ |
2 | pj | 24 | |
25 | File: $File$ |
||
80 | pj | 26 | Revision: $Revision: 1.2 $ |
27 | Last update: $Date: 2003-03-13 13:41:04 $ |
||
2 | pj | 28 | ------------ |
29 | |||
30 | unistd.h, inspired on BSD one... |
||
31 | and heavy modified by Massy (inspired on GLibc one...) |
||
32 | |||
33 | **/ |
||
34 | |||
35 | /* |
||
36 | * Copyright (C) 2000 Paolo Gai |
||
37 | * |
||
38 | * This program is free software; you can redistribute it and/or modify |
||
39 | * it under the terms of the GNU General Public License as published by |
||
40 | * the Free Software Foundation; either version 2 of the License, or |
||
41 | * (at your option) any later version. |
||
42 | * |
||
43 | * This program is distributed in the hope that it will be useful, |
||
44 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
45 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
46 | * GNU General Public License for more details. |
||
47 | * |
||
48 | * You should have received a copy of the GNU General Public License |
||
49 | * along with this program; if not, write to the Free Software |
||
50 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
51 | * |
||
52 | */ |
||
53 | |||
54 | /* |
||
55 | * Copyright (c) 1989, 1993 |
||
56 | * The Regents of the University of California. All rights reserved. |
||
57 | * |
||
58 | * Redistribution and use in source and binary forms, with or without |
||
59 | * modification, are permitted provided that the following conditions |
||
60 | * are met: |
||
61 | * 1. Redistributions of source code must retain the above copyright |
||
62 | * notice, this list of conditions and the following disclaimer. |
||
63 | * 2. Redistributions in binary form must reproduce the above copyright |
||
64 | * notice, this list of conditions and the following disclaimer in the |
||
65 | * documentation and/or other materials provided with the distribution. |
||
66 | * 3. All advertising materials mentioning features or use of this software |
||
67 | * must display the following acknowledgement: |
||
68 | * This product includes software developed by the University of |
||
69 | * California, Berkeley and its contributors. |
||
70 | * 4. Neither the name of the University nor the names of its contributors |
||
71 | * may be used to endorse or promote products derived from this software |
||
72 | * without specific prior written permission. |
||
73 | * |
||
74 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
||
75 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
76 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
77 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
||
78 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
79 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||
80 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||
81 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||
82 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||
83 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||
84 | * SUCH DAMAGE. |
||
85 | * |
||
86 | * @(#)unistd.h 8.2 (Berkeley) 1/7/94 |
||
87 | */ |
||
88 | |||
89 | #ifndef __UNISTD_H__ |
||
90 | #define __UNISTD_H__ |
||
91 | |||
92 | #include <features.h> |
||
80 | pj | 93 | #include "ll/sys/cdefs.h" |
2 | pj | 94 | |
80 | pj | 95 | __BEGIN_DECLS |
96 | |||
2 | pj | 97 | void _exit(int status); |
98 | |||
99 | /* compile-time symbolic constants */ |
||
100 | |||
101 | /* NYI = Not Yet Implemented */ |
||
102 | |||
103 | // NYI #define _POSIX_ASYNCHRONOUS_IO |
||
104 | // NYI #define _POSIX_ASYNC_IO |
||
105 | // NRQ for PSE52 #define _POSIX_CHOWN_RESTRICTED 1 |
||
106 | // NYI #define _POSIX_FSYNC |
||
107 | // NRQ for PSE52 #define _POSIX_JOB_CONTROL |
||
108 | // NYI #define _POSIX_MAPPED_FILES |
||
109 | // NYI #define _POSIX_MEMLOCK |
||
110 | // NYI #define _POSIX_MEMLOCK_RANGE |
||
111 | // NRQ for PSE52 #define _POSIX_MEMORY_PROTECTION |
||
112 | #define _POSIX_MESSAGE_PASSING |
||
113 | // NYI #define _POSIX_NO_TRUNC 1 |
||
114 | // NRQ for PSE52 #define _POSIX_PRIORITIZED_IO |
||
115 | // NRQ for PSE52 #define _POSIX_PRIORITY_SCHEDULING |
||
116 | // NYI #define _POSIX_PRIO_IO |
||
117 | #define _POSIX_REALTIME_SIGNALS |
||
118 | // NRQ for PSE52 #define _POSIX_SAVED_IDS |
||
119 | #define _POSIX_SEMAPHORES |
||
120 | // NYI #define _POSIX_SHARED_MEMORY_OBJECTS |
||
121 | // NYI #define _POSIX_SYNCHRONIZED_IO |
||
122 | // NYI #define _POSIX_SYNC_IO |
||
123 | #define _POSIX_THREADS |
||
124 | #define _POSIX_THREAD_ATTR_STACKADDR |
||
125 | #define _POSIX_THREAD_ATTR_STACKSIZE |
||
126 | #define _POSIX_THREAD_PRIO_INHERIT |
||
127 | #define _POSIX_THREAD_PRIO_PROTECT |
||
128 | #define _POSIX_THREAD_PRIORITY_SCHEDULING |
||
129 | // NRQ for PSE52 #define _POSIX_THREAD_PROCESS_SHARED |
||
130 | // NYI #define _POSIX_THREAD_SAFE_FUNCTIONS |
||
131 | #define _POSIX_TIMERS |
||
132 | // NRQ for PSE52 #define _POSIX_VDISABLE 0xff |
||
133 | #define _POSIX_VERSION 199506L |
||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
140 | |||
141 | /* access function */ |
||
142 | #define F_OK 0 /* test for existence of file */ |
||
143 | #define X_OK 0x01 /* test for execute or search permission */ |
||
144 | #define W_OK 0x02 /* test for write permission */ |
||
145 | #define R_OK 0x04 /* test for read permission */ |
||
146 | |||
147 | /* whence values for lseek(2) */ |
||
148 | #define SEEK_SET 0 /* set file offset to offset */ |
||
149 | #define SEEK_CUR 1 /* set file offset to current plus offset */ |
||
150 | #define SEEK_END 2 /* set file offset to EOF plus offset */ |
||
151 | |||
152 | #ifndef _POSIX_SOURCE |
||
153 | /* whence values for lseek(2); renamed by POSIX 1003.1 */ |
||
154 | #define L_SET SEEK_SET |
||
155 | #define L_INCR SEEK_CUR |
||
156 | #define L_XTND SEEK_END |
||
157 | #endif |
||
158 | |||
159 | /* configurable pathname variables */ |
||
160 | #define _PC_ASYNC_IO 1 |
||
161 | #define _PC_CHOWN_RESTRICTED 2 |
||
162 | #define _PC_LINK_MAX 3 |
||
163 | #define _PC_MAX_CANON 4 |
||
164 | #define _PC_MAX_INPUT 5 |
||
165 | #define _PC_NAME_MAX 6 |
||
166 | #define _PC_NO_TRUNC 7 |
||
167 | #define _PC_PATH_MAX 8 |
||
168 | #define _PC_PIPE_BUF 9 |
||
169 | #define _PC_PRIO_IO 10 |
||
170 | #define _PC_SYNC_IO 11 |
||
171 | #define _PC_VDISABLE 12 |
||
172 | |||
173 | /* configurable system variables */ |
||
174 | #define _SC_AIO_LISTIO_MAX 1 |
||
175 | #define _SC_AIO_MAX 2 |
||
176 | #define _SC_AIO_PRIO_DELTA_MAX 3 |
||
177 | #define _SC_ARG_MAX 4 |
||
178 | #define _SC_CHILD_MAX 5 |
||
179 | #define _SC_CLK_TICK 6 |
||
180 | #define _SC_DELAYTIMER_MAX 7 |
||
181 | #define _SC_GETGR_R_SIZE_MAX 8 |
||
182 | #define _SC_GETPW_R_SIZE_MAX 9 |
||
183 | #define _SC_LOGIN_NAME_MAX 10 |
||
184 | #define _SC_MQ_OPEN_MAX 11 |
||
185 | #define _SC_MQ_PRIO_MAX 12 |
||
186 | #define _SC_NGROUPS_MAX 13 |
||
187 | #define _SC_OPEN_MAX 14 |
||
188 | #define _SC_PAGESIZE 15 |
||
189 | #define _SC_RTSIG_MAX 16 |
||
190 | #define _SC_SEM_NSEMS_MAX 17 |
||
191 | #define _SC_SEM_VALUE_MAX 18 |
||
192 | #define _SC_SIGQUEUE_MAX 19 |
||
193 | #define _SC_STREAM_MAX 20 |
||
194 | #define _SC_THREAD_DESTRUCTOR_ITERATIONS 21 |
||
195 | #define _SC_THREAD_KEYS_MAX 22 |
||
196 | #define _SC_THREAD_STACK_MIN 23 |
||
197 | #define _SC_THREAD_THREADS_MAX 24 |
||
198 | #define _SC_TIMER_MAX 25 |
||
199 | #define _SC_TTY_NAME_MAX 26 |
||
200 | #define _SC_TZNAME_MAX 27 |
||
201 | |||
202 | #define _SC_ASYNCHRONOUS_IO 28 |
||
203 | #define _SC_FSYNC 29 |
||
204 | #define _SC_JOB_CONTROL 30 |
||
205 | #define _SC_MAPPED_FILES 31 |
||
206 | #define _SC_MEMLOCK 32 |
||
207 | #define _SC_MEMLOCK_RANGE 33 |
||
208 | #define _SC_MEMORY_PROTECTION 34 |
||
209 | #define _SC_MESSAGE_PASSING 35 |
||
210 | #define _SC_PRIORITIZED_IO 36 |
||
211 | #define _SC_PRIORITY_SCHEDULING 37 |
||
212 | #define _SC_REALTIME_SIGNALS 38 |
||
213 | #define _SC_SAVED_IDS 39 |
||
214 | #define _SC_SEMAPHORES 40 |
||
215 | #define _SC_SHARED_MEMORY_OBJECTS 41 |
||
216 | #define _SC_SYNCHRONIZED_IO 42 |
||
217 | #define _SC_TIMERS 43 |
||
218 | #define _SC_THREADS 44 |
||
219 | #define _SC_THREAD_ATTR_STACKADDR 45 |
||
220 | #define _SC_THREAD_ATTR_STACKSIZE 46 |
||
221 | #define _SC_THREAD_PRIORITY_SCHEDULING 47 |
||
222 | #define _SC_THREAD_PRIO_INHERIT 48 |
||
223 | #define _SC_THREAD_PRIO_PROTECT 49 |
||
224 | #define _SC_THREAD_PROCESS_SHARED 50 |
||
225 | #define _SC_THREAD_SAFE_FUNCTIONS 51 |
||
226 | #define _SC_VERSION 52 |
||
227 | |||
228 | /* configurable system strings */ |
||
229 | #define _CS_PATH 1 |
||
230 | |||
231 | /*+ send an alarm signal +*/ |
||
232 | unsigned int alarm(unsigned int seconds); |
||
233 | |||
234 | /*+ wait a signal delivery +*/ |
||
235 | int pause(void); |
||
236 | |||
237 | /*+ sleep for n seconds or until a signal is delivered to the thread +*/ |
||
238 | unsigned int sleep(unsigned int seconds); |
||
239 | |||
240 | /* |
||
241 | * |
||
242 | * |
||
243 | * |
||
244 | * |
||
245 | * |
||
246 | * |
||
247 | */ |
||
248 | |||
249 | /* X/Open version number to which the library conforms. It is selectable. */ |
||
250 | //#ifdef __USE_UNIX98 |
||
251 | //# define _XOPEN_VERSION 500 |
||
252 | //#else |
||
253 | //# define _XOPEN_VERSION 4 |
||
254 | //#endif |
||
255 | |||
256 | /* Commands and utilities from XPG4 are available. */ |
||
257 | //#define _XOPEN_XCU_VERSION 4 |
||
258 | |||
259 | /* We are compatible with the old published standards as well. */ |
||
260 | //#define _XOPEN_XPG2 1 |
||
261 | //#define _XOPEN_XPG3 1 |
||
262 | //#define _XOPEN_XPG4 1 |
||
263 | |||
264 | /* The X/Open Unix extensions are available. */ |
||
265 | //#define _XOPEN_UNIX 1 |
||
266 | |||
267 | /* Encryption is present. */ |
||
268 | //#define _XOPEN_CRYPT 1 |
||
269 | |||
270 | /* The enhanced internationalization capabilities according to XPG4.2 |
||
271 | are present. */ |
||
272 | //#define _XOPEN_ENH_I18N 1 |
||
273 | |||
274 | /* The legacy interfaces are also available. */ |
||
275 | //#define _XOPEN_LEGACY 1 |
||
276 | |||
277 | /* Standard file descriptors. */ |
||
278 | #define STDIN_FILENO 0 /* Standard input. */ |
||
279 | #define STDOUT_FILENO 1 /* Standard output. */ |
||
280 | #define STDERR_FILENO 2 /* Standard error output. */ |
||
281 | |||
282 | #include <ll/sys/types.h> |
||
283 | #include <sys/types.h> |
||
284 | |||
285 | __DJ_dev_t |
||
286 | #undef __DJ_dev_t |
||
287 | #define __DJ_dev_t |
||
288 | |||
289 | __DJ_ino_t |
||
290 | #undef __DJ_ino_t |
||
291 | #define __DJ_ino_t |
||
292 | |||
293 | __DJ_mode_t |
||
294 | #undef __DJ_mode_t |
||
295 | #define __DJ_mode_t |
||
296 | |||
297 | __DJ_nlink_t |
||
298 | #undef __DJ_nlink_t |
||
299 | #define __DJ_nlink_t |
||
300 | |||
301 | __DJ_gid_t |
||
302 | #undef __DJ_gid_t |
||
303 | #define __DJ_gid_t |
||
304 | |||
305 | __DJ_off_t |
||
306 | #undef __DJ_off_t |
||
307 | #define __DJ_off_t |
||
308 | |||
309 | __DJ_pid_t |
||
310 | #undef __DJ_pid_t |
||
311 | #define __DJ_pid_t |
||
312 | |||
313 | __DJ_uid_t |
||
314 | #undef __DJ_uid_t |
||
315 | #define __DJ_uid_t |
||
316 | |||
317 | /* Test for access to NAME using the real UID and real GID. */ |
||
318 | extern int access __P ((__const char *__name, int __type)); |
||
319 | #if defined __USE_BSD && !defined L_SET |
||
320 | |||
321 | /* Old BSD names for the same constants; just for compatibility. */ |
||
322 | # define L_SET SEEK_SET |
||
323 | # define L_INCR SEEK_CUR |
||
324 | # define L_XTND SEEK_END |
||
325 | #endif |
||
326 | |||
327 | /* Move FD's file position to OFFSET bytes from the |
||
328 | beginning of the file (if WHENCE is SEEK_SET), |
||
329 | the current position (if WHENCE is SEEK_CUR), |
||
330 | or the end of the file (if WHENCE is SEEK_END). |
||
331 | Return the new file position. */ |
||
332 | //extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence)); |
||
333 | #ifndef __USE_FILE_OFFSET64 |
||
334 | extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence)); |
||
335 | #else |
||
336 | # ifdef __REDIRECT |
||
337 | extern __off64_t __REDIRECT (lseek, |
||
338 | __P ((int __fd, __off64_t __offset, |
||
339 | int __whence)), |
||
340 | lseek64); |
||
341 | # else |
||
342 | # define lseek lseek64 |
||
343 | # endif |
||
344 | #endif |
||
345 | #ifdef __USE_LARGEFILE64 |
||
346 | extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); |
||
347 | #endif |
||
348 | |||
349 | /* Close the file descriptor FD. */ |
||
350 | //extern int __close __P ((int __fd)); |
||
351 | extern int close __P ((int __fd)); |
||
352 | |||
353 | /* Read NBYTES into BUF from FD. Return the |
||
354 | number read, -1 for errors or 0 for EOF. */ |
||
355 | //extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes)); |
||
356 | extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes)); |
||
357 | |||
358 | /* Write N bytes of BUF to FD. Return the number written, or -1. */ |
||
359 | //extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n)); |
||
360 | extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n)); |
||
361 | |||
362 | /* Change the process's working directory to PATH. */ |
||
363 | extern int chdir __P ((__const char *__path)); |
||
364 | |||
365 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
366 | /* Change the process's working directory to the one FD is open on. */ |
||
367 | //extern int fchdir __P ((int __fd)); |
||
368 | #endif |
||
369 | |||
370 | /* Get the pathname of the current working directory, |
||
371 | and put it in SIZE bytes of BUF. Returns NULL if the |
||
372 | directory couldn't be determined or SIZE was too small. |
||
373 | If successful, returns BUF. In GNU, if BUF is NULL, |
||
374 | an array is allocated with `malloc'; the array is SIZE |
||
375 | bytes long, unless SIZE == 0, in which case it is as |
||
376 | big as necessary. */ |
||
377 | extern char *getcwd __P ((char *__buf, size_t __size)); |
||
378 | |||
379 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
380 | /* Put the absolute pathname of the current working directory in BUF. |
||
381 | If successful, return BUF. If not, put an error message in |
||
382 | BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ |
||
383 | extern char *getwd __P ((char *__buf)); |
||
384 | #endif |
||
385 | |||
386 | |||
387 | /* Duplicate FD, returning a new file descriptor on the same file. */ |
||
388 | extern int dup __P ((int __fd)); |
||
389 | |||
390 | /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */ |
||
391 | extern int dup2 __P ((int __fd, int __fd2)); |
||
392 | |||
393 | /* Return 1 if FD is a valid descriptor associated |
||
394 | with a terminal, zero if not. */ |
||
395 | extern int isatty __P ((int __fd)); |
||
396 | |||
397 | /* Make all changes done to FD actually appear on disk. */ |
||
398 | extern int fsync __P ((int __fd)); |
||
399 | |||
400 | /* Truncate FILE to LENGTH bytes. */ |
||
401 | #ifndef __USE_FILE_OFFSET64 |
||
402 | extern int truncate __P ((__const char *__file, __off_t __length)); |
||
403 | #else |
||
404 | # ifdef __REDIRECT |
||
405 | extern int __REDIRECT (truncate, |
||
406 | __P ((__const char *__file, __off64_t __length)), |
||
407 | truncate64); |
||
408 | # else |
||
409 | # define truncate truncate64 |
||
410 | # endif |
||
411 | #endif |
||
412 | #ifdef __USE_LARGEFILE64 |
||
413 | extern int truncate64 __P ((__const char *__file, __off64_t __length)); |
||
414 | #endif |
||
415 | |||
416 | /* Truncate the file FD is open on to LENGTH bytes. */ |
||
417 | extern int __ftruncate __P ((int __fd, __off_t __length)); |
||
418 | #ifndef __USE_FILE_OFFSET64 |
||
419 | extern int ftruncate __P ((int __fd, __off_t __length)); |
||
420 | #else |
||
421 | # ifdef __REDIRECT |
||
422 | extern int __REDIRECT (ftruncate, __P ((int __fd, __off64_t __length)), |
||
423 | ftruncate64); |
||
424 | # else |
||
425 | # define ftruncate ftruncate64 |
||
426 | # endif |
||
427 | #endif |
||
428 | #ifdef __USE_LARGEFILE64 |
||
429 | extern int ftruncate64 __P ((int __fd, __off64_t __length)); |
||
430 | #endif |
||
431 | |||
432 | /* Return the maximum number of file descriptors |
||
433 | the current process could possibly have. */ |
||
434 | extern int getdtablesize __P ((void)); |
||
435 | |||
436 | /* Make a link to FROM named TO. */ |
||
437 | extern int link __P ((__const char *__from, __const char *__to)); |
||
438 | |||
439 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
440 | /* Make a symbolic link to FROM named TO. */ |
||
441 | extern int symlink __P ((__const char *__from, __const char *__to)); |
||
442 | |||
443 | /* Read the contents of the symbolic link PATH into no more than |
||
444 | LEN bytes of BUF. The contents are not null-terminated. |
||
445 | Returns the number of characters read, or -1 for errors. */ |
||
446 | extern int readlink __P ((__const char *__path, char *__buf, size_t __len)); |
||
447 | #endif /* Use BSD. */ |
||
448 | |||
449 | /* Remove the link NAME. */ |
||
450 | extern int unlink __P ((__const char *__name)); |
||
451 | |||
452 | /* Remove the directory PATH. */ |
||
453 | extern int rmdir __P ((__const char *__path)); |
||
454 | |||
455 | /* ??? */ |
||
456 | char *mktemp __P((char *)); |
||
457 | |||
458 | extern __inline__ pid_t getpid(void) |
||
459 | { |
||
460 | return 0; |
||
461 | } |
||
462 | |||
463 | extern long pathconf(const char *path, int name); |
||
464 | extern long fpathconf(int filedes, int name); |
||
465 | |||
80 | pj | 466 | __END_DECLS |
2 | pj | 467 | #endif /* !__UNISTD_H_ */ |