Skip to content

Commit

Permalink
xglobals: Add static assertions
Browse files Browse the repository at this point in the history
Signed-off-by: LIU Hao <lh_mouse@126.com>
  • Loading branch information
lhmouse committed Nov 26, 2024
1 parent 39ddd4a commit 54be94a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions mcfgthread/xglobals.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,39 @@ __MCF_DLLEXPORT
void
__MCF_gthread_initialize_globals(void)
{
/* Ensure we don't mess things up. */
#if __MCF_PTR_BITS == 64
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __self_ptr) == 0);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __self_size) == 8);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __tls_index) == 12);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __main_thread) == 16);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __exit_mtx) == 1616);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __exit_queue) == 1624);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __quick_exit_mtx) == 3152);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __quick_exit_queue) == 3160);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __mutex_spin_field) == 4736);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __interrupt_cond) == 6784);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __f_GetSystemTimePreciseAsFileTime) == 6792);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __f_QueryInterruptTime) == 6800);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __thread_oom_mtx) == 6808);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __thread_oom_self_st) == 6816);
#else
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __self_ptr) == 0);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __self_size) == 4);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __tls_index) == 8);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __main_thread) == 16);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __exit_mtx) == 816);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __exit_queue) == 820);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __quick_exit_mtx) == 1584);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __quick_exit_queue) == 1588);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __mutex_spin_field) == 2368);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __interrupt_cond) == 4416);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __f_GetSystemTimePreciseAsFileTime) == 4420);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __f_QueryInterruptTime) == 4424);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __thread_oom_mtx) == 4428);
__MCF_STATIC_ASSERT(offsetof(__MCF_crt_xglobals, __thread_oom_self_st) == 4432);
#endif

/* Initialize static global constants. */
GetSystemInfo(&__MCF_crt_sysinfo);

Expand Down

0 comments on commit 54be94a

Please sign in to comment.