Subversion Repositories shark

Rev

Rev 2 | Rev 80 | 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
 ------------
23
 CVS :        $Id: unistd.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1.1.1 $
27
 Last update: $Date: 2002-03-29 14:12:51 $
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>
93
 
94
void _exit(int status);
95
 
96
/* compile-time symbolic constants */
97
 
98
/* NYI = Not Yet Implemented */
99
 
100
// NYI #define _POSIX_ASYNCHRONOUS_IO
101
// NYI #define _POSIX_ASYNC_IO
102
// NRQ for PSE52 #define        _POSIX_CHOWN_RESTRICTED 1
103
// NYI #define _POSIX_FSYNC
104
// NRQ for PSE52 #define        _POSIX_JOB_CONTROL
105
// NYI #define _POSIX_MAPPED_FILES
106
// NYI #define _POSIX_MEMLOCK
107
// NYI #define _POSIX_MEMLOCK_RANGE
108
// NRQ for PSE52 #define _POSIX_MEMORY_PROTECTION
109
#define _POSIX_MESSAGE_PASSING
110
// NYI #define  _POSIX_NO_TRUNC         1
111
// NRQ for PSE52 #define _POSIX_PRIORITIZED_IO
112
// NRQ for PSE52 #define _POSIX_PRIORITY_SCHEDULING
113
// NYI #define _POSIX_PRIO_IO
114
#define _POSIX_REALTIME_SIGNALS
115
// NRQ for PSE52 #define        _POSIX_SAVED_IDS
116
#define _POSIX_SEMAPHORES
117
// NYI #define _POSIX_SHARED_MEMORY_OBJECTS
118
// NYI #define _POSIX_SYNCHRONIZED_IO
119
// NYI #define _POSIX_SYNC_IO
120
#define _POSIX_THREADS
121
#define _POSIX_THREAD_ATTR_STACKADDR
122
#define _POSIX_THREAD_ATTR_STACKSIZE
123
#define _POSIX_THREAD_PRIO_INHERIT
124
#define _POSIX_THREAD_PRIO_PROTECT
125
#define _POSIX_THREAD_PRIORITY_SCHEDULING
126
// NRQ for PSE52 #define _POSIX_THREAD_PROCESS_SHARED
127
// NYI #define _POSIX_THREAD_SAFE_FUNCTIONS
128
#define _POSIX_TIMERS
129
// NRQ for PSE52 #define        _POSIX_VDISABLE         0xff
130
#define _POSIX_VERSION          199506L
131
 
132
 
133
 
134
 
135
 
136
 
137
 
138
/* access function */
139
#define F_OK            0       /* test for existence of file */
140
#define X_OK            0x01    /* test for execute or search permission */
141
#define W_OK            0x02    /* test for write permission */
142
#define R_OK            0x04    /* test for read permission */
143
 
144
/* whence values for lseek(2) */
145
#define SEEK_SET        0       /* set file offset to offset */
146
#define SEEK_CUR        1       /* set file offset to current plus offset */
147
#define SEEK_END        2       /* set file offset to EOF plus offset */
148
 
149
#ifndef _POSIX_SOURCE
150
/* whence values for lseek(2); renamed by POSIX 1003.1 */
151
#define L_SET           SEEK_SET
152
#define L_INCR          SEEK_CUR
153
#define L_XTND          SEEK_END
154
#endif
155
 
156
/* configurable pathname variables */
157
#define _PC_ASYNC_IO             1
158
#define _PC_CHOWN_RESTRICTED     2
159
#define _PC_LINK_MAX             3
160
#define _PC_MAX_CANON            4
161
#define _PC_MAX_INPUT            5
162
#define _PC_NAME_MAX             6
163
#define _PC_NO_TRUNC             7
164
#define _PC_PATH_MAX             8
165
#define _PC_PIPE_BUF             9
166
#define _PC_PRIO_IO             10
167
#define _PC_SYNC_IO             11
168
#define _PC_VDISABLE            12
169
 
170
/* configurable system variables */
171
#define _SC_AIO_LISTIO_MAX                1
172
#define _SC_AIO_MAX                       2
173
#define _SC_AIO_PRIO_DELTA_MAX            3
174
#define _SC_ARG_MAX                       4
175
#define _SC_CHILD_MAX                     5
176
#define _SC_CLK_TICK                      6
177
#define _SC_DELAYTIMER_MAX                7
178
#define _SC_GETGR_R_SIZE_MAX              8
179
#define _SC_GETPW_R_SIZE_MAX              9
180
#define _SC_LOGIN_NAME_MAX               10
181
#define _SC_MQ_OPEN_MAX                  11
182
#define _SC_MQ_PRIO_MAX                  12
183
#define _SC_NGROUPS_MAX                  13
184
#define _SC_OPEN_MAX                     14
185
#define _SC_PAGESIZE                     15
186
#define _SC_RTSIG_MAX                    16
187
#define _SC_SEM_NSEMS_MAX                17
188
#define _SC_SEM_VALUE_MAX                18
189
#define _SC_SIGQUEUE_MAX                 19
190
#define _SC_STREAM_MAX                   20
191
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 21
192
#define _SC_THREAD_KEYS_MAX              22
193
#define _SC_THREAD_STACK_MIN             23
194
#define _SC_THREAD_THREADS_MAX           24
195
#define _SC_TIMER_MAX                    25
196
#define _SC_TTY_NAME_MAX                 26
197
#define _SC_TZNAME_MAX                   27
198
 
