From 06ace4e7b4f4ad5aeada4a59bb9f2a212ecdf27a Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Thu, 7 Dec 2023 14:20:12 -0800 Subject: [PATCH] Always use compiler builtin for offsetof() 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. --- libc/integral/c.inc | 5 ----- libc/thread/pthread_cancel.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libc/integral/c.inc b/libc/integral/c.inc index 11fbbd946..c1f86f5ae 100644 --- a/libc/integral/c.inc +++ b/libc/integral/c.inc @@ -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 diff --git a/libc/thread/pthread_cancel.c b/libc/thread/pthread_cancel.c index cd378673d..c9b446628 100644 --- a/libc/thread/pthread_cancel.c +++ b/libc/thread/pthread_cancel.c @@ -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);