You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1010 B
46 lines
1010 B
#ifndef _EVENTLOG_H_ |
|
#define _EVENTLOG_H_ |
|
|
|
#include <stdatomic.h> |
|
#include <stdint.h> |
|
#include <stddef.h> |
|
|
|
#define EVENTLOG_DATA_MAX_SIZE (128 - 16) |
|
|
|
#define EVENTLOG_TYPE_STRING 0 |
|
|
|
|
|
struct eventlog_entry |
|
{ |
|
atomic_uint_fast64_t timestamp; |
|
uint32_t type_id; |
|
uint32_t datalen; |
|
uint8_t data[EVENTLOG_DATA_MAX_SIZE]; |
|
}; |
|
|
|
struct eventlog_shm_header |
|
{ |
|
uint32_t magic; |
|
uint32_t version; |
|
atomic_uint_fast64_t tail; |
|
uint64_t size; |
|
struct eventlog_entry* entries; |
|
}; |
|
|
|
enum eventlog_mode |
|
{ |
|
EVENTLOG_MODE_CREATE = 0, |
|
EVENTLOG_MODE_ATTACH = 1, |
|
}; |
|
|
|
int eventlog_init(const char* path, enum eventlog_mode mode); |
|
int eventlog_shutdown(); |
|
|
|
int eventlog_emit_event(uint64_t timestamp, const char* fmt, ...); |
|
int eventlog_emit_event_struct(uint64_t timestamp, uint32_t type, void* data, size_t data_size); |
|
uint64_t eventlog_get_timestamp(); |
|
|
|
int eventlog_get_snapshot(uint64_t* head, struct eventlog_entry* buffer, size_t buffer_size, size_t* actual_size); |
|
|
|
#endif /* _EVENTLOG_H_ */ |
|
|
|
|