stat.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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 "port/codes.h"
  66. /*
  67. #ifndef dev_t
  68. typedef short dev_t;
  69. #endif
  70. #ifndef ino_t
  71. typedef unsigned int ino_t;
  72. #endif
  73. #ifndef mode_t
  74. typedef unsigned int mode_t;
  75. #endif
  76. */
  77. typedef unsigned short nlink_t;
  78. typedef long off_t;
  79. typedef unsigned short gid_t;
  80. typedef unsigned short uid_t;
  81. typedef int pid_t;
  82. //
  83. typedef void *cyg_io_handle_t;
  84. /* Variable names for pathconf() */
  85. #define _PC_ASYNC_IO 1
  86. #define _PC_CHOWN_RESTRICTED 2
  87. #define _PC_LINK_MAX 3
  88. #define _PC_MAX_CANON 4
  89. #define _PC_MAX_INPUT 5
  90. #define _PC_NAME_MAX 6
  91. #define _PC_NO_TRUNC 7
  92. #define _PC_PATH_MAX 8
  93. #define _PC_PIPE_BUF 9
  94. #define _PC_PRIO_IO 10
  95. #define _PC_SYNC_IO 11
  96. #define _PC_VDISABLE 12
  97. //limit.h
  98. /* DEFINES */
  99. /*-----------------------------------------------------------------------------
  100. * Minimum values from POSIX.1 tables 2-3, 2-7 and 2-7a.
  101. * These are the standard-mandated minimum values.
  102. * These values do not vary with the implementation - they may
  103. * simply be defined
  104. */
  105. /* Minimum number of operations in one list I/O call. */
  106. #define _POSIX_AIO_LISTIO_MAX 2
  107. /* Minimal number of outstanding asynchronous I/O operations. */
  108. #define _POSIX_AIO_MAX 1
  109. /* Maximum length of arguments to `execve', including environment. */
  110. #define _POSIX_ARG_MAX 4096
  111. /* Maximum simultaneous processes per real user ID. */
  112. #define _POSIX_CHILD_MAX 6
  113. /* Minimal number of timer expiration overruns. */
  114. #define _POSIX_DELAYTIMER_MAX 32
  115. /* Maximum link count of a file. */
  116. #define _POSIX_LINK_MAX 8
  117. /* Size of storage required for a login name */
  118. #define _POSIX_LOGIN_NAME_MAX 9
  119. /* Number of bytes in a terminal canonical input queue. */
  120. #define _POSIX_MAX_CANON 255
  121. /* Number of bytes for which space will be
  122. available in a terminal input queue. */
  123. #define _POSIX_MAX_INPUT 255
  124. /* Maximum number of message queues open for a process. */
  125. #define _POSIX_MQ_OPEN_MAX 8
  126. /* Maximum number of supported message priorities. */
  127. #define _POSIX_MQ_PRIO_MAX 32
  128. /* Number of bytes in a filename. */
  129. #define _POSIX_NAME_MAX 14
  130. /* Number of simultaneous supplementary group IDs per process. */
  131. #define _POSIX_NGROUPS_MAX 0
  132. /* Number of files one process can have open at once. */
  133. #define _POSIX_OPEN_MAX 16
  134. /* Number of bytes in a pathname. */
  135. #define _POSIX_PATH_MAX 255
  136. /* Number of bytes than can be written atomically to a pipe. */
  137. #define _POSIX_PIPE_BUF 512
  138. /* Minimal number of realtime signals reserved for the application. */
  139. #define _POSIX_RTSIG_MAX 8
  140. /* Number of semaphores a process can have. */
  141. #define _POSIX_SEM_NSEMS_MAX 256
  142. /* Maximal value of a semaphore. */
  143. #define _POSIX_SEM_VALUE_MAX 32767
  144. /* Number of pending realtime signals. */
  145. #define _POSIX_SIGQUEUE_MAX 32
  146. /* Largest value of a `ssize_t'. */
  147. #define _POSIX_SSIZE_MAX 32767
  148. /* Number of streams a process can have open at once. */
  149. #define _POSIX_STREAM_MAX 8
  150. /* Controlling the iterations of destructors for thread-specific data. */
  151. #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
  152. /* The number of data keys per process. */
  153. #define _POSIX_THREAD_KEYS_MAX 128
  154. /* The number of threads per process. */
  155. #define _POSIX_THREAD_THREADS_MAX 64
  156. /* Maximum number of characters in a tty name. */
  157. #define _POSIX_TTY_NAME_MAX 9
  158. /* Number of timer for a process. */
  159. #define _POSIX_TIMER_MAX 32
  160. /* Maximum length of a timezone name (element of `tzname'). */
  161. #define _POSIX_TZNAME_MAX 3
  162. /* Maximum clock resolution in nanoseconds. */
  163. #define _POSIX_CLOCKRES_MIN 20000000
  164. #ifdef CYGBLD_ISO_SSIZET_HEADER
  165. # include CYGBLD_ISO_SSIZET_HEADER
  166. #else
  167. # ifndef __STRICT_ANSI__
  168. # define SSIZE_MAX LONG_MAX
  169. # endif
  170. #endif
  171. /* INCLUDES */
  172. #ifdef CYGBLD_ISO_OPEN_MAX_HEADER
  173. # include CYGBLD_ISO_OPEN_MAX_HEADER
  174. #else
  175. # ifndef __STRICT_ANSI__
  176. # define OPEN_MAX _POSIX_OPEN_MAX
  177. # endif
  178. #endif
  179. #ifdef CYGBLD_ISO_LINK_MAX_HEADER
  180. # include CYGBLD_ISO_LINK_MAX_HEADER
  181. #else
  182. # ifndef __STRICT_ANSI__
  183. # define LINK_MAX _POSIX_LINK_MAX
  184. # endif
  185. #endif
  186. #ifdef CYGBLD_ISO_NAME_MAX_HEADER
  187. # include CYGBLD_ISO_NAME_MAX_HEADER
  188. #else
  189. # ifndef __STRICT_ANSI__
  190. # define NAME_MAX _POSIX_NAME_MAX
  191. # endif
  192. #endif
  193. #ifdef CYGBLD_ISO_PATH_MAX_HEADER
  194. # include CYGBLD_ISO_PATH_MAX_HEADER
  195. #else
  196. # ifndef __STRICT_ANSI__
  197. # define PATH_MAX _POSIX_PATH_MAX
  198. # endif
  199. #endif
  200. #if CYGINT_ISO_POSIX_LIMITS
  201. # ifdef CYGBLD_ISO_POSIX_LIMITS_HEADER
  202. # include CYGBLD_ISO_POSIX_LIMITS_HEADER
  203. # endif
  204. #endif
  205. #define CYGNUM_FILEIO_MTAB_MAX 16
  206. //-----------------------------------------------
  207. // stat.h need by fs-ecos.h
  208. //-----------------------------------------------
  209. #define __stat_mode_DIR (1<<0)
  210. #define __stat_mode_CHR (1<<1)
  211. #define __stat_mode_BLK (1<<2)
  212. #define __stat_mode_REG (1<<3)
  213. #define __stat_mode_FIFO (1<<4)
  214. #define __stat_mode_MQ (1<<5)
  215. #define __stat_mode_SEM (1<<6)
  216. #define __stat_mode_SHM (1<<7)
  217. #define __stat_mode_LNK (1<<8)
  218. #define __stat_mode_SOCK (1<<9)
  219. #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
  220. #define S_IFDIR (__stat_mode_DIR)
  221. #define S_IFCHR (__stat_mode_CHR)
  222. #define S_IFBLK (__stat_mode_BLK)
  223. #define S_IFREG (__stat_mode_REG)
  224. #define S_IFIFO (__stat_mode_FIFO)
  225. #define S_IFLNK (__stat_mode_LNK)
  226. #define S_IFSOCK (__stat_mode_SOCK)
  227. #define S_IFMT (S_IFDIR|S_IFCHR|S_IFBLK|S_IFREG| \
  228. S_IFIFO|S_IFLNK|S_IFSOCK)
  229. #endif
  230. #define S_ISDIR(__mode) ((__mode) & __stat_mode_DIR )
  231. #define S_ISCHR(__mode) ((__mode) & __stat_mode_CHR )
  232. #define S_ISBLK(__mode) ((__mode) & __stat_mode_BLK )
  233. #define S_ISREG(__mode) ((__mode) & __stat_mode_REG )
  234. #define S_ISFIFO(__mode) ((__mode) & __stat_mode_FIFO )
  235. #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
  236. #define S_ISLNK(__mode) ((__mode) & __stat_mode_LNK )
  237. #define S_ISSOCK(__mode) ((__mode) & __stat_mode_SOCK )
  238. #endif
  239. #define S_TYPEISMQ(__buf) ((__buf)->st_mode & __stat_mode_MQ )
  240. #define S_TYPEISSEM(__buf) ((__buf)->st_mode & __stat_mode_SEM )
  241. #define S_TYPEISSHM(__buf) ((__buf)->st_mode & __stat_mode_SHM )
  242. #define S_IRUSR (1<<16)
  243. #define S_IWUSR (1<<17)
  244. #define S_IXUSR (1<<18)
  245. #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
  246. #define S_IRGRP (1<<19)
  247. #define S_IWGRP (1<<20)
  248. #define S_IXGRP (1<<21)
  249. #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
  250. #define S_IROTH (1<<22)
  251. #define S_IWOTH (1<<23)
  252. #define S_IXOTH (1<<24)
  253. #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
  254. #define S_ISUID (1<<25)
  255. #define S_ISGID (1<<26)
  256. #if defined(MSVC)
  257. /* for time_t */
  258. #include <time.h>
  259. typedef unsigned long mode_t;
  260. typedef unsigned int ino_t;
  261. typedef unsigned int dev_t;
  262. typedef long ssize_t;
  263. #elif defined(__CC_ARM)
  264. #define mode_t unsigned long
  265. typedef unsigned int ino_t;
  266. typedef unsigned int dev_t;
  267. typedef long ssize_t;
  268. typedef long time_t;
  269. #elif defined(__GNUC__) && !defined(__CC_ARM)
  270. #include <sys/types.h>
  271. #endif
  272. struct stat {
  273. mode_t st_mode; /* File mode */
  274. ino_t st_ino; /* File serial number */
  275. dev_t st_dev; /* ID of device containing file */
  276. nlink_t st_nlink; /* Number of hard links */
  277. uid_t st_uid; /* User ID of the file owner */
  278. gid_t st_gid; /* Group ID of the file's group */
  279. off_t st_size; /* File size (regular files only) */
  280. time_t st_atime; /* Last access time */
  281. time_t st_mtime; /* Last data modification time */
  282. time_t st_ctime; /* Last file status change time */
  283. };
  284. //fcntl.h
  285. #define O_NONBLOCK (1<<9) /* No delay */
  286. #endif /* CYGONCE_ISO_SYS_TYPES_H multiple inclusion protection */
  287. /* EOF sys/types.h */