Remove prefix snapshot from snapshot.

See previous commit on shared pointer.
This commit is contained in:
Patrick Pelissier committed 2017-07-25 22:44:17 +02:00
1 parent 62e2024658
commit 8a716cd4f4
3 files changed
+30 -29

No files matched your search

+2 -2
View File
@@ -1698,7 +1698,7 @@ This header is for created snapshots.
#### SNAPSHOT\_DEF(name, type[, oplist]) #### SNAPSHOT\_DEF(name, type[, oplist])
Define the snapshot 'snapshot\_##name##\_t' and its associated methods as "static inline" functions. Define the snapshot 'name##\_t' and its associated methods as "static inline" functions.
A snapshot is a mechanism to allows a consumer thread and a produce thread, **working at different speeds**, to exchange messages in a reliable and thread safe way (the message is passed atomatically). A snapshot is a mechanism to allows a consumer thread and a produce thread, **working at different speeds**, to exchange messages in a reliable and thread safe way (the message is passed atomatically).
In practice, it is implemented using a triple buffer. In practice, it is implemented using a triple buffer.
@@ -1710,7 +1710,7 @@ The object oplist is expected to have the following operators (INIT, INIT\_SET,
Example: Example:
SNAPSHOT_DEF(uint, unsigned int) SNAPSHOT_DEF(snapshot_uint, unsigned int)
void f(unsigned int * i) { void f(unsigned int * i) {
snapshot_uint_t t; snapshot_uint_t t;
snapshot_uint_init(t); snapshot_uint_init(t);
+26 -25
View File
@@ -49,15 +49,15 @@
/* Define the oplist of a snapshot */ /* Define the oplist of a snapshot */
#define SNAPSHOTI_OPLIST(name, oplist) \ #define SNAPSHOTI_OPLIST(name, oplist) \
(INIT(M_C3(snapshot_, name, _init)), \ (INIT(M_C(name, _init)), \
INIT_SET(M_C3(snapshot_, name, _init_set)), \ INIT_SET(M_C(name, _init_set)), \
SET(M_C3(snapshot_, name, _set)), \ SET(M_C(name, _set)), \
CLEAR(M_C3(snapshot_, name, _clear)), \ CLEAR(M_C(name, _clear)), \
TYPE(M_C3(snapshot_, name, _t)), \ TYPE(M_C(name, _t)), \
SUBTYPE(M_C3(snapshot_name_, name, _t)) \ SUBTYPE(M_C(name_, type_t)) \
,OPLIST(oplist) \ ,OPLIST(oplist) \
,M_IF_METHOD(INIT_MOVE, oplist)(INIT_MOVE(M_C3(snapshot_, name, _init_move)),) \ ,M_IF_METHOD(INIT_MOVE, oplist)(INIT_MOVE(M_C(name, _init_move)),) \
,M_IF_METHOD(MOVE, oplist)(MOVE(M_C3(snapshot_, name, _move)),) \ ,M_IF_METHOD(MOVE, oplist)(MOVE(M_C(name, _move)),) \
) )
/* Flag defining the atomic state of a snapshot: /* Flag defining the atomic state of a snapshot:
@@ -90,13 +90,14 @@
} while (0) } while (0)
#define SNAPSHOTI_DEF2(name, type, oplist) \ #define SNAPSHOTI_DEF2(name, type, oplist) \
typedef struct M_C3(snapshot_, name, _s) { \ \
typedef struct M_C(name, _s) { \
type data[3]; \ type data[3]; \
atomic_uchar flags; \ atomic_uchar flags; \
} M_C3(snapshot_, name, _t)[1]; \ } M_C(name, _t)[1]; \
typedef type M_C3(snapshot_type_, name, _t); \ typedef type M_C(name, _type_t); \
\ \
static inline void M_C3(snapshot_, name, _init)(M_C3(snapshot_, name, _t) snap) \ static inline void M_C(name, _init)(M_C(name, _t) snap) \
{ \ { \
assert(snap != NULL); \ assert(snap != NULL); \
for(int i = 0; i < 3; i++) { \ for(int i = 0; i < 3; i++) { \
@@ -106,7 +107,7 @@
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
} \ } \
\ \
static inline void M_C3(snapshot_, name, _clear)(M_C3(snapshot_, name, _t) snap) \ static inline void M_C(name, _clear)(M_C(name, _t) snap) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
for(int i = 0; i < 3; i++) { \ for(int i = 0; i < 3; i++) { \
@@ -114,8 +115,8 @@
} \ } \
} \ } \
\ \
static inline void M_C3(snapshot_, name, _init_set)(M_C3(snapshot_, name, _t) snap, \ static inline void M_C(name, _init_set)(M_C(name, _t) snap, \
M_C3(snapshot_, name, _t) org) \ M_C(name, _t) org) \
{ \ { \
SNAPSHOTI_CONTRACT(org); \ SNAPSHOTI_CONTRACT(org); \
assert(snap != NULL && snap != org); \ assert(snap != NULL && snap != org); \
@@ -126,8 +127,8 @@
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
} \ } \
\ \
static inline void M_C3(snapshot_, name, _set)(M_C3(snapshot_, name, _t) snap, \ static inline void M_C(name, _set)(M_C(name, _t) snap, \
M_C3(snapshot_, name, _t) org) \ M_C(name, _t) org) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
SNAPSHOTI_CONTRACT(org); \ SNAPSHOTI_CONTRACT(org); \
@@ -139,8 +140,8 @@
} \ } \
\ \
M_IF_METHOD(INIT_MOVE, oplist)( \ M_IF_METHOD(INIT_MOVE, oplist)( \
static inline void M_C3(snapshot_, name, _init_move)(M_C3(snapshot_, name, _t) snap, \ static inline void M_C(name, _init_move)(M_C(name, _t) snap, \
M_C3(snapshot_, name, _t) org) \ M_C(name, _t) org) \
{ \ { \
SNAPSHOTI_CONTRACT(org); \ SNAPSHOTI_CONTRACT(org); \
assert(snap != NULL && snap != org); \ assert(snap != NULL && snap != org); \
@@ -154,8 +155,8 @@
,) /* IF_METHOD (INIT_MOVE) */ \ ,) /* IF_METHOD (INIT_MOVE) */ \
\ \
M_IF_METHOD(MOVE, oplist)( \ M_IF_METHOD(MOVE, oplist)( \
static inline void M_C3(snapshot_, name, _move)(M_C3(snapshot_, name, _t) snap, \ static inline void M_C(name, _move)(M_C(name, _t) snap, \
M_C3(snapshot_, name, _t) org) \ M_C(name, _t) org) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
SNAPSHOTI_CONTRACT(org); \ SNAPSHOTI_CONTRACT(org); \
@@ -169,7 +170,7 @@
} \ } \
,) /* IF_METHOD (MOVE) */ \ ,) /* IF_METHOD (MOVE) */ \
\ \
static inline type *M_C3(snapshot_, name, _take)(M_C3(snapshot_, name, _t) snap) \ static inline type *M_C(name, _take)(M_C(name, _t) snap) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
unsigned char nextFlags, origFlags = atomic_load (&snap->flags); \ unsigned char nextFlags, origFlags = atomic_load (&snap->flags); \
@@ -182,7 +183,7 @@
return &snap->data[SNAPSHOTI_W(nextFlags)]; \ return &snap->data[SNAPSHOTI_W(nextFlags)]; \
} \ } \
\ \
static inline const type *M_C3(snapshot_, name, _look)(M_C3(snapshot_, name, _t) snap) \ static inline const type *M_C(name, _look)(M_C(name, _t) snap) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
unsigned char nextFlags, origFlags = atomic_load (&snap->flags); \ unsigned char nextFlags, origFlags = atomic_load (&snap->flags); \
@@ -198,14 +199,14 @@
return M_CONST_CAST(type, &snap->data[SNAPSHOTI_R(nextFlags)]); \ return M_CONST_CAST(type, &snap->data[SNAPSHOTI_R(nextFlags)]); \
} \ } \
\ \
static inline type *M_C3(snapshot_, name, _get_produced)(M_C3(snapshot_, name, _t) snap) \ static inline type *M_C(name, _get_produced)(M_C(name, _t) snap) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
unsigned char flags = atomic_load(&snap->flags); \ unsigned char flags = atomic_load(&snap->flags); \
return &snap->data[SNAPSHOTI_W(flags)]; \ return &snap->data[SNAPSHOTI_W(flags)]; \
} \ } \
\ \
static inline const type *M_C3(snapshot_, name, _get_consummed)(M_C3(snapshot_, name, _t) snap) \ static inline const type *M_C(name, _get_consummed)(M_C(name, _t) snap) \
{ \ { \
SNAPSHOTI_CONTRACT(snap); \ SNAPSHOTI_CONTRACT(snap); \
unsigned char flags = atomic_load(&snap->flags); \ unsigned char flags = atomic_load(&snap->flags); \
+2 -2
View File
@@ -26,8 +26,8 @@
#include "coverage.h" #include "coverage.h"
START_COVERAGE START_COVERAGE
SNAPSHOT_DEF(uint, unsigned int) SNAPSHOT_DEF(snapshot_uint, unsigned int)
SNAPSHOT_DEF(mpz, mpz_t, SNAPSHOT_DEF(snapshot_mpz, mpz_t,
(INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear))) (INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear)))
END_COVERAGE END_COVERAGE