Skip to content

Commit

Permalink
Optimize TLS access in generated code on FreeBSD (JuliaLang#47891)
Browse files Browse the repository at this point in the history
* Optimize TLS access in generated code on FreeBSD

This extends the optimization made for Linux in PR 17178 to FreeBSD. The
build and all tests pass locally with this change.

* Incorporate FreeBSD D31427 to support 12.2
  • Loading branch information
ararslan committed Dec 14, 2022
1 parent 437ebe1 commit c8a0521
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Ref https://www.uclibc.org/docs/tls.pdf
// For variant 1 JL_ELF_TLS_INIT_SIZE is the size of the thread control block (TCB)
// For variant 2 JL_ELF_TLS_INIT_SIZE is 0
#ifdef _OS_LINUX_
#if defined(_OS_LINUX_) || defined(_OS_FREEBSD_)
# if defined(_CPU_X86_64_) || defined(_CPU_X86_)
# define JL_ELF_TLS_VARIANT 2
# define JL_ELF_TLS_INIT_SIZE 0
Expand All @@ -30,6 +30,11 @@
# include <link.h>
#endif

// `ElfW` was added to FreeBSD in 12.3 but we still support 12.2
#if defined(_OS_FREEBSD_) && !defined(ElfW)
# define ElfW(x) __ElfN(x)
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down

0 comments on commit c8a0521

Please sign in to comment.