/build/riscv-tools/riscv-gnu-toolchain/newlib/newlib/libc/machine/riscv/sys/fcntl.h

https://gitlab.com/arunc/proact-processor · C Header · 205 lines · 148 code · 26 blank · 31 comment · 1 complexity · 991a4a3858f290ddf4d8ba6b14a6de1b MD5 · raw file

  1. /* YUNSUP: snatched _default_fcntl.h and matched numbers with linux host
  2. * machine */
  3. #ifndef _RISCV_SYS_FCNTL_H_
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define _RISCV_SYS_FCNTL_H_
  8. #include <_ansi.h>
  9. #define _FOPEN (-1) /* from sys/file.h, kernel use only */
  10. #define _FREAD 0x0001 /* read enabled */
  11. #define _FWRITE 0x0002 /* write enabled */
  12. #define _FCREAT 0100 /* open with file create */
  13. #define _FEXCL 0200 /* error on open if file exists */
  14. #define _FNOCTTY 0400 /* don't assign a ctty on this open */
  15. #define _FTRUNC 01000 /* open with truncation */
  16. #define _FAPPEND 02000 /* append (writes guaranteed at the end) */
  17. #define _FNONBLOCK 04000 /* non blocking I/O (POSIX style) */
  18. #define _FSYNC 010000 /* do all writes synchronously */
  19. #define _FMARK 0x2000 /* internal; mark during gc() */
  20. #define _FDEFER 0x4000 /* internal; defer for next gc pass */
  21. #define _FASYNC 0x8000 /* signal pgrp when data ready */
  22. #define _FSHLOCK 0x10000 /* BSD flock() shared lock present */
  23. #define _FEXLOCK 0x20000 /* BSD flock() exclusive lock present */
  24. #define _FNBIO 0x40000 /* non blocking I/O (sys5 style) */
  25. #define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
  26. #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
  27. /*
  28. * Flag values for open(2) and fcntl(2)
  29. * The kernel adds 1 to the open modes to turn it into some
  30. * combination of FREAD and FWRITE.
  31. */
  32. #define O_RDONLY 00 /* +1 == FREAD */
  33. #define O_WRONLY 01 /* +1 == FWRITE */
  34. #define O_RDWR 02 /* +1 == FREAD|FWRITE */
  35. #define O_CREAT _FCREAT
  36. #define O_EXCL _FEXCL
  37. #define O_NOCTTY _FNOCTTY
  38. #define O_TRUNC _FTRUNC
  39. #define O_APPEND _FAPPEND
  40. #define O_NONBLOCK _FNONBLOCK
  41. #define O_SYNC _FSYNC
  42. /* O_NDELAY _FNDELAY set in include/fcntl.h */
  43. /* O_NDELAY _FNBIO set in include/fcntl.h */
  44. /* For machines which care - */
  45. #if defined (_WIN32) || defined (__CYGWIN__)
  46. #define _FBINARY 0x10000
  47. #define _FTEXT 0x20000
  48. #define _FNOINHERIT 0x40000
  49. #define O_BINARY _FBINARY
  50. #define O_TEXT _FTEXT
  51. #define O_NOINHERIT _FNOINHERIT
  52. /* The windows header files define versions with a leading underscore. */
  53. #define _O_RDONLY O_RDONLY
  54. #define _O_WRONLY O_WRONLY
  55. #define _O_RDWR O_RDWR
  56. #define _O_APPEND O_APPEND
  57. #define _O_CREAT O_CREAT
  58. #define _O_TRUNC O_TRUNC
  59. #define _O_EXCL O_EXCL
  60. #define _O_TEXT O_TEXT
  61. #define _O_BINARY O_BINARY
  62. #define _O_RAW O_BINARY
  63. #define _O_NOINHERIT O_NOINHERIT
  64. #endif
  65. #ifndef _POSIX_SOURCE
  66. /*
  67. * Flags that work for fcntl(fd, F_SETFL, FXXXX)
  68. */
  69. #define FAPPEND _FAPPEND
  70. #define FSYNC _FSYNC
  71. #define FASYNC _FASYNC
  72. #define FNBIO _FNBIO
  73. #define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
  74. #define FNDELAY _FNDELAY
  75. /*
  76. * Flags that are disallowed for fcntl's (FCNTLCANT);
  77. * used for opens, internal state, or locking.
  78. */
  79. #define FREAD _FREAD
  80. #define FWRITE _FWRITE
  81. #define FMARK _FMARK
  82. #define FDEFER _FDEFER
  83. #define FSHLOCK _FSHLOCK
  84. #define FEXLOCK _FEXLOCK
  85. /*
  86. * The rest of the flags, used only for opens
  87. */
  88. #define FOPEN _FOPEN
  89. #define FCREAT _FCREAT
  90. #define FTRUNC _FTRUNC
  91. #define FEXCL _FEXCL
  92. #define FNOCTTY _FNOCTTY
  93. #endif /* !_POSIX_SOURCE */
  94. /* XXX close on exec request; must match UF_EXCLOSE in user.h */
  95. #define FD_CLOEXEC 1 /* posix */
  96. /* fcntl(2) requests */
  97. #define F_DUPFD 0 /* Duplicate fildes */
  98. #define F_GETFD 1 /* Get fildes flags (close on exec) */
  99. #define F_SETFD 2 /* Set fildes flags (close on exec) */
  100. #define F_GETFL 3 /* Get file flags */
  101. #define F_SETFL 4 /* Set file flags */
  102. #ifndef _POSIX_SOURCE
  103. #define F_GETOWN 5 /* Get owner - for ASYNC */
  104. #define F_SETOWN 6 /* Set owner - for ASYNC */
  105. #endif /* !_POSIX_SOURCE */
  106. #define F_GETLK 7 /* Get record-locking information */
  107. #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
  108. #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
  109. #ifndef _POSIX_SOURCE
  110. #define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
  111. #define F_RSETLK 11 /* Set or unlock a remote lock */
  112. #define F_CNVT 12 /* Convert a fhandle to an open fd */
  113. #define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
  114. #endif /* !_POSIX_SOURCE */
  115. /* fcntl(2) flags (l_type field of flock structure) */
  116. #define F_RDLCK 1 /* read lock */
  117. #define F_WRLCK 2 /* write lock */
  118. #define F_UNLCK 3 /* remove lock(s) */
  119. #ifndef _POSIX_SOURCE
  120. #define F_UNLKSYS 4 /* remove remote locks for a given system */
  121. #endif /* !_POSIX_SOURCE */
  122. #ifdef __CYGWIN__
  123. /* Special descriptor value to denote the cwd in calls to openat(2) etc. */
  124. #define AT_FDCWD -2
  125. /* Flag values for faccessat2) et al. */
  126. #define AT_EACCESS 1
  127. #define AT_SYMLINK_NOFOLLOW 2
  128. #define AT_SYMLINK_FOLLOW 4
  129. #define AT_REMOVEDIR 8
  130. #endif
  131. /*#include <sys/stdtypes.h>*/
  132. #ifndef __CYGWIN__
  133. /* file segment locking set data type - information passed to system by user */
  134. struct flock {
  135. short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
  136. short l_whence; /* flag to choose starting offset */
  137. long l_start; /* relative offset, in bytes */
  138. long l_len; /* length, in bytes; 0 means lock to EOF */
  139. short l_pid; /* returned with F_GETLK */
  140. short l_xxx; /* reserved for future use */
  141. };
  142. #endif /* __CYGWIN__ */
  143. #ifndef _POSIX_SOURCE
  144. /* extended file segment locking set data type */
  145. struct eflock {
  146. short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
  147. short l_whence; /* flag to choose starting offset */
  148. long l_start; /* relative offset, in bytes */
  149. long l_len; /* length, in bytes; 0 means lock to EOF */
  150. short l_pid; /* returned with F_GETLK */
  151. short l_xxx; /* reserved for future use */
  152. long l_rpid; /* Remote process id wanting this lock */
  153. long l_rsys; /* Remote system id wanting this lock */
  154. };
  155. #endif /* !_POSIX_SOURCE */
  156. #include <sys/types.h>
  157. #include <sys/stat.h> /* sigh. for the mode bits for open/creat */
  158. extern int open _PARAMS ((const char *, int, ...));
  159. extern int creat _PARAMS ((const char *, mode_t));
  160. extern int fcntl _PARAMS ((int, int, ...));
  161. #ifdef __CYGWIN__
  162. #include <sys/time.h>
  163. extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
  164. extern int openat _PARAMS ((int, const char *, int, ...));
  165. extern int unlinkat _PARAMS ((int, const char *, int));
  166. #endif
  167. /* Provide _<systemcall> prototypes for functions provided by some versions
  168. of newlib. */
  169. #ifdef _COMPILING_NEWLIB
  170. extern int _open _PARAMS ((const char *, int, ...));
  171. extern int _fcntl _PARAMS ((int, int, ...));
  172. #ifdef __LARGE64_FILES
  173. extern int _open64 _PARAMS ((const char *, int, ...));
  174. #endif
  175. #endif
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /* !_RISCV_SYS_FCNTL_H_ */