diff options
author | Patrick Pelissier <patrick.pelissier@gmail.com> | 2020-05-09 22:38:32 +0300 |
---|---|---|
committer | Patrick Pelissier <patrick.pelissier@gmail.com> | 2020-05-09 22:38:32 +0300 |
commit | 439177ec71a62b342759696531b84b8bbfb7b9e9 (patch) | |
tree | 69821dad8eaf440d366740d3ad3fdc32ba3f4ecd /m-concurrent.h | |
parent | aadd4f11b1799df1fafd71f8cb9d83a69fabf4b3 (diff) |
Add protection against wrong oplist in more headers
Diffstat (limited to 'm-concurrent.h')
-rw-r--r-- | m-concurrent.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/m-concurrent.h b/m-concurrent.h index 2c32016..dc1b28d 100644 --- a/m-concurrent.h +++ b/m-concurrent.h @@ -115,13 +115,21 @@ so that all arguments are evaluated before further expansion */ #define CONCURRENTI_DEF_P1(arg) CONCURRENTI_DEF_P2 arg +/* Validate the value oplist before going further */ +#define CONCURRENTI_DEF_P2(name, type, oplist, concurrent_t) \ + M_IF_OPLIST(oplist)(CONCURRENTI_DEF_P3, CONCURRENTI_DEF_FAILURE)(name, type, oplist, concurrent_t) + +/* Stop processing with a compilation failure */ +#define CONCURRENTI_DEF_FAILURE(name, type, oplist, concurrent_t) \ + M_STATIC_FAILURE(M_LIB_NOT_AN_OPLIST, "(CONCURRENT_DEF): the given argument is not a valid oplist: " M_AS_STR(oplist)) + /* Internal concurrent definition - name: prefix to be used - type: type of the sub container - oplist: oplist of the type of the sub container - concurrent_t: alias for M_C(name, _t) [ type of the container ] */ -#define CONCURRENTI_DEF_P2(name, type, oplist, concurrent_t) \ +#define CONCURRENTI_DEF_P3(name, type, oplist, concurrent_t) \ \ typedef struct M_C(name, _s) { \ struct M_C(name, _s) *self; \ @@ -641,13 +649,21 @@ so that all arguments are evaluated before further expansion */ #define CONCURRENTI_RP_DEF_P1(arg) CONCURRENTI_RP_DEF_P2 arg +/* Validate the value oplist before going further */ +#define CONCURRENTI_RP_DEF_P2(name, type, oplist, concurrent_t) \ + M_IF_OPLIST(oplist)(CONCURRENTI_RP_DEF_P3, CONCURRENTI_RP_DEF_FAILURE)(name, type, oplist, concurrent_t) + +/* Stop processing with a compilation failure */ +#define CONCURRENTI_RP_DEF_FAILURE(name, type, oplist, concurrent_t) \ + M_STATIC_FAILURE(M_LIB_NOT_AN_OPLIST, "(CONCURRENT_RP_DEF): the given argument is not a valid oplist: " M_AS_STR(oplist)) + /* Internal RP concurrent definition - name: prefix to be used - type: type of the sub container - oplist: oplist of the type of the sub container - concurrent_t: alias for M_C(name, _t) [ type of the container ] */ -#define CONCURRENTI_RP_DEF_P2(name, type, oplist, concurrent_t) \ +#define CONCURRENTI_RP_DEF_P3(name, type, oplist, concurrent_t) \ \ typedef struct M_C(name, _s) { \ struct M_C(name, _s) *self; \ |