Create Xref-Html Frames                    Remove All Frames
file:c:/local/Cygwin/usr/include/sys/types.h        (Tue May 25 21:07:26 2004 )


   1: /* unified sys/types.h: 
   2:    start with sef's sysvi386 version.
   3:    merge go32 version -- a few ifdefs.
   4:    h8300hms, h8300xray, and sysvnecv70 disagree on the following types:
   5: 
   6:    typedef int gid_t;
   7:    typedef int uid_t;
   8:    typedef int dev_t;
   9:    typedef int ino_t;
  10:    typedef int mode_t;
  11:    typedef int caddr_t;
  12: 
  13:    however, these aren't "reasonable" values, the sysvi386 ones make far 
  14:    more sense, and should work sufficiently well (in particular, h8300 
  15:    doesn't have a stat, and the necv70 doesn't matter.) -- eichin
  16:  */
  17: 
  18: #ifndef _SYS_TYPES_H
  19: 
  20: #include <_ansi.h>
  21: 
  22: #ifndef __INTTYPES_DEFINED__
  23: #define __INTTYPES_DEFINED__
  24: typedef short int __int16_t;
  25: typedef unsigned short int __uint16_t;
  26: 
  27: #if __INT_MAX__ == 32767
  28: typedef long int __int32_t;
  29: typedef unsigned long int __uint32_t;
  30: #else
  31: typedef int __int32_t;
  32: typedef unsigned int __uint32_t;
  33: #endif
  34: 
  35: #if __LONG_MAX__ > 2147483647 || !defined(__GNUC__)
  36: typedef long int __int64_t;
  37: typedef unsigned long int __uint64_t;
  38: #else
  39: __extension__ typedef long long __int64_t;
  40: __extension__ typedef unsigned long long __uint64_t;
  41: #endif
  42: #endif /* ! __INTTYPES_DEFINED */
  43: 
  44: #ifndef __need_inttypes
  45: 
  46: #define _SYS_TYPES_H
  47: #include <sys/_types.h>
  48: 
  49: #ifdef __i386__
  50: #if defined (GO32) || defined (__MSDOS__)
  51: #define __MS_types__
  52: #endif
  53: #endif
  54: 
  55: # include <stddef.h>
  56: # include <machine/types.h>
  57: 
  58: /* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
  59:    changes, we assume sizeof short and long never change and have all types
  60:    used to define struct stat use them and not int where possible.
  61:    Where not possible, _ST_INTxx are used.  It would be preferable to not have
  62:    such assumptions, but until the extra fluff is necessary, it's avoided.
  63:    No 64 bit targets use stat yet.  What to do about them is postponed
  64:    until necessary.  */
  65: #ifdef __GNUC__
  66: #define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
  67: #else
  68: #define _ST_INT32
  69: #endif
  70: 
  71: # ifndef  _POSIX_SOURCE
  72: 
  73: #  define physadr   physadr_t
  74: #  define quad    quad_t
  75: 
  76: #ifndef _BSDTYPES_DEFINED
  77: /* also defined in mingw/gmon.h and in w32api/winsock[2].h */
  78: typedef unsigned char u_char;
  79: typedef unsigned short  u_short;
  80: typedef unsigned int  u_int;
  81: typedef unsigned long u_long;
  82: #define _BSDTYPES_DEFINED
  83: #endif
  84: 
  85: typedef unsigned short  ushort;   /* System V compatibility */
  86: typedef unsigned int  uint;   /* System V compatibility */
  87: # endif /*!_POSIX_SOURCE */
  88: 
  89: #ifndef __clock_t_defined
  90: typedef _CLOCK_T_ clock_t;
  91: #define __clock_t_defined
  92: #endif
  93: 
  94: #ifndef __time_t_defined
  95: typedef _TIME_T_ time_t;
  96: #define __time_t_defined
  97: 
  98: /* Time Value Specification Structures, P1003.1b-1993, p. 261 */
  99: 
 100: struct timespec {
 101:   time_t  tv_sec;   /* Seconds */
 102:   long    tv_nsec;  /* Nanoseconds */
 103: };
 104: 
 105: struct itimerspec {
 106:   struct timespec  it_interval;  /* Timer period */
 107:   struct timespec  it_value;     /* Timer expiration */
 108: };
 109: #endif
 110: 
 111: typedef long  daddr_t;
 112: typedef char *  caddr_t;
 113: 
 114: #ifndef __CYGWIN__
 115: #if defined(__MS_types__) || defined(__rtems__)
 116: typedef unsigned long ino_t;
 117: #else
 118: #ifdef __sparc__
 119: typedef unsigned long ino_t;
 120: #else
 121: typedef unsigned short  ino_t;
 122: #endif
 123: #endif
 124: #endif /*__CYGWIN__*/
 125: 
 126: #ifdef __MS_types__
 127: typedef unsigned long vm_offset_t;
 128: typedef unsigned long vm_size_t;
 129: 
 130: #define __BIT_TYPES_DEFINED__
 131: 
 132: typedef signed char int8_t;
 133: typedef unsigned char u_int8_t;
 134: typedef short int16_t;
 135: typedef unsigned short u_int16_t;
 136: typedef int int32_t;
 137: typedef unsigned int u_int32_t;
 138: typedef long long int64_t;
 139: typedef unsigned long long u_int64_t;
 140: typedef int32_t register_t;
 141: #endif /* __MS_types__ */
 142: 
 143: /*
 144:  * All these should be machine specific - right now they are all broken.
 145:  * However, for all of Cygnus' embedded targets, we want them to all be
 146:  * the same.  Otherwise things like sizeof (struct stat) might depend on
 147:  * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
 148:  */
 149: 
 150: #if defined(__rtems__)
 151: /* device numbers are 32-bit major and and 32-bit minor */
 152: typedef unsigned long long dev_t;
 153: #else
 154: #ifndef __CYGWIN__
 155: typedef short dev_t;
 156: #endif
 157: #endif
 158: 
 159: #ifndef __CYGWIN__  /* which defines these types in it's own types.h. */
 160: typedef long    off_t;
 161: 
 162: typedef unsigned short  uid_t;
 163: typedef unsigned short  gid_t;
 164: #endif
 165: 
 166: typedef int pid_t;
 167: #ifndef __CYGWIN__
 168: typedef long key_t;
 169: #endif
 170: typedef _ssize_t ssize_t;
 171: 
 172: #ifndef __CYGWIN__
 173: #ifdef __MS_types__
 174: typedef char *  addr_t;
 175: typedef int mode_t;
 176: #else
 177: #if defined (__sparc__) && !defined (__sparc_v9__)
 178: #ifdef __svr4__
 179: typedef unsigned long mode_t;
 180: #else
 181: typedef unsigned short mode_t;
 182: #endif
 183: #else
 184: typedef unsigned int mode_t _ST_INT32;
 185: #endif
 186: #endif /* ! __MS_types__ */
 187: #endif /*__CYGWIN__*/
 188: 
 189: typedef unsigned short nlink_t;
 190: 
 191: /* We don't define fd_set and friends if we are compiling POSIX
 192:    source, or if we have included (or may include as indicated
 193:    by __USE_W32_SOCKETS) the W32api winsock[2].h header which
 194:    defines Windows versions of them.   Note that a program which
 195:    includes the W32api winsock[2].h header must know what it is doing;
 196:    it must not call the cygwin32 select function.
 197: */
 198: # if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) 
 199: #  define _SYS_TYPES_FD_SET
 200: #  define NBBY  8   /* number of bits in a byte */
 201: /*
 202:  * Select uses bit masks of file descriptors in longs.
 203:  * These macros manipulate such bit fields (the filesystem macros use chars).
 204:  * FD_SETSIZE may be defined by the user, but the default here
 205:  * should be >= NOFILE (param.h).
 206:  */
 207: #  ifndef FD_SETSIZE
 208: # define  FD_SETSIZE  64
 209: #  endif
 210: 
 211: typedef long  fd_mask;
 212: #  define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
 213: #  ifndef howmany
 214: # define  howmany(x,y)  (((x)+((y)-1))/(y))
 215: #  endif
 216: 
 217: /* We use a macro for fd_set so that including Sockets.h afterwards
 218:    can work.  */
 219: typedef struct _types_fd_set {
 220:   fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
 221: } _types_fd_set;
 222: 
 223: #define fd_set _types_fd_set
 224: 
 225: #  define FD_SET(n, p)  ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
 226: #  define FD_CLR(n, p)  ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
 227: #  define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
 228: #  define FD_ZERO(p)  (__extension__ (void)({ \
 229:      size_t __i; \
 230:      char *__tmp = (char *)p; \
 231:      for (__i = 0; __i < sizeof (*(p)); ++__i) \
 232:        *__tmp++ = 0; \
 233: }))
 234: 
 235: # endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
 236: 
 237: #undef __MS_types__
 238: #undef _ST_INT32
 239: 
 240: /* The following are actually standard POSIX 1003.1b-1993 threads, mutexes,
 241:    condition variables, and keys.  But since RTEMS is currently the only
 242:    newlib user of these, the ifdef is just on RTEMS. */
 243: 
 244: #if defined(__rtems__) || defined(__CYGWIN__)
 245: 
 246: #ifndef __clockid_t_defined
 247: typedef _CLOCKID_T_ clockid_t;
 248: #define __clockid_t_defined
 249: #endif
 250: 
 251: #ifndef __timer_t_defined
 252: typedef _TIMER_T_ timer_t;
 253: #define __timer_t_defined
 254: #endif
 255: 
 256: #if defined(__CYGWIN__) || defined(__rtems__)
 257: typedef long useconds_t;
 258: #endif
 259: 
 260: #include <sys/features.h>
 261: 
 262: 
 263: /* Cygwin will probably never have full posix compliance due to little things
 264:  * like an inability to set the stackaddress. Cygwin is also using void *  
 265:  * pointers rather than structs to ensure maximum binary compatability with
 266:  * previous releases.
 267:  * This means that we don't use the types defined here, but rather in
 268:  * <cygwin/types.h>
 269:  */
 270: #if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
 271: 
 272: #include <sys/sched.h>
 273: 
 274: /*
 275:  *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
 276:  */
 277: 
 278: typedef __uint32_t pthread_t;            /* identify a thread */
 279: 
 280: /* P1003.1c/D10, p. 118-119 */
 281: #define PTHREAD_SCOPE_PROCESS 0
 282: #define PTHREAD_SCOPE_SYSTEM  1
 283: 
 284: /* P1003.1c/D10, p. 111 */
 285: #define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
 286:                                       /*   attributes are inherited from */
 287:                                       /*   the calling thread. */
 288: #define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
 289: 
 290: /* P1003.1c/D10, p. 141 */
 291: #define PTHREAD_CREATE_DETACHED 0
 292: #define PTHREAD_CREATE_JOINABLE  1
 293: 
 294: typedef struct {
 295:   int is_initialized;
 296:   void *stackaddr;
 297:   int stacksize;
 298:   int contentionscope;
 299:   int inheritsched;
 300:   int schedpolicy;
 301:   struct sched_param schedparam;
 302: 
 303:   /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
 304: #if defined(_POSIX_THREAD_CPUTIME)
 305:   int  cputime_clock_allowed;  /* see time.h */
 306: #endif
 307:   int  detachstate;
 308: 
 309: } pthread_attr_t;
 310: 
 311: #if defined(_POSIX_THREAD_PROCESS_SHARED)
 312: /* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
 313: 
 314: #define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
 315: #define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
 316:                                   /*   the memory where the resource is */
 317:                                   /*   located */
 318: #endif
 319: 
 320: #if defined(_POSIX_THREAD_PRIO_PROTECT)
 321: /* Mutexes */
 322: 
 323: /* Values for blocking protocol. */
 324: 
 325: #define PTHREAD_PRIO_NONE    0
 326: #define PTHREAD_PRIO_INHERIT 1
 327: #define PTHREAD_PRIO_PROTECT 2
 328: #endif
 329: 
 330: typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
 331: 
 332: typedef struct {
 333:   int   is_initialized;
 334: #if defined(_POSIX_THREAD_PROCESS_SHARED)
 335:   int   process_shared;  /* allow mutex to be shared amongst processes */
 336: #endif
 337: #if defined(_POSIX_THREAD_PRIO_PROTECT)
 338:   int   prio_ceiling;
 339:   int   protocol;
 340: #endif
 341:   int   recursive;
 342: } pthread_mutexattr_t;
 343: 
 344: /* Condition Variables */
 345: 
 346: typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
 347: 
 348: typedef struct {
 349:   int   is_initialized;
 350: #if defined(_POSIX_THREAD_PROCESS_SHARED)
 351:   int   process_shared;       /* allow this to be shared amongst processes */
 352: #endif
 353: } pthread_condattr_t;         /* a condition attribute object */
 354: 
 355: /* Keys */
 356: 
 357: typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
 358: 
 359: typedef struct {
 360:   int   is_initialized;  /* is this structure initialized? */
 361:   int   init_executed;   /* has the initialization routine been run? */
 362: } pthread_once_t;       /* dynamic package initialization */
 363: #else
 364: #if defined (__CYGWIN__)
 365: #include <cygwin/types.h>
 366: #endif
 367: #endif /* defined(_POSIX_THREADS) */
 368: 
 369: #endif  /* defined(__rtems__) */
 370: 
 371: #endif  /* !__need_inttypes */
 372: 
 373: #undef __need_inttypes
 374: 
 375: #endif  /* _SYS_TYPES_H */
 376: 








































Html form generated by Xrefactory version 1.6.7 on Fri Sep 03 17:18:59 2004