1 /* This header file provides the reentrancy. */ 2 3 /* The reentrant system calls here serve two purposes: 4 5 1) Provide reentrant versions of the system calls the ANSI C library 6 requires. 7 2) Provide these system calls in a namespace clean way. 8 9 It is intended that *all* system calls that the ANSI C library needs 10 be declared here. It documents them all in one place. All library access 11 to the system is via some form of these functions. 12 13 There are three ways a target may provide the needed syscalls. 14 15 1) Define the reentrant versions of the syscalls directly. 16 (eg: _open_r, _close_r, etc.). Please keep the namespace clean. 17 When you do this, set "syscall_dir" to "syscalls" and add 18 -DREENTRANT_SYSCALLS_PROVIDED to newlib_cflags in configure.host. 19 20 2) Define namespace clean versions of the system calls by prefixing 21 them with '_' (eg: _open, _close, etc.). Technically, there won't be 22 true reentrancy at the syscall level, but the library will be namespace 23 clean. 24 When you do this, set "syscall_dir" to "syscalls" in configure.host. 25 26 3) Define or otherwise provide the regular versions of the syscalls 27 (eg: open, close, etc.). The library won't be reentrant nor namespace 28 clean, but at least it will work. 29 When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in 30 configure.host. 31 32 Stubs of the reentrant versions of the syscalls exist in the libc/reent 33 source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined. 34 They use the native system calls: _open, _close, etc. if they're available 35 (MISSING_SYSCALL_NAMES is *not* defined), otherwise open, close, etc. 36 (MISSING_SYSCALL_NAMES *is* defined). */ 37 38 /* WARNING: All identifiers here must begin with an underscore. This file is 39 included by stdio.h and others and we therefore must only use identifiers 40 in the namespace allotted to us. */ 41 42 #ifndef _REENT_H_ 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 #define _REENT_H_ 47 48 #include <sys/reent.h> 49 #include <sys/_types.h> 50 #include <machine/types.h> 51 52 #define __need_size_t 53 #define __need_ptrdiff_t 54 #include <stddef.h> 55 56 /* FIXME: not namespace clean */ 57 struct stat; 58 struct tms; 59 struct timeval; 60 struct timezone; 61 62 /* Reentrant versions of system calls. */ 63 64 extern int _close_r _PARAMS ((struct _reent *, int)); 65 extern int _execve_r _PARAMS ((struct _reent *, char *, char **, char **)); 66 extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int)); 67 extern int _fork_r _PARAMS ((struct _reent *)); 68 extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)); 69 extern int _getpid_r _PARAMS ((struct _reent *)); 70 extern int _kill_r _PARAMS ((struct _reent *, int, int)); 71 extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); 72 extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)); 73 extern int _open_r _PARAMS ((struct _reent *, const char *, int, int)); 74 extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t)); 75 extern void *_sbrk_r _PARAMS ((struct _reent *, ptrdiff_t)); 76 extern int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *)); 77 extern _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *)); 78 extern int _unlink_r _PARAMS ((struct _reent *, const char *)); 79 extern int _wait_r _PARAMS ((struct _reent *, int *)); 80 extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t)); 81 82 /* This one is not guaranteed to be available on all targets. */ 83 extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *tp, struct timezone *tzp)); 84 85 #ifdef __LARGE64_FILES 86 87 #if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB) 88 #define stat64 __stat64 89 #endif 90 91 struct stat64; 92 93 extern _off64_t _lseek64_r _PARAMS ((struct _reent *, int, _off64_t, int)); 94 extern int _fstat64_r _PARAMS ((struct _reent *, int, struct stat64 *)); 95 extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int)); 96 #endif 97 98 #ifdef __cplusplus 99 } 100 #endif 101 #endif /* _REENT_H_ */ 102