-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathushm_buffer.h
More file actions
54 lines (41 loc) · 1.97 KB
/
Copy pathushm_buffer.h
File metadata and controls
54 lines (41 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* =============================================================================
* File : ushm_buffer.h
* Author : Leandro Martins dos Santos
* Description : Functions and constants declarations for handling buffers
* in the user shared memory.
* =============================================================================
*/
#ifndef USHM_BUFFER_H
#define USHM_BUFFER_H
// Buffer definitions
////////////////////////////////////////////////////////////////////////////////////////
// Constants
#define INT_SHIFT 2 // sizeof(int) == 2^2
#define DOUBLE_SHIFT 3 // sizeof(double) == 2^3
////////////////////////////////////////////////////////////////////////////////////////
// User defined
#define USHM_BASE_ADDR 4000 // Base Address
#define USHM_BUFF_SIZE 1000
#define MAX_FRAME_NUMEL 20
////////////////////////////////////////////////////////////////////////////////////////
#include <stdbool.h>
////////////////////////////////////////////////////////////////////////////////////////
typedef union {
double d;
int i;
} Point;
int init_buffer(char *types, Point *ptr_arr[], size_t *frame_bytesize, void *base_memory);
size_t get_frame_len(char *types);
void set_aligned_pointer(Point *ptr_arr[], int idx, void **next_free_memory, size_t size);
bool is_aligned(void* addr, size_t alignment);
void* align_addr(void *addr, size_t alignment);
int update_buffer(char *types, Point *ptr_arr[], size_t size);
void update_addr(Point *ptr_arr[], int idx, size_t size);
void write_double(Point *ptr_arr[], int idx , size_t size, double value);
void write_int(Point *ptr_arr[], int idx, size_t size, int value);
void write_frame(char *types, Point *ptr_arr[], size_t size, Point values[]);
void test_write_buffer(char *frame_types, Point *ptr_arr[], size_t size);
void test_print_buffer(char *frame_types, Point *ptr_arr[], size_t size);
////////////////////////////////////////////////////////////////////////////////////////
#endif // USHM_BUFFER_H