199
#define _SC_ASYNCHRONOUS_IO              28
200
#define _SC_FSYNC                        29
201
#define _SC_JOB_CONTROL                  30
202
#define _SC_MAPPED_FILES                 31
203
#define _SC_MEMLOCK                      32
204
#define _SC_MEMLOCK_RANGE                33
205
#define _SC_MEMORY_PROTECTION            34
206
#define _SC_MESSAGE_PASSING              35
207
#define _SC_PRIORITIZED_IO               36
208
#define _SC_PRIORITY_SCHEDULING          37
209
#define _SC_REALTIME_SIGNALS             38
210
#define _SC_SAVED_IDS                    39
211
#define _SC_SEMAPHORES                   40
212
#define _SC_SHARED_MEMORY_OBJECTS        41
213
#define _SC_SYNCHRONIZED_IO              42
214
#define _SC_TIMERS                       43
215
#define _SC_THREADS                      44
216
#define _SC_THREAD_ATTR_STACKADDR        45
217
#define _SC_THREAD_ATTR_STACKSIZE        46
218
#define _SC_THREAD_PRIORITY_SCHEDULING   47
219
#define _SC_THREAD_PRIO_INHERIT          48
220
#define _SC_THREAD_PRIO_PROTECT          49
221
#define _SC_THREAD_PROCESS_SHARED        50
222
#define _SC_THREAD_SAFE_FUNCTIONS        51
223
#define _SC_VERSION                      52
224
 
225
/* configurable system strings */
226
#define _CS_PATH                 1
227
 
228
/*+ send an alarm signal +*/
229
unsigned int alarm(unsigned int seconds);
230
 
231
/*+ wait a signal delivery +*/
232
int pause(void);
233
 
234
/*+ sleep for n seconds or until a signal is delivered to the thread +*/
235
unsigned int sleep(unsigned int seconds);
236
 
237
/*
238
 *
239
 *
240
 *
241
 *
242
 *
243
 *
244
 */
245
 
246
/* X/Open version number to which the library conforms.  It is selectable.  */
247
//#ifdef __USE_UNIX98
248
//# define _XOPEN_VERSION       500
249
//#else
250
//# define _XOPEN_VERSION       4
251
//#endif
252
 
253
/* Commands and utilities from XPG4 are available.  */
254
//#define _XOPEN_XCU_VERSION    4
255
 
256
/* We are compatible with the old published standards as well.  */
257
//#define _XOPEN_XPG2   1
258
//#define _XOPEN_XPG3   1
259
//#define _XOPEN_XPG4   1
260
 
261
/* The X/Open Unix extensions are available.  */
262
//#define _XOPEN_UNIX   1
263
 
264
/* Encryption is present.  */
265
//#define       _XOPEN_CRYPT    1
266
 
267
/* The enhanced internationalization capabilities according to XPG4.2
268
   are present.  */
269
//#define       _XOPEN_ENH_I18N 1
270
 
271
/* The legacy interfaces are also available.  */
272
//#define _XOPEN_LEGACY 1
273
 
274
/* Standard file descriptors.  */
275
#define STDIN_FILENO    0       /* Standard input.  */
276
#define STDOUT_FILENO   1       /* Standard output.  */
277
#define STDERR_FILENO   2       /* Standard error output.  */
278
 
279
#include <ll/sys/types.h>
280
#include <sys/types.h>
281
 
282
__DJ_dev_t
283
#undef __DJ_dev_t
284
#define __DJ_dev_t
285
 
286
__DJ_ino_t
287
#undef __DJ_ino_t
288
#define __DJ_ino_t
289
 
290
__DJ_mode_t
291
#undef __DJ_mode_t
292
#define __DJ_mode_t
293
 
294
__DJ_nlink_t
295
#undef __DJ_nlink_t
296
#define __DJ_nlink_t
297
 
298
__DJ_gid_t
299
#undef __DJ_gid_t
300
#define __DJ_gid_t
301
 
302
__DJ_off_t
303
#undef __DJ_off_t
304
#define __DJ_off_t
305
 
306
__DJ_pid_t
307
#undef __DJ_pid_t
308
#define __DJ_pid_t
309
 
310
__DJ_uid_t
311
#undef __DJ_uid_t
312
#define __DJ_uid_t
313
 
314
/* Test for access to NAME using the real UID and real GID.  */
315
extern int access __P ((__const char *__name, int __type));
316
#if defined __USE_BSD && !defined L_SET
317
 
318
/* Old BSD names for the same constants; just for compatibility.  */
319
# define L_SET          SEEK_SET
320
# define L_INCR         SEEK_CUR
321
# define L_XTND         SEEK_END
322
#endif
323
 
