Skip to content

Commit

Permalink
Always use compiler builtin for offsetof()
Browse files Browse the repository at this point in the history
We have received multiple reports of GCC breaking builds when compiler
flags like `-std=c11` were being passed. The workaround until the next
release is to simply not define `__STRICT_ANSI__` which is a bad idea.
  • Loading branch information
jart committed Dec 7, 2023
1 parent e36283f commit 06ace4e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions libc/integral/c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,7 @@ typedef struct {
#define autotype(x) typeof(x)
#endif

#if defined(__STRICT_ANSI__) || \
(!defined(__GNUC__) && !defined(__builtin_offsetof))
#define offsetof(type, member) ((unsigned long)&((type *)0)->member)
#else
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif

#ifdef _COSMO_SOURCE

Expand Down
2 changes: 1 addition & 1 deletion libc/thread/pthread_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void _pthread_cancel_sig(int sig, siginfo_t *si, void *arg) {
if (pt->pt_flags & PT_NOCANCEL) return;
if (!atomic_load_explicit(&pt->pt_canceled, memory_order_acquire)) return;

// in asynchronous mode we'll just the exit asynchronously
// in asynchronous mode the asynchronous signal calls exit
if (pt->pt_flags & PT_ASYNC) {
sigaddset(&ctx->uc_sigmask, SIGTHR);
pthread_sigmask(SIG_SETMASK, &ctx->uc_sigmask, 0);
Expand Down

0 comments on commit 06ace4e

Please sign in to comment.