Rev 1618 | 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 | ------------ |
||
166 | giacomo | 23 | CVS : $Id: unistd.h,v 1.3 2003-05-22 09:35:08 giacomo Exp $ |
2 | pj | 24 | |
25 | File: $File$ |
||
166 | giacomo | 26 | Revision: $Revision: 1.3 $ |
27 | Last update: $Date: 2003-05-22 09:35:08 $ |
||
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> |
||
1621 | fabio | 93 | #include <arch/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 | |||
166 | giacomo | 240 | /*+ sleep for n useconds */ |
241 | unsigned int usleep(unsigned int usec); |
||
242 | |||
243 | #define udelay(x) usleep(x) |
||
2 | pj | 244 | /* |
245 | * |
||
246 | * |
||
247 | * |
||
248 | * |
||
249 | * |
||
250 | * |
||
251 | */ |
||
252 | |||
253 | /* X/Open version number to which the library conforms. It is selectable. */ |
||
254 | //#ifdef __USE_UNIX98 |
||
255 | //# define _XOPEN_VERSION 500 |
||
256 | //#else |
||
257 | //# define _XOPEN_VERSION 4 |
||
258 | //#endif |
||
259 | |||
260 | /* Commands and utilities from XPG4 are available. */ |
||
261 | //#define _XOPEN_XCU_VERSION 4 |
||
262 | |||
263 | /* We are compatible with the old published standards as well. */ |
||
264 | //#define _XOPEN_XPG2 1 |
||
265 | //#define _XOPEN_XPG3 1 |
||
266 | //#define _XOPEN_XPG4 1 |
||
267 | |||
268 | /* The X/Open Unix extensions are available. */ |
||
269 | //#define _XOPEN_UNIX 1 |
||
270 | |||
271 | /* Encryption is present. */ |
||
272 | //#define _XOPEN_CRYPT 1 |
||
273 | |||
274 | /* The enhanced internationalization capabilities according to XPG4.2 |
||
275 | are present. */ |
||
276 | //#define _XOPEN_ENH_I18N 1 |
||
277 | |||
278 | /* The legacy interfaces are also available. */ |
||
279 | //#define _XOPEN_LEGACY 1 |
||
280 | |||
281 | /* Standard file descriptors. */ |
||
282 | #define STDIN_FILENO 0 /* Standard input. */ |
||
283 | #define STDOUT_FILENO 1 /* Standard output. */ |
||
284 | #define STDERR_FILENO 2 /* Standard error output. */ |
||
285 | |||
286 | #include <ll/sys/types.h> |
||
287 | #include <sys/types.h> |
||
288 | |||
289 | __DJ_dev_t |
||
290 | #undef __DJ_dev_t |
||
291 | #define __DJ_dev_t |
||
292 | |||
293 | __DJ_ino_t |
||
294 | #undef __DJ_ino_t |
||
295 | #define __DJ_ino_t |
||
296 | |||
297 | __DJ_mode_t |
||
298 | #undef __DJ_mode_t |
||
299 | #define __DJ_mode_t |
||
300 | |||
301 | __DJ_nlink_t |
||
302 | #undef __DJ_nlink_t |
||
303 | #define __DJ_nlink_t |
||
304 | |||
305 | __DJ_gid_t |
||
306 | #undef __DJ_gid_t |
||
307 | #define __DJ_gid_t |
||
308 | |||
309 | __DJ_off_t |
||
310 | #undef __DJ_off_t |
||
311 | #define __DJ_off_t |
||
312 | |||
313 | __DJ_pid_t |
||
314 | #undef __DJ_pid_t |
||
315 | #define __DJ_pid_t |
||
316 | |||
317 | __DJ_uid_t |
||
318 | #undef __DJ_uid_t |
||
319 | #define __DJ_uid_t |
||
320 | |||
321 | /* Test for access to NAME using the real UID and real GID. */ |
||
322 | extern int access __P ((__const char *__name, int __type)); |
||
323 | #if defined __USE_BSD && !defined L_SET |
||
324 | |||
325 | /* Old BSD names for the same constants; just for compatibility. */ |
||
326 | # define L_SET SEEK_SET |
||
327 | # define L_INCR SEEK_CUR |
||
328 | # define L_XTND SEEK_END |
||
329 | #endif |
||
330 | |||
331 | /* Move FD's file position to OFFSET bytes from the |
||
332 | beginning of the file (if WHENCE is SEEK_SET), |
||
333 | the current position (if WHENCE is SEEK_CUR), |
||
334 | or the end of the file (if WHENCE is SEEK_END). |
||
335 | Return the new file position. */ |
||
336 | //extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence)); |
||
337 | #ifndef __USE_FILE_OFFSET64 |
||
338 | extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence)); |
||
339 | #else |
||
340 | # ifdef __REDIRECT |
||
341 | extern __off64_t __REDIRECT (lseek, |
||
342 | __P ((int __fd, __off64_t __offset, |
||
343 | int __whence)), |
||
344 | lseek64); |
||
345 | # else |
||
346 | # define lseek lseek64 |
||
347 | # endif |
||
348 | #endif |
||
349 | #ifdef __USE_LARGEFILE64 |
||
350 | extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); |
||
351 | #endif |
||
352 | |||
353 | /* Close the file descriptor FD. */ |
||
354 | //extern int __close __P ((int __fd)); |
||
355 | extern int close __P ((int __fd)); |
||
356 | |||
357 | /* Read NBYTES into BUF from FD. Return the |
||
358 | number read, -1 for errors or 0 for EOF. */ |
||
359 | //extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes)); |
||
360 | extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes)); |
||
361 | |||
362 | /* Write N bytes of BUF to FD. Return the number written, or -1. */ |
||
363 | //extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n)); |
||
364 | extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n)); |
||
365 | |||
366 | /* Change the process's working directory to PATH. */ |
||
367 | extern int chdir __P ((__const char *__path)); |
||
368 | |||
369 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
370 | /* Change the process's working directory to the one FD is open on. */ |
||
371 | //extern int fchdir __P ((int __fd)); |
||
372 | #endif |
||
373 | |||
374 | /* Get the pathname of the current working directory, |
||
375 | and put it in SIZE bytes of BUF. Returns NULL if the |
||
376 | directory couldn't be determined or SIZE was too small. |
||
377 | If successful, returns BUF. In GNU, if BUF is NULL, |
||
378 | an array is allocated with `malloc'; the array is SIZE |
||
379 | bytes long, unless SIZE == 0, in which case it is as |
||
380 | big as necessary. */ |
||
381 | extern char *getcwd __P ((char *__buf, size_t __size)); |
||
382 | |||
383 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
384 | /* Put the absolute pathname of the current working directory in BUF. |
||
385 | If successful, return BUF. If not, put an error message in |
||
386 | BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ |
||
387 | extern char *getwd __P ((char *__buf)); |
||
388 | #endif |
||
389 | |||
390 | |||
391 | /* Duplicate FD, returning a new file descriptor on the same file. */ |
||
392 | extern int dup __P ((int __fd)); |
||
393 | |||
394 | /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */ |
||
395 | extern int dup2 __P ((int __fd, int __fd2)); |
||
396 | |||
397 | /* Return 1 if FD is a valid descriptor associated |
||
398 | with a terminal, zero if not. */ |
||
399 | extern int isatty __P ((int __fd)); |
||
400 | |||
401 | /* Make all changes done to FD actually appear on disk. */ |
||
402 | extern int fsync __P ((int __fd)); |
||
403 | |||
404 | /* Truncate FILE to LENGTH bytes. */ |
||
405 | #ifndef __USE_FILE_OFFSET64 |
||
406 | extern int truncate __P ((__const char *__file, __off_t __length)); |
||
407 | #else |
||
408 | # ifdef __REDIRECT |
||
409 | extern int __REDIRECT (truncate, |
||
410 | __P ((__const char *__file, __off64_t __length)), |
||
411 | truncate64); |
||
412 | # else |
||
413 | # define truncate truncate64 |
||
414 | # endif |
||
415 | #endif |
||
416 | #ifdef __USE_LARGEFILE64 |
||
417 | extern int truncate64 __P ((__const char *__file, __off64_t __length)); |
||
418 | #endif |
||
419 | |||
420 | /* Truncate the file FD is open on to LENGTH bytes. */ |
||
421 | extern int __ftruncate __P ((int __fd, __off_t __length)); |
||
422 | #ifndef __USE_FILE_OFFSET64 |
||
423 | extern int ftruncate __P ((int __fd, __off_t __length)); |
||
424 | #else |
||
425 | # ifdef __REDIRECT |
||
426 | extern int __REDIRECT (ftruncate, __P ((int __fd, __off64_t __length)), |
||
427 | ftruncate64); |
||
428 | # else |
||
429 | # define ftruncate ftruncate64 |
||
430 | # endif |
||
431 | #endif |
||
432 | #ifdef __USE_LARGEFILE64 |
||
433 | extern int ftruncate64 __P ((int __fd, __off64_t __length)); |
||
434 | #endif |
||
435 | |||
436 | /* Return the maximum number of file descriptors |
||
437 | the current process could possibly have. */ |
||
438 | extern int getdtablesize __P ((void)); |
||
439 | |||
440 | /* Make a link to FROM named TO. */ |
||
441 | extern int link __P ((__const char *__from, __const char *__to)); |
||
442 | |||
443 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
444 | /* Make a symbolic link to FROM named TO. */ |
||
445 | extern int symlink __P ((__const char *__from, __const char *__to)); |
||
446 | |||
447 | /* Read the contents of the symbolic link PATH into no more than |
||
448 | LEN bytes of BUF. The contents are not null-terminated. |
||
449 | Returns the number of characters read, or -1 for errors. */ |
||
450 | extern int readlink __P ((__const char *__path, char *__buf, size_t __len)); |
||
451 | #endif /* Use BSD. */ |
||
452 | |||
453 | /* Remove the link NAME. */ |
||
454 | extern int unlink __P ((__const char *__name)); |
||
455 | |||
456 | /* Remove the directory PATH. */ |
||
457 | extern int rmdir __P ((__const char *__path)); |
||
458 | |||
459 | /* ??? */ |
||
460 | char *mktemp __P((char *)); |
||
461 | |||
462 | extern __inline__ pid_t getpid(void) |
||
463 | { |
||
464 | return 0; |
||
465 | } |
||
466 | |||
467 | extern long pathconf(const char *path, int name); |
||
468 | extern long fpathconf(int filedes, int name); |
||
469 | |||
80 | pj | 470 | __END_DECLS |
2 | pj | 471 | #endif /* !__UNISTD_H_ */ |