324
/* Move FD's file position to OFFSET bytes from the
325
   beginning of the file (if WHENCE is SEEK_SET),
326
   the current position (if WHENCE is SEEK_CUR),
327
   or the end of the file (if WHENCE is SEEK_END).
328
   Return the new file position.  */
329
//extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence));
330
#ifndef __USE_FILE_OFFSET64
331
extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence));
332
#else
333
# ifdef __REDIRECT
334
extern __off64_t __REDIRECT (lseek,
335
                             __P ((int __fd, __off64_t __offset,
336
                                   int __whence)),
337
                             lseek64);
338
# else
339
#  define lseek lseek64
340
# endif
341
#endif
342
#ifdef __USE_LARGEFILE64
343
extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
344
#endif
345
 
346
/* Close the file descriptor FD.  */
347
//extern int __close __P ((int __fd));
348
extern int close __P ((int __fd));
349
 
350
/* Read NBYTES into BUF from FD.  Return the
351
   number read, -1 for errors or 0 for EOF.  */
352
//extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
353
extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
354
 
355
/* Write N bytes of BUF to FD.  Return the number written, or -1.  */
356
//extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
357
extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
358
 
359
/* Change the process's working directory to PATH.  */
360
extern int chdir __P ((__const char *__path));
361
 
362
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
363
/* Change the process's working directory to the one FD is open on.  */
364
//extern int fchdir __P ((int __fd));
365
#endif
366
 
367
/* Get the pathname of the current working directory,
368
   and put it in SIZE bytes of BUF.  Returns NULL if the
369
   directory couldn't be determined or SIZE was too small.
370
   If successful, returns BUF.  In GNU, if BUF is NULL,
371
   an array is allocated with `malloc'; the array is SIZE
372
   bytes long, unless SIZE == 0, in which case it is as
373
   big as necessary.  */
374
extern char *getcwd __P ((char *__buf, size_t __size));
375
 
376
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
377
/* Put the absolute pathname of the current working directory in BUF.
378
   If successful, return BUF.  If not, put an error message in
379
   BUF and return NULL.  BUF should be at least PATH_MAX bytes long.  */
380
extern char *getwd __P ((char *__buf));
381
#endif
382
 
383
 
384
/* Duplicate FD, returning a new file descriptor on the same file.  */
385
extern int dup __P ((int __fd));
386
 
387
/* Duplicate FD to FD2, closing FD2 and making it open on the same file.  */
388
extern int dup2 __P ((int __fd, int __fd2));
389
 
390
/* Return 1 if FD is a valid descriptor associated
391
   with a terminal, zero if not.  */
392
extern int isatty __P ((int __fd));
393
 
394
/* Make all changes done to FD actually appear on disk.  */
395
extern int fsync __P ((int __fd));
396
 
397
/* Truncate FILE to LENGTH bytes.  */
398
#ifndef __USE_FILE_OFFSET64
399
extern int truncate __P ((__const char *__file, __off_t __length));
400
#else
401
# ifdef __REDIRECT
402
extern int __REDIRECT (truncate,
403
                       __P ((__const char *__file, __off64_t __length)),
404
                       truncate64);
405
# else
406
#  define truncate truncate64
407
# endif
408
#endif
409
#ifdef __USE_LARGEFILE64
410
extern int truncate64 __P ((__const char *__file, __off64_t __length));
411
#endif
412
 
413
/* Truncate the file FD is open on to LENGTH bytes.  */
414
extern int __ftruncate __P ((int __fd, __off_t __length));
415
#ifndef __USE_FILE_OFFSET64
416
extern int ftruncate __P ((int __fd, __off_t __length));
417
#else
418
# ifdef __REDIRECT
419
extern int __REDIRECT (ftruncate, __P ((int __fd, __off64_t __length)),
420
                       ftruncate64);
421
# else
422
#  define ftruncate ftruncate64
423
# endif
424
#endif
425
#ifdef __USE_LARGEFILE64
426
extern int ftruncate64 __P ((int __fd, __off64_t __length));
427
#endif
428
 
429
/* Return the maximum number of file descriptors
430
   the current process could possibly have.  */
431
extern int getdtablesize __P ((void));
432
 
433
/* Make a link to FROM named TO.  */
434
extern int link __P ((__const char *__from, __const char *__to));
435
 
436
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
437
/* Make a symbolic link to FROM named TO.  */
438
extern int symlink __P ((__const char *__from, __const char *__to));
439
 
440
/* Read the contents of the symbolic link PATH into no more than
441
   LEN bytes of BUF.  The contents are not null-terminated.
442
   Returns the number of characters read, or -1 for errors.  */
443
extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
444
#endif /* Use BSD.  */
445
 
446
/* Remove the link NAME.  */
447
extern int unlink __P ((__const char *__name));
448
 
449
/* Remove the directory PATH.  */
450
extern int rmdir __P ((__const char *__path));
451
 
452
/* ??? */
453
char    *mktemp __P((char *));
454
 
455
extern __inline__ pid_t getpid(void)
456
{
457
  return 0;
458
}
459
 
460
extern long pathconf(const char *path, int name);
461
extern long fpathconf(int filedes, int name);
462
 
463
#endif /* !__UNISTD_H_ */