types.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
  3. * The President and Fellows of Harvard College.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. #ifndef _KERN_TYPES_H_
  30. #define _KERN_TYPES_H_
  31. /* Get machine-dependent types. */
  32. #include <kern/machine/types.h>
  33. /*
  34. * Machine-independent types visible to user level.
  35. *
  36. * Define everything with leading underscores to avoid polluting the C
  37. * namespace for applications.
  38. *
  39. * The C standard (and additionally the POSIX standard) define rules
  40. * for what families of symbol names are allowed to be used by
  41. * application programmers, and what families of symbol names can be
  42. * defined by various standard header files. The C library needs to
  43. * conform to those rules, to the extent reasonably practical, to make
  44. * sure that application code compiles and behaves as intended.
  45. *
  46. * Many of the C library's headers need to use one or more of these
  47. * types in places where the "real" name of the type cannot be
  48. * exposed, or expose the names of some of these types and not others.
  49. * (For example, <string.h> is supposed to define size_t, but is not
  50. * supposed to also define e.g. pid_t.)
  51. *
  52. * For this reason we define everything with two underscores in front
  53. * of it; in C such symbol names are reserved for the implementation,
  54. * which we are, so this file can be included anywhere in any libc
  55. * header without causing namespace problems. The "real" type names
  56. * are defined with an additional layer of typedefs; this happens for
  57. * the kernel in <types.h> and for userland in (mostly) <sys/types.h>
  58. * and also various other places as per relevant standards.
  59. */
  60. typedef __u32 __blkcnt_t; /* Count of blocks */
  61. typedef __u32 __blksize_t; /* Size of an I/O block */
  62. typedef __u64 __counter_t; /* Event counter */
  63. typedef __u32 __daddr_t; /* Disk block number */
  64. typedef __u32 __dev_t; /* Hardware device ID */
  65. typedef __u32 __fsid_t; /* Filesystem ID */
  66. typedef __i32 __gid_t; /* Group ID */
  67. typedef __u32 __in_addr_t; /* Internet address */
  68. typedef __u32 __in_port_t; /* Internet port number */
  69. typedef __u32 __ino_t; /* Inode number */
  70. typedef __u32 __mode_t; /* File access mode */
  71. typedef __u16 __nlink_t; /* Number of links (intentionally only 16 bits) */
  72. typedef __i64 __off_t; /* Offset within file */
  73. typedef __i32 __pid_t; /* Process ID */
  74. typedef __u64 __rlim_t; /* Resource limit quantity */
  75. typedef __u8 __sa_family_t;/* Socket address family */
  76. typedef __i64 __time_t; /* Time in seconds */
  77. typedef __i32 __uid_t; /* User ID */
  78. typedef int __nfds_t; /* Number of file handles */
  79. typedef int __socklen_t; /* Socket-related length */
  80. /* See note in <stdarg.h> */
  81. #ifdef __GNUC__
  82. typedef __builtin_va_list __va_list;
  83. #endif
  84. #endif /* _KERN_TYPES_H_ */