Skip to content

Commit

Permalink
lib: use ctassert macro
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Aug 12, 2024
1 parent 46a58b8 commit b32fc8f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions lib/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
*
* Note: on i386, alignof(uint64_t) == 4.
*/
_Static_assert(sizeof(_Atomic uint8_t) == sizeof(uint8_t), "atomic 8 size");
_Static_assert(sizeof(_Atomic uint16_t) == sizeof(uint16_t), "atomic 16 size");
_Static_assert(sizeof(_Atomic uint32_t) == sizeof(uint32_t), "atomic 32 size");
_Static_assert(sizeof(_Atomic uint64_t) == sizeof(uint64_t), "atomic 64 size");
_Static_assert(alignof(_Atomic uint8_t) <= 1, "atomic 8 align");
_Static_assert(alignof(_Atomic uint16_t) <= 2, "atomic 16 align");
_Static_assert(alignof(_Atomic uint32_t) <= 4, "atomic 32 align");
_Static_assert(alignof(_Atomic uint64_t) <= 8, "atomic 64 align");
ctassert(sizeof(_Atomic uint8_t) == sizeof(uint8_t), "atomic 8 size");
ctassert(sizeof(_Atomic uint16_t) == sizeof(uint16_t), "atomic 16 size");
ctassert(sizeof(_Atomic uint32_t) == sizeof(uint32_t), "atomic 32 size");
ctassert(sizeof(_Atomic uint64_t) == sizeof(uint64_t), "atomic 64 size");
ctassert(alignof(_Atomic uint8_t) <= 1, "atomic 8 align");
ctassert(alignof(_Atomic uint16_t) <= 2, "atomic 16 align");
ctassert(alignof(_Atomic uint32_t) <= 4, "atomic 32 align");
ctassert(alignof(_Atomic uint64_t) <= 8, "atomic 64 align");

void
frame_clear(struct funcframe *frame)
Expand Down
4 changes: 2 additions & 2 deletions lib/lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ void toywasm_cv_broadcast(pthread_cond_t *cv, struct toywasm_mutex *lock)
__END_EXTERN_C

#else /* defined(USE_PTHREAD) */
#define TOYWASM_MUTEX_DEFINE(name) _Static_assert(1, "suppress -Wextra-semi")
#define TOYWASM_MUTEX_DEFINE(name) ctassert(1, "suppress -Wextra-semi")
#define toywasm_mutex_init(a)
#define toywasm_mutex_destroy(a)
#define toywasm_mutex_lock(a)
#define toywasm_mutex_unlock(a)
#define TOYWASM_CV_DEFINE(name) _Static_assert(1, "suppress -Wextra-semi")
#define TOYWASM_CV_DEFINE(name) ctassert(1, "suppress -Wextra-semi")
#define toywasm_cv_init(a)
#define toywasm_cv_destroy(a)
#define toywasm_cv_timedwait(a, lk, abs) timespec_sleep(CLOCK_REALTIME, abs)
Expand Down
12 changes: 6 additions & 6 deletions lib/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ union v128 {
double f64[2];
};

_Static_assert(sizeof(float) == 4, "float");
_Static_assert(sizeof(double) == 8, "double");
_Static_assert(sizeof(union v128) == 16, "v128");
ctassert(sizeof(float) == 4, "float");
ctassert(sizeof(double) == 8, "double");
ctassert(sizeof(union v128) == 16, "v128");

#if defined(TOYWASM_ENABLE_WASM_EXCEPTION_HANDLING)
#if !defined(TOYWASM_USE_SMALL_CELLS)
Expand Down Expand Up @@ -243,9 +243,9 @@ struct val {
* alignment, the union can be a bit larger than what's calculated above.
* in that case, the last 4 byte of the structure is just an unused padding.
*/
_Static_assert(sizeof(struct val) == VAL_NCELLS * 4 ||
sizeof(struct val) == (VAL_NCELLS + 1) * 4,
"struct val");
ctassert(sizeof(struct val) == VAL_NCELLS * 4 ||
sizeof(struct val) == (VAL_NCELLS + 1) * 4,
"struct val");
#endif

struct localchunk {
Expand Down

0 comments on commit b32fc8f

Please sign in to comment.