From: Eric Wong <mwrap-perl@80x24.org>
To: mwrap-perl@80x24.org
Subject: [PATCH 1/4] favor _Thread_local under C11
Date: Sat, 3 Sep 2022 11:18:25 +0000 [thread overview]
Message-ID: <20220903111828.2316808-2-mwrap-perl@80x24.org> (raw)
In-Reply-To: <20220903111828.2316808-1-mwrap-perl@80x24.org>
__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 <urcu/rculist.h>
#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
];
next prev parent reply other threads:[~2022-09-03 11:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-03 11:18 [PATCH 0/4] various cleanups and fixes from the Ruby side Eric Wong
2022-09-03 11:18 ` Eric Wong [this message]
2022-09-03 11:18 ` [PATCH 2/4] cleanup some FreeBSD-related workarounds Eric Wong
2022-09-04 7:01 ` Eric Wong
2022-09-03 11:18 ` [PATCH 3/4] use macro to quiet uninitialized and unused variable warnings Eric Wong
2022-09-03 11:18 ` [PATCH 4/4] workaround breakage from urcu v0.11.4 Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220903111828.2316808-2-mwrap-perl@80x24.org \
--to=mwrap-perl@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mwrap-perl.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).