FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
mapped_vars.h
Go to the documentation of this file.
1 #ifndef _MAPPED_VARS_H_
2 #define _MAPPED_VARS_H_ "$Id: mapped_vars.h 465 2020-07-24 22:59:56Z fargos $"
4 
6 /* Copyright (C) 2011 - 2019 FARGOS Development, LLC */
7 
8 #include <utils/io/mapped_file.h>
9 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
29  unsigned char *address;
30  unsigned char *outputAddress;
31  const char *varName;
32  const char *formatPattern;
33  uint32_t len; /* NOT CURRENTLY USED */
34  union {
35  uint64_t u64;
36  int64_t i64;
37  int32_t i32;
38  uint32_t u32;
39  float f;
40  double d;
41  unsigned char *cp;
42  } val;
43 };
44 
79 int createMappedVars(const uint_fast32_t numVars, struct MappedVarRecord vars[],
80  unsigned char **segment, size_t *segmentLenPtr, const uint_fast32_t doInit,
81  const char *fileName);
82 
90 #define INIT_MAPPED_VAR(name, fmt, len) { 0, 0, name, fmt, len, 0}
91 
98 #define INIT_MAPPED_INT_VAR(name) INIT_MAPPED_VAR(name, "=%d", sizeof(int))
99 
100 /* Would be a reinterpret_cast<> in C++, but these are intended to be usable
101  * by C source
102  */
108 #define MAPPED_TYPE_VAR(t, tbl, id) ((t *)(tbl[id].address))
109 
114 #define MAPPED_INT_VAR(tbl, id) MAPPED_TYPE_VAR(int32_t, tbl,id)
115 
121 #define UPDATE_MAPPED_TYPE_VAR(t, tbl, id) { int _l = sprintf((char *) tbl[id].outputAddress, tbl[id].formatPattern, *MAPPED_TYPE_VAR(t, tbl, id)); tbl[id].outputAddress[_l] = ' '; }
122 
129 #define RELOAD_MAPPED_TYPE_VAR(t, tbl, id) { int _l = sscanf((char *) tbl[id].outputAddress, tbl[id].formatPattern, MAPPED_TYPE_VAR(t, tbl, id)); }
130 
131 #define UPDATE_MAPPED_INT_VAR(tbl, id) { uint32_t workBfr[6]; uint32_t _l; uint64_t _v = *MAPPED_INT_VAR(tbl, id); char *_r = int_to_ascii(workBfr, sizeof(workBfr), _v, &_l); int _i = 0; while (tbl[id].formatPattern[_i] != '%') { tbl[id].outputAddress[_i] = tbl[id].formatPattern[_i]; _i+=1; } memcpy(tbl[id].outputAddress+_i, _r, _l); }
132 
133 
134 #ifdef __cplusplus
135 }; /* close extern "C" scope */
136 
137 #if 0
138 // C++-specific additions
139 template <typename T> struct MappedVarRecordOfType {
140 };
141 #endif
142 
143 #endif
144 
148 #endif
149 /* vim: set expandtab shiftwidth=4 tabstop=4: */
mapped_vars.h
MappedVarRecord::u64
uint64_t u64
Definition: mapped_vars.h:35
stderr
#define stderr
Definition: tmp.o.cpp:3115
MAP_FILE_INIT
#define MAP_FILE_INIT
Definition: mapped_file.h:69
MappedVarRecord::address
unsigned char * address
Definition: mapped_vars.h:29
srcID
const char srcID[]
Definition: catSym.c:17
MappedVarRecord::i64
int64_t i64
Definition: mapped_vars.h:36
mapped_file.h
MappedVarRecord::formatPattern
const char * formatPattern
Definition: mapped_vars.h:32
MappedVarRecord::val
union MappedVarRecord::@20 val
createMappedFile
int createMappedFile(unsigned char **segment, const char *fileName, size_t *segmentLenPtr, uint_fast32_t doInit)
Create or open a mapped file with the specified file name.
Definition: mapped_file.cpp:207
MappedVarRecord::i32
int32_t i32
Definition: mapped_vars.h:37
MappedVarRecord::varName
const char * varName
Definition: mapped_vars.h:31
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
MappedVarRecord::len
uint32_t len
Definition: mapped_vars.h:33
compiler_hints.h
Compiler-specific macros to provide performance-related hints.
MappedVarRecord::d
double d
Definition: mapped_vars.h:40
MappedVarRecord::u32
uint32_t u32
Definition: mapped_vars.h:38
MappedVarRecord::f
float f
Definition: mapped_vars.h:39
createMappedVars
int createMappedVars(const uint_fast32_t numVars, struct MappedVarRecord vars[], unsigned char **segment, size_t *segmentLenPtr, const uint_fast32_t doInit, const char *fileName)
Create/reload an array of MappedVarRecords that is mapped by a memory mapped file.
Definition: mapped_vars.cpp:30
MappedVarRecord::cp
unsigned char * cp
Definition: mapped_vars.h:41
MappedVarRecord
Data structure to reference a variable record within a memory-mapped segment.
Definition: mapped_vars.h:28
MappedVarRecord::outputAddress
unsigned char * outputAddress
Definition: mapped_vars.h:30
Generated: Fri Jul 31 2020 18:19:14
Support Information