From 4ff4c8d352f76b658214029988eab7ce1d69efe8 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 23 Feb 2023 08:35:44 +0100 Subject: Internal updates. --- include/stc/algo/cco.h | 34 ++++++++++++++++------------------ include/stc/cbits.h | 11 +++++++++-- 2 files changed, 25 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/stc/algo/cco.h b/include/stc/algo/cco.h index fdb8ece3..c94382b1 100644 --- a/include/stc/algo/cco.h +++ b/include/stc/algo/cco.h @@ -99,38 +99,36 @@ * `c_' macros for re-entrant coroutines. */ typedef struct { - int _ccoline; + int cco_line; } *cco_handle; -#define cco_context(cref, ...) \ +#define cco_context(handle, ...) \ struct ccoContext { \ - int _ccoline; \ + int cco_line; \ __VA_ARGS__ \ - } **_ccoparam = (struct ccoContext **)cref + } **_ccoparam = (struct ccoContext **)handle + 0*sizeof((*(handle))->cco_line) #define cco_routine(ctx, ...) \ - do { \ - if (!*_ccoparam) { \ - *_ccoparam = malloc(sizeof **_ccoparam); \ - (*_ccoparam)->_ccoline = 0; \ - } \ - struct ccoContext *ctx = *_ccoparam; \ - switch (ctx->_ccoline) { \ - case 0: __VA_ARGS__ break; \ - default: assert(!"cco_finish: missing"); \ - } \ - free(ctx), *_ccoparam = 0; \ - } while (0) + if (!*_ccoparam) { \ + *_ccoparam = (struct ccoContext *)malloc(sizeof **_ccoparam); \ + (*_ccoparam)->cco_line = 0; \ + } \ + struct ccoContext *ctx = *_ccoparam; \ + switch (ctx->cco_line) { \ + case 0: __VA_ARGS__ break; \ + default: assert(!"cco_finish: missing"); \ + } \ + free(ctx), *_ccoparam = NULL #define cco_yield(ret) \ do { \ - (*_ccoparam)->_ccoline = __LINE__; return ret; \ + (*_ccoparam)->cco_line = __LINE__; return ret; \ case __LINE__:; \ } while (0) #define cco_finish case -1 #define cco_stop(ctx) \ - ((*(ctx))->_ccoline = -1, (ctx)) + ((*(ctx))->cco_line = -1, (ctx)) #endif /* COROUTINE_H */ diff --git a/include/stc/cbits.h b/include/stc/cbits.h index e2d97f8c..fa0da665 100644 --- a/include/stc/cbits.h +++ b/include/stc/cbits.h @@ -61,8 +61,13 @@ int main() { #define _cbits_words(n) (i_ssize)(((n) + 63)>>6) #define _cbits_bytes(n) (_cbits_words(n) * c_sizeof(uint64_t)) -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) STC_INLINE int cpopcount64(uint64_t x) {return __builtin_popcountll(x);} + #ifndef __clang__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstringop-overflow=" + #pragma GCC diagnostic ignored "-Walloc-size-larger-than=" + #endif #elif defined(_MSC_VER) && defined(_WIN64) #include STC_INLINE int cpopcount64(uint64_t x) {return (int)__popcnt64(x);} @@ -303,7 +308,9 @@ STC_INLINE bool _i_memb(_disjoint)(const i_type* self, const i_type* other) { _i_assert(self->_size == other->_size); return _cbits_disjoint(self->data64, other->data64, _i_memb(_size)(self)); } - +#if defined __GNUC__ && !defined __clang__ +#pragma GCC diagnostic pop +#endif #define CBITS_H_INCLUDED #undef _i_size #undef _i_memb -- cgit v1.2.3