shim_types.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #ifndef _SHIM_TYPES_H_
  4. #define _SHIM_TYPES_H_
  5. #define _GNU_SOURCE
  6. #include <features.h>
  7. #include <stddef.h>
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. #include <signal.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <sys/ustat.h>
  14. #include <sys/socket.h>
  15. #include <sys/poll.h>
  16. #include <asm/statfs.h>
  17. #include <asm/ldt.h>
  18. #include <netinet/in.h>
  19. #include <linux/types.h>
  20. #include <linux/utsname.h>
  21. #include <linux/times.h>
  22. #include <linux/shm.h>
  23. #include <linux/msg.h>
  24. #include <linux/sem.h>
  25. #include <linux/kernel.h>
  26. #include <linux/utime.h>
  27. #include <linux/futex.h>
  28. #include <linux/aio_abi.h>
  29. #include <linux/perf_event.h>
  30. typedef unsigned int __u32;
  31. /* linux/time.h */
  32. struct __kernel_timespec {
  33. __kernel_time_t tv_sec; /* seconds */
  34. long tv_nsec; /* nanoseconds */
  35. };
  36. struct __kernel_timeval {
  37. __kernel_time_t tv_sec; /* seconds */
  38. __kernel_suseconds_t tv_usec; /* microsecond */
  39. };
  40. struct __kernel_itimerspec {
  41. struct __kernel_timespec it_interval; /* timer period */
  42. struct __kernel_timespec it_value; /* timer expiration */
  43. };
  44. struct __kernel_itimerval {
  45. struct __kernel_timeval it_interval; /* time interval */
  46. struct __kernel_timeval it_value; /* current value */
  47. };
  48. struct __kernel_timezone {
  49. int tz_minuteswest; /* minutes west of Greenwich */
  50. int tz_dsttime; /* type of dst correction */
  51. };
  52. /* linux/time.h
  53. * syscall interface - used (mainly by NTP daemon)
  54. * to discipline kernel clock oscillator
  55. */
  56. struct __kernel_timex {
  57. unsigned int modes; /* mode selector */
  58. long offset; /* time offset (usec) */
  59. long freq; /* frequency offset (scaled ppm) */
  60. long maxerror; /* maximum error (usec) */
  61. long esterror; /* estimated error (usec) */
  62. int status; /* clock command/status */
  63. long constant; /* pll time constant */
  64. long precision; /* clock precision (usec) (read only) */
  65. long tolerance; /* clock frequency tolerance (ppm)
  66. * (read only) */
  67. struct __kernel_timeval time; /* (read only) */
  68. long tick; /* (modified) usecs between clock ticks */
  69. long ppsfreq; /* pps frequency (scaled ppm) (ro) */
  70. long jitter; /* pps jitter (us) (ro) */
  71. int shift; /* interval duration (s) (shift) (ro) */
  72. long stabil; /* pps stability (scaled ppm) (ro) */
  73. long jitcnt; /* jitter limit exceeded (ro) */
  74. long calcnt; /* calibration intervals (ro) */
  75. long errcnt; /* calibration errors (ro) */
  76. long stbcnt; /* stability limit exceeded (ro) */
  77. int tai; /* TAI offset (ro) */
  78. int :32; int :32; int :32; int :32;
  79. int :32; int :32; int :32; int :32;
  80. int :32; int :32; int :32;
  81. };
  82. /* /arch/x86/include/asm/posix_types_64.h */
  83. typedef unsigned int __kernel_uid_t;
  84. typedef __kernel_uid_t __kernel_uid32_t;
  85. /* quota.h */
  86. typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
  87. /* capability.h */
  88. typedef struct __user_cap_header_struct {
  89. __u32 version;
  90. int pid;
  91. } *cap_user_header_t;
  92. typedef struct __user_cap_data_struct {
  93. __u32 effective;
  94. __u32 permitted;
  95. __u32 inheritable;
  96. } *cap_user_data_t;
  97. /* defined in function in sysdeps/unix/sysv/linux/sysctl.c */
  98. struct __kernel_sysctl_args {
  99. int *name; /* integer vector describing variable */
  100. int nlen; /* length of this vector */
  101. void *oldval; /* 0 or address where to store old value */
  102. size_t *oldlenp; /* available room for old value,
  103. overwritten by actual size of old value */
  104. void *newval; /* 0 or address of new value */
  105. size_t newlen; /* size of new value */
  106. };
  107. struct __kernel_sched_param {
  108. int __sched_priority;
  109. };
  110. struct __kernel_sigaction {
  111. __sighandler_t k_sa_handler;
  112. unsigned long sa_flags;
  113. void (*sa_restorer) (void);
  114. sigset_t sa_mask;
  115. };
  116. /* linux/aio_abi.h (for io_setup which has no glibc wrapper) */
  117. typedef unsigned long aio_context_t;
  118. /* linux/rlimit.h */
  119. struct __kernel_rusage {
  120. struct __kernel_timeval ru_utime; /* user time used */
  121. struct __kernel_timeval ru_stime; /* system time used */
  122. long ru_maxrss; /* maximum resident set size */
  123. long ru_ixrss; /* integral shared memory size */
  124. long ru_idrss; /* integral unshared data size */
  125. long ru_isrss; /* integral unshared stack size */
  126. long ru_minflt; /* page reclaims */
  127. long ru_majflt; /* page faults */
  128. long ru_nswap; /* swaps */
  129. long ru_inblock; /* block input operations */
  130. long ru_oublock; /* block output operations */
  131. long ru_msgsnd; /* messages sent */
  132. long ru_msgrcv; /* messages received */
  133. long ru_nsignals; /* signals received */
  134. long ru_nvcsw; /* voluntary context switches */
  135. long ru_nivcsw; /* involuntary " */
  136. };
  137. struct __kernel_rlimit {
  138. unsigned long rlim_cur;
  139. unsigned long rlim_max;
  140. };
  141. /* linux/eventpoll.h
  142. * On x86-64 make the 64bit structure have the same alignment as the
  143. * 32bit structure. This makes 32bit emulation easier.
  144. *
  145. * UML/x86_64 needs the same packing as x86_64
  146. */
  147. struct __kernel_epoll_event {
  148. __u32 events;
  149. __u64 data;
  150. }
  151. #ifdef __x86_64__
  152. __attribute__((packed));
  153. #else
  154. ;
  155. #endif
  156. /* buts/socket.h */
  157. #ifndef __USE_GNU
  158. /* For `recvmmsg'. */
  159. struct mmsghdr {
  160. struct msghdr msg_hdr; /* Actual message header. */
  161. unsigned int msg_len; /* Number of received bytes for the entry. */
  162. };
  163. #endif
  164. /* linux/mqueue.h */
  165. struct __kernel_mq_attr {
  166. long mq_flags; /* message queue flags */
  167. long mq_maxmsg; /* maximum number of messages */
  168. long mq_msgsize; /* maximum message size */
  169. long mq_curmsgs; /* number of messages currently queued */
  170. long __reserved[4]; /* ignored for input, zeroed for output */
  171. };
  172. /* bits/sched.h */
  173. /* Type for array elements in 'cpu_set_t'. */
  174. typedef unsigned long int __kernel_cpu_mask;
  175. /* Size definition for CPU sets. */
  176. # define __CPU_SETSIZE 1024
  177. # define __NCPUBITS (8 * sizeof (__kernel_cpu_mask))
  178. /* Data structure to describe CPU mask. */
  179. typedef struct {
  180. __kernel_cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
  181. } __kernel_cpu_set_t;
  182. # undef __CPU_SETSIZE
  183. # undef __NCPUBITS
  184. #define LINUX_DT_UNKNOWN 0
  185. #define LINUX_DT_FIFO 1
  186. #define LINUX_DT_CHR 2
  187. #define LINUX_DT_DIR 4
  188. #define LINUX_DT_BLK 6
  189. #define LINUX_DT_REG 8
  190. #define LINUX_DT_LNK 10
  191. #define LINUX_DT_SOCK 12
  192. #define LINUX_DT_WHT 14
  193. struct linux_dirent64 {
  194. uint64_t d_ino; /* Inode number */
  195. uint64_t d_off; /* Offset to next linux_dirent */
  196. unsigned short int d_reclen; /* Length of this linux_dirent */
  197. unsigned char d_type;
  198. char d_name[]; /* File name (null-terminated) */
  199. };
  200. struct linux_dirent {
  201. unsigned long d_ino; /* Inode number */
  202. unsigned long d_off; /* Offset to next linux_dirent */
  203. unsigned short int d_reclen; /* Length of this linux_dirent */
  204. char d_name[]; /* File name (null-terminated) */
  205. };
  206. struct linux_dirent_tail {
  207. char pad;
  208. unsigned char d_type;
  209. };
  210. struct __kernel_addrinfo
  211. {
  212. int ai_flags; /* Input flags. */
  213. int ai_family; /* Protocol family for socket. */
  214. int ai_socktype; /* Socket type. */
  215. int ai_protocol; /* Protocol for socket. */
  216. socklen_t ai_addrlen; /* Length of socket address. */
  217. struct sockaddr *ai_addr; /* Socket address for socket. */
  218. char *ai_canonname; /* Canonical name for service location. */
  219. struct addrinfo *ai_next; /* Pointer to next in list. */
  220. };
  221. #include "elf.h"
  222. #ifdef __x86_64__
  223. typedef Elf64_auxv_t elf_auxv_t;
  224. #else
  225. typedef Elf64_auxv_t elf_auxv_t;
  226. #endif
  227. /* typedef for shim internal types */
  228. typedef unsigned int IDTYPE;
  229. typedef uint16_t FDTYPE;
  230. typedef unsigned long LEASETYPE;
  231. typedef unsigned long HASHTYPE;
  232. struct shim_atomic {
  233. #ifndef __i386__
  234. long counter;
  235. #else
  236. int counter;
  237. #endif
  238. };
  239. typedef struct shim_atomic REFTYPE;
  240. #include <pal.h>
  241. typedef struct shim_lock {
  242. PAL_HANDLE lock;
  243. IDTYPE owner;
  244. } LOCKTYPE;
  245. typedef struct shim_aevent {
  246. PAL_HANDLE event;
  247. } AEVENTTYPE;
  248. #define STR_SIZE 256
  249. struct shim_str {
  250. char str[STR_SIZE];
  251. };
  252. #define QSTR_SIZE 32
  253. /* Use qstr for names. This has fix size string + string object
  254. * if len > SHIM_QSTR_SIZE then use overflow string */
  255. struct shim_qstr {
  256. HASHTYPE hash;
  257. size_t len;
  258. char name[QSTR_SIZE];
  259. struct shim_str * oflow;
  260. };
  261. #endif /* _SHIM_TYPES_H_ */