Skip to content

Instantly share code, notes, and snippets.

@dstogov
Created March 5, 2021 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstogov/c7c01283766376478b5f7073c1a432a9 to your computer and use it in GitHub Desktop.
Save dstogov/c7c01283766376478b5f7073c1a432a9 to your computer and use it in GitHub Desktop.
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index cd340035a2..2d60b6a9d6 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -729,13 +729,13 @@ TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
#if defined(__APPLE__) && defined(__x86_64__)
// TODO: Implement support for fast JIT ZTS code ???
return 0;
-#elif defined(__x86_64__) && defined(__GNUC__)
+#elif defined(__x86_64__) && defined(__GNUC__) && !defined(__FreeBSD__)
size_t ret;
asm ("movq _tsrm_ls_cache@gottpoff(%%rip),%0"
: "=r" (ret));
return ret;
-#elif defined(__i386__) && defined(__GNUC__)
+#elif defined(__i386__) && defined(__GNUC__) && !defined(__FreeBSD__)
size_t ret;
asm ("leal _tsrm_ls_cache@ntpoff,%0"
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index 6978b49732..eea158d015 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -147,7 +147,7 @@ TSRM_API const char *tsrm_api_name(void);
# define __has_attribute(x) 0
#endif
-#if !__has_attribute(tls_model)
+#if !__has_attribute(tls_model) || defined(__FreeBSD__)
# define TSRM_TLS_MODEL_ATTR
#elif __PIC__
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 3e9d9f7f13..56fd87a047 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -2933,7 +2933,7 @@ static int zend_jit_setup(void)
# elif defined(__GNUC__) && defined(__x86_64__)
tsrm_ls_cache_tcb_offset = tsrm_get_ls_cache_tcb_offset();
if (tsrm_ls_cache_tcb_offset == 0) {
-#if defined(__has_attribute) && __has_attribute(tls_model)
+#if defined(__has_attribute) && __has_attribute(tls_model) && !defined(__FreeBSD__)
size_t ret;
asm ("movq _tsrm_ls_cache@gottpoff(%%rip),%0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment