From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EB52C1F59D for ; Sat, 3 Sep 2022 11:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662203908; bh=OImkFWz9s5O0v6rSgGLYjh3M6UY7vrZ07NeiS2LKrgM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=osg/0OhivToGPY4vva6LQMQtGl1raBGhq3ACg4PjcAumHqfVjovKsSCnoevuwq5mL XAXnENWvDJuv/eHxoiuvGLd+M+igvgDmZG5qYwNdNopLwHYXcHzA0DYEdAZ81xl3V2 F2ogQvPdtBY4yPxfWn3mPHQ8NmW1gLzKWsBBF6tY= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 1/4] favor _Thread_local under C11 Date: Sat, 3 Sep 2022 11:18:25 +0000 Message-Id: <20220903111828.2316808-2-mwrap-perl@80x24.org> In-Reply-To: <20220903111828.2316808-1-mwrap-perl@80x24.org> References: <20220903111828.2316808-1-mwrap-perl@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: __thread is a gcc-ism which clang supports, but _Thread_local is part of C11 and more likely to be supported by future compilers. --- Mwrap.xs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Mwrap.xs b/Mwrap.xs index bb51930..e888a1c 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -26,6 +26,14 @@ #include #include "jhash.h" +#if __STDC_VERSION__ >= 201112 +# define MWRAP_TSD _Thread_local +#elif defined(__GNUC__) +# define MWRAP_TSD __thread +#else +# error _Thread_local nor __thread supported +#endif + /* * Perl doesn't have a GC the same way (C) Ruby does, so no GC count. * Instead, the relative age of an object is the number of total bytes @@ -62,7 +70,7 @@ static int resolving_malloc; } \ } while (0) -static __thread size_t locating; +static MWRAP_TSD size_t locating; #ifndef PERL_IMPLICIT_CONTEXT static size_t *root_locating; /* determines if PL_curcop is our thread */ #endif @@ -237,7 +245,7 @@ struct alloc_hdr { size_t size; }; -static __thread char kbuf[ +static MWRAP_TSD char kbuf[ PATH_MAX + INT2STR_MAX + sizeof(struct alloc_hdr) + 2 ];