litl 0.1.9
Loading...
Searching...
No Matches
litl_tools.c
Go to the documentation of this file.
1/* -*- c-file-style: "GNU" -*- */
2/*
3 * Copyright © Télécom SudParis.
4 * See COPYING in top-level directory.
5 */
6
7#include <stdlib.h>
8#include <inttypes.h>
9#include <math.h>
10
11#include "litl_tools.h"
12#include "litl_write.h"
13
14/*
15 * Returns the size in bytes of a REGULAR event depending on
16 * the number of arguments
17 */
19 return LITL_BASE_SIZE + (nb_params * sizeof(litl_param_t)) + sizeof(litl_data_t);
20}
21
23 switch (type) {
25 return LITL_BASE_SIZE + (param_size * sizeof(litl_param_t)) + sizeof(litl_data_t);
26 case LITL_TYPE_RAW:
27 return LITL_BASE_SIZE + param_size + sizeof(((litl_t*)0)->parameters.raw.size);
29 return LITL_BASE_SIZE + param_size + sizeof(((litl_t*)0)->parameters.packed.size);
31 return LITL_BASE_SIZE + param_size + sizeof(((litl_t*)0)->parameters.offset.nb_params);
32 default:
33 fprintf(stderr, "Unknown event type %d!\n", type);
34 abort();
35 }
36 return 0;
37}
38
39/*
40 * Returns the size in bytes of an event of any type
41 */
43 switch (p_evt->type) {
46 case LITL_TYPE_RAW:
47 return __litl_get_event_size(p_evt->type, p_evt->parameters.raw.size);
49 return __litl_get_event_size(p_evt->type, p_evt->parameters.packed.size);
51 return __litl_get_event_size(p_evt->type, p_evt->parameters.offset.nb_params);
52 default:
53 fprintf(stderr, "Unknown event type %d!\n", p_evt->type);
54 abort();
55 }
56
57 return 0;
58}
litl_size_t __litl_get_event_size(litl_type_t type, int param_size)
Returns the size of an event (in Bytes) depending on the number or size of its parameters.
Definition litl_tools.c:22
litl_size_t __litl_get_reg_event_size(litl_data_t nb_params)
Returns the size of a regular event (in Bytes) depending on the number of its parameters.
Definition litl_tools.c:18
litl_size_t __litl_get_gen_event_size(litl_t *p_evt)
Returns the size of a general event (in Bytes) depending on its type and the number of its parameters...
Definition litl_tools.c:42
uint64_t litl_param_t
A data type for the non-optimized storage of parameters.
Definition litl_types.h:124
litl_type_t
The enumeration of event types.
Definition litl_types.h:180
uint8_t litl_data_t
A data type for the optimized storage of parameters.
Definition litl_types.h:157
uint32_t litl_size_t
An auxiliary data type for storing data.
Definition litl_types.h:147
@ LITL_TYPE_RAW
Definition litl_types.h:182
@ LITL_TYPE_PACKED
Definition litl_types.h:183
@ LITL_TYPE_REGULAR
Definition litl_types.h:181
@ LITL_TYPE_OFFSET
Definition litl_types.h:184
litl_tools Provides a set of auxiliary functions
#define LITL_BASE_SIZE
Definition litl_types.h:460
litl_write Provides a set of functions for recording events in a trace file
A general structure of LiTL event type.
Definition litl_types.h:192
union litl_t::@0 parameters
litl_data_t nb_params
Definition litl_types.h:206
litl_size_t size
Definition litl_types.h:214
litl_param_t offset
Definition litl_types.h:231
struct litl_t::@0::@1 regular
struct litl_t::@0::@2 raw
struct litl_t::@0::@3 packed
litl_type_t type
Definition litl_types.h:195
Event parameters.