diff --git a/src/emu/clkoff.h b/src/emu/clkoff.h index c080105..74dd3f4 100644 --- a/src/emu/clkoff.h +++ b/src/emu/clkoff.h @@ -4,6 +4,7 @@ #ifndef CLKOFF_H #define CLKOFF_H +#include "common.h" #include "uthash.h" #include @@ -24,9 +25,9 @@ struct clkoff { struct clkoff_entry **index; }; -void clkoff_init(struct clkoff *table); -int clkoff_load(struct clkoff *table, FILE *file); -int clkoff_count(struct clkoff *table); -struct clkoff_entry *clkoff_get(struct clkoff *table, int i); + void clkoff_init(struct clkoff *table); +USE_RET int clkoff_load(struct clkoff *table, FILE *file); +USE_RET int clkoff_count(struct clkoff *table); +USE_RET struct clkoff_entry *clkoff_get(struct clkoff *table, int i); #endif /* CLKOFF_H */ diff --git a/src/emu/cpu.h b/src/emu/cpu.h index 517c2ba..7bf5aec 100644 --- a/src/emu/cpu.h +++ b/src/emu/cpu.h @@ -78,7 +78,7 @@ USE_RET int cpu_add_thread(struct cpu *cpu, struct thread *thread); USE_RET int cpu_remove_thread(struct cpu *cpu, struct thread *thread); USE_RET int cpu_migrate_thread(struct cpu *cpu, struct thread *thread, struct cpu *newcpu); -struct chan *cpu_get_th_chan(struct cpu *cpu, enum track_th mode); -struct pcf_value *cpu_add_to_pcf_type(struct cpu *cpu, struct pcf_type *type); +USE_RET struct chan *cpu_get_th_chan(struct cpu *cpu, enum track_th mode); +USE_RET struct pcf_value *cpu_add_to_pcf_type(struct cpu *cpu, struct pcf_type *type); #endif /* CPU_H */ diff --git a/src/emu/emu.h b/src/emu/emu.h index 7ca0193..2bf16d9 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -14,11 +14,6 @@ #include "recorder.h" #include "emu_stat.h" -enum error_values { - ST_BAD = 666, - ST_TOO_MANY_TH = 777, -}; - struct emu { struct bay bay; @@ -40,15 +35,9 @@ struct emu { struct loom *loom; }; -int emu_init(struct emu *emu, int argc, char *argv[]); -int emu_connect(struct emu *emu); -int emu_step(struct emu *emu); -int emu_finish(struct emu *emu); - -static inline struct emu * -emu_get(void *ptr) -{ - return (struct emu *) ptr; -} +USE_RET int emu_init(struct emu *emu, int argc, char *argv[]); +USE_RET int emu_connect(struct emu *emu); +USE_RET int emu_step(struct emu *emu); +USE_RET int emu_finish(struct emu *emu); #endif /* EMU_H */ diff --git a/src/emu/extend.h b/src/emu/extend.h index eb6333f..762c5fd 100644 --- a/src/emu/extend.h +++ b/src/emu/extend.h @@ -4,14 +4,16 @@ #ifndef EXTEND_H #define EXTEND_H +#include "common.h" + #define MAX_EXTEND 256 struct extend { void *ctx[MAX_EXTEND]; }; -void extend_set(struct extend *ext, int id, void *ctx); -void *extend_get(struct extend *ext, int id); + void extend_set(struct extend *ext, int id, void *ctx); +USE_RET void *extend_get(struct extend *ext, int id); #define EXT(st, m) extend_get(&(st)->ext, (m)) diff --git a/src/emu/loom.h b/src/emu/loom.h index 8baf461..cd53f35 100644 --- a/src/emu/loom.h +++ b/src/emu/loom.h @@ -13,6 +13,7 @@ struct loom; #include "cpu.h" #include "proc.h" #include "thread.h" +#include "common.h" struct loom { size_t gindex; @@ -47,22 +48,22 @@ struct loom { struct loom *next; struct loom *prev; - //struct model_ctx ctx; + struct extend ext; }; -int loom_matches(const char *relpath); -int loom_init_begin(struct loom *loom, const char *name); -int loom_init_end(struct loom *loom); -int loom_add_cpu(struct loom *loom, struct cpu *cpu); -int64_t loom_get_gindex(struct loom *loom); -void loom_set_gindex(struct loom *loom, int64_t gindex); -struct cpu *loom_find_cpu(struct loom *loom, int phyid); -struct cpu *loom_get_cpu(struct loom *loom, int index); -void loom_set_vcpu(struct loom *loom, struct cpu *vcpu); -struct cpu *loom_get_vcpu(struct loom *loom); -struct proc *loom_find_proc(struct loom *loom, pid_t pid); -struct thread *loom_find_thread(struct loom *loom, int tid); -int loom_add_proc(struct loom *loom, struct proc *proc); -void loom_sort(struct loom *loom); +USE_RET int loom_matches(const char *relpath); +USE_RET int loom_init_begin(struct loom *loom, const char *name); +USE_RET int loom_init_end(struct loom *loom); +USE_RET int loom_add_cpu(struct loom *loom, struct cpu *cpu); +USE_RET int64_t loom_get_gindex(struct loom *loom); + void loom_set_gindex(struct loom *loom, int64_t gindex); +USE_RET struct cpu *loom_find_cpu(struct loom *loom, int phyid); +USE_RET struct cpu *loom_get_cpu(struct loom *loom, int index); + void loom_set_vcpu(struct loom *loom, struct cpu *vcpu); +USE_RET struct cpu *loom_get_vcpu(struct loom *loom); +USE_RET struct proc *loom_find_proc(struct loom *loom, pid_t pid); +USE_RET struct thread *loom_find_thread(struct loom *loom, int tid); +USE_RET int loom_add_proc(struct loom *loom, struct proc *proc); + void loom_sort(struct loom *loom); #endif /* LOOM_H */ diff --git a/src/emu/metadata.h b/src/emu/metadata.h index d3e711f..244d9bf 100644 --- a/src/emu/metadata.h +++ b/src/emu/metadata.h @@ -6,7 +6,8 @@ #include "loom.h" #include "proc.h" +#include "common.h" -int metadata_load(const char *path, struct loom *loom, struct proc *proc); +USE_RET int metadata_load(const char *path, struct loom *loom, struct proc *proc); #endif /* METADATA_H */ diff --git a/src/emu/model.h b/src/emu/model.h index 5d59fc2..5533001 100644 --- a/src/emu/model.h +++ b/src/emu/model.h @@ -5,6 +5,7 @@ #define MODEL_H #include "emu_hook.h" +#include "common.h" struct model_spec { const char *name; @@ -25,13 +26,12 @@ struct model { int enabled[MAX_MODELS]; }; -void model_init(struct model *model); -int model_register(struct model *model, struct model_spec *spec); - -int model_probe(struct model *model, struct emu *emu); -int model_create(struct model *model, struct emu *emu); -int model_connect(struct model *model, struct emu *emu); -int model_event(struct model *model, struct emu *emu, int index); -int model_finish(struct model *model, struct emu *emu); + void model_init(struct model *model); +USE_RET int model_register(struct model *model, struct model_spec *spec); +USE_RET int model_probe(struct model *model, struct emu *emu); +USE_RET int model_create(struct model *model, struct emu *emu); +USE_RET int model_connect(struct model *model, struct emu *emu); +USE_RET int model_event(struct model *model, struct emu *emu, int index); +USE_RET int model_finish(struct model *model, struct emu *emu); #endif /* MODEL_H */ diff --git a/src/emu/model_cpu.h b/src/emu/model_cpu.h index 8b2ce51..7a4813b 100644 --- a/src/emu/model_cpu.h +++ b/src/emu/model_cpu.h @@ -11,6 +11,7 @@ struct model_cpu_spec; #include "track.h" #include "model.h" #include "model_chan.h" +#include "common.h" struct model_cpu_spec { size_t size; @@ -24,7 +25,7 @@ struct model_cpu { struct track *track; }; -int model_cpu_create(struct emu *emu, const struct model_cpu_spec *spec); -int model_cpu_connect(struct emu *emu, const struct model_cpu_spec *spec); +USE_RET int model_cpu_create(struct emu *emu, const struct model_cpu_spec *spec); +USE_RET int model_cpu_connect(struct emu *emu, const struct model_cpu_spec *spec); #endif /* MODEL_CPU_H */ diff --git a/src/emu/model_pvt.h b/src/emu/model_pvt.h index a944488..b3a01d0 100644 --- a/src/emu/model_pvt.h +++ b/src/emu/model_pvt.h @@ -6,6 +6,7 @@ #include "emu.h" #include "pv/pcf.h" +#include "common.h" struct model_pvt_spec { const int *type; @@ -18,7 +19,7 @@ struct model_pvt_spec { #include "model_cpu.h" #include "model_thread.h" -int model_pvt_connect_cpu(struct emu *emu, const struct model_cpu_spec *spec); -int model_pvt_connect_thread(struct emu *emu, const struct model_thread_spec *spec); +USE_RET int model_pvt_connect_cpu(struct emu *emu, const struct model_cpu_spec *spec); +USE_RET int model_pvt_connect_thread(struct emu *emu, const struct model_thread_spec *spec); #endif /* MODEL_PRV_H */ diff --git a/src/emu/model_thread.h b/src/emu/model_thread.h index cc7614d..cfe7f23 100644 --- a/src/emu/model_thread.h +++ b/src/emu/model_thread.h @@ -11,6 +11,7 @@ struct model_thread_spec; #include "track.h" #include "model.h" #include "model_chan.h" +#include "common.h" struct model_thread_spec { size_t size; @@ -25,7 +26,7 @@ struct model_thread { struct track *track; }; -int model_thread_create(struct emu *emu, const struct model_thread_spec *spec); -int model_thread_connect(struct emu *emu, const struct model_thread_spec *spec); +USE_RET int model_thread_create(struct emu *emu, const struct model_thread_spec *spec); +USE_RET int model_thread_connect(struct emu *emu, const struct model_thread_spec *spec); #endif /* MODEL_THREAD_H */ diff --git a/src/emu/models.h b/src/emu/models.h index d999243..9cd4ca5 100644 --- a/src/emu/models.h +++ b/src/emu/models.h @@ -6,7 +6,6 @@ #include "model.h" -int -models_register(struct model *model); +USE_RET int models_register(struct model *model); #endif /* MODELS_H */ diff --git a/src/emu/path.h b/src/emu/path.h index 486542e..1d845a7 100644 --- a/src/emu/path.h +++ b/src/emu/path.h @@ -4,12 +4,14 @@ #ifndef PATH_H #define PATH_H -int path_has_prefix(const char *path, const char *prefix); -int path_count(const char *path, char c); -int path_next(const char *path, char sep, const char (**next)); -int path_keep(char *path, int n); -int path_strip(const char *path, int n, const char (**next)); -void path_remove_trailing(char *path); -const char *path_filename(const char *path); +#include "common.h" + +USE_RET int path_has_prefix(const char *path, const char *prefix); +USE_RET int path_count(const char *path, char c); +USE_RET int path_next(const char *path, char sep, const char (**next)); +USE_RET int path_keep(char *path, int n); +USE_RET int path_strip(const char *path, int n, const char (**next)); + void path_remove_trailing(char *path); +USE_RET const char *path_filename(const char *path); #endif /* PATH_H */ diff --git a/src/emu/player.h b/src/emu/player.h index db29e2d..837343d 100644 --- a/src/emu/player.h +++ b/src/emu/player.h @@ -22,11 +22,11 @@ struct player { struct emu_ev ev; }; -int player_init(struct player *player, struct trace *trace, int unsorted); -int player_step(struct player *player); -struct emu_ev *player_ev(struct player *player); -struct stream *player_stream(struct player *player); -double player_progress(struct player *player); -int64_t player_nprocessed(struct player *player); +USE_RET int player_init(struct player *player, struct trace *trace, int unsorted); +USE_RET int player_step(struct player *player); +USE_RET struct emu_ev *player_ev(struct player *player); +USE_RET struct stream *player_stream(struct player *player); +USE_RET double player_progress(struct player *player); +USE_RET int64_t player_nprocessed(struct player *player); #endif /* EMU_PLAYER_H */ diff --git a/src/emu/proc.h b/src/emu/proc.h index 5504c11..af43b0e 100644 --- a/src/emu/proc.h +++ b/src/emu/proc.h @@ -44,16 +44,16 @@ struct proc { struct extend ext; }; -int proc_relpath_get_pid(const char *relpath, int *pid); -int proc_init_begin(struct proc *proc, const char *id); -int proc_init_end(struct proc *proc); -int proc_get_pid(struct proc *proc); -void proc_set_gindex(struct proc *proc, int64_t gindex); -void proc_set_loom(struct proc *proc, struct loom *loom); -void proc_sort(struct proc *proc); -int proc_load_metadata(struct proc *proc, JSON_Object *meta); -struct thread *proc_find_thread(struct proc *proc, int tid); -int proc_add_thread(struct proc *proc, struct thread *thread); -void proc_sort(struct proc *proc); +USE_RET int proc_relpath_get_pid(const char *relpath, int *pid); +USE_RET int proc_init_begin(struct proc *proc, const char *id); +USE_RET int proc_init_end(struct proc *proc); +USE_RET int proc_get_pid(struct proc *proc); + void proc_set_gindex(struct proc *proc, int64_t gindex); + void proc_set_loom(struct proc *proc, struct loom *loom); + void proc_sort(struct proc *proc); +USE_RET int proc_load_metadata(struct proc *proc, JSON_Object *meta); +USE_RET struct thread *proc_find_thread(struct proc *proc, int tid); +USE_RET int proc_add_thread(struct proc *proc, struct thread *thread); + void proc_sort(struct proc *proc); #endif /* PROC_H */ diff --git a/src/emu/recorder.h b/src/emu/recorder.h index 9a12052..f3178b6 100644 --- a/src/emu/recorder.h +++ b/src/emu/recorder.h @@ -15,10 +15,10 @@ struct recorder { struct pvt *pvt; /* Hash table by name */ }; -int recorder_init(struct recorder *rec, const char *dir); -struct pvt *recorder_find_pvt(struct recorder *rec, const char *name); -struct pvt *recorder_add_pvt(struct recorder *rec, const char *name, long nrows); -int recorder_advance(struct recorder *rec, int64_t time); -int recorder_finish(struct recorder *rec); +USE_RET int recorder_init(struct recorder *rec, const char *dir); +USE_RET struct pvt *recorder_find_pvt(struct recorder *rec, const char *name); +USE_RET struct pvt *recorder_add_pvt(struct recorder *rec, const char *name, long nrows); +USE_RET int recorder_advance(struct recorder *rec, int64_t time); +USE_RET int recorder_finish(struct recorder *rec); #endif /* RECORDER_H */ diff --git a/src/emu/stream.h b/src/emu/stream.h index ea66a08..65d365e 100644 --- a/src/emu/stream.h +++ b/src/emu/stream.h @@ -1,8 +1,8 @@ /* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ -#ifndef EMU_STREAM_H -#define EMU_STREAM_H +#ifndef STREAM_H +#define STREAM_H #include "ovni.h" #include "heap.h" @@ -36,19 +36,15 @@ struct stream { double progress; }; -int stream_load(struct stream *stream, - const char *tracedir, const char *relpath); +USE_RET int stream_load(struct stream *stream, const char *tracedir, const char *relpath); +USE_RET int stream_clkoff_set(struct stream *stream, int64_t clock_offset); + void stream_progress(struct stream *stream, int64_t *done, int64_t *total); +USE_RET int stream_step(struct stream *stream); +USE_RET struct ovni_ev *stream_ev(struct stream *stream); +USE_RET int64_t stream_evclock(struct stream *stream, struct ovni_ev *ev); +USE_RET int64_t stream_lastclock(struct stream *stream); + void stream_allow_unsorted(struct stream *stream); + void stream_data_set(struct stream *stream, void *data); + void *stream_data_get(struct stream *stream); -int stream_clkoff_set(struct stream *stream, int64_t clock_offset); - -void stream_progress(struct stream *stream, int64_t *done, int64_t *total); -int stream_step(struct stream *stream); -struct ovni_ev *stream_ev(struct stream *stream); -int64_t stream_evclock(struct stream *stream, struct ovni_ev *ev); -int64_t stream_lastclock(struct stream *stream); -void stream_allow_unsorted(struct stream *stream); - -void stream_data_set(struct stream *stream, void *data); -void *stream_data_get(struct stream *stream); - -#endif /* EMU_STREAM_H */ +#endif /* STREAM_H */ diff --git a/src/emu/system.h b/src/emu/system.h index 4365533..0da1571 100644 --- a/src/emu/system.h +++ b/src/emu/system.h @@ -41,8 +41,8 @@ struct system { struct lpt *lpt; }; -int system_init(struct system *sys, struct emu_args *args, struct trace *trace); -int system_connect(struct system *sys, struct bay *bay, struct recorder *rec); -struct lpt *system_get_lpt(struct stream *stream); +USE_RET int system_init(struct system *sys, struct emu_args *args, struct trace *trace); +USE_RET int system_connect(struct system *sys, struct bay *bay, struct recorder *rec); +USE_RET struct lpt *system_get_lpt(struct stream *stream); #endif /* EMU_SYSTEM_H */ diff --git a/src/emu/task.h b/src/emu/task.h index 6c81922..426b537 100644 --- a/src/emu/task.h +++ b/src/emu/task.h @@ -53,19 +53,16 @@ struct task_stack { struct thread *thread; }; -struct task *task_find(struct task *tasks, uint32_t task_id); - -int task_create(struct task_info *info, uint32_t type_id, uint32_t task_id); -int task_execute(struct task_stack *stack, struct task *task); -int task_pause(struct task_stack *stack, struct task *task); -int task_resume(struct task_stack *stack, struct task *task); -int task_end(struct task_stack *stack, struct task *task); - -struct task_type *task_type_find(struct task_type *types, uint32_t type_id); -int task_type_create(struct task_info *info, uint32_t type_id, const char *label); -uint32_t task_get_type_gid(const char *label); - -int task_create_pcf_types(struct pcf_type *pcftype, struct task_type *types); -struct task *task_get_running(struct task_stack *stack); +USE_RET struct task *task_find(struct task *tasks, uint32_t task_id); +USE_RET int task_create(struct task_info *info, uint32_t type_id, uint32_t task_id); +USE_RET int task_execute(struct task_stack *stack, struct task *task); +USE_RET int task_pause(struct task_stack *stack, struct task *task); +USE_RET int task_resume(struct task_stack *stack, struct task *task); +USE_RET int task_end(struct task_stack *stack, struct task *task); +USE_RET struct task_type *task_type_find(struct task_type *types, uint32_t type_id); +USE_RET int task_type_create(struct task_info *info, uint32_t type_id, const char *label); +USE_RET uint32_t task_get_type_gid(const char *label); +USE_RET int task_create_pcf_types(struct pcf_type *pcftype, struct task_type *types); +USE_RET struct task *task_get_running(struct task_stack *stack); #endif /* TASK_H */ diff --git a/src/emu/thread.h b/src/emu/thread.h index ee1fad2..b69d110 100644 --- a/src/emu/thread.h +++ b/src/emu/thread.h @@ -72,23 +72,21 @@ struct thread { UT_hash_handle hh; /* threads in the process */ }; -int thread_relpath_get_tid(const char *relpath, int *tid); -int thread_init_begin(struct thread *thread, const char *relpath); -int thread_init_end(struct thread *thread); -int thread_set_state(struct thread *th, enum thread_state state); -int thread_set_cpu(struct thread *th, struct cpu *cpu); -int thread_unset_cpu(struct thread *th); -int thread_migrate_cpu(struct thread *th, struct cpu *cpu); -int thread_get_tid(struct thread *thread); -void thread_set_gindex(struct thread *th, int64_t gindex); -void thread_set_proc(struct thread *th, struct proc *proc); -int thread_connect(struct thread *th, struct bay *bay, struct recorder *rec); - -int thread_select_active(struct mux *mux, struct value value, struct mux_input **input); -int thread_select_running(struct mux *mux, struct value value, struct mux_input **input); -int thread_select_any(struct mux *mux, struct value value, struct mux_input **input); - -int thread_create_pcf_types(struct pcf *pcf); -struct pcf_type *thread_get_affinity_pcf_type(struct pcf *pcf); +USE_RET int thread_relpath_get_tid(const char *relpath, int *tid); +USE_RET int thread_init_begin(struct thread *thread, const char *relpath); +USE_RET int thread_init_end(struct thread *thread); +USE_RET int thread_set_state(struct thread *th, enum thread_state state); +USE_RET int thread_set_cpu(struct thread *th, struct cpu *cpu); +USE_RET int thread_unset_cpu(struct thread *th); +USE_RET int thread_migrate_cpu(struct thread *th, struct cpu *cpu); +USE_RET int thread_get_tid(struct thread *thread); + void thread_set_gindex(struct thread *th, int64_t gindex); + void thread_set_proc(struct thread *th, struct proc *proc); +USE_RET int thread_connect(struct thread *th, struct bay *bay, struct recorder *rec); +USE_RET int thread_select_active(struct mux *mux, struct value value, struct mux_input **input); +USE_RET int thread_select_running(struct mux *mux, struct value value, struct mux_input **input); +USE_RET int thread_select_any(struct mux *mux, struct value value, struct mux_input **input); +USE_RET int thread_create_pcf_types(struct pcf *pcf); +USE_RET struct pcf_type *thread_get_affinity_pcf_type(struct pcf *pcf); #endif /* THREAD_H */ diff --git a/src/emu/trace.h b/src/emu/trace.h index a314739..8a5352a 100644 --- a/src/emu/trace.h +++ b/src/emu/trace.h @@ -15,6 +15,6 @@ struct trace { struct stream *streams; }; -int trace_load(struct trace *trace, const char *tracedir); +USE_RET int trace_load(struct trace *trace, const char *tracedir); #endif /* EMU_TRACE_H */ diff --git a/src/emu/track.h b/src/emu/track.h index 1ecdce9..0dc514a 100644 --- a/src/emu/track.h +++ b/src/emu/track.h @@ -28,12 +28,10 @@ struct track { struct mux mux; }; -int track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...); -int track_set_select(struct track *track, struct chan *sel, mux_select_func_t fsel, int64_t ninputs); -int track_set_input(struct track *track, int64_t index, struct chan *inp); - -struct chan *track_get_output(struct track *track); - -int track_connect_thread(struct track *tracks, struct chan *chans, struct chan *sel, int n); +USE_RET int track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...); +USE_RET int track_set_select(struct track *track, struct chan *sel, mux_select_func_t fsel, int64_t ninputs); +USE_RET int track_set_input(struct track *track, int64_t index, struct chan *inp); +USE_RET struct chan *track_get_output(struct track *track); +USE_RET int track_connect_thread(struct track *tracks, struct chan *chans, struct chan *sel, int n); #endif /* TRACK_H */