0001
0002 #ifndef __TRACE_AGENT_H__
0003 #define __TRACE_AGENT_H__
0004 #include <pthread.h>
0005 #include <stdbool.h>
0006
0007 #define MAX_CPUS 256
0008 #define PIPE_INIT (1024*1024)
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 struct agent_info {
0019 unsigned long pipe_size;
0020 bool use_stdout;
0021 int cpus;
0022 int ctl_fd;
0023 struct rw_thread_info *rw_ti[MAX_CPUS];
0024 };
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 struct rw_thread_info {
0036 int cpu_num;
0037 int in_fd;
0038 int out_fd;
0039 int read_pipe;
0040 int write_pipe;
0041 unsigned long pipe_size;
0042 };
0043
0044
0045 extern bool global_sig_receive;
0046
0047
0048 extern bool global_run_operation;
0049 extern pthread_mutex_t mutex_notify;
0050 extern pthread_cond_t cond_wakeup;
0051
0052
0053 extern int rw_ctl_init(const char *ctl_path);
0054 extern void *rw_ctl_loop(int ctl_fd);
0055
0056
0057 extern void *rw_thread_info_new(void);
0058 extern void *rw_thread_init(int cpu, const char *in_path, const char *out_path,
0059 bool stdout_flag, unsigned long pipe_size,
0060 struct rw_thread_info *rw_ti);
0061 extern pthread_t rw_thread_run(struct rw_thread_info *rw_ti);
0062
0063 static inline void *zalloc(size_t size)
0064 {
0065 return calloc(1, size);
0066 }
0067
0068 #define pr_err(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
0069 #define pr_info(format, ...) fprintf(stdout, format, ## __VA_ARGS__)
0070 #ifdef DEBUG
0071 #define pr_debug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
0072 #else
0073 #define pr_debug(format, ...) do {} while (0)
0074 #endif
0075
0076 #endif