shim_types.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. #include <stddef.h>
  6. #include <stdint.h>
  7. #include <stdbool.h>
  8. #define __KERNEL__
  9. #include <linux/types.h>
  10. #include <linux/utsname.h>
  11. #include <linux/times.h>
  12. #include <linux/shm.h>
  13. #include <linux/msg.h>
  14. #include <linux/sem.h>
  15. #include <linux/kernel.h>
  16. #include <linux/utime.h>
  17. #include <linux/futex.h>
  18. #include <linux/aio_abi.h>
  19. #include <linux/perf_event.h>
  20. #include <asm/posix_types.h>
  21. #include <asm/statfs.h>
  22. #include <asm/stat.h>
  23. #include <asm/ldt.h>
  24. #include <asm/signal.h>
  25. #include <asm/siginfo.h>
  26. #include <asm/poll.h>
  27. typedef unsigned int __u32;
  28. typedef unsigned long int nfds_t;
  29. typedef unsigned long int nlink_t;
  30. typedef __kernel_caddr_t caddr_t;
  31. typedef __kernel_mode_t mode_t;
  32. typedef __kernel_loff_t loff_t;
  33. typedef __kernel_time_t time_t;
  34. typedef __kernel_old_dev_t dev_t;
  35. typedef __kernel_ino_t ino_t;
  36. typedef __kernel_clockid_t clockid_t;
  37. typedef __kernel_key_t key_t;
  38. typedef __kernel_timer_t timer_t;
  39. typedef __kernel_fd_set fd_set;
  40. /* linux/time.h */
  41. struct __kernel_timespec {
  42. __kernel_time_t tv_sec; /* seconds */
  43. long tv_nsec; /* nanoseconds */
  44. };
  45. struct __kernel_timeval {
  46. __kernel_time_t tv_sec; /* seconds */
  47. __kernel_suseconds_t tv_usec; /* microsecond */
  48. };
  49. struct __kernel_itimerspec {
  50. struct __kernel_timespec it_interval; /* timer period */
  51. struct __kernel_timespec it_value; /* timer expiration */
  52. };
  53. struct __kernel_itimerval {
  54. struct __kernel_timeval it_interval; /* time interval */
  55. struct __kernel_timeval it_value; /* current value */
  56. };
  57. struct __kernel_timezone {
  58. int tz_minuteswest; /* minutes west of Greenwich */
  59. int tz_dsttime; /* type of dst correction */
  60. };
  61. /* linux/time.h
  62. * syscall interface - used (mainly by NTP daemon)
  63. * to discipline kernel clock oscillator
  64. */
  65. struct __kernel_timex {
  66. unsigned int modes; /* mode selector */
  67. long offset; /* time offset (usec) */
  68. long freq; /* frequency offset (scaled ppm) */
  69. long maxerror; /* maximum error (usec) */
  70. long esterror; /* estimated error (usec) */
  71. int status; /* clock command/status */
  72. long constant; /* pll time constant */
  73. long precision; /* clock precision (usec) (read only) */
  74. long tolerance; /* clock frequency tolerance (ppm)
  75. * (read only) */
  76. struct __kernel_timeval time; /* (read only) */
  77. long tick; /* (modified) usecs between clock ticks */
  78. long ppsfreq; /* pps frequency (scaled ppm) (ro) */
  79. long jitter; /* pps jitter (us) (ro) */
  80. int shift; /* interval duration (s) (shift) (ro) */
  81. long stabil; /* pps stability (scaled ppm) (ro) */
  82. long jitcnt; /* jitter limit exceeded (ro) */
  83. long calcnt; /* calibration intervals (ro) */
  84. long errcnt; /* calibration errors (ro) */
  85. long stbcnt; /* stability limit exceeded (ro) */
  86. int tai; /* TAI offset (ro) */
  87. int :32; int :32; int :32; int :32;
  88. int :32; int :32; int :32; int :32;
  89. int :32; int :32; int :32;
  90. };
  91. /* /arch/x86/include/asm/posix_types_64.h */
  92. typedef unsigned int __kernel_uid_t;
  93. typedef __kernel_uid_t __kernel_uid32_t;
  94. /* quota.h */
  95. typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
  96. /* capability.h */
  97. typedef struct __user_cap_header_struct {
  98. __u32 version;
  99. int pid;
  100. } *cap_user_header_t;
  101. typedef struct __user_cap_data_struct {
  102. __u32 effective;
  103. __u32 permitted;
  104. __u32 inheritable;
  105. } *cap_user_data_t;
  106. /* defined in function in sysdeps/unix/sysv/linux/sysctl.c */
  107. struct __kernel_sysctl_args {
  108. int *name; /* integer vector describing variable */
  109. int nlen; /* length of this vector */
  110. void *oldval; /* 0 or address where to store old value */
  111. size_t *oldlenp; /* available room for old value,
  112. overwritten by actual size of old value */
  113. void *newval; /* 0 or address of new value */
  114. size_t newlen; /* size of new value */
  115. };
  116. struct __kernel_sched_param {
  117. int __sched_priority;
  118. };
  119. struct __kernel_sigaction {
  120. __sighandler_t k_sa_handler;
  121. unsigned long sa_flags;
  122. void (*sa_restorer) (void);
  123. sigset_t sa_mask;
  124. };
  125. /* linux/aio_abi.h (for io_setup which has no glibc wrapper) */
  126. typedef unsigned long aio_context_t;
  127. /* bits/sigset.h */
  128. # define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
  129. typedef struct {
  130. unsigned long int __val[_SIGSET_NWORDS];
  131. } __sigset_t;
  132. /* linux/rlimit.h */
  133. struct __kernel_rusage {
  134. struct __kernel_timeval ru_utime; /* user time used */
  135. struct __kernel_timeval ru_stime; /* system time used */
  136. long ru_maxrss; /* maximum resident set size */
  137. long ru_ixrss; /* integral shared memory size */
  138. long ru_idrss; /* integral unshared data size */
  139. long ru_isrss; /* integral unshared stack size */
  140. long ru_minflt; /* page reclaims */
  141. long ru_majflt; /* page faults */
  142. long ru_nswap; /* swaps */
  143. long ru_inblock; /* block input operations */
  144. long ru_oublock; /* block output operations */
  145. long ru_msgsnd; /* messages sent */
  146. long ru_msgrcv; /* messages received */
  147. long ru_nsignals; /* signals received */
  148. long ru_nvcsw; /* voluntary context switches */
  149. long ru_nivcsw; /* involuntary " */
  150. };
  151. struct __kernel_rlimit {
  152. unsigned long rlim_cur;
  153. unsigned long rlim_max;
  154. };
  155. /* linux/eventpoll.h
  156. * On x86-64 make the 64bit structure have the same alignment as the
  157. * 32bit structure. This makes 32bit emulation easier.
  158. *
  159. * UML/x86_64 needs the same packing as x86_64
  160. */
  161. struct __kernel_epoll_event {
  162. __u32 events;
  163. __u64 data;
  164. }
  165. #ifdef __x86_64__
  166. __attribute__((packed));
  167. #else
  168. ;
  169. #endif
  170. /* sys/ucontext.h */
  171. /* Type for general register. */
  172. typedef long int greg_t;
  173. /* Number of general registers. */
  174. #define NGREG 23
  175. /* Container for all general registers. */
  176. typedef greg_t gregset_t[NGREG];
  177. /* Number of each register in the `gregset_t' array. */
  178. enum
  179. {
  180. REG_R8 = 0,
  181. # define REG_R8 REG_R8
  182. REG_R9,
  183. # define REG_R9 REG_R9
  184. REG_R10,
  185. # define REG_R10 REG_R10
  186. REG_R11,
  187. # define REG_R11 REG_R11
  188. REG_R12,
  189. # define REG_R12 REG_R12
  190. REG_R13,
  191. # define REG_R13 REG_R13
  192. REG_R14,
  193. # define REG_R14 REG_R14
  194. REG_R15,
  195. # define REG_R15 REG_R15
  196. REG_RDI,
  197. # define REG_RDI REG_RDI
  198. REG_RSI,
  199. # define REG_RSI REG_RSI
  200. REG_RBP,
  201. # define REG_RBP REG_RBP
  202. REG_RBX,
  203. # define REG_RBX REG_RBX
  204. REG_RDX,
  205. # define REG_RDX REG_RDX
  206. REG_RAX,
  207. # define REG_RAX REG_RAX
  208. REG_RCX,
  209. # define REG_RCX REG_RCX
  210. REG_RSP,
  211. # define REG_RSP REG_RSP
  212. REG_RIP,
  213. # define REG_RIP REG_RIP
  214. REG_EFL,
  215. # define REG_EFL REG_EFL
  216. REG_CSGSFS, /* Actually short cs, gs, fs, __pad0. */
  217. # define REG_CSGSFS REG_CSGSFS
  218. REG_ERR,
  219. # define REG_ERR REG_ERR
  220. REG_TRAPNO,
  221. # define REG_TRAPNO REG_TRAPNO
  222. REG_OLDMASK,
  223. # define REG_OLDMASK REG_OLDMASK
  224. REG_CR2
  225. # define REG_CR2 REG_CR2
  226. };
  227. struct _libc_fpxreg {
  228. unsigned short int significand[4];
  229. unsigned short int exponent;
  230. unsigned short int padding[3];
  231. };
  232. struct _libc_xmmreg {
  233. __uint32_t element[4];
  234. };
  235. struct _libc_fpstate {
  236. /* 64-bit FXSAVE format. */
  237. __uint16_t cwd;
  238. __uint16_t swd;
  239. __uint16_t ftw;
  240. __uint16_t fop;
  241. __uint64_t rip;
  242. __uint64_t rdp;
  243. __uint32_t mxcsr;
  244. __uint32_t mxcr_mask;
  245. struct _libc_fpxreg st[8];
  246. struct _libc_xmmreg _xmm[16];
  247. __uint32_t padding[24];
  248. };
  249. /* Structure to describe FPU registers. */
  250. typedef struct _libc_fpstate *fpregset_t;
  251. /* Context to describe whole processor state. */
  252. typedef struct {
  253. gregset_t gregs;
  254. /* Note that fpregs is a pointer. */
  255. fpregset_t fpregs;
  256. unsigned long __reserved1 [8];
  257. } mcontext_t;
  258. /* Userlevel context. */
  259. typedef struct ucontext {
  260. unsigned long int uc_flags;
  261. struct ucontext *uc_link;
  262. stack_t uc_stack;
  263. mcontext_t uc_mcontext;
  264. __sigset_t uc_sigmask;
  265. struct _libc_fpstate __fpregs_mem;
  266. } ucontext_t;
  267. /* bits/ustat.h */
  268. struct __kernel_ustat
  269. {
  270. __daddr_t f_tfree; /* Number of free blocks. */
  271. __ino_t f_tinode; /* Number of free inodes. */
  272. char f_fname[6];
  273. char f_fpack[6];
  274. };
  275. /* bits/socket.h */
  276. struct msghdr {
  277. void *msg_name; /* Address to send to/receive from. */
  278. socklen_t msg_namelen; /* Length of address data. */
  279. struct iovec *msg_iov; /* Vector of data to send/receive into. */
  280. size_t msg_iovlen; /* Number of elements in the vector. */
  281. void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
  282. size_t msg_controllen; /* Ancillary data buffer length.
  283. !! The type should be socklen_t but the
  284. definition of the kernel is incompatible
  285. with this. */
  286. int msg_flags; /* Flags on received message. */
  287. };
  288. /* For `recvmmsg'. */
  289. struct mmsghdr {
  290. struct msghdr msg_hdr; /* Actual message header. */
  291. unsigned int msg_len; /* Number of received bytes for the entry. */
  292. };
  293. /* POSIX.1g specifies this type name for the `sa_family' member. */
  294. typedef unsigned short int sa_family_t;
  295. /* This macro is used to declare the initial common members
  296. of the data types used for socket addresses, `struct sockaddr',
  297. `struct sockaddr_in', `struct sockaddr_un', etc. */
  298. #define __SOCKADDR_COMMON(sa_prefix) \
  299. sa_family_t sa_prefix##family
  300. /* Structure describing a generic socket address. */
  301. struct sockaddr {
  302. __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
  303. char sa_data[14]; /* Address data. */
  304. };
  305. /* linux/mqueue.h */
  306. struct __kernel_mq_attr {
  307. long mq_flags; /* message queue flags */
  308. long mq_maxmsg; /* maximum number of messages */
  309. long mq_msgsize; /* maximum message size */
  310. long mq_curmsgs; /* number of messages currently queued */
  311. long __reserved[4]; /* ignored for input, zeroed for output */
  312. };
  313. /* bits/uio.h */
  314. /* Structure for scatter/gather I/O. */
  315. struct iovec {
  316. void * iov_base; /* Pointer to data. */
  317. size_t iov_len; /* Length of data. */
  318. };
  319. /* bits/sched.h */
  320. /* Type for array elements in 'cpu_set_t'. */
  321. typedef unsigned long int __kernel_cpu_mask;
  322. /* Size definition for CPU sets. */
  323. # define __CPU_SETSIZE 1024
  324. # define __NCPUBITS (8 * sizeof (__kernel_cpu_mask))
  325. /* Data structure to describe CPU mask. */
  326. typedef struct {
  327. __kernel_cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
  328. } __kernel_cpu_set_t;
  329. # undef __CPU_SETSIZE
  330. # undef __NCPUBITS
  331. #define LINUX_DT_UNKNOWN 0
  332. #define LINUX_DT_FIFO 1
  333. #define LINUX_DT_CHR 2
  334. #define LINUX_DT_DIR 4
  335. #define LINUX_DT_BLK 6
  336. #define LINUX_DT_REG 8
  337. #define LINUX_DT_LNK 10
  338. #define LINUX_DT_SOCK 12
  339. #define LINUX_DT_WHT 14
  340. struct linux_dirent64 {
  341. uint64_t d_ino; /* Inode number */
  342. uint64_t d_off; /* Offset to next linux_dirent */
  343. unsigned short int d_reclen; /* Length of this linux_dirent */
  344. unsigned char d_type;
  345. char d_name[]; /* File name (null-terminated) */
  346. };
  347. struct linux_dirent {
  348. unsigned long d_ino; /* Inode number */
  349. unsigned long d_off; /* Offset to next linux_dirent */
  350. unsigned short int d_reclen; /* Length of this linux_dirent */
  351. char d_name[]; /* File name (null-terminated) */
  352. };
  353. struct linux_dirent_tail {
  354. char pad;
  355. unsigned char d_type;
  356. };
  357. struct __kernel_addrinfo
  358. {
  359. int ai_flags; /* Input flags. */
  360. int ai_family; /* Protocol family for socket. */
  361. int ai_socktype; /* Socket type. */
  362. int ai_protocol; /* Protocol for socket. */
  363. socklen_t ai_addrlen; /* Length of socket address. */
  364. struct sockaddr *ai_addr; /* Socket address for socket. */
  365. char *ai_canonname; /* Canonical name for service location. */
  366. struct addrinfo *ai_next; /* Pointer to next in list. */
  367. };
  368. #include "elf.h"
  369. #ifdef __x86_64__
  370. typedef Elf64_auxv_t elf_auxv_t;
  371. #else
  372. typedef Elf64_auxv_t elf_auxv_t;
  373. #endif
  374. /* typedef for shim internal types */
  375. typedef unsigned int IDTYPE;
  376. typedef uint16_t FDTYPE;
  377. typedef unsigned long LEASETYPE;
  378. typedef unsigned long HASHTYPE;
  379. struct shim_atomic {
  380. #ifndef __i386__
  381. long counter;
  382. #else
  383. int counter;
  384. #endif
  385. };
  386. typedef struct shim_atomic REFTYPE;
  387. #include <pal.h>
  388. typedef struct shim_lock {
  389. PAL_HANDLE lock;
  390. IDTYPE owner;
  391. } LOCKTYPE;
  392. typedef struct shim_aevent {
  393. PAL_HANDLE event;
  394. } AEVENTTYPE;
  395. #define STR_SIZE 256
  396. struct shim_str {
  397. char str[STR_SIZE];
  398. };
  399. #define QSTR_SIZE 32
  400. /* Use qstr for names. This has fix size string + string object
  401. * if len > SHIM_QSTR_SIZE then use overflow string */
  402. struct shim_qstr {
  403. HASHTYPE hash;
  404. size_t len;
  405. char name[QSTR_SIZE];
  406. struct shim_str * oflow;
  407. };
  408. #endif /* _SHIM_TYPES_H_ */