Use const qualifier in public ovni.h functions

This commit is contained in:
Rodrigo Arias 2021-11-19 17:09:39 +01:00
parent a663f2c11b
commit 5eadcb404e
2 changed files with 17 additions and 17 deletions

20
ovni.c
View File

@ -61,7 +61,7 @@ struct ovni_rproc rproc = {0};
_Thread_local struct ovni_rthread rthread = {0}; _Thread_local struct ovni_rthread rthread = {0};
static int static int
create_trace_dirs(char *tracedir, char *loom, int proc) create_trace_dirs(char *tracedir, const char *loom, int proc)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
@ -213,7 +213,7 @@ proc_set_app(int appid)
} }
int int
ovni_proc_init(int app, char *loom, int proc) ovni_proc_init(int app, const char *loom, int proc)
{ {
assert(rproc.ready == 0); assert(rproc.ready == 0);
@ -407,13 +407,13 @@ ovni_ev_set_clock(struct ovni_ev *ev)
} }
uint64_t uint64_t
ovni_ev_get_clock(struct ovni_ev *ev) ovni_ev_get_clock(const struct ovni_ev *ev)
{ {
return ev->header.clock; return ev->header.clock;
} }
void void
ovni_ev_set_mcv(struct ovni_ev *ev, char *mcv) ovni_ev_set_mcv(struct ovni_ev *ev, const char *mcv)
{ {
ev->header.model = mcv[0]; ev->header.model = mcv[0];
ev->header.category = mcv[1]; ev->header.category = mcv[1];
@ -421,13 +421,13 @@ ovni_ev_set_mcv(struct ovni_ev *ev, char *mcv)
} }
static size_t static size_t
get_jumbo_payload_size(struct ovni_ev *ev) get_jumbo_payload_size(const struct ovni_ev *ev)
{ {
return sizeof(ev->payload.jumbo.size) + ev->payload.jumbo.size; return sizeof(ev->payload.jumbo.size) + ev->payload.jumbo.size;
} }
int int
ovni_payload_size(struct ovni_ev *ev) ovni_payload_size(const struct ovni_ev *ev)
{ {
int size; int size;
@ -447,7 +447,7 @@ ovni_payload_size(struct ovni_ev *ev)
} }
void void
ovni_payload_add(struct ovni_ev *ev, uint8_t *buf, int size) ovni_payload_add(struct ovni_ev *ev, const uint8_t *buf, int size)
{ {
size_t payload_size; size_t payload_size;
@ -466,7 +466,7 @@ ovni_payload_add(struct ovni_ev *ev, uint8_t *buf, int size)
} }
int int
ovni_ev_size(struct ovni_ev *ev) ovni_ev_size(const struct ovni_ev *ev)
{ {
return sizeof(ev->header) + ovni_payload_size(ev); return sizeof(ev->header) + ovni_payload_size(ev);
} }
@ -517,7 +517,7 @@ add_flush_events(uint64_t t0, uint64_t t1)
} }
static void static void
ovni_ev_add_jumbo(struct ovni_ev *ev, uint8_t *buf, uint32_t bufsize) ovni_ev_add_jumbo(struct ovni_ev *ev, const uint8_t *buf, uint32_t bufsize)
{ {
size_t evsize, totalsize; size_t evsize, totalsize;
int flushed = 0; int flushed = 0;
@ -593,7 +593,7 @@ ovni_ev_add(struct ovni_ev *ev)
} }
void void
ovni_ev_jumbo_emit(struct ovni_ev *ev, uint8_t *buf, uint32_t bufsize) ovni_ev_jumbo_emit(struct ovni_ev *ev, const uint8_t *buf, uint32_t bufsize)
{ {
ovni_ev_set_clock(ev); ovni_ev_set_clock(ev);
ovni_ev_add_jumbo(ev, buf, bufsize); ovni_ev_add_jumbo(ev, buf, bufsize);

14
ovni.h
View File

@ -133,7 +133,7 @@ struct ovni_rproc {
JSON_Value *meta; JSON_Value *meta;
}; };
int ovni_proc_init(int app, char *loom, int proc); int ovni_proc_init(int app, const char *loom, int proc);
int ovni_proc_fini(void); int ovni_proc_fini(void);
@ -145,23 +145,23 @@ int ovni_thread_isready(void);
void ovni_clock_update(void); void ovni_clock_update(void);
void ovni_ev_set_mcv(struct ovni_ev *ev, char *mcv); void ovni_ev_set_mcv(struct ovni_ev *ev, const char *mcv);
uint64_t ovni_ev_get_clock(struct ovni_ev *ev); uint64_t ovni_ev_get_clock(const struct ovni_ev *ev);
uint64_t ovni_get_clock(void); uint64_t ovni_get_clock(void);
void ovni_payload_add(struct ovni_ev *ev, uint8_t *buf, int size); void ovni_payload_add(struct ovni_ev *ev, const uint8_t *buf, int size);
int ovni_ev_size(struct ovni_ev *ev); int ovni_ev_size(const struct ovni_ev *ev);
int ovni_payload_size(struct ovni_ev *ev); int ovni_payload_size(const struct ovni_ev *ev);
void ovni_add_cpu(int index, int phyid); void ovni_add_cpu(int index, int phyid);
/* Set the current clock in the event and queue it */ /* Set the current clock in the event and queue it */
void ovni_ev_emit(struct ovni_ev *ev); void ovni_ev_emit(struct ovni_ev *ev);
void ovni_ev_jumbo_emit(struct ovni_ev *ev, uint8_t *buf, uint32_t bufsize); void ovni_ev_jumbo_emit(struct ovni_ev *ev, const uint8_t *buf, uint32_t bufsize);
int ovni_flush(void); int ovni_flush(void);