split up constants.h some
[trinity.git] / include / shm.h
blobd53423af1a2a5096300e646c8f3bc56bdf52dd5f
1 #pragma once
3 #include <sys/time.h>
4 #include <sys/types.h>
6 #include <stdio.h>
8 #include "constants.h"
9 #include "epoll.h"
10 #include "eventfd.h"
11 #include "exit.h"
12 #include "files.h"
13 #include "locks.h"
14 #include "net.h"
15 #include "pipes.h"
16 #include "perf.h"
17 #include "types.h"
19 void create_shm(void);
20 void create_shm_arrays(void);
21 void init_shm(void);
23 struct syscallrecord {
24 unsigned int nr; /* protected by syscall_lock */
25 unsigned long a1;
26 unsigned long a2;
27 unsigned long a3;
28 unsigned long a4;
29 unsigned long a5;
30 unsigned long a6;
31 unsigned long retval;
32 bool do32bit; /* protected by syscall_lock */
35 struct shm_s {
36 unsigned long total_syscalls_done;
37 unsigned long successes;
38 unsigned long failures;
40 unsigned long previous_op_count; /* combined total of all children */
41 unsigned long *child_op_count; /* these are per-child so we can see if
42 a child is making progress or not. */
43 unsigned long regenerate;
45 unsigned int seed;
46 unsigned int *seeds;
48 /* Indices of syscall in syscall table that are active.
49 * All indices shifted by +1. Empty index equals to 0.
51 * 'active_syscalls' is only used on uniarch. The other two
52 * are only used on biarch. FIXME: Make this compile-time somehow? */
53 int active_syscalls32[MAX_NR_SYSCALL];
54 int active_syscalls64[MAX_NR_SYSCALL];
55 int active_syscalls[MAX_NR_SYSCALL];
56 unsigned int nr_active_syscalls;
57 unsigned int nr_active_32bit_syscalls;
58 unsigned int nr_active_64bit_syscalls;
60 pid_t mainpid;
61 pid_t *pids;
63 pid_t last_reaped;
64 bool spawn_no_more;
65 unsigned char *kill_count;
67 unsigned int running_childs;
68 struct timeval *tv;
69 struct timeval taint_tv;
71 FILE **logfiles;
73 int pipe_fds[MAX_PIPE_FDS*2];
74 int file_fds[NR_FILE_FDS]; /* All children inherit these */
75 int perf_fds[MAX_PERF_FDS];
76 int epoll_fds[MAX_EPOLL_FDS];
77 int eventfd_fds[MAX_EPOLL_FDS];
79 struct socketinfo sockets[NR_SOCKET_FDS];
81 struct syscallrecord *syscall; /* FIXME: protect all accesses with syscall_lock */
82 struct syscallrecord *previous;
84 unsigned long *scratch;
86 int current_fd;
87 unsigned int fd_lifetime;
89 /* per-child mmaps */
90 struct map **mappings;
91 unsigned int *num_mappings;
93 /* various flags. */
94 bool dont_make_it_fail;
95 enum exit_reasons exit_reason;
97 /* locks */
98 volatile unsigned char regenerating;
99 lock_t reaper_lock;
100 lock_t syscall_lock;
102 bool ready;
104 extern struct shm_s *shm;
106 #define SHM_OK 0
107 #define SHM_CORRUPT 1