os_sys_stat.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. #ifndef CYGONCE_ISO_SYS_TYPES_H
  2. #define CYGONCE_ISO_SYS_TYPES_H
  3. /*========================================================================
  4. //
  5. // sys/types.h
  6. //
  7. // POSIX types
  8. //
  9. //========================================================================
  10. // ####ECOSGPLCOPYRIGHTBEGIN####
  11. // -------------------------------------------
  12. // This file is part of eCos, the Embedded Configurable Operating System.
  13. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  14. //
  15. // eCos is free software; you can redistribute it and/or modify it under
  16. // the terms of the GNU General Public License as published by the Free
  17. // Software Foundation; either version 2 or (at your option) any later
  18. // version.
  19. //
  20. // eCos is distributed in the hope that it will be useful, but WITHOUT
  21. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  22. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  23. // for more details.
  24. //
  25. // You should have received a copy of the GNU General Public License
  26. // along with eCos; if not, write to the Free Software Foundation, Inc.,
  27. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  28. //
  29. // As a special exception, if other files instantiate templates or use
  30. // macros or inline functions from this file, or you compile this file
  31. // and link it with other works to produce a work based on this file,
  32. // this file does not by itself cause the resulting work to be covered by
  33. // the GNU General Public License. However the source code for this file
  34. // must still be made available in accordance with section (3) of the GNU
  35. // General Public License v2.
  36. //
  37. // This exception does not invalidate any other reasons why a work based
  38. // on this file might be covered by the GNU General Public License.
  39. // -------------------------------------------
  40. // ####ECOSGPLCOPYRIGHTEND####
  41. //========================================================================
  42. //#####DESCRIPTIONBEGIN####
  43. //
  44. // Author(s): jlarmour
  45. // Contributors:
  46. // Date: 2000-04-14
  47. // Purpose: This file provides various types required by POSIX 1003.1.
  48. // Description: The real contents of this file get set from the
  49. // configuration (set by the implementation)
  50. // Usage: #include <sys/types.h>
  51. //
  52. //####DESCRIPTIONEND####
  53. //
  54. //======================================================================
  55. */
  56. /* CONFIGURATION */
  57. //#include <pkgconf/system.h>
  58. //#include <pkgconf/isoinfra.h> /* Configuration header */
  59. /* INCLUDES */
  60. /* This is the "standard" way to get size_t from stddef.h,
  61. * which is the canonical location of the definition.
  62. */
  63. //#define __need_size_t
  64. //#include <stddef.h>
  65. #include "codes.h"
  66. typedef long ssize_t;
  67. /*
  68. #ifndef dev_t
  69. typedef short dev_t;
  70. #endif
  71. #ifndef ino_t
  72. typedef unsigned int ino_t;
  73. #endif
  74. #ifndef mode_t
  75. typedef unsigned int mode_t;
  76. #endif
  77. */
  78. typedef unsigned short nlink_t;
  79. typedef long off_t;
  80. typedef unsigned short gid_t;
  81. typedef unsigned short uid_t;
  82. typedef int pid_t;
  83. //
  84. typedef void *cyg_io_handle_t;
  85. /* Variable names for pathconf() */
  86. #define _PC_ASYNC_IO 1
  87. #define _PC_CHOWN_RESTRICTED 2
  88. #define _PC_LINK_MAX 3
  89. #define _PC_MAX_CANON 4
  90. #define _PC_MAX_INPUT 5
  91. #define _PC_NAME_MAX 6
  92. #define _PC_NO_TRUNC 7
  93. #define _PC_PATH_MAX 8
  94. #define _PC_PIPE_BUF 9
  95. #define _PC_PRIO_IO 10
  96. #define _PC_SYNC_IO 11
  97. #define _PC_VDISABLE 12
  98. //limit.h
  99. /* DEFINES */
  100. /*-----------------------------------------------------------------------------
  101. * Minimum values from POSIX.1 tables 2-3, 2-7 and 2-7a.
  102. * These are the standard-mandated minimum values.
  103. * These values do not vary with the implementation - they may
  104. * simply be defined
  105. */
  106. /* Minimum number of operations in one list I/O call. */
  107. #define _POSIX_AIO_LISTIO_MAX 2
  108. /* Minimal number of outstanding asynchronous I/O operations. */
  109. #define _POSIX_AIO_MAX 1
  110. /* Maximum length of arguments to `execve', including environment. */
  111. #define _POSIX_ARG_MAX 4096
  112. /* Maximum simultaneous processes per real user ID. */
  113. #define _POSIX_CHILD_MAX 6
  114. /* Minimal number of timer expiration overruns. */
  115. #define _POSIX_DELAYTIMER_MAX 32
  116. /* Maximum link count of a file. */
  117. #define _POSIX_LINK_MAX 8
  118. /* Size of storage required for a login name */
  119. #define _POSIX_LOGIN_NAME_MAX 9
  120. /* Number of bytes in a terminal canonical input queue. */
  121. #define _POSIX_MAX_CANON 255
  122. /* Number of bytes for which space will be
  123. available in a terminal input queue. */
  124. #define _POSIX_MAX_INPUT 255
  125. /* Maximum number of message queues open for a process. */
  126. #define _POSIX_MQ_OPEN_MAX 8
  127. /* Maximum number of supported message priorities. */
  128. #define _POSIX_MQ_PRIO_MAX 32
  129. /* Number of bytes in a filename. */
  130. #define _POSIX_NAME_MAX 14
  131. /* Number of simultaneous supplementary group IDs per process. */
  132. #define _POSIX_NGROUPS_MAX 0
  133. /* Number of files one process can have open at once. */
  134. #define _POSIX_OPEN_MAX 16
  135. /* Number of bytes in a pathname. */
  136. #define _POSIX_PATH_MAX 255
  137. /* Number of bytes than can be written atomically to a pipe. */
  138. #define _POSIX_PIPE_BUF 512
  139. /* Minimal number of realtime signals reserved for the application. */
  140. #define _POSIX_RTSIG_MAX 8
  141. /* Number of semaphores a process can have. */
  142. #define _POSIX_SEM_NSEMS_MAX 256
  143. /* Maximal value of a semaphore. */
  144. #define _POSIX_SEM_VALUE_MAX 32767
  145. /* Number of pending realtime signals. */
  146. #define _POSIX_SIGQUEUE_MAX 32
  147. /* Largest value of a `ssize_t'. */
  148. #define _POSIX_SSIZE_MAX 32767
  149. /* Number of streams a process can have open at once. */
  150. #define _POSIX_STREAM_MAX 8
  151. /* Controlling the iterations of destructors for thread-specific data. */
  152. #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
  153. /* The number of data keys per process. */
  154. #define _POSIX_THREAD_KEYS_MAX 128
  155. /* The number of threads per process. */
  156. #define _POSIX_THREAD_THREADS_MAX 64
  157. /* Maximum number of characters in a tty name. */
  158. #define _POSIX_TTY_NAME_MAX 9
  159. /* Number of timer for a process. */
  160. #define _POSIX_TIMER_MAX 32
  161. /* Maximum length of a timezone name (element of `tzname'). */
  162. #define _POSIX_TZNAME_MAX 3
  163. /* Maximum clock resolution in nanoseconds. */
  164. #define _POSIX_CLOCKRES_MIN 20000000
  165. #ifdef CYGBLD_ISO_SSIZET_HEADER
  166. # include CYGBLD_ISO_SSIZET_HEADER
  167. #else
  168. # ifndef __STRICT_ANSI__
  169. # define SSIZE_MAX LONG_MAX
  170. # endif
  171. #endif
  172. /* INCLUDES */
  173. #ifdef CYGBLD_ISO_OPEN_MAX_HEADER
  174. # include CYGBLD_ISO_OPEN_MAX_HEADER
  175. #else
  176. # ifndef __STRICT_ANSI__
  177. # define OPEN_MAX _POSIX_OPEN_MAX
  178. # endif
  179. #endif
  180. #ifdef CYGBLD_ISO_LINK_MAX_HEADER
  181. # include CYGBLD_ISO_LINK_MAX_HEADER
  182. #else
  183. # ifndef __STRICT_ANSI__
  184. # define LINK_MAX _POSIX_LINK_MAX
  185. # endif
  186. #endif
  187. #ifdef CYGBLD_ISO_NAME_MAX_HEADER
  188. # include CYGBLD_ISO_NAME_MAX_HEADER
  189. #else
  190. # ifndef __STRICT_ANSI__
  191. # define NAME_MAX _POSIX_NAME_MAX
  192. # endif
  193. #endif
  194. #ifdef CYGBLD_ISO_PATH_MAX_HEADER
  195. # include CYGBLD_ISO_PATH_MAX_HEADER
  196. #else
  197. # ifndef __STRICT_ANSI__
  198. # define PATH_MAX _POSIX_PATH_MAX
  199. # endif
  200. #endif
  201. #if CYGINT_ISO_POSIX_LIMITS
  202. # ifdef CYGBLD_ISO_POSIX_LIMITS_HEADER
  203. # include CYGBLD_ISO_POSIX_LIMITS_HEADER
  204. # endif
  205. #endif
  206. #define CYGNUM_FILEIO_MTAB_MAX 16
  207. //-----------------------------------------------
  208. // stat.h need by fs-ecos.h
  209. //-----------------------------------------------
  210. #define __stat_mode_DIR (1<<0)
  211. #define __stat_mode_CHR (1<<1)
  212. #define __stat_mode_BLK (1<<2)
  213. #define __stat_mode_REG (1<<3)
  214. #define __stat_mode_FIFO (1<<4)
  215. #define __stat_mode_MQ (1<<5)
  216. #define __stat_mode_SEM (1<<6)
  217. #define __stat_mode_SHM (1<<7)
  218. #define __stat_mode_LNK (1<<8)
  219. #define __stat_mode_SOCK (1<<9)
  220. #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
  221. #define S_IFDIR (__stat_mode_DIR)
  222. #define S_IFCHR (__stat_mode_CHR)
  223. #define S_IFBLK (__stat_mode_BLK)
  224. #define S_IFREG (__stat_mode_REG)
  225. #define S_IFIFO (__stat_mode_FIFO)
  226. #define S_IFLNK (__stat_mode_LNK)
  227. #define S_IFSOCK (__stat_mode_SOCK)
  228. #define S_IFMT (S_IFDIR|S_IFCHR|S_IFBLK|S_IFREG| \
  229. S_IFIFO|S_IFLNK|S_IFSOCK)
  230. #endif
  231. #define S_ISDIR(__mode) ((__mode) & __stat_mode_DIR )
  232. #define S_ISCHR(__mode) ((__mode) & __stat_mode_CHR )
  233. #define S_ISBLK(__mode) ((__mode) & __stat_mode_BLK )
  234. #define S_ISREG(__mode) ((__mode) & __stat_mode_REG )
  235. #define S_ISFIFO(__mode) ((__mode) & __stat_mode_FIFO )
  236. #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
  237. #define S_ISLNK(__mode) ((__mode) & __stat_mode_LNK )
  238. #define S_ISSOCK(__mode) ((__mode) & __stat_mode_SOCK )
  239. #endif
  240. #define S_TYPEISMQ(__buf) ((__buf)->st_mode & __stat_mode_MQ )
  241. #define S_TYPEISSEM(__buf) ((__buf)->st_mode & __stat_mode_SEM )
  242. #define S_TYPEISSHM(__buf) ((__buf)->st_mode & __stat_mode_SHM )
  243. #define S_IRUSR (1<<16)
  244. #define S_IWUSR (1<<17)
  245. #define S_IXUSR (1<<18)
  246. #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
  247. #define S_IRGRP (1<<19)
  248. #define S_IWGRP (1<<20)
  249. #define S_IXGRP (1<<21)
  250. #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
  251. #define S_IROTH (1<<22)
  252. #define S_IWOTH (1<<23)
  253. #define S_IXOTH (1<<24)
  254. #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
  255. #define S_ISUID (1<<25)
  256. #define S_ISGID (1<<26)
  257. #if defined(MSVC)
  258. typedef unsigned long mode_t;
  259. typedef unsigned int ino_t;
  260. typedef unsigned int dev_t;
  261. #elif defined(__CC_ARM)
  262. #define mode_t unsigned long
  263. typedef unsigned int ino_t;
  264. typedef unsigned int dev_t;
  265. typedef long time_t;
  266. #endif
  267. struct stat {
  268. mode_t st_mode; /* File mode */
  269. ino_t st_ino; /* File serial number */
  270. dev_t st_dev; /* ID of device containing file */
  271. nlink_t st_nlink; /* Number of hard links */
  272. uid_t st_uid; /* User ID of the file owner */
  273. gid_t st_gid; /* Group ID of the file's group */
  274. off_t st_size; /* File size (regular files only) */
  275. time_t st_atime; /* Last access time */
  276. time_t st_mtime; /* Last data modification time */
  277. time_t st_ctime; /* Last file status change time */
  278. };
  279. //fcntl.h
  280. #define O_NONBLOCK (1<<9) /* No delay */
  281. #endif /* CYGONCE_ISO_SYS_TYPES_H multiple inclusion protection */
  282. /* EOF sys/types.h */