move eventfd stuff out to own file
[trinity.git] / include / shm.h
blob26327e272b7065e1f7932f5d2ca1916476cd38ca
1 #pragma once
3 #include <sys/time.h>
4 #include <sys/types.h>
6 #include <stdio.h>
8 #include "constants.h"
9 #include "exit.h"
10 #include "locks.h"
11 #include "net.h"
12 #include "types.h"
14 void create_shm(void);
15 void create_shm_arrays(void);
16 void init_shm(void);
18 struct syscallrecord {
19 unsigned int nr; /* protected by syscall_lock */
20 unsigned long a1;
21 unsigned long a2;
22 unsigned long a3;
23 unsigned long a4;
24 unsigned long a5;
25 unsigned long a6;
26 unsigned long retval;
27 bool do32bit; /* protected by syscall_lock */
30 struct shm_s {
31 unsigned long total_syscalls_done;
32 unsigned long successes;
33 unsigned long failures;
34 unsigned long previous_count;
35 unsigned long *child_syscall_count;
37 unsigned long regenerate;
38 unsigned int seed;
39 unsigned int *seeds;
41 /* Indices of syscall in syscall table that are active.
42 * All indices shifted by +1. Empty index equals to 0.
44 * 'active_syscalls' is only used on uniarch. The other two
45 * are only used on biarch. FIXME: Make this compile-time somehow? */
46 int active_syscalls32[MAX_NR_SYSCALL];
47 int active_syscalls64[MAX_NR_SYSCALL];
48 int active_syscalls[MAX_NR_SYSCALL];
49 unsigned int nr_active_syscalls;
50 unsigned int nr_active_32bit_syscalls;
51 unsigned int nr_active_64bit_syscalls;
53 pid_t mainpid;
54 pid_t *pids;
56 pid_t last_reaped;
57 bool spawn_no_more;
58 unsigned char *kill_count;
60 unsigned int running_childs;
61 struct timeval *tv;
62 struct timeval taint_tv;
64 FILE **logfiles;
66 int pipe_fds[MAX_PIPE_FDS*2];
67 int file_fds[NR_FILE_FDS]; /* All children inherit these */
68 int perf_fds[MAX_PERF_FDS];
69 int epoll_fds[MAX_EPOLL_FDS];
70 int eventfd_fds[MAX_EPOLL_FDS];
72 struct socketinfo sockets[NR_SOCKET_FDS];
74 struct syscallrecord *syscall; /* FIXME: protect all accesses with syscall_lock */
75 struct syscallrecord *previous;
77 unsigned long *scratch;
79 int current_fd;
80 unsigned int fd_lifetime;
82 /* per-child mmaps */
83 struct map **mappings;
84 unsigned int *num_mappings;
86 /* various flags. */
87 bool dont_make_it_fail;
88 enum exit_reasons exit_reason;
90 /* locks */
91 volatile unsigned char regenerating;
92 lock_t reaper_lock;
93 lock_t syscall_lock;
95 bool ready;
97 extern struct shm_s *shm;
99 #define SHM_OK 0
100 #define SHM_CORRUPT 1