commentary on the active_* vars in the shm
[trinity.git] / include / shm.h
blob3910b4edccc84f7f4020dc60e948a0a40d2908c7
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 "net.h"
11 #include "types.h"
13 void create_shm(void);
14 void create_shm_arrays(void);
15 void init_shm(void);
17 struct shm_s {
18 unsigned long total_syscalls_done;
19 unsigned long successes;
20 unsigned long failures;
21 unsigned long previous_count;
22 unsigned long *child_syscall_count;
24 unsigned long regenerate;
25 unsigned int seed;
26 unsigned int *seeds;
27 unsigned int reseed_counter;
29 /* Indices of syscall in syscall table that are active.
30 * All indices shifted by +1. Empty index equals to 0.
32 * 'active_syscalls' is only used on uniarch. The other two
33 * are only used on biarch. FIXME: Make this compile-time somehow? */
34 int active_syscalls32[MAX_NR_SYSCALL];
35 int active_syscalls64[MAX_NR_SYSCALL];
36 int active_syscalls[MAX_NR_SYSCALL];
37 unsigned int nr_active_syscalls;
38 unsigned int nr_active_32bit_syscalls;
39 unsigned int nr_active_64bit_syscalls;
41 pid_t mainpid;
42 pid_t *pids;
43 unsigned char *child_type;
45 pid_t last_reaped;
46 bool spawn_no_more;
47 unsigned char *kill_count;
49 unsigned int running_childs;
50 struct timeval *tv;
52 FILE **logfiles;
54 int pipe_fds[MAX_PIPE_FDS*2];
55 int file_fds[NR_FILE_FDS]; /* All children inherit these */
56 int perf_fds[MAX_PERF_FDS];
57 int epoll_fds[MAX_EPOLL_FDS];
58 int eventfd_fds[MAX_EPOLL_FDS];
60 struct socketinfo sockets[NR_SOCKET_FDS];
62 /* state for the syscall currently in progress. */
63 unsigned int *previous_syscallno;
64 unsigned long *previous_a1;
65 unsigned long *previous_a2;
66 unsigned long *previous_a3;
67 unsigned long *previous_a4;
68 unsigned long *previous_a5;
69 unsigned long *previous_a6;
71 unsigned int *syscallno; /* protected by syscall_lock */
72 unsigned long *a1;
73 unsigned long *a2;
74 unsigned long *a3;
75 unsigned long *a4;
76 unsigned long *a5;
77 unsigned long *a6;
79 unsigned long *retval;
81 unsigned long *scratch;
83 int current_fd;
84 unsigned int fd_lifetime;
86 /* per-child mmaps */
87 struct map **mappings;
88 unsigned int *num_mappings;
90 /* various flags. */
91 bool *do32bit; /* protected by syscall_lock */
92 bool do_make_it_fail;
93 bool need_reseed;
94 enum exit_reasons exit_reason;
96 /* locks */
97 volatile unsigned char regenerating;
98 volatile unsigned char reaper_lock;
99 volatile unsigned char syscall_lock;
101 bool ready;
103 extern struct shm_s *shm;
105 #define SHM_OK 0
106 #define SHM_CORRUPT 1