devel
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
July 2016
- 9 participants
- 26 discussions
Hello,
While investigating a build failure of the "gamin" package in Buildroot
on the Microblaze architecture
(http://autobuild.buildroot.net/results/887/887df97196d7777efbf18a7bee91aa45…)
regarding PTHREAD_MUTEX_RECURSIVE being undefined, I noticed a
discrepancy between the definition of PTHREAD_MUTEX_RECURSIVE in the
linuxthreads variant of pthread.h and the NPTL variant of pthread.h.
Indeed, libpthread/nptl/sysdeps/pthread/pthread.h contains:
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
,
PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
#endif
while the corresponding linuxthreads version, in
libpthread/linuxthreads/sysdeps/pthread/pthread.h contains:
#ifdef __USE_UNIX98
,
PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_ADAPTIVE_NP,
PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
#endif
Notice how the NPTL code defines all the non-NP variants if
__USE_XOPEN2K8 is defined, but not the linuxthreads version?
Maybe this difference is normal, I am not familiar enough with all the
standards and conformance issues, but I thought it would be good to
point it out.
Thanks,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
3
7

08 Aug '16
I ran into this issue while trying to debug a _different_ issue witin
the uClinc(-ng) arc dynamic linker. I turned on debugging support
within the dynamic linker, and the linker would no longer complete its
bootstrap phase due to a lack of support for the R_ARC_JMP_SLOT
relocation type.
To reproduce this issue it should be enough to configure uClibc(-ng)
for ARC with 'DODEBUG=y', then try to run anything that requires
dynamic linking.
The R_ARC_JMP_SLOT relocation type is used within the .plt, so I
believe it makes sense for these relocations to be generated.
I updated the associated comment above the boostrap patching code so
that it makes more sense (to me at least) with the extra relocation
support.
I wonder if you would consider merging this patch?
Thanks,
Andrew
---
This commit adds support for R_ARC_JMP_SLOT relocations during the
bootstrap phase of the dynamic linker. These relocations will be
generated if uClibc is configured with 'DODEBUG=y'.
---
ldso/ldso/arc/dl-startup.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h
index ef89b53..fadc433 100644
--- a/ldso/ldso/arc/dl-startup.h
+++ b/ldso/ldso/arc/dl-startup.h
@@ -64,10 +64,11 @@ __asm__(
/*
* Dynamic loader bootstrapping:
- * Since we don't modify text at runtime, these can only be data relos
- * (so safe to assume that they are word aligned).
- * And also they HAVE to be RELATIVE relos only
- * @RELP is the relo entry being processed
+ * The only relocations that should be found are either R_ARC_RELATIVE for
+ * data relocations (.got, etc) or R_ARC_JMP_SLOT for code relocations
+ * (.plt). It is safe to assume that all of these relocations are word
+ * aligned.
+ * @RELP is the reloc entry being processed
* @REL is the pointer to the address we are relocating.
* @SYMBOL is the symbol involved in the relocation
* @LOAD is the load address.
@@ -78,6 +79,8 @@ do { \
int type = ELF32_R_TYPE((RELP)->r_info); \
if (likely(type == R_ARC_RELATIVE)) \
*REL += (unsigned long) LOAD; \
+ else if (type == R_ARC_JMP_SLOT) \
+ *REL = SYMBOL; \
else \
_dl_exit(1); \
}while(0)
--
2.5.1
3
2

uClibc-ng - small C library for embedded systems branch master updated. v1.0.16-19-gef7cb0f
by wbx@helium.openadk.org 31 Jul '16
by wbx@helium.openadk.org 31 Jul '16
31 Jul '16
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via ef7cb0f8678ea5cf55aa210c09e8f27d262f42d9 (commit)
from 7a575d98449780a95fc4004b179a2ea0dcd0f468 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ef7cb0f8678ea5cf55aa210c09e8f27d262f42d9
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Sun Jul 31 21:15:17 2016 +0200
fix minor portability issue, use printf
-----------------------------------------------------------------------
Summary of changes:
Rules.mak | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Rules.mak b/Rules.mak
index 3c80016..6188d16 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -463,7 +463,7 @@ ifeq ($(TARGET_ARCH),powerpc)
# faster code.
PICFLAG:=-fpic
PIEFLAG_NAME:=-fpie
- PPC_HAS_REL16:=$(shell echo -e "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n)
+ PPC_HAS_REL16:=$(shell printf "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha\n" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n)
CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES"
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
1
0

uClibc-ng - small C library for embedded systems branch master updated. v1.0.16-18-g7a575d9
by wbx@helium.openadk.org 31 Jul '16
by wbx@helium.openadk.org 31 Jul '16
31 Jul '16
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via 7a575d98449780a95fc4004b179a2ea0dcd0f468 (commit)
from 3649052470197e302eee69de7c7f519d63dd1f45 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7a575d98449780a95fc4004b179a2ea0dcd0f468
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Sun Jul 31 13:22:00 2016 +0200
include missing Linux extension headers for poll.h
This was found by Buildroot autobuilders for m68k.
-----------------------------------------------------------------------
Summary of changes:
libc/sysdeps/linux/c6x/bits/poll.h | 7 +++++++
libc/sysdeps/linux/m68k/bits/poll.h | 7 +++++++
libc/sysdeps/linux/microblaze/bits/poll.h | 7 +++++++
3 files changed, 21 insertions(+)
diff --git a/libc/sysdeps/linux/c6x/bits/poll.h b/libc/sysdeps/linux/c6x/bits/poll.h
index 1d845eb..4c984cc 100644
--- a/libc/sysdeps/linux/c6x/bits/poll.h
+++ b/libc/sysdeps/linux/c6x/bits/poll.h
@@ -34,6 +34,13 @@
# define POLLWRBAND 0x100 /* Priority data may be written. */
#endif
+#ifdef __USE_GNU
+/* These are extensions for Linux. */
+# define POLLMSG 0x400
+# define POLLREMOVE 0x1000
+# define POLLRDHUP 0x2000
+#endif
+
/* Event types always implicitly polled for. These bits need not be set in
`events', but they will appear in `revents' to indicate the status of
the file descriptor. */
diff --git a/libc/sysdeps/linux/m68k/bits/poll.h b/libc/sysdeps/linux/m68k/bits/poll.h
index 1d845eb..4c984cc 100644
--- a/libc/sysdeps/linux/m68k/bits/poll.h
+++ b/libc/sysdeps/linux/m68k/bits/poll.h
@@ -34,6 +34,13 @@
# define POLLWRBAND 0x100 /* Priority data may be written. */
#endif
+#ifdef __USE_GNU
+/* These are extensions for Linux. */
+# define POLLMSG 0x400
+# define POLLREMOVE 0x1000
+# define POLLRDHUP 0x2000
+#endif
+
/* Event types always implicitly polled for. These bits need not be set in
`events', but they will appear in `revents' to indicate the status of
the file descriptor. */
diff --git a/libc/sysdeps/linux/microblaze/bits/poll.h b/libc/sysdeps/linux/microblaze/bits/poll.h
index 9b284c8..27c3219 100644
--- a/libc/sysdeps/linux/microblaze/bits/poll.h
+++ b/libc/sysdeps/linux/microblaze/bits/poll.h
@@ -34,6 +34,13 @@
# define POLLWRBAND 0x0200 /* Priority data may be written. */
#endif
+#ifdef __USE_GNU
+/* These are extensions for Linux. */
+# define POLLMSG 0x400
+# define POLLREMOVE 0x1000
+# define POLLRDHUP 0x2000
+#endif
+
/* Event types always implicitly polled for. These bits need not be set in
`events', but they will appear in `revents' to indicate the status of
the file descriptor. */
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
1
0

31 Jul '16
Hi Andrew, all,
On Thu, 2016-07-28 at 15:40 -0700, Vineet Gupta wrote:
> On 07/28/2016 03:04 PM, Bernhard Reutner-Fischer wrote:
> >
> > >
> > > Indeed your 2/2 seems to be the most "past-proof" code change. So I
> > > >
> > > > would think it
> > > > is indeed better and is something I should have done in the first
> > > > place.
> > > >
> > > > @Alexey, @Vlad what say you ?
> > uClibc traditionally supports the current stable release of binutils, which would make it patch #1 I think.
> >
>
> But 2/2 works for both and makes actual binutils version moot. FWIW, ARC tools
> don't as of last release didn't use the upstream/stable binutils, but we are
> pretty close to that now though.
Personally I'd prefer to not add more conditional defines in uClibc but
make it a little-bit simpler.
I.e. either Vlad's patch or #1 from this series IMHO looks better.
It's been quite some time since we updated our tools with PCL support
and I'm not really sure if there's anybody interested in using ages old
tools with today's uClibc. We don't test such combinations and there could
be issues already in such combos.
BTW I noticed that Vlad's patch removes/reverts that thing as well:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/ldso/ldso/arc/dl-sy…
c5187
While Andrew just replaces ".&" construction with "@pcl".
I'm wondering which is the correct approach here?
-Alexey
3
3

31 Jul '16
This short series introduces fixes of 2 observed isues (#1 & #2) in clone()
syscall in ARC port and one enhancement (#3).
It all started from failing tst-clone1 in uClibc testsuite and during
its debugging we observed another quite subtle issue which was then not only
solved but better (which means shorter and simpler) implementation was made.
Alexey Brodkin (3):
arc: clone: Recover PID correctly
arc: clone: Fix CLONE_THREAD detection
arc: clone: Simplify CLONE_THREAD detection
libc/sysdeps/linux/arc/clone.S | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
--
2.7.4
2
4

uClibc-ng - small C library for embedded systems branch master updated. v1.0.16-17-g3649052
by wbx@helium.openadk.org 31 Jul '16
by wbx@helium.openadk.org 31 Jul '16
31 Jul '16
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via 3649052470197e302eee69de7c7f519d63dd1f45 (commit)
via 334ddb1b8fe5d4b473a9e410b882952f2075b417 (commit)
via b2c2bbcc8ccd0d0b281db653d22e568b8871ad46 (commit)
via 25f4ae1de711b2001b4958d65e77b6dba222e7b5 (commit)
via ae01de4d1d1e16e46c5180ba7fb081792081996a (commit)
via d1bf524bae265e54d7695019d23e7416507bbe24 (commit)
via acc7443a4feb0aa098f12207f2da44c21d382e66 (commit)
via 5478c44ceb136a4dc7166bd287684cdbef6ca9ce (commit)
from 345181fb9a36ad18c0a40ccb74bff9ee4d03819b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3649052470197e302eee69de7c7f519d63dd1f45
Author: Andrew Burgess <andrew.burgess(a)embecosm.com>
Date: Fri Jul 29 14:26:09 2016 +0100
ARC: Update relocation syntax for old-thread model code
This commit reverses a change introduced in commit 20554a78a9bba that
split some of the ARC code into two based on whether uClibc was
configured with native threads or not.
The native thread code was updated to use the relocation syntax of
modern binutils, while the non-native code path used a syntax only
accepted in older versions of binutils.
The problem with this is that the choice of old binutils or not is
orthogonal to the choice of native threads or not, and so, inevitably a
user with a recent version of binutils can make the choice to configure
uClibc with non-native thread support, and run into code that will not
assemble.
The solution is either to abandon support for the old tools completely,
or to add a new compile time flag for ARC that is set when the version
of binutils being used is old; this new flag would allow the old
relocation structure to be selected.
In this commit I have simply dropped support for older versions of the
tools.
commit 334ddb1b8fe5d4b473a9e410b882952f2075b417
Author: Alexey Brodkin <Alexey.Brodkin(a)synopsys.com>
Date: Fri Jul 29 12:17:20 2016 +0300
arc: clone: Simplify CLONE_THREAD detection
This change was inspired by similar change in glibc:
https://sourceware.org/git/?p=glibc.git;a=commit;h=0cb313f7cb0e418b3d56f3a2…
Current Linux kernel requires CLONE_VM to be set with CLONE_THREAD
otherwise returning -EINVAL, see man clone2. This means we don't need
to check for both CLONE_THREAD and CLONE_VM instead we may simplify
code a lot and just check 1 bit (CLONE_THREAD).
Signed-off-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Acked-by: Vineet Gupta <vgupta(a)synopsys.com>
commit b2c2bbcc8ccd0d0b281db653d22e568b8871ad46
Author: Alexey Brodkin <Alexey.Brodkin(a)synopsys.com>
Date: Fri Jul 29 12:17:19 2016 +0300
arc: clone: Fix CLONE_THREAD detection
For thread group case (CLONE_THREAD), the cached PID of new process/thread
need not be reset. The old logic to decide that was flawed as it would be
true only for exact combination of CLONE_THREAD + _VM, but would fail for
CLONE_THREAD + _VM + _xyz.
More detailed tear-down of current and new code below.
Current implementation is:
--------------------->8--------------------
; r12 contains clone flags
mov_s r2, CLONE_THREAD_N_VM; r2 contains bit mask
and_s r2, r2, r12 ; r2 contains bit mask AND clone flags
; but r12 still contains the same flags
brne r2, r12, .Lgo_thread ; here we compare modified mask with
; flags as they were and skip pthread TID/PID
; setup if r2 != r12 which happens all
; the time except clone flags were
; exactly CLONE_THREAD | CLONE_VM
--------------------->8--------------------
New implementation is:
--------------------->8--------------------
; r12 contains clone flags
mov_s r2, CLONE_THREAD_N_VM; r2 contains bit mask
and_s r12, r12, r2 ; r12 contains clone flags AND bit mask
; i.e. we did mask all flags except
; CLONE_THREAD and CLONE_VM
breq r2, r12, .Lgo_thread ; here we compare masked flags with
; target mask and if they match we skip
; pthread TID/PID setup
--------------------->8--------------------
Signed-off-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Acked-by: Vineet Gupta <vgupta(a)synopsys.com>
commit 25f4ae1de711b2001b4958d65e77b6dba222e7b5
Author: Alexey Brodkin <Alexey.Brodkin(a)synopsys.com>
Date: Fri Jul 29 12:17:18 2016 +0300
arc: clone: Recover PID correctly
Caught by tst-getpid1 test from uClibc's test-suite.
It looks like original implementation was not correct.
The code in question is supposed to recover PID of the new
thread. And by no means that could happen with clone() syscall
while getpid() does exactly this.
Signed-off-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Acked-by: Vineet Gupta <vgupta(a)synopsys.com>
Reported-by: Eugeniy Paltsev <paltsev(a)synopsys.com>
commit ae01de4d1d1e16e46c5180ba7fb081792081996a
Author: Andrew Burgess <andrew.burgess(a)embecosm.com>
Date: Thu Jul 28 18:59:08 2016 +0100
ARC: Support R_ARC_JMP_SLOT relocations during bootstrap
This commit adds support for R_ARC_JMP_SLOT relocations during the
bootstrap phase of the dynamic linker. These relocations will be
generated if uClibc-ng is configured with 'DODEBUG=y'.
commit d1bf524bae265e54d7695019d23e7416507bbe24
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Tue Jul 26 22:39:39 2016 +0200
remove unused code, RTLD_PRIVATE_ERRNO is never defined
commit acc7443a4feb0aa098f12207f2da44c21d382e66
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Tue Jul 26 21:32:47 2016 +0200
deduplicate jmpbuf-unwind.h
Reviewed-by: Max Filippov <jcmvbkbc(a)gmail.com>
commit 5478c44ceb136a4dc7166bd287684cdbef6ca9ce
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Mon Jul 25 19:13:20 2016 +0200
test: reorganize tls macros in separate architecture files
To be more consistent separate all TLS macros in separate files and
remove obsolete macros for not supported architectures.
Reviewed-by: Max Filippov <jcmvbkbc(a)gmail.com>
-----------------------------------------------------------------------
Summary of changes:
ldso/ldso/arc/dl-startup.h | 18 +-
ldso/ldso/arc/dl-sysdep.h | 10 -
libc/sysdeps/linux/alpha/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/arc/clone.S | 9 +-
libc/sysdeps/linux/arc/jmpbuf-unwind.h | 6 -
libc/sysdeps/linux/arm/jmpbuf-unwind.h | 7 +-
libc/sysdeps/linux/arm/sysdep.h | 11 -
libc/sysdeps/linux/avr32/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/bfin/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/c6x/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/cris/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/hppa/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/i386/sysdep.h | 12 +-
libc/sysdeps/linux/ia64/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/m68k/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/metag/bits/setjmp.h | 10 -
libc/sysdeps/linux/metag/jmpbuf-offsets.h | 7 +
libc/sysdeps/linux/metag/jmpbuf-unwind.h | 8 +-
libc/sysdeps/linux/metag/sysdep.h | 11 -
libc/sysdeps/linux/microblaze/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/mips/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/nios2/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/powerpc/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/sh/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/sh/sysdep.h | 17 +-
libc/sysdeps/linux/sparc/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/x86_64/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/x86_64/sysdep.h | 9 -
libc/sysdeps/linux/xtensa/jmpbuf-unwind.h | 1 +
libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h | 27 -
libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h | 32 -
libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h | 32 -
libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h | 27 -
libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h | 35 -
libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h | 26 -
libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h | 27 -
libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h | 27 -
libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h | 27 -
libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h | 27 -
libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h | 32 -
test/tls/tls-macros-alpha.h | 25 +
test/tls/tls-macros-arc.h | 28 +
test/tls/tls-macros-i386.h | 76 ++
test/tls/tls-macros-ia64.h | 63 ++
test/tls/tls-macros-metag.h | 38 +
test/tls/tls-macros-powerpc.h | 87 +++
test/tls/tls-macros-sh.h | 143 ++++
test/tls/tls-macros-sparc.h | 67 ++
test/tls/tls-macros-x86_64.h | 40 +
test/tls/tls-macros-xtensa.h | 61 ++
test/tls/tls-macros.h | 984 +-----------------------
51 files changed, 697 insertions(+), 1385 deletions(-)
create mode 100644 libc/sysdeps/linux/metag/jmpbuf-offsets.h
delete mode 100644 libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
create mode 100644 test/tls/tls-macros-alpha.h
create mode 100644 test/tls/tls-macros-arc.h
create mode 100644 test/tls/tls-macros-i386.h
create mode 100644 test/tls/tls-macros-ia64.h
create mode 100644 test/tls/tls-macros-metag.h
create mode 100644 test/tls/tls-macros-powerpc.h
create mode 100644 test/tls/tls-macros-sh.h
create mode 100644 test/tls/tls-macros-sparc.h
create mode 100644 test/tls/tls-macros-x86_64.h
create mode 100644 test/tls/tls-macros-xtensa.h
diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h
index ef89b53..232ecb9 100644
--- a/ldso/ldso/arc/dl-startup.h
+++ b/ldso/ldso/arc/dl-startup.h
@@ -34,15 +34,8 @@ __asm__(
" ; skip the extra args calc by dl_start() \n"
" ld_s r1, [sp] ; orig argc from aux-vec Tbl \n"
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
" ld r12, [pcl, _dl_skip_args@pcl] \n"
-
" add r2, pcl, _dl_fini@pcl ; finalizer \n"
-#else
- " add r12, pcl, _dl_skip_args-.+(.&2) \n"
- " ld r12, [r12] \n"
- " add r2, pcl, _dl_fini-.+(.&2) ; finalizer \n"
-#endif
" add2 sp, sp, r12 ; discard argv entries from stack\n"
" sub_s r1, r1, r12 ; adjusted argc, on stack \n"
@@ -64,10 +57,11 @@ __asm__(
/*
* Dynamic loader bootstrapping:
- * Since we don't modify text at runtime, these can only be data relos
- * (so safe to assume that they are word aligned).
- * And also they HAVE to be RELATIVE relos only
- * @RELP is the relo entry being processed
+ * The only relocations that should be found are either R_ARC_RELATIVE for
+ * data relocations (.got, etc) or R_ARC_JMP_SLOT for code relocations
+ * (.plt). It is safe to assume that all of these relocations are word
+ * aligned.
+ * @RELP is the reloc entry being processed
* @REL is the pointer to the address we are relocating.
* @SYMBOL is the symbol involved in the relocation
* @LOAD is the load address.
@@ -78,6 +72,8 @@ do { \
int type = ELF32_R_TYPE((RELP)->r_info); \
if (likely(type == R_ARC_RELATIVE)) \
*REL += (unsigned long) LOAD; \
+ else if (type == R_ARC_JMP_SLOT) \
+ *REL = SYMBOL; \
else \
_dl_exit(1); \
}while(0)
diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h
index caece99..c6086e6 100644
--- a/ldso/ldso/arc/dl-sysdep.h
+++ b/ldso/ldso/arc/dl-sysdep.h
@@ -132,7 +132,6 @@ static __always_inline Elf32_Addr elf_machine_dynamic(void)
/* Return the run-time load address of the shared object. */
static __always_inline Elf32_Addr elf_machine_load_address(void)
{
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
/* To find the loadaddr we subtract the runtime addr of a non-local symbol
* say _DYNAMIC from it's build-time addr.
* N.B., gotpc loads get optimized by the linker if it finds the symbol
@@ -150,15 +149,6 @@ static __always_inline Elf32_Addr elf_machine_load_address(void)
"sub %0, %0, %1 ;delta" "\n"
: "=&r" (addr), "=r"(tmp)
);
-#else
- Elf32_Addr addr, tmp;
- __asm__ (
- "ld %1, [pcl, _dl_start@gotpc] ;build addr of _dl_start \n"
- "add %0, pcl, _dl_start-.+(.&2) ;runtime addr of _dl_start \n"
- "sub %0, %0, %1 ;delta \n"
- : "=&r" (addr), "=r"(tmp)
- );
-#endif
return addr;
}
diff --git a/libc/sysdeps/linux/alpha/jmpbuf-unwind.h b/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
index 80fe8b3..b14837e 100644
--- a/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/arc/clone.S b/libc/sysdeps/linux/arc/clone.S
index 3c1388e..3942b88 100644
--- a/libc/sysdeps/linux/arc/clone.S
+++ b/libc/sysdeps/linux/arc/clone.S
@@ -27,10 +27,7 @@
; void *tls,
; int __user *child_tidptr)
-#define CLONE_VM 0x00000100
-#define CLONE_THREAD 0x00010000
#define CLONE_SETTLS 0x00080000
-#define CLONE_THREAD_N_VM (CLONE_THREAD | CLONE_VM)
ENTRY(clone)
cmp r0, 0 ; @fn can't be NULL
@@ -68,11 +65,9 @@ ENTRY(clone)
.Lnext_clone_quirk:
#ifdef RESET_PID
- mov_s r2, CLONE_THREAD_N_VM
- and_s r2, r2, r12
- brne r2, r12, .Lgo_thread
+ bbit1 r12, 16, .Lgo_thread ; CLONE_THREAD = (1 << 16)
- mov r8, __NR_clone
+ mov r8, __NR_getpid
ARC_TRAP_INSN ; r0 has PID
THREAD_SELF r1 ; Get to struct pthread (just before TCB)
st r0, [r1, PTHREAD_PID]
diff --git a/libc/sysdeps/linux/arc/jmpbuf-unwind.h b/libc/sysdeps/linux/arc/jmpbuf-unwind.h
index 8c41816..d16506a 100644
--- a/libc/sysdeps/linux/arc/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/arc/jmpbuf-unwind.h
@@ -16,12 +16,6 @@
#include <stdint.h>
#include <unwind.h>
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
_JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
diff --git a/libc/sysdeps/linux/arm/jmpbuf-unwind.h b/libc/sysdeps/linux/arm/jmpbuf-unwind.h
index d7b49e2..44f9a1b 100644
--- a/libc/sysdeps/linux/arm/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/arm/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
@@ -15,12 +16,6 @@
#include <stdint.h>
#include <unwind.h>
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
_JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h
index f8f2f8a..80bf9ec 100644
--- a/libc/sysdeps/linux/arm/sysdep.h
+++ b/libc/sysdeps/linux/arm/sysdep.h
@@ -142,16 +142,6 @@
#if defined NOT_IN_libc
# define SYSCALL_ERROR __local_syscall_error
-# ifdef RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_HANDLER \
-__local_syscall_error: \
- ldr r1, 1f; \
- rsb r0, r0, #0; \
-0: str r0, [pc, r1]; \
- mvn r0, #0; \
- DO_RET(lr); \
-1: .word C_SYMBOL_NAME(rtld_errno) - 0b - 8;
-# else
# define SYSCALL_ERROR_HANDLER \
__local_syscall_error: \
str lr, [sp, #-4]!; \
@@ -162,7 +152,6 @@ __local_syscall_error: \
str r1, [r0]; \
mvn r0, #0; \
ldr pc, [sp], #4;
-# endif
#else
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
# define SYSCALL_ERROR __syscall_error
diff --git a/libc/sysdeps/linux/avr32/jmpbuf-unwind.h b/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
index 5caa2ee..f19f491 100644
--- a/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
@@ -5,6 +5,7 @@
* Public License. See the file "COPYING.LIB" in the main directory of this
* archive for more details.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/bfin/jmpbuf-unwind.h b/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
index bb7a374..26b56db 100644
--- a/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/c6x/jmpbuf-unwind.h b/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
index ad2ab59..58eb18a 100644
--- a/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
@@ -17,6 +17,7 @@
* along with this program; see the file COPYING.LIB. If not, see
* <http://www.gnu.org/licenses/>.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/cris/jmpbuf-unwind.h b/libc/sysdeps/linux/cris/jmpbuf-unwind.h
index 8b75dce..b5950ad 100644
--- a/libc/sysdeps/linux/cris/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/cris/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/hppa/jmpbuf-unwind.h b/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
index 0590754..efed134 100644
--- a/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/i386/sysdep.h b/libc/sysdeps/linux/i386/sysdep.h
index 79e53a1..c15c1b4 100644
--- a/libc/sysdeps/linux/i386/sysdep.h
+++ b/libc/sysdeps/linux/i386/sysdep.h
@@ -186,17 +186,7 @@ __x86.get_pc_thunk.reg: \
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
#else
-# ifdef RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG(cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- xorl %edx, %edx; \
- subl %eax, %edx; \
- movl %edx, rtld_errno@GOTOFF(%ecx); \
- orl $-1, %eax; \
- jmp L(pseudo_end);
-
-# elif defined _LIBC_REENTRANT
+# if defined _LIBC_REENTRANT
# if defined USE___THREAD
# ifndef NOT_IN_libc
diff --git a/libc/sysdeps/linux/ia64/jmpbuf-unwind.h b/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
index 91e2df8..4eb0eea 100644
--- a/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame containing a local
diff --git a/libc/sysdeps/linux/m68k/jmpbuf-unwind.h b/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
index d87ace3..c5a8886 100644
--- a/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/metag/bits/setjmp.h b/libc/sysdeps/linux/metag/bits/setjmp.h
index 8ad4b12..d80a355 100644
--- a/libc/sysdeps/linux/metag/bits/setjmp.h
+++ b/libc/sysdeps/linux/metag/bits/setjmp.h
@@ -28,17 +28,7 @@
*/
#define _JBLEN 24
-#if defined (__USE_MISC) || defined (_ASM)
-#define JB_SP 0
-#endif
-#ifndef _ASM
typedef int __jmp_buf[_JBLEN] __attribute__((aligned (8)));
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) > (void *) (jmpbuf)[JB_SP])
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/metag/jmpbuf-offsets.h b/libc/sysdeps/linux/metag/jmpbuf-offsets.h
new file mode 100644
index 0000000..e4faf42
--- /dev/null
+++ b/libc/sysdeps/linux/metag/jmpbuf-offsets.h
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define JB_SP 0
diff --git a/libc/sysdeps/linux/metag/jmpbuf-unwind.h b/libc/sysdeps/linux/metag/jmpbuf-unwind.h
index 175cd7a..bf79141 100644
--- a/libc/sysdeps/linux/metag/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/metag/jmpbuf-unwind.h
@@ -1,14 +1,16 @@
/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include <setjmp.h>
+#include <jmpbuf-offsets.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) > (void *) demangle (jmpbuf[JB_SP]))
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) > (void *) jmpbuf[JB_SP])
#ifdef __UCLIBC_HAS_THREADS_NATIVE__
#include <stdint.h>
diff --git a/libc/sysdeps/linux/metag/sysdep.h b/libc/sysdeps/linux/metag/sysdep.h
index 8750641..3af7131 100644
--- a/libc/sysdeps/linux/metag/sysdep.h
+++ b/libc/sysdeps/linux/metag/sysdep.h
@@ -24,16 +24,6 @@
#if defined NOT_IN_libc
# define SYSCALL_ERROR __local_syscall_error
-# ifdef RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_HANDLER \
-__local_syscall_error: \
- NEG D0Re0, D0Re0; \
- ADDT D1Re0, CPC1, #HI(_rtld_errno); \
- ADD D1Re0, D1Re0, #LO(_rtld_errno) + 4; \
- SETD [D1Re0], D0Re0; \
- NEG D0Re0, #0x1; \
- MOV PC, D1RtP;
-# else
# define SYSCALL_ERROR_HANDLER \
__local_syscall_error: \
MOV D1Re0, D1RtP; \
@@ -46,7 +36,6 @@ __local_syscall_error: \
GETD D1RtP, [A0StP+#-4]; \
SUB A0StP, A0StP, #0x8; \
MOV PC, D1RtP;
-# endif
#else
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
# define SYSCALL_ERROR ___syscall_error
diff --git a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
index a24cd12..2c1c079 100644
--- a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/mips/jmpbuf-unwind.h b/libc/sysdeps/linux/mips/jmpbuf-unwind.h
index 2c0df95..3242eae 100644
--- a/libc/sysdeps/linux/mips/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/mips/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
index 64cd55f..c22ab24 100644
--- a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h b/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
index 54322b8..d650b32 100644
--- a/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/sh/jmpbuf-unwind.h b/libc/sysdeps/linux/sh/jmpbuf-unwind.h
index 8875cc1..34977df 100644
--- a/libc/sysdeps/linux/sh/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/sh/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/sh/sysdep.h b/libc/sysdeps/linux/sh/sysdep.h
index 137dd1d..56fa3f7 100644
--- a/libc/sysdeps/linux/sh/sysdep.h
+++ b/libc/sysdeps/linux/sh/sysdep.h
@@ -130,22 +130,7 @@
#include <libc/sysdeps/linux/sh/syscall_error.S>
#else
-# ifdef RTLD_PRIVATE_ERRNO
-
-# define SYSCALL_ERROR_HANDLER \
- neg r0,r1; \
- mov.l 0f,r12; \
- mova 0f,r0; \
- add r0,r12; \
- mov.l 1f,r0; \
- mov.l r1,@(r0,r12)
- bra .Lpseudo_end; \
- mov _IMM1,r0; \
- .align 2; \
- 0: .long _GLOBAL_OFFSET_TABLE_; \
- 1: .long rtld_errno@GOTOFF
-
-# elif defined _LIBC_REENTRANT
+# if defined _LIBC_REENTRANT
# if defined USE___THREAD
diff --git a/libc/sysdeps/linux/sparc/jmpbuf-unwind.h b/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
index 90efb77..31449d8 100644
--- a/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h b/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
index 1525872..b3f39b5 100644
--- a/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/x86_64/sysdep.h b/libc/sysdeps/linux/x86_64/sysdep.h
index a5971d7..61d2be8 100644
--- a/libc/sysdeps/linux/x86_64/sysdep.h
+++ b/libc/sysdeps/linux/x86_64/sysdep.h
@@ -167,15 +167,6 @@ lose: \
# ifndef __PIC__
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
-# elif defined(RTLD_PRIVATE_ERRNO)
-# define SYSCALL_ERROR_HANDLER \
-0: \
- leaq rtld_errno(%rip), %rcx; \
- xorl %edx, %edx; \
- subq %rax, %rdx; \
- movl %edx, (%rcx); \
- orq $-1, %rax; \
- jmp L(pseudo_end);
# elif USE___THREAD
# ifndef NOT_IN_libc
# define SYSCALL_ERROR_ERRNO __libc_errno
diff --git a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
index 4516d93..13161e9 100644
--- a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
deleted file mode 100644
index 2f64e7d..0000000
--- a/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
deleted file mode 100644
index 11a043b..0000000
--- a/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
deleted file mode 100644
index 11a043b..0000000
--- a/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
deleted file mode 100644
index 2f64e7d..0000000
--- a/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
deleted file mode 100644
index b3da6bd..0000000
--- a/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) > (void *) demangle (jmpbuf[JB_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) > (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
-
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
deleted file mode 100644
index 9739efd..0000000
--- a/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[0].__sp - (_adj))
diff --git a/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
deleted file mode 100644
index 4a88b04..0000000
--- a/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_GPR1] - (_adj))
diff --git a/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
deleted file mode 100644
index 2f7f852..0000000
--- a/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(jmpbuf, address, adj) \
- ((uintptr_t) (address) - (adj) < (uintptr_t) (jmpbuf)[0].__regs[7] - (adj))
diff --git a/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
deleted file mode 100644
index 2f64e7d..0000000
--- a/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
deleted file mode 100644
index 304bf85..0000000
--- a/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_RSP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
deleted file mode 100644
index bda498b..0000000
--- a/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[JB_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/test/tls/tls-macros-alpha.h b/test/tls/tls-macros-alpha.h
new file mode 100644
index 0000000..78820ec
--- /dev/null
+++ b/test/tls/tls-macros-alpha.h
@@ -0,0 +1,25 @@
+register void *__gp __asm__("$29");
+
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
+ __l; })
+
+# define TLS_IE(x) \
+ ({ char *__tp; unsigned long __o; \
+ __asm__ ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
+ : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
+ (int *)(__tp + __o); })
+
+# define TLS_LD(x) \
+ ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
+ __asm__ ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
+ __i = __tls_get_addr(__i); \
+ __asm__ ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
+ __l; })
+
+# define TLS_GD(x) \
+ ({ extern void *__tls_get_addr(void *); void *__i; \
+ __asm__ ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
+ (int *) __tls_get_addr(__i); })
+
diff --git a/test/tls/tls-macros-arc.h b/test/tls/tls-macros-arc.h
new file mode 100644
index 0000000..4b2d6f8
--- /dev/null
+++ b/test/tls/tls-macros-arc.h
@@ -0,0 +1,28 @@
+/* For now */
+#define TLS_LD(x) TLS_IE(x)
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ __asm__ ("add r0, pcl, @" #x "@tlsgd \n" \
+ ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n" \
+ "mov %0, r0 \n" \
+ : "=&r" (__result) \
+ ::"r0","r1","r2","r3","r4","r5","r6","r7", \
+ "r8","r9","r10","r11","r12"); \
+ __result; })
+
+#define TLS_LE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer(); \
+ __asm__ ("add %0, %1, @" #x "@tpoff \n" \
+ : "=r" (__result) : "r"(tp)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer(); \
+ __asm__ ("ld %0, [pcl, @" #x "@tlsie] \n" \
+ "add %0, %1, %0 \n" \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
diff --git a/test/tls/tls-macros-i386.h b/test/tls/tls-macros-i386.h
new file mode 100644
index 0000000..6690753
--- /dev/null
+++ b/test/tls/tls-macros-i386.h
@@ -0,0 +1,76 @@
+#define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("movl %%gs:0,%0\n\t" \
+ "subl $" #x "@tpoff,%0" \
+ : "=r" (__l)); \
+ __l; })
+
+#ifdef __PIC__
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("movl %%gs:0,%0\n\t" \
+ "subl " #x "@gottpoff(%%ebx),%0" \
+ : "=r" (__l)); \
+ __l; })
+#else
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "movl %%gs:0,%0\n\t" \
+ "subl " #x "@gottpoff(%%ebx),%0" \
+ : "=r" (__l)); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_LD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "leal " #x "@dtpoff(%%eax), %%eax" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#else
+# define TLS_LD(x) \
+ ({ int *__l, __b, __c, __d; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "leal " #x "@dtpoff(%%eax), %%eax" \
+ : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "nop" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#else
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "nop" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#endif
diff --git a/test/tls/tls-macros-ia64.h b/test/tls/tls-macros-ia64.h
new file mode 100644
index 0000000..2584020
--- /dev/null
+++ b/test/tls/tls-macros-ia64.h
@@ -0,0 +1,63 @@
+#define TLS_LE(x) \
+ ({ void *__l; \
+ __asm__ ("mov r2=r13\n\t" \
+ ";;\n\t" \
+ "addl %0=@tprel(" #x "),r2\n\t" \
+ : "=r" (__l) : : "r2" ); __l; })
+
+#define TLS_IE(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
+ ";;\n\t" \
+ "ld8 r17=[r16]\n\t" \
+ ";;\n\t" \
+ "add %0=r13,r17\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
+
+#define __TLS_CALL_CLOBBERS \
+ "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
+ "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
+ "r27", "r28", "r29", "r30", "r31", \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ "b6", "b7", \
+ "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
+
+#define TLS_LD(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "mov loc0=gp\n\t" \
+ "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
+ "addl out1=@dtprel(" #x "),r0\n\t" \
+ ";;\n\t" \
+ "ld8 out0=[r16]\n\t" \
+ "br.call.sptk.many b0=__tls_get_addr" \
+ ";;\n\t" \
+ "mov gp=loc0\n\t" \
+ "mov %0=r8\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
+ __l; })
+
+#define TLS_GD(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "mov loc0=gp\n\t" \
+ "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
+ "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
+ ";;\n\t" \
+ "ld8 out0=[r16]\n\t" \
+ "ld8 out1=[r17]\n\t" \
+ "br.call.sptk.many b0=__tls_get_addr" \
+ ";;\n\t" \
+ "mov gp=loc0\n\t" \
+ "mov %0=r8\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
+ __l; })
+
diff --git a/test/tls/tls-macros-metag.h b/test/tls/tls-macros-metag.h
new file mode 100644
index 0000000..5533ecd
--- /dev/null
+++ b/test/tls/tls-macros-metag.h
@@ -0,0 +1,38 @@
+#define TLS_GD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("MOV %0, A1LbP\n\t" \
+ "ADD %0, %0, #(" #x "@TLSGD)" \
+ : "=d" (__result)); \
+ (int *)__tls_get_addr (__result); })
+
+#define TLS_LD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("MOV %0, A1LbP\n\t" \
+ "ADD %0, %0, #(" #x "@TLSLDM)" \
+ : "=d" (__result)); \
+ __result = __tls_get_addr (__result); \
+ __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLDO)\n\t" \
+ "ADD %0,%0,#LO(" #x "@TLSLDO)" \
+ : "+d" (__result)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ void *__result; \
+ unsigned long __rel; \
+ extern void *__metag_load_tp (void); \
+ __asm__ ("GETD %0,[A1LbP+#(" #x "@TLSIE)]" \
+ : "=d" (__rel)); \
+ __result = __metag_load_tp(); \
+ __result + __rel; })
+
+#define TLS_LE(x) \
+ ({ void *__result; \
+ extern void *__metag_load_tp (void); \
+ __result = __metag_load_tp(); \
+ __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLE)\n\t" \
+ "ADD %0,%0,#LO(" #x "@TLSLE)" \
+ : "+d" (__result)); \
+ __result; })
+
diff --git a/test/tls/tls-macros-powerpc.h b/test/tls/tls-macros-powerpc.h
new file mode 100644
index 0000000..ef293bb
--- /dev/null
+++ b/test/tls/tls-macros-powerpc.h
@@ -0,0 +1,87 @@
+#define __TLS_CALL_CLOBBERS \
+ "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
+ "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
+
+/* PowerPC32 Local Exec TLS access. */
+#define TLS_LE(x) \
+ ({ int *__result; \
+ __asm__ ("addi %0,2," #x "@tprel" \
+ : "=r" (__result)); \
+ __result; })
+
+/* PowerPC32 Initial Exec TLS access. */
+#ifdef HAVE_ASM_PPC_REL16
+# define TLS_IE(x) \
+ ({ int *__result; \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr %0\n\t" \
+ "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
+ __result; })
+#else
+# define TLS_IE(x) \
+ ({ int *__result; \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr %0\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
+ __result; })
+#endif
+
+/* PowerPC32 Local Dynamic TLS access. */
+#ifdef HAVE_ASM_PPC_REL16
+# define TLS_LD(x) \
+ ({ int *__result; \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#else
+# define TLS_LD(x) \
+ ({ int *__result; \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#endif
+
+/* PowerPC32 General Dynamic TLS access. */
+#ifdef HAVE_ASM_PPC_REL16
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#else
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#endif
diff --git a/test/tls/tls-macros-sh.h b/test/tls/tls-macros-sh.h
new file mode 100644
index 0000000..f84399c
--- /dev/null
+++ b/test/tls/tls-macros-sh.h
@@ -0,0 +1,143 @@
+#define TLS_LE(x) \
+ ({ int *__l; void *__tp; \
+ __asm__ ("stc gbr,%1\n\t" \
+ "mov.l 1f,%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tpoff\n\t" \
+ "2:" \
+ : "=r" (__l), "=r" (__tp)); \
+ __l; })
+
+#ifdef __PIC__
+# define TLS_IE(x) \
+ ({ int *__l; void *__tp; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r0\n\t" \
+ "stc gbr,%1\n\t" \
+ "mov.l @(r0,r12),%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@gottpoff\n\t" \
+ "2:" \
+ : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
+ __l; })
+#else
+# define TLS_IE(x) \
+ ({ int *__l; void *__tp; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r0\n\t" \
+ "stc gbr,%1\n\t" \
+ "mov.l @(r0,r12),%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@gottpoff\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "2: mov.l @r15+,r12" \
+ : "=r" (__l), "=r" (__tp) : : "r0"); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_LD(x) \
+ ({ int *__l; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 4f\n\t" \
+ " nop\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsldm\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "4: mov.l 3f,%0\n\t" \
+ "bra 5f\n\t" \
+ " add r0,%0\n\t" \
+ ".align 2\n\t" \
+ "3: .long " #x "@dtpoff\n\t" \
+ "5:" \
+ : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
+ "r6", "r7", "pr", "t"); \
+ __l; })
+#else
+# define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 4f\n\t" \
+ " nop\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsldm\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "4: mov.l 3f,%0\n\t" \
+ "bra 5f\n\t" \
+ " add r0,%0\n\t" \
+ ".align 2\n\t" \
+ "3: .long " #x "@dtpoff\n\t" \
+ "5: mov.l @r15+,r12" \
+ : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
+ "pr", "t"); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_GD(x) \
+ ({ int *__l; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 3f\n\t" \
+ " mov r0,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsgd\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "3:" \
+ : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
+ "r6", "r7", "pr", "t"); \
+ __l; })
+#else
+# define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 3f\n\t" \
+ " mov r0,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsgd\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "3: mov.l @r15+,r12" \
+ : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
+ "pr", "t"); \
+ __l; })
+#endif
diff --git a/test/tls/tls-macros-sparc.h b/test/tls/tls-macros-sparc.h
new file mode 100644
index 0000000..710ced1
--- /dev/null
+++ b/test/tls/tls-macros-sparc.h
@@ -0,0 +1,67 @@
+#define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+#ifdef __PIC__
+# define TLS_LOAD_PIC \
+ ({ register long pc __asm__ ("%o7"); \
+ long got; \
+ __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
+ "call .+8\n\t" \
+ "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
+ "add %1, %0, %1\n\t" \
+ : "=r" (pc), "=r" (got)); \
+ got; })
+#else
+# define TLS_LOAD_PIC \
+ ({ long got; \
+ __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
+ "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
+ "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
+ : "=r" (got)); \
+ got; })
+#endif
+
+#define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
+ : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ long __o; \
+ __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
+ __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
+ __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
+ : "r" (__o0), "r" (__o)); \
+ __l; })
+
+#define TLS_GD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __o0; })
+
diff --git a/test/tls/tls-macros-x86_64.h b/test/tls/tls-macros-x86_64.h
new file mode 100644
index 0000000..b8a8b71
--- /dev/null
+++ b/test/tls/tls-macros-x86_64.h
@@ -0,0 +1,40 @@
+#define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("mov %%fs:0,%0\n\t" \
+ "lea " #x "@tpoff(%0), %0" \
+ : "=r" (__l)); \
+ __l; })
+
+#define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("mov %%fs:0,%0\n\t" \
+ "add " #x "@gottpoff(%%rip),%0" \
+ : "=r" (__l)); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
+ "call __tls_get_addr@plt\n\t" \
+ "leaq " #x "@dtpoff(%%rax), %%rax" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d) \
+ : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
+ __l; })
+
+#ifdef __ILP32__
+# define TLS_GD_PREFIX
+#else
+# define TLS_GD_PREFIX ".byte 0x66\n\t"
+#endif
+
+#define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ (TLS_GD_PREFIX \
+ "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
+ ".word 0x6666\n\t" \
+ "rex64\n\t" \
+ "call __tls_get_addr@plt" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d) \
+ : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
+ __l; })
+
diff --git a/test/tls/tls-macros-xtensa.h b/test/tls/tls-macros-xtensa.h
new file mode 100644
index 0000000..179dc5e
--- /dev/null
+++ b/test/tls/tls-macros-xtensa.h
@@ -0,0 +1,61 @@
+#if defined(__XTENSA_WINDOWED_ABI__)
+#define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a8, " #x "@TLSFUNC\n\t" \
+ "movi a10, " #x "@TLSARG\n\t" \
+ "callx8.tls a8, " #x "@TLSCALL\n\t" \
+ "mov %0, a10\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a8, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
+ "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t" \
+ "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t" \
+ "movi %0, " #x "@TPOFF\n\t" \
+ "add %0, %0, a10\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
+ __l; })
+#elif defined(__XTENSA_CALL0_ABI__)
+#define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
+ "movi a2, " #x "@TLSARG\n\t" \
+ "callx0.tls a0, " #x "@TLSCALL\n\t" \
+ "mov %0, a2\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a0, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
+ "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t" \
+ "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t" \
+ "movi %0, " #x "@TPOFF\n\t" \
+ "add %0, %0, a2\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
+ __l; })
+#else
+#error Unsupported Xtensa ABI
+#endif
+
+#define TLS_IE(x) TLS_LE(x)
+
+#define TLS_LE(x) \
+ ({ int *__l; \
+ int __t; \
+ __asm__ ("rur %0, threadptr\n\t" \
+ "movi %1, " #x "@TPOFF\n\t" \
+ "add %0, %0, %1\n\t" \
+ : "=r" (__l), "=r" (__t) ); \
+ __l; }); \
+
diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h
index e4d87f2..0300dba 100644
--- a/test/tls/tls-macros.h
+++ b/test/tls/tls-macros.h
@@ -16,8 +16,12 @@
/* XXX Until we get compiler support we don't need declarations. */
#define VAR_INT_DECL(x)
-#ifdef __mips__
-#include <tls-macros-mips.h>
+#ifdef __alpha__
+#include <tls-macros-alpha.h>
+#endif
+
+#ifdef __arc__
+#include <tls-macros-arc.h>
#endif
#ifdef __arm__
@@ -28,973 +32,43 @@
#endif
#endif
- /* XXX Each architecture must have its own asm for now. */
#ifdef __i386__
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("movl %%gs:0,%0\n\t" \
- "subl $" #x "@tpoff,%0" \
- : "=r" (__l)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("movl %%gs:0,%0\n\t" \
- "subl " #x "@gottpoff(%%ebx),%0" \
- : "=r" (__l)); \
- __l; })
-# else
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("call 1f\n\t" \
- ".subsection 1\n" \
- "1:\tmovl (%%esp), %%ebx\n\t" \
- "ret\n\t" \
- ".previous\n\t" \
- "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
- "movl %%gs:0,%0\n\t" \
- "subl " #x "@gottpoff(%%ebx),%0" \
- : "=r" (__l)); \
- __l; })
-# endif
-
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "leal " #x "@dtpoff(%%eax), %%eax" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# else
-# define TLS_LD(x) \
- ({ int *__l, __b, __c, __d; \
- __asm__ ("call 1f\n\t" \
- ".subsection 1\n" \
- "1:\tmovl (%%esp), %%ebx\n\t" \
- "ret\n\t" \
- ".previous\n\t" \
- "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
- "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "leal " #x "@dtpoff(%%eax), %%eax" \
- : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# endif
-
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "nop" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# else
-# define TLS_GD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("call 1f\n\t" \
- ".subsection 1\n" \
- "1:\tmovl (%%esp), %%ebx\n\t" \
- "ret\n\t" \
- ".previous\n\t" \
- "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
- "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "nop" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# endif
-
-#elif defined __x86_64__
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("mov %%fs:0,%0\n\t" \
- "lea " #x "@tpoff(%0), %0" \
- : "=r" (__l)); \
- __l; })
-
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("mov %%fs:0,%0\n\t" \
- "add " #x "@gottpoff(%%rip),%0" \
- : "=r" (__l)); \
- __l; })
-
-# define TLS_LD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
- "call __tls_get_addr@plt\n\t" \
- "leaq " #x "@dtpoff(%%rax), %%rax" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d) \
- : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
- __l; })
-
-# ifdef __ILP32__
-# define TLS_GD_PREFIX
-# else
-# define TLS_GD_PREFIX ".byte 0x66\n\t"
-# endif
-
-# define TLS_GD(x) \
- ({ int *__l, __c, __d; \
- __asm__ (TLS_GD_PREFIX \
- "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
- ".word 0x6666\n\t" \
- "rex64\n\t" \
- "call __tls_get_addr@plt" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d) \
- : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
- __l; })
-
-#elif defined __sh__
-
-# define TLS_LE(x) \
- ({ int *__l; void *__tp; \
- __asm__ ("stc gbr,%1\n\t" \
- "mov.l 1f,%0\n\t" \
- "bra 2f\n\t" \
- " add %1,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tpoff\n\t" \
- "2:" \
- : "=r" (__l), "=r" (__tp)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ int *__l; void *__tp; \
- register void *__gp __asm__("r12"); \
- __asm__ ("mov.l 1f,r0\n\t" \
- "stc gbr,%1\n\t" \
- "mov.l @(r0,r12),%0\n\t" \
- "bra 2f\n\t" \
- " add %1,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@gottpoff\n\t" \
- "2:" \
- : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
- __l; })
-# else
-# define TLS_IE(x) \
- ({ int *__l; void *__tp; \
- __asm__ ("mov.l r12,@-r15\n\t" \
- "mova 0f,r0\n\t" \
- "mov.l 0f,r12\n\t" \
- "add r0,r12\n\t" \
- "mov.l 1f,r0\n\t" \
- "stc gbr,%1\n\t" \
- "mov.l @(r0,r12),%0\n\t" \
- "bra 2f\n\t" \
- " add %1,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@gottpoff\n\t" \
- "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
- "2: mov.l @r15+,r12" \
- : "=r" (__l), "=r" (__tp) : : "r0"); \
- __l; })
+#include <tls-macros-i386.h>
#endif
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ int *__l; \
- register void *__gp __asm__("r12"); \
- __asm__ ("mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 4f\n\t" \
- " nop\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsldm\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "4: mov.l 3f,%0\n\t" \
- "bra 5f\n\t" \
- " add r0,%0\n\t" \
- ".align 2\n\t" \
- "3: .long " #x "@dtpoff\n\t" \
- "5:" \
- : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
- "r6", "r7", "pr", "t"); \
- __l; })
-# else
-# define TLS_LD(x) \
- ({ int *__l; \
- __asm__ ("mov.l r12,@-r15\n\t" \
- "mova 0f,r0\n\t" \
- "mov.l 0f,r12\n\t" \
- "add r0,r12\n\t" \
- "mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 4f\n\t" \
- " nop\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsldm\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
- "4: mov.l 3f,%0\n\t" \
- "bra 5f\n\t" \
- " add r0,%0\n\t" \
- ".align 2\n\t" \
- "3: .long " #x "@dtpoff\n\t" \
- "5: mov.l @r15+,r12" \
- : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
- "pr", "t"); \
- __l; })
+#ifdef __ia64__
+#include <tls-macros-ia64.h>
#endif
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ int *__l; \
- register void *__gp __asm__("r12"); \
- __asm__ ("mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 3f\n\t" \
- " mov r0,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsgd\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "3:" \
- : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
- "r6", "r7", "pr", "t"); \
- __l; })
-# else
-# define TLS_GD(x) \
- ({ int *__l; \
- __asm__ ("mov.l r12,@-r15\n\t" \
- "mova 0f,r0\n\t" \
- "mov.l 0f,r12\n\t" \
- "add r0,r12\n\t" \
- "mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 3f\n\t" \
- " mov r0,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsgd\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
- "3: mov.l @r15+,r12" \
- : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
- "pr", "t"); \
- __l; })
+#ifdef __metag__
+#include <tls-macros-metag.h>
#endif
-#elif defined __alpha__
-
-register void *__gp __asm__("$29");
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
- __l; })
-
-# define TLS_IE(x) \
- ({ char *__tp; unsigned long __o; \
- __asm__ ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
- : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
- (int *)(__tp + __o); })
-
-# define TLS_LD(x) \
- ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
- __asm__ ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
- __i = __tls_get_addr(__i); \
- __asm__ ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
- __l; })
-
-# define TLS_GD(x) \
- ({ extern void *__tls_get_addr(void *); void *__i; \
- __asm__ ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
- (int *) __tls_get_addr(__i); })
-
-
-#elif defined __ia64__
-
-# define TLS_LE(x) \
- ({ void *__l; \
- __asm__ ("mov r2=r13\n\t" \
- ";;\n\t" \
- "addl %0=@tprel(" #x "),r2\n\t" \
- : "=r" (__l) : : "r2" ); __l; })
-
-# define TLS_IE(x) \
- ({ void *__l; \
- register long __gp __asm__ ("gp"); \
- __asm__ (";;\n\t" \
- "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
- ";;\n\t" \
- "ld8 r17=[r16]\n\t" \
- ";;\n\t" \
- "add %0=r13,r17\n\t" \
- ";;\n\t" \
- : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
-
-# define __TLS_CALL_CLOBBERS \
- "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
- "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
- "r27", "r28", "r29", "r30", "r31", \
- "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
- "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
- "b6", "b7", \
- "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
-
-# define TLS_LD(x) \
- ({ void *__l; \
- register long __gp __asm__ ("gp"); \
- __asm__ (";;\n\t" \
- "mov loc0=gp\n\t" \
- "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
- "addl out1=@dtprel(" #x "),r0\n\t" \
- ";;\n\t" \
- "ld8 out0=[r16]\n\t" \
- "br.call.sptk.many b0=__tls_get_addr" \
- ";;\n\t" \
- "mov gp=loc0\n\t" \
- "mov %0=r8\n\t" \
- ";;\n\t" \
- : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
- __l; })
-
-# define TLS_GD(x) \
- ({ void *__l; \
- register long __gp __asm__ ("gp"); \
- __asm__ (";;\n\t" \
- "mov loc0=gp\n\t" \
- "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
- "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
- ";;\n\t" \
- "ld8 out0=[r16]\n\t" \
- "ld8 out1=[r17]\n\t" \
- "br.call.sptk.many b0=__tls_get_addr" \
- ";;\n\t" \
- "mov gp=loc0\n\t" \
- "mov %0=r8\n\t" \
- ";;\n\t" \
- : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
- __l; })
-
-#elif defined __sparc__ && !defined __arch64__
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_LOAD_PIC \
- ({ register long pc __asm__ ("%o7"); \
- long got; \
- __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
- "call .+8\n\t" \
- "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
- "add %1, %0, %1\n\t" \
- : "=r" (pc), "=r" (got)); \
- got; })
-# else
-# define TLS_LOAD_PIC \
- ({ long got; \
- __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
- "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
- "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
- : "=r" (got)); \
- got; })
-# endif
-
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
- : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# define TLS_LD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- long __o; \
- __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
- __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
- __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
- : "r" (__o0), "r" (__o)); \
- __l; })
-
-# define TLS_GD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __o0; })
-
-#elif defined __sparc__ && defined __arch64__
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_LOAD_PIC \
- ({ long pc, got; \
- __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
- "rd %%pc, %0\n\t" \
- "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
- "add %1, %0, %1\n\t" \
- : "=r" (pc), "=r" (got)); \
- got; })
-# else
-# define TLS_LOAD_PIC \
- ({ long got; \
- __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
- "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
- "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
- : "=r" (got)); \
- got; })
-# endif
-
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("ldx [%1 + %2], %0, %%tie_ldx(" #x ")" \
- : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# define TLS_LD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- long __o; \
- __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
- __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
- __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
- : "r" (__o0), "r" (__o)); \
- __l; })
-
-# define TLS_GD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __o0; })
-
-#elif defined __s390x__
-
-# define TLS_LE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@ntpoff\n" \
- "1:\tlg %0,0(%0)" \
- : "=a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@gotntpoff\n" \
- "1:\tlg %0,0(%0)\n\t" \
- "lg %0,0(%0,%%r12):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@indntpoff\n" \
- "1:\t lg %0,0(%0)\n\t" \
- "lg %0,0(%0):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsldm\n\t" \
- ".quad " #x "@dtpoff\n" \
- "1:\tlgr %1,%%r12\n\t" \
- "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
- "lg %0,8(%0)\n\t" \
- "algr %0,%%r2\n\t" \
- "lgr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_LD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsldm\n\t" \
- ".quad " #x "@dtpoff\n" \
- "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
- "lg %0,8(%0)\n\t" \
- "algr %0,%%r2" \
- : "=&a" (__offset) \
- : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsgd\n" \
- "1:\tlgr %1,%%r12\n\t" \
- "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
- "lgr %0,%%r2\n\t" \
- "lgr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_GD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsgd\n" \
- "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
- "lgr %0,%%r2" \
- : "=&a" (__offset) \
- : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-#elif defined __s390__
-
-# define TLS_LE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long " #x "@ntpoff\n" \
- "1:\tl %0,0(%0)" \
- : "=a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long " #x "@gotntpoff\n" \
- "1:\tl %0,0(%0)\n\t" \
- "l %0,0(%0,%%r12):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long " #x "@indntpoff\n" \
- "1:\t l %0,0(%0)\n\t" \
- "l %0,0(%0):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
- ".long __tls_get_offset@plt-0b\n\t" \
- ".long " #x "@tlsldm\n\t" \
- ".long " #x "@dtpoff\n" \
- "1:\tlr %1,%%r12\n\t" \
- "l %%r12,0(%0)\n\t" \
- "la %%r12,0(%%r12,%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t" \
- "l %0,12(%0)\n\t" \
- "alr %0,%%r2\n\t" \
- "lr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_LD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
- ".long __tls_get_offset@plt\n\t" \
- ".long " #x "@tlsldm\n\t" \
- ".long " #x "@dtpoff\n" \
- "1:\tl %%r12,0(%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t" \
- "l %0,12(%0)\n\t" \
- "alr %0,%%r2" \
- : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
- ".long __tls_get_offset@plt-0b\n\t" \
- ".long " #x "@tlsgd\n" \
- "1:\tlr %1,%%r12\n\t" \
- "l %%r12,0(%0)\n\t" \
- "la %%r12,0(%%r12,%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t" \
- "lr %0,%%r2\n\t" \
- "lr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_GD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
- ".long __tls_get_offset@plt\n\t" \
- ".long " #x "@tlsgd\n" \
- "1:\tl %%r12,0(%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t" \
- "lr %0,%%r2" \
- : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-#elif defined __powerpc__ && !defined __powerpc64__
-
-/*#include "config.h"*/
-
-# define __TLS_CALL_CLOBBERS \
- "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
- "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
-
-/* PowerPC32 Local Exec TLS access. */
-# define TLS_LE(x) \
- ({ int *__result; \
- __asm__ ("addi %0,2," #x "@tprel" \
- : "=r" (__result)); \
- __result; })
-
-/* PowerPC32 Initial Exec TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_IE(x) \
- ({ int *__result; \
- __asm__ ("bcl 20,31,1f\n1:\t" \
- "mflr %0\n\t" \
- "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "lwz %0," #x "@got@tprel(%0)\n\t" \
- "add %0,%0," #x "@tls" \
- : "=b" (__result) : \
- : "lr"); \
- __result; })
-# else
-# define TLS_IE(x) \
- ({ int *__result; \
- __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr %0\n\t" \
- "lwz %0," #x "@got@tprel(%0)\n\t" \
- "add %0,%0," #x "@tls" \
- : "=b" (__result) : \
- : "lr"); \
- __result; })
-# endif
-
-/* PowerPC32 Local Dynamic TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_LD(x) \
- ({ int *__result; \
- __asm__ ("bcl 20,31,1f\n1:\t" \
- "mflr 3\n\t" \
- "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "addi 3,3," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr@plt\n\t" \
- "addi %0,3," #x "@dtprel" \
- : "=r" (__result) : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# else
-# define TLS_LD(x) \
- ({ int *__result; \
- __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr 3\n\t" \
- "addi 3,3," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr@plt\n\t" \
- "addi %0,3," #x "@dtprel" \
- : "=r" (__result) : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# endif
-
-/* PowerPC32 General Dynamic TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_GD(x) \
- ({ register int *__result __asm__ ("r3"); \
- __asm__ ("bcl 20,31,1f\n1:\t" \
- "mflr 3\n\t" \
- "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "addi 3,3," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr@plt" \
- : : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# else
-# define TLS_GD(x) \
- ({ register int *__result __asm__ ("r3"); \
- __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr 3\n\t" \
- "addi 3,3," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr@plt" \
- : : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# endif
-
-#elif defined __powerpc__ && defined __powerpc64__
-
-/* PowerPC64 Local Exec TLS access. */
-# define TLS_LE(x) \
- ({ int * __result; \
- __asm__ ( \
- " addis %0,13," #x "@tprel@ha\n" \
- " addi %0,%0," #x "@tprel@l\n" \
- : "=b" (__result) ); \
- __result; \
- })
-/* PowerPC64 Initial Exec TLS access. */
-# define TLS_IE(x) \
- ({ int * __result; \
- __asm__ ( \
- " ld %0," #x "@got@tprel(2)\n" \
- " add %0,%0," #x "@tls\n" \
- : "=b" (__result) ); \
- __result; \
- })
-/* PowerPC64 Local Dynamic TLS access. */
-# define TLS_LD(x) \
- ({ int * __result; \
- __asm__ ( \
- " addi 3,2," #x "@got@tlsld\n" \
- " bl .__tls_get_addr\n" \
- " nop \n" \
- " addis %0,3," #x "@dtprel@ha\n" \
- " addi %0,%0," #x "@dtprel@l\n" \
- : "=b" (__result) : \
- : "0", "3", "4", "5", "6", "7", \
- "8", "9", "10", "11", "12", \
- "lr", "ctr", \
- "cr0", "cr1", "cr5", "cr6", "cr7"); \
- __result; \
- })
-/* PowerPC64 General Dynamic TLS access. */
-# define TLS_GD(x) \
- ({ int * __result; \
- __asm__ ( \
- " addi 3,2," #x "@got@tlsgd\n" \
- " bl .__tls_get_addr\n" \
- " nop \n" \
- " mr %0,3\n" \
- : "=b" (__result) : \
- : "0", "3", "4", "5", "6", "7", \
- "8", "9", "10", "11", "12", \
- "lr", "ctr", \
- "cr0", "cr1", "cr5", "cr6", "cr7"); \
- __result; \
- })
-
-#elif defined __arc__
-
-/* For now */
-#define TLS_LD(x) TLS_IE(x)
-
-#define TLS_GD(x) \
- ({ int *__result; \
- __asm__ ("add r0, pcl, @" #x "@tlsgd \n" \
- ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n" \
- "mov %0, r0 \n" \
- : "=&r" (__result) \
- ::"r0","r1","r2","r3","r4","r5","r6","r7", \
- "r8","r9","r10","r11","r12"); \
- __result; })
-
-#define TLS_LE(x) \
- ({ int *__result; \
- void *tp = __builtin_thread_pointer(); \
- __asm__ ("add %0, %1, @" #x "@tpoff \n" \
- : "=r" (__result) : "r"(tp)); \
- __result; })
-
-#define TLS_IE(x) \
- ({ int *__result; \
- void *tp = __builtin_thread_pointer(); \
- __asm__ ("ld %0, [pcl, @" #x "@tlsie] \n" \
- "add %0, %1, %0 \n" \
- : "=&r" (__result) : "r" (tp)); \
- __result; })
-
-#elif defined __xtensa__
-
-#if defined(__XTENSA_WINDOWED_ABI__)
-#define TLS_GD(x) \
- ({ int *__l; \
- __asm__ ("movi a8, " #x "@TLSFUNC\n\t" \
- "movi a10, " #x "@TLSARG\n\t" \
- "callx8.tls a8, " #x "@TLSCALL\n\t" \
- "mov %0, a10\n\t" \
- : "=r" (__l) \
- : \
- : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
- __l; })
-
-#define TLS_LD(x) \
- ({ int *__l; \
- __asm__ ("movi a8, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
- "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t" \
- "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t" \
- "movi %0, " #x "@TPOFF\n\t" \
- "add %0, %0, a10\n\t" \
- : "=r" (__l) \
- : \
- : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
- __l; })
-#elif defined(__XTENSA_CALL0_ABI__)
-#define TLS_GD(x) \
- ({ int *__l; \
- __asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
- "movi a2, " #x "@TLSARG\n\t" \
- "callx0.tls a0, " #x "@TLSCALL\n\t" \
- "mov %0, a2\n\t" \
- : "=r" (__l) \
- : \
- : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
- __l; })
-
-#define TLS_LD(x) \
- ({ int *__l; \
- __asm__ ("movi a0, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
- "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t" \
- "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t" \
- "movi %0, " #x "@TPOFF\n\t" \
- "add %0, %0, a2\n\t" \
- : "=r" (__l) \
- : \
- : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
- __l; })
-#else
-#error Unsupported Xtensa ABI
+#ifdef __mips__
+#include <tls-macros-mips.h>
#endif
-#define TLS_IE(x) TLS_LE(x)
-
-#define TLS_LE(x) \
- ({ int *__l; \
- int __t; \
- __asm__ ("rur %0, threadptr\n\t" \
- "movi %1, " #x "@TPOFF\n\t" \
- "add %0, %0, %1\n\t" \
- : "=r" (__l), "=r" (__t) ); \
- __l; }); \
-
-#elif defined __metag__
+#ifdef __powerpc__
+#include <tls-macros-powerpc.h>
+#endif
-# define TLS_GD(x) \
- ({ void *__result; \
- extern void *__tls_get_addr (void *); \
- __asm__ ("MOV %0, A1LbP\n\t" \
- "ADD %0, %0, #(" #x "@TLSGD)" \
- : "=d" (__result)); \
- (int *)__tls_get_addr (__result); })
+#ifdef __sh__
+#include <tls-macros-sh.h>
+#endif
-# define TLS_LD(x) \
- ({ void *__result; \
- extern void *__tls_get_addr (void *); \
- __asm__ ("MOV %0, A1LbP\n\t" \
- "ADD %0, %0, #(" #x "@TLSLDM)" \
- : "=d" (__result)); \
- __result = __tls_get_addr (__result); \
- __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLDO)\n\t" \
- "ADD %0,%0,#LO(" #x "@TLSLDO)" \
- : "+d" (__result)); \
- __result; })
+#ifdef __sparc__
+#include <tls-macros-sparc.h>
+#endif
-# define TLS_IE(x) \
- ({ void *__result; \
- unsigned long __rel; \
- extern void *__metag_load_tp (void); \
- __asm__ ("GETD %0,[A1LbP+#(" #x "@TLSIE)]" \
- : "=d" (__rel)); \
- __result = __metag_load_tp(); \
- __result + __rel; })
+#ifdef __x86_64__
+#include <tls-macros-x86_64.h>
+#endif
-# define TLS_LE(x) \
- ({ void *__result; \
- extern void *__metag_load_tp (void); \
- __result = __metag_load_tp(); \
- __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLE)\n\t" \
- "ADD %0,%0,#LO(" #x "@TLSLE)" \
- : "+d" (__result)); \
- __result; })
+#ifdef __xtensa__
+#include <tls-macros-xtensa.h>
+#endif
-#elif !defined TLS_LE || !defined TLS_IE \
+#if !defined TLS_LE || !defined TLS_IE \
|| !defined TLS_LD || !defined TLS_GD
# error "No support for this architecture so far."
#endif
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
1
0

30 Jul '16
To be more consistent separate all TLS macros in separate files and
remove obsolete macros for not supported architectures.
Signed-off-by: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
---
Any objections?
---
test/tls/tls-macros-alpha.h | 25 ++
test/tls/tls-macros-arc.h | 28 ++
test/tls/tls-macros-i386.h | 76 ++++
test/tls/tls-macros-ia64.h | 63 +++
test/tls/tls-macros-metag.h | 38 ++
test/tls/tls-macros-powerpc.h | 87 ++++
test/tls/tls-macros-sh.h | 143 ++++++
test/tls/tls-macros-sparc.h | 67 +++
test/tls/tls-macros-x86_64.h | 40 ++
test/tls/tls-macros-xtensa.h | 61 +++
test/tls/tls-macros.h | 984 ++---------------------------------------
11 files changed, 657 insertions(+), 955 deletions(-)
create mode 100644 test/tls/tls-macros-alpha.h
create mode 100644 test/tls/tls-macros-arc.h
create mode 100644 test/tls/tls-macros-i386.h
create mode 100644 test/tls/tls-macros-ia64.h
create mode 100644 test/tls/tls-macros-metag.h
create mode 100644 test/tls/tls-macros-powerpc.h
create mode 100644 test/tls/tls-macros-sh.h
create mode 100644 test/tls/tls-macros-sparc.h
create mode 100644 test/tls/tls-macros-x86_64.h
create mode 100644 test/tls/tls-macros-xtensa.h
diff --git a/test/tls/tls-macros-alpha.h b/test/tls/tls-macros-alpha.h
new file mode 100644
index 0000000..78820ec
--- /dev/null
+++ b/test/tls/tls-macros-alpha.h
@@ -0,0 +1,25 @@
+register void *__gp __asm__("$29");
+
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
+ __l; })
+
+# define TLS_IE(x) \
+ ({ char *__tp; unsigned long __o; \
+ __asm__ ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
+ : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
+ (int *)(__tp + __o); })
+
+# define TLS_LD(x) \
+ ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
+ __asm__ ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
+ __i = __tls_get_addr(__i); \
+ __asm__ ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
+ __l; })
+
+# define TLS_GD(x) \
+ ({ extern void *__tls_get_addr(void *); void *__i; \
+ __asm__ ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
+ (int *) __tls_get_addr(__i); })
+
diff --git a/test/tls/tls-macros-arc.h b/test/tls/tls-macros-arc.h
new file mode 100644
index 0000000..4b2d6f8
--- /dev/null
+++ b/test/tls/tls-macros-arc.h
@@ -0,0 +1,28 @@
+/* For now */
+#define TLS_LD(x) TLS_IE(x)
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ __asm__ ("add r0, pcl, @" #x "@tlsgd \n" \
+ ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n" \
+ "mov %0, r0 \n" \
+ : "=&r" (__result) \
+ ::"r0","r1","r2","r3","r4","r5","r6","r7", \
+ "r8","r9","r10","r11","r12"); \
+ __result; })
+
+#define TLS_LE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer(); \
+ __asm__ ("add %0, %1, @" #x "@tpoff \n" \
+ : "=r" (__result) : "r"(tp)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer(); \
+ __asm__ ("ld %0, [pcl, @" #x "@tlsie] \n" \
+ "add %0, %1, %0 \n" \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
diff --git a/test/tls/tls-macros-i386.h b/test/tls/tls-macros-i386.h
new file mode 100644
index 0000000..6690753
--- /dev/null
+++ b/test/tls/tls-macros-i386.h
@@ -0,0 +1,76 @@
+#define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("movl %%gs:0,%0\n\t" \
+ "subl $" #x "@tpoff,%0" \
+ : "=r" (__l)); \
+ __l; })
+
+#ifdef __PIC__
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("movl %%gs:0,%0\n\t" \
+ "subl " #x "@gottpoff(%%ebx),%0" \
+ : "=r" (__l)); \
+ __l; })
+#else
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "movl %%gs:0,%0\n\t" \
+ "subl " #x "@gottpoff(%%ebx),%0" \
+ : "=r" (__l)); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_LD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "leal " #x "@dtpoff(%%eax), %%eax" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#else
+# define TLS_LD(x) \
+ ({ int *__l, __b, __c, __d; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "leal " #x "@dtpoff(%%eax), %%eax" \
+ : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "nop" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#else
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "nop" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+#endif
diff --git a/test/tls/tls-macros-ia64.h b/test/tls/tls-macros-ia64.h
new file mode 100644
index 0000000..2584020
--- /dev/null
+++ b/test/tls/tls-macros-ia64.h
@@ -0,0 +1,63 @@
+#define TLS_LE(x) \
+ ({ void *__l; \
+ __asm__ ("mov r2=r13\n\t" \
+ ";;\n\t" \
+ "addl %0=@tprel(" #x "),r2\n\t" \
+ : "=r" (__l) : : "r2" ); __l; })
+
+#define TLS_IE(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
+ ";;\n\t" \
+ "ld8 r17=[r16]\n\t" \
+ ";;\n\t" \
+ "add %0=r13,r17\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
+
+#define __TLS_CALL_CLOBBERS \
+ "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
+ "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
+ "r27", "r28", "r29", "r30", "r31", \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ "b6", "b7", \
+ "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
+
+#define TLS_LD(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "mov loc0=gp\n\t" \
+ "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
+ "addl out1=@dtprel(" #x "),r0\n\t" \
+ ";;\n\t" \
+ "ld8 out0=[r16]\n\t" \
+ "br.call.sptk.many b0=__tls_get_addr" \
+ ";;\n\t" \
+ "mov gp=loc0\n\t" \
+ "mov %0=r8\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
+ __l; })
+
+#define TLS_GD(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "mov loc0=gp\n\t" \
+ "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
+ "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
+ ";;\n\t" \
+ "ld8 out0=[r16]\n\t" \
+ "ld8 out1=[r17]\n\t" \
+ "br.call.sptk.many b0=__tls_get_addr" \
+ ";;\n\t" \
+ "mov gp=loc0\n\t" \
+ "mov %0=r8\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
+ __l; })
+
diff --git a/test/tls/tls-macros-metag.h b/test/tls/tls-macros-metag.h
new file mode 100644
index 0000000..5533ecd
--- /dev/null
+++ b/test/tls/tls-macros-metag.h
@@ -0,0 +1,38 @@
+#define TLS_GD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("MOV %0, A1LbP\n\t" \
+ "ADD %0, %0, #(" #x "@TLSGD)" \
+ : "=d" (__result)); \
+ (int *)__tls_get_addr (__result); })
+
+#define TLS_LD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("MOV %0, A1LbP\n\t" \
+ "ADD %0, %0, #(" #x "@TLSLDM)" \
+ : "=d" (__result)); \
+ __result = __tls_get_addr (__result); \
+ __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLDO)\n\t" \
+ "ADD %0,%0,#LO(" #x "@TLSLDO)" \
+ : "+d" (__result)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ void *__result; \
+ unsigned long __rel; \
+ extern void *__metag_load_tp (void); \
+ __asm__ ("GETD %0,[A1LbP+#(" #x "@TLSIE)]" \
+ : "=d" (__rel)); \
+ __result = __metag_load_tp(); \
+ __result + __rel; })
+
+#define TLS_LE(x) \
+ ({ void *__result; \
+ extern void *__metag_load_tp (void); \
+ __result = __metag_load_tp(); \
+ __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLE)\n\t" \
+ "ADD %0,%0,#LO(" #x "@TLSLE)" \
+ : "+d" (__result)); \
+ __result; })
+
diff --git a/test/tls/tls-macros-powerpc.h b/test/tls/tls-macros-powerpc.h
new file mode 100644
index 0000000..ef293bb
--- /dev/null
+++ b/test/tls/tls-macros-powerpc.h
@@ -0,0 +1,87 @@
+#define __TLS_CALL_CLOBBERS \
+ "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
+ "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
+
+/* PowerPC32 Local Exec TLS access. */
+#define TLS_LE(x) \
+ ({ int *__result; \
+ __asm__ ("addi %0,2," #x "@tprel" \
+ : "=r" (__result)); \
+ __result; })
+
+/* PowerPC32 Initial Exec TLS access. */
+#ifdef HAVE_ASM_PPC_REL16
+# define TLS_IE(x) \
+ ({ int *__result; \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr %0\n\t" \
+ "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
+ __result; })
+#else
+# define TLS_IE(x) \
+ ({ int *__result; \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr %0\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
+ __result; })
+#endif
+
+/* PowerPC32 Local Dynamic TLS access. */
+#ifdef HAVE_ASM_PPC_REL16
+# define TLS_LD(x) \
+ ({ int *__result; \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#else
+# define TLS_LD(x) \
+ ({ int *__result; \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#endif
+
+/* PowerPC32 General Dynamic TLS access. */
+#ifdef HAVE_ASM_PPC_REL16
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#else
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+#endif
diff --git a/test/tls/tls-macros-sh.h b/test/tls/tls-macros-sh.h
new file mode 100644
index 0000000..f84399c
--- /dev/null
+++ b/test/tls/tls-macros-sh.h
@@ -0,0 +1,143 @@
+#define TLS_LE(x) \
+ ({ int *__l; void *__tp; \
+ __asm__ ("stc gbr,%1\n\t" \
+ "mov.l 1f,%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tpoff\n\t" \
+ "2:" \
+ : "=r" (__l), "=r" (__tp)); \
+ __l; })
+
+#ifdef __PIC__
+# define TLS_IE(x) \
+ ({ int *__l; void *__tp; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r0\n\t" \
+ "stc gbr,%1\n\t" \
+ "mov.l @(r0,r12),%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@gottpoff\n\t" \
+ "2:" \
+ : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
+ __l; })
+#else
+# define TLS_IE(x) \
+ ({ int *__l; void *__tp; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r0\n\t" \
+ "stc gbr,%1\n\t" \
+ "mov.l @(r0,r12),%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@gottpoff\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "2: mov.l @r15+,r12" \
+ : "=r" (__l), "=r" (__tp) : : "r0"); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_LD(x) \
+ ({ int *__l; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 4f\n\t" \
+ " nop\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsldm\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "4: mov.l 3f,%0\n\t" \
+ "bra 5f\n\t" \
+ " add r0,%0\n\t" \
+ ".align 2\n\t" \
+ "3: .long " #x "@dtpoff\n\t" \
+ "5:" \
+ : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
+ "r6", "r7", "pr", "t"); \
+ __l; })
+#else
+# define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 4f\n\t" \
+ " nop\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsldm\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "4: mov.l 3f,%0\n\t" \
+ "bra 5f\n\t" \
+ " add r0,%0\n\t" \
+ ".align 2\n\t" \
+ "3: .long " #x "@dtpoff\n\t" \
+ "5: mov.l @r15+,r12" \
+ : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
+ "pr", "t"); \
+ __l; })
+#endif
+
+#ifdef __PIC__
+# define TLS_GD(x) \
+ ({ int *__l; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 3f\n\t" \
+ " mov r0,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsgd\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "3:" \
+ : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
+ "r6", "r7", "pr", "t"); \
+ __l; })
+#else
+# define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 3f\n\t" \
+ " mov r0,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsgd\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "3: mov.l @r15+,r12" \
+ : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
+ "pr", "t"); \
+ __l; })
+#endif
diff --git a/test/tls/tls-macros-sparc.h b/test/tls/tls-macros-sparc.h
new file mode 100644
index 0000000..710ced1
--- /dev/null
+++ b/test/tls/tls-macros-sparc.h
@@ -0,0 +1,67 @@
+#define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+#ifdef __PIC__
+# define TLS_LOAD_PIC \
+ ({ register long pc __asm__ ("%o7"); \
+ long got; \
+ __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
+ "call .+8\n\t" \
+ "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
+ "add %1, %0, %1\n\t" \
+ : "=r" (pc), "=r" (got)); \
+ got; })
+#else
+# define TLS_LOAD_PIC \
+ ({ long got; \
+ __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
+ "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
+ "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
+ : "=r" (got)); \
+ got; })
+#endif
+
+#define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
+ : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ long __o; \
+ __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
+ __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
+ __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
+ : "r" (__o0), "r" (__o)); \
+ __l; })
+
+#define TLS_GD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __o0; })
+
diff --git a/test/tls/tls-macros-x86_64.h b/test/tls/tls-macros-x86_64.h
new file mode 100644
index 0000000..b8a8b71
--- /dev/null
+++ b/test/tls/tls-macros-x86_64.h
@@ -0,0 +1,40 @@
+#define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("mov %%fs:0,%0\n\t" \
+ "lea " #x "@tpoff(%0), %0" \
+ : "=r" (__l)); \
+ __l; })
+
+#define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("mov %%fs:0,%0\n\t" \
+ "add " #x "@gottpoff(%%rip),%0" \
+ : "=r" (__l)); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
+ "call __tls_get_addr@plt\n\t" \
+ "leaq " #x "@dtpoff(%%rax), %%rax" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d) \
+ : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
+ __l; })
+
+#ifdef __ILP32__
+# define TLS_GD_PREFIX
+#else
+# define TLS_GD_PREFIX ".byte 0x66\n\t"
+#endif
+
+#define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ (TLS_GD_PREFIX \
+ "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
+ ".word 0x6666\n\t" \
+ "rex64\n\t" \
+ "call __tls_get_addr@plt" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d) \
+ : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
+ __l; })
+
diff --git a/test/tls/tls-macros-xtensa.h b/test/tls/tls-macros-xtensa.h
new file mode 100644
index 0000000..179dc5e
--- /dev/null
+++ b/test/tls/tls-macros-xtensa.h
@@ -0,0 +1,61 @@
+#if defined(__XTENSA_WINDOWED_ABI__)
+#define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a8, " #x "@TLSFUNC\n\t" \
+ "movi a10, " #x "@TLSARG\n\t" \
+ "callx8.tls a8, " #x "@TLSCALL\n\t" \
+ "mov %0, a10\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a8, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
+ "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t" \
+ "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t" \
+ "movi %0, " #x "@TPOFF\n\t" \
+ "add %0, %0, a10\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
+ __l; })
+#elif defined(__XTENSA_CALL0_ABI__)
+#define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
+ "movi a2, " #x "@TLSARG\n\t" \
+ "callx0.tls a0, " #x "@TLSCALL\n\t" \
+ "mov %0, a2\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a0, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
+ "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t" \
+ "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t" \
+ "movi %0, " #x "@TPOFF\n\t" \
+ "add %0, %0, a2\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
+ __l; })
+#else
+#error Unsupported Xtensa ABI
+#endif
+
+#define TLS_IE(x) TLS_LE(x)
+
+#define TLS_LE(x) \
+ ({ int *__l; \
+ int __t; \
+ __asm__ ("rur %0, threadptr\n\t" \
+ "movi %1, " #x "@TPOFF\n\t" \
+ "add %0, %0, %1\n\t" \
+ : "=r" (__l), "=r" (__t) ); \
+ __l; }); \
+
diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h
index e4d87f2..0300dba 100644
--- a/test/tls/tls-macros.h
+++ b/test/tls/tls-macros.h
@@ -16,8 +16,12 @@
/* XXX Until we get compiler support we don't need declarations. */
#define VAR_INT_DECL(x)
-#ifdef __mips__
-#include <tls-macros-mips.h>
+#ifdef __alpha__
+#include <tls-macros-alpha.h>
+#endif
+
+#ifdef __arc__
+#include <tls-macros-arc.h>
#endif
#ifdef __arm__
@@ -28,973 +32,43 @@
#endif
#endif
- /* XXX Each architecture must have its own asm for now. */
#ifdef __i386__
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("movl %%gs:0,%0\n\t" \
- "subl $" #x "@tpoff,%0" \
- : "=r" (__l)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("movl %%gs:0,%0\n\t" \
- "subl " #x "@gottpoff(%%ebx),%0" \
- : "=r" (__l)); \
- __l; })
-# else
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("call 1f\n\t" \
- ".subsection 1\n" \
- "1:\tmovl (%%esp), %%ebx\n\t" \
- "ret\n\t" \
- ".previous\n\t" \
- "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
- "movl %%gs:0,%0\n\t" \
- "subl " #x "@gottpoff(%%ebx),%0" \
- : "=r" (__l)); \
- __l; })
-# endif
-
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "leal " #x "@dtpoff(%%eax), %%eax" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# else
-# define TLS_LD(x) \
- ({ int *__l, __b, __c, __d; \
- __asm__ ("call 1f\n\t" \
- ".subsection 1\n" \
- "1:\tmovl (%%esp), %%ebx\n\t" \
- "ret\n\t" \
- ".previous\n\t" \
- "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
- "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "leal " #x "@dtpoff(%%eax), %%eax" \
- : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# endif
-
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "nop" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# else
-# define TLS_GD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("call 1f\n\t" \
- ".subsection 1\n" \
- "1:\tmovl (%%esp), %%ebx\n\t" \
- "ret\n\t" \
- ".previous\n\t" \
- "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
- "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
- "call ___tls_get_addr@plt\n\t" \
- "nop" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
- __l; })
-# endif
-
-#elif defined __x86_64__
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("mov %%fs:0,%0\n\t" \
- "lea " #x "@tpoff(%0), %0" \
- : "=r" (__l)); \
- __l; })
-
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("mov %%fs:0,%0\n\t" \
- "add " #x "@gottpoff(%%rip),%0" \
- : "=r" (__l)); \
- __l; })
-
-# define TLS_LD(x) \
- ({ int *__l, __c, __d; \
- __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
- "call __tls_get_addr@plt\n\t" \
- "leaq " #x "@dtpoff(%%rax), %%rax" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d) \
- : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
- __l; })
-
-# ifdef __ILP32__
-# define TLS_GD_PREFIX
-# else
-# define TLS_GD_PREFIX ".byte 0x66\n\t"
-# endif
-
-# define TLS_GD(x) \
- ({ int *__l, __c, __d; \
- __asm__ (TLS_GD_PREFIX \
- "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
- ".word 0x6666\n\t" \
- "rex64\n\t" \
- "call __tls_get_addr@plt" \
- : "=a" (__l), "=&c" (__c), "=&d" (__d) \
- : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
- __l; })
-
-#elif defined __sh__
-
-# define TLS_LE(x) \
- ({ int *__l; void *__tp; \
- __asm__ ("stc gbr,%1\n\t" \
- "mov.l 1f,%0\n\t" \
- "bra 2f\n\t" \
- " add %1,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tpoff\n\t" \
- "2:" \
- : "=r" (__l), "=r" (__tp)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ int *__l; void *__tp; \
- register void *__gp __asm__("r12"); \
- __asm__ ("mov.l 1f,r0\n\t" \
- "stc gbr,%1\n\t" \
- "mov.l @(r0,r12),%0\n\t" \
- "bra 2f\n\t" \
- " add %1,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@gottpoff\n\t" \
- "2:" \
- : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
- __l; })
-# else
-# define TLS_IE(x) \
- ({ int *__l; void *__tp; \
- __asm__ ("mov.l r12,@-r15\n\t" \
- "mova 0f,r0\n\t" \
- "mov.l 0f,r12\n\t" \
- "add r0,r12\n\t" \
- "mov.l 1f,r0\n\t" \
- "stc gbr,%1\n\t" \
- "mov.l @(r0,r12),%0\n\t" \
- "bra 2f\n\t" \
- " add %1,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@gottpoff\n\t" \
- "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
- "2: mov.l @r15+,r12" \
- : "=r" (__l), "=r" (__tp) : : "r0"); \
- __l; })
+#include <tls-macros-i386.h>
#endif
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ int *__l; \
- register void *__gp __asm__("r12"); \
- __asm__ ("mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 4f\n\t" \
- " nop\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsldm\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "4: mov.l 3f,%0\n\t" \
- "bra 5f\n\t" \
- " add r0,%0\n\t" \
- ".align 2\n\t" \
- "3: .long " #x "@dtpoff\n\t" \
- "5:" \
- : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
- "r6", "r7", "pr", "t"); \
- __l; })
-# else
-# define TLS_LD(x) \
- ({ int *__l; \
- __asm__ ("mov.l r12,@-r15\n\t" \
- "mova 0f,r0\n\t" \
- "mov.l 0f,r12\n\t" \
- "add r0,r12\n\t" \
- "mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 4f\n\t" \
- " nop\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsldm\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
- "4: mov.l 3f,%0\n\t" \
- "bra 5f\n\t" \
- " add r0,%0\n\t" \
- ".align 2\n\t" \
- "3: .long " #x "@dtpoff\n\t" \
- "5: mov.l @r15+,r12" \
- : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
- "pr", "t"); \
- __l; })
+#ifdef __ia64__
+#include <tls-macros-ia64.h>
#endif
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ int *__l; \
- register void *__gp __asm__("r12"); \
- __asm__ ("mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 3f\n\t" \
- " mov r0,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsgd\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "3:" \
- : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
- "r6", "r7", "pr", "t"); \
- __l; })
-# else
-# define TLS_GD(x) \
- ({ int *__l; \
- __asm__ ("mov.l r12,@-r15\n\t" \
- "mova 0f,r0\n\t" \
- "mov.l 0f,r12\n\t" \
- "add r0,r12\n\t" \
- "mov.l 1f,r4\n\t" \
- "mova 2f,r0\n\t" \
- "mov.l 2f,r1\n\t" \
- "add r0,r1\n\t" \
- "jsr @r1\n\t" \
- " add r12,r4\n\t" \
- "bra 3f\n\t" \
- " mov r0,%0\n\t" \
- ".align 2\n\t" \
- "1: .long " #x "@tlsgd\n\t" \
- "2: .long __tls_get_addr@plt\n\t" \
- "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
- "3: mov.l @r15+,r12" \
- : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
- "pr", "t"); \
- __l; })
+#ifdef __metag__
+#include <tls-macros-metag.h>
#endif
-#elif defined __alpha__
-
-register void *__gp __asm__("$29");
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
- __l; })
-
-# define TLS_IE(x) \
- ({ char *__tp; unsigned long __o; \
- __asm__ ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
- : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
- (int *)(__tp + __o); })
-
-# define TLS_LD(x) \
- ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
- __asm__ ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
- __i = __tls_get_addr(__i); \
- __asm__ ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
- __l; })
-
-# define TLS_GD(x) \
- ({ extern void *__tls_get_addr(void *); void *__i; \
- __asm__ ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
- (int *) __tls_get_addr(__i); })
-
-
-#elif defined __ia64__
-
-# define TLS_LE(x) \
- ({ void *__l; \
- __asm__ ("mov r2=r13\n\t" \
- ";;\n\t" \
- "addl %0=@tprel(" #x "),r2\n\t" \
- : "=r" (__l) : : "r2" ); __l; })
-
-# define TLS_IE(x) \
- ({ void *__l; \
- register long __gp __asm__ ("gp"); \
- __asm__ (";;\n\t" \
- "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
- ";;\n\t" \
- "ld8 r17=[r16]\n\t" \
- ";;\n\t" \
- "add %0=r13,r17\n\t" \
- ";;\n\t" \
- : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
-
-# define __TLS_CALL_CLOBBERS \
- "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
- "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
- "r27", "r28", "r29", "r30", "r31", \
- "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
- "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
- "b6", "b7", \
- "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
-
-# define TLS_LD(x) \
- ({ void *__l; \
- register long __gp __asm__ ("gp"); \
- __asm__ (";;\n\t" \
- "mov loc0=gp\n\t" \
- "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
- "addl out1=@dtprel(" #x "),r0\n\t" \
- ";;\n\t" \
- "ld8 out0=[r16]\n\t" \
- "br.call.sptk.many b0=__tls_get_addr" \
- ";;\n\t" \
- "mov gp=loc0\n\t" \
- "mov %0=r8\n\t" \
- ";;\n\t" \
- : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
- __l; })
-
-# define TLS_GD(x) \
- ({ void *__l; \
- register long __gp __asm__ ("gp"); \
- __asm__ (";;\n\t" \
- "mov loc0=gp\n\t" \
- "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
- "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
- ";;\n\t" \
- "ld8 out0=[r16]\n\t" \
- "ld8 out1=[r17]\n\t" \
- "br.call.sptk.many b0=__tls_get_addr" \
- ";;\n\t" \
- "mov gp=loc0\n\t" \
- "mov %0=r8\n\t" \
- ";;\n\t" \
- : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
- __l; })
-
-#elif defined __sparc__ && !defined __arch64__
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_LOAD_PIC \
- ({ register long pc __asm__ ("%o7"); \
- long got; \
- __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
- "call .+8\n\t" \
- "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
- "add %1, %0, %1\n\t" \
- : "=r" (pc), "=r" (got)); \
- got; })
-# else
-# define TLS_LOAD_PIC \
- ({ long got; \
- __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
- "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
- "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
- : "=r" (got)); \
- got; })
-# endif
-
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
- : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# define TLS_LD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- long __o; \
- __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
- __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
- __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
- : "r" (__o0), "r" (__o)); \
- __l; })
-
-# define TLS_GD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __o0; })
-
-#elif defined __sparc__ && defined __arch64__
-
-# define TLS_LE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# ifdef __PIC__
-# define TLS_LOAD_PIC \
- ({ long pc, got; \
- __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
- "rd %%pc, %0\n\t" \
- "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
- "add %1, %0, %1\n\t" \
- : "=r" (pc), "=r" (got)); \
- got; })
-# else
-# define TLS_LOAD_PIC \
- ({ long got; \
- __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
- "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
- "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
- : "=r" (got)); \
- got; })
-# endif
-
-# define TLS_IE(x) \
- ({ int *__l; \
- __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("ldx [%1 + %2], %0, %%tie_ldx(" #x ")" \
- : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
- __l; })
-
-# define TLS_LD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- long __o; \
- __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
- __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
- __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
- : "r" (__o0), "r" (__o)); \
- __l; })
-
-# define TLS_GD(x) \
- ({ int *__l; register void *__o0 __asm__ ("%o0"); \
- __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
- __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
- __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
- : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
- __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
- " nop" \
- : "=r" (__o0) : "0" (__o0) \
- : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
- "o5", "o7", "cc"); \
- __o0; })
-
-#elif defined __s390x__
-
-# define TLS_LE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@ntpoff\n" \
- "1:\tlg %0,0(%0)" \
- : "=a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@gotntpoff\n" \
- "1:\tlg %0,0(%0)\n\t" \
- "lg %0,0(%0,%%r12):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@indntpoff\n" \
- "1:\t lg %0,0(%0)\n\t" \
- "lg %0,0(%0):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsldm\n\t" \
- ".quad " #x "@dtpoff\n" \
- "1:\tlgr %1,%%r12\n\t" \
- "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
- "lg %0,8(%0)\n\t" \
- "algr %0,%%r2\n\t" \
- "lgr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_LD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsldm\n\t" \
- ".quad " #x "@dtpoff\n" \
- "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
- "lg %0,8(%0)\n\t" \
- "algr %0,%%r2" \
- : "=&a" (__offset) \
- : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsgd\n" \
- "1:\tlgr %1,%%r12\n\t" \
- "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
- "lgr %0,%%r2\n\t" \
- "lgr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_GD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.quad " #x "@tlsgd\n" \
- "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
- "lg %%r2,0(%0)\n\t" \
- "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
- "lgr %0,%%r2" \
- : "=&a" (__offset) \
- : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-#elif defined __s390__
-
-# define TLS_LE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long " #x "@ntpoff\n" \
- "1:\tl %0,0(%0)" \
- : "=a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-
-# ifdef __PIC__
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long " #x "@gotntpoff\n" \
- "1:\tl %0,0(%0)\n\t" \
- "l %0,0(%0,%%r12):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_IE(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long " #x "@indntpoff\n" \
- "1:\t l %0,0(%0)\n\t" \
- "l %0,0(%0):tls_load:" #x \
- : "=&a" (__offset) : : "cc" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_LD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
- ".long __tls_get_offset@plt-0b\n\t" \
- ".long " #x "@tlsldm\n\t" \
- ".long " #x "@dtpoff\n" \
- "1:\tlr %1,%%r12\n\t" \
- "l %%r12,0(%0)\n\t" \
- "la %%r12,0(%%r12,%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t" \
- "l %0,12(%0)\n\t" \
- "alr %0,%%r2\n\t" \
- "lr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_LD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
- ".long __tls_get_offset@plt\n\t" \
- ".long " #x "@tlsldm\n\t" \
- ".long " #x "@dtpoff\n" \
- "1:\tl %%r12,0(%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t" \
- "l %0,12(%0)\n\t" \
- "alr %0,%%r2" \
- : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-# ifdef __PIC__
-# define TLS_GD(x) \
- ({ unsigned long __offset, __save12; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
- ".long __tls_get_offset@plt-0b\n\t" \
- ".long " #x "@tlsgd\n" \
- "1:\tlr %1,%%r12\n\t" \
- "l %%r12,0(%0)\n\t" \
- "la %%r12,0(%%r12,%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t" \
- "lr %0,%%r2\n\t" \
- "lr %%r12,%1" \
- : "=&a" (__offset), "=&a" (__save12) \
- : : "cc", "0", "1", "2", "3", "4", "5" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# else
-# define TLS_GD(x) \
- ({ unsigned long __offset; \
- __asm__ ("bras %0,1f\n" \
- "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
- ".long __tls_get_offset@plt\n\t" \
- ".long " #x "@tlsgd\n" \
- "1:\tl %%r12,0(%0)\n\t" \
- "l %%r1,4(%0)\n\t" \
- "l %%r2,8(%0)\n\t" \
- "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t" \
- "lr %0,%%r2" \
- : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
- (int *) (__builtin_thread_pointer() + __offset); })
-# endif
-
-#elif defined __powerpc__ && !defined __powerpc64__
-
-/*#include "config.h"*/
-
-# define __TLS_CALL_CLOBBERS \
- "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
- "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
-
-/* PowerPC32 Local Exec TLS access. */
-# define TLS_LE(x) \
- ({ int *__result; \
- __asm__ ("addi %0,2," #x "@tprel" \
- : "=r" (__result)); \
- __result; })
-
-/* PowerPC32 Initial Exec TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_IE(x) \
- ({ int *__result; \
- __asm__ ("bcl 20,31,1f\n1:\t" \
- "mflr %0\n\t" \
- "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "lwz %0," #x "@got@tprel(%0)\n\t" \
- "add %0,%0," #x "@tls" \
- : "=b" (__result) : \
- : "lr"); \
- __result; })
-# else
-# define TLS_IE(x) \
- ({ int *__result; \
- __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr %0\n\t" \
- "lwz %0," #x "@got@tprel(%0)\n\t" \
- "add %0,%0," #x "@tls" \
- : "=b" (__result) : \
- : "lr"); \
- __result; })
-# endif
-
-/* PowerPC32 Local Dynamic TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_LD(x) \
- ({ int *__result; \
- __asm__ ("bcl 20,31,1f\n1:\t" \
- "mflr 3\n\t" \
- "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "addi 3,3," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr@plt\n\t" \
- "addi %0,3," #x "@dtprel" \
- : "=r" (__result) : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# else
-# define TLS_LD(x) \
- ({ int *__result; \
- __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr 3\n\t" \
- "addi 3,3," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr@plt\n\t" \
- "addi %0,3," #x "@dtprel" \
- : "=r" (__result) : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# endif
-
-/* PowerPC32 General Dynamic TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_GD(x) \
- ({ register int *__result __asm__ ("r3"); \
- __asm__ ("bcl 20,31,1f\n1:\t" \
- "mflr 3\n\t" \
- "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "addi 3,3," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr@plt" \
- : : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# else
-# define TLS_GD(x) \
- ({ register int *__result __asm__ ("r3"); \
- __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr 3\n\t" \
- "addi 3,3," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr@plt" \
- : : \
- : __TLS_CALL_CLOBBERS); \
- __result; })
-# endif
-
-#elif defined __powerpc__ && defined __powerpc64__
-
-/* PowerPC64 Local Exec TLS access. */
-# define TLS_LE(x) \
- ({ int * __result; \
- __asm__ ( \
- " addis %0,13," #x "@tprel@ha\n" \
- " addi %0,%0," #x "@tprel@l\n" \
- : "=b" (__result) ); \
- __result; \
- })
-/* PowerPC64 Initial Exec TLS access. */
-# define TLS_IE(x) \
- ({ int * __result; \
- __asm__ ( \
- " ld %0," #x "@got@tprel(2)\n" \
- " add %0,%0," #x "@tls\n" \
- : "=b" (__result) ); \
- __result; \
- })
-/* PowerPC64 Local Dynamic TLS access. */
-# define TLS_LD(x) \
- ({ int * __result; \
- __asm__ ( \
- " addi 3,2," #x "@got@tlsld\n" \
- " bl .__tls_get_addr\n" \
- " nop \n" \
- " addis %0,3," #x "@dtprel@ha\n" \
- " addi %0,%0," #x "@dtprel@l\n" \
- : "=b" (__result) : \
- : "0", "3", "4", "5", "6", "7", \
- "8", "9", "10", "11", "12", \
- "lr", "ctr", \
- "cr0", "cr1", "cr5", "cr6", "cr7"); \
- __result; \
- })
-/* PowerPC64 General Dynamic TLS access. */
-# define TLS_GD(x) \
- ({ int * __result; \
- __asm__ ( \
- " addi 3,2," #x "@got@tlsgd\n" \
- " bl .__tls_get_addr\n" \
- " nop \n" \
- " mr %0,3\n" \
- : "=b" (__result) : \
- : "0", "3", "4", "5", "6", "7", \
- "8", "9", "10", "11", "12", \
- "lr", "ctr", \
- "cr0", "cr1", "cr5", "cr6", "cr7"); \
- __result; \
- })
-
-#elif defined __arc__
-
-/* For now */
-#define TLS_LD(x) TLS_IE(x)
-
-#define TLS_GD(x) \
- ({ int *__result; \
- __asm__ ("add r0, pcl, @" #x "@tlsgd \n" \
- ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n" \
- "mov %0, r0 \n" \
- : "=&r" (__result) \
- ::"r0","r1","r2","r3","r4","r5","r6","r7", \
- "r8","r9","r10","r11","r12"); \
- __result; })
-
-#define TLS_LE(x) \
- ({ int *__result; \
- void *tp = __builtin_thread_pointer(); \
- __asm__ ("add %0, %1, @" #x "@tpoff \n" \
- : "=r" (__result) : "r"(tp)); \
- __result; })
-
-#define TLS_IE(x) \
- ({ int *__result; \
- void *tp = __builtin_thread_pointer(); \
- __asm__ ("ld %0, [pcl, @" #x "@tlsie] \n" \
- "add %0, %1, %0 \n" \
- : "=&r" (__result) : "r" (tp)); \
- __result; })
-
-#elif defined __xtensa__
-
-#if defined(__XTENSA_WINDOWED_ABI__)
-#define TLS_GD(x) \
- ({ int *__l; \
- __asm__ ("movi a8, " #x "@TLSFUNC\n\t" \
- "movi a10, " #x "@TLSARG\n\t" \
- "callx8.tls a8, " #x "@TLSCALL\n\t" \
- "mov %0, a10\n\t" \
- : "=r" (__l) \
- : \
- : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
- __l; })
-
-#define TLS_LD(x) \
- ({ int *__l; \
- __asm__ ("movi a8, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
- "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t" \
- "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t" \
- "movi %0, " #x "@TPOFF\n\t" \
- "add %0, %0, a10\n\t" \
- : "=r" (__l) \
- : \
- : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
- __l; })
-#elif defined(__XTENSA_CALL0_ABI__)
-#define TLS_GD(x) \
- ({ int *__l; \
- __asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
- "movi a2, " #x "@TLSARG\n\t" \
- "callx0.tls a0, " #x "@TLSCALL\n\t" \
- "mov %0, a2\n\t" \
- : "=r" (__l) \
- : \
- : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
- __l; })
-
-#define TLS_LD(x) \
- ({ int *__l; \
- __asm__ ("movi a0, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
- "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t" \
- "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t" \
- "movi %0, " #x "@TPOFF\n\t" \
- "add %0, %0, a2\n\t" \
- : "=r" (__l) \
- : \
- : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
- __l; })
-#else
-#error Unsupported Xtensa ABI
+#ifdef __mips__
+#include <tls-macros-mips.h>
#endif
-#define TLS_IE(x) TLS_LE(x)
-
-#define TLS_LE(x) \
- ({ int *__l; \
- int __t; \
- __asm__ ("rur %0, threadptr\n\t" \
- "movi %1, " #x "@TPOFF\n\t" \
- "add %0, %0, %1\n\t" \
- : "=r" (__l), "=r" (__t) ); \
- __l; }); \
-
-#elif defined __metag__
+#ifdef __powerpc__
+#include <tls-macros-powerpc.h>
+#endif
-# define TLS_GD(x) \
- ({ void *__result; \
- extern void *__tls_get_addr (void *); \
- __asm__ ("MOV %0, A1LbP\n\t" \
- "ADD %0, %0, #(" #x "@TLSGD)" \
- : "=d" (__result)); \
- (int *)__tls_get_addr (__result); })
+#ifdef __sh__
+#include <tls-macros-sh.h>
+#endif
-# define TLS_LD(x) \
- ({ void *__result; \
- extern void *__tls_get_addr (void *); \
- __asm__ ("MOV %0, A1LbP\n\t" \
- "ADD %0, %0, #(" #x "@TLSLDM)" \
- : "=d" (__result)); \
- __result = __tls_get_addr (__result); \
- __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLDO)\n\t" \
- "ADD %0,%0,#LO(" #x "@TLSLDO)" \
- : "+d" (__result)); \
- __result; })
+#ifdef __sparc__
+#include <tls-macros-sparc.h>
+#endif
-# define TLS_IE(x) \
- ({ void *__result; \
- unsigned long __rel; \
- extern void *__metag_load_tp (void); \
- __asm__ ("GETD %0,[A1LbP+#(" #x "@TLSIE)]" \
- : "=d" (__rel)); \
- __result = __metag_load_tp(); \
- __result + __rel; })
+#ifdef __x86_64__
+#include <tls-macros-x86_64.h>
+#endif
-# define TLS_LE(x) \
- ({ void *__result; \
- extern void *__metag_load_tp (void); \
- __result = __metag_load_tp(); \
- __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLE)\n\t" \
- "ADD %0,%0,#LO(" #x "@TLSLE)" \
- : "+d" (__result)); \
- __result; })
+#ifdef __xtensa__
+#include <tls-macros-xtensa.h>
+#endif
-#elif !defined TLS_LE || !defined TLS_IE \
+#if !defined TLS_LE || !defined TLS_IE \
|| !defined TLS_LD || !defined TLS_GD
# error "No support for this architecture so far."
#endif
--
1.7.10.4
2
1
There are two copies of jmpbuf-unwind.h in the tree,
the NPTL one isn't really used. No regressions found
by embedded-test run.
Signed-off-by: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
---
libc/sysdeps/linux/alpha/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/arc/jmpbuf-unwind.h | 6 ----
libc/sysdeps/linux/arm/jmpbuf-unwind.h | 7 +----
libc/sysdeps/linux/avr32/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/bfin/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/c6x/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/cris/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/hppa/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/ia64/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/m68k/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/metag/bits/setjmp.h | 10 -------
libc/sysdeps/linux/metag/jmpbuf-offsets.h | 7 +++++
libc/sysdeps/linux/metag/jmpbuf-unwind.h | 8 ++++--
libc/sysdeps/linux/microblaze/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/mips/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/nios2/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/powerpc/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/sh/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/sparc/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/x86_64/jmpbuf-unwind.h | 1 +
libc/sysdeps/linux/xtensa/jmpbuf-unwind.h | 1 +
libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h | 27 -----------------
libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h | 32 ---------------------
libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h | 32 ---------------------
libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h | 27 -----------------
libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h | 35 -----------------------
libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h | 26 -----------------
libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h | 27 -----------------
libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h | 27 -----------------
libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h | 27 -----------------
libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h | 27 -----------------
libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h | 32 ---------------------
32 files changed, 29 insertions(+), 344 deletions(-)
create mode 100644 libc/sysdeps/linux/metag/jmpbuf-offsets.h
delete mode 100644 libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
delete mode 100644 libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
diff --git a/libc/sysdeps/linux/alpha/jmpbuf-unwind.h b/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
index 80fe8b3..b14837e 100644
--- a/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/arc/jmpbuf-unwind.h b/libc/sysdeps/linux/arc/jmpbuf-unwind.h
index 8c41816..d16506a 100644
--- a/libc/sysdeps/linux/arc/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/arc/jmpbuf-unwind.h
@@ -16,12 +16,6 @@
#include <stdint.h>
#include <unwind.h>
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
_JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
diff --git a/libc/sysdeps/linux/arm/jmpbuf-unwind.h b/libc/sysdeps/linux/arm/jmpbuf-unwind.h
index d7b49e2..44f9a1b 100644
--- a/libc/sysdeps/linux/arm/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/arm/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
@@ -15,12 +16,6 @@
#include <stdint.h>
#include <unwind.h>
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
_JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
diff --git a/libc/sysdeps/linux/avr32/jmpbuf-unwind.h b/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
index 5caa2ee..f19f491 100644
--- a/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
@@ -5,6 +5,7 @@
* Public License. See the file "COPYING.LIB" in the main directory of this
* archive for more details.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/bfin/jmpbuf-unwind.h b/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
index bb7a374..26b56db 100644
--- a/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/c6x/jmpbuf-unwind.h b/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
index ad2ab59..58eb18a 100644
--- a/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
@@ -17,6 +17,7 @@
* along with this program; see the file COPYING.LIB. If not, see
* <http://www.gnu.org/licenses/>.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/cris/jmpbuf-unwind.h b/libc/sysdeps/linux/cris/jmpbuf-unwind.h
index 8b75dce..b5950ad 100644
--- a/libc/sysdeps/linux/cris/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/cris/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/hppa/jmpbuf-unwind.h b/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
index 0590754..efed134 100644
--- a/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/ia64/jmpbuf-unwind.h b/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
index 91e2df8..4eb0eea 100644
--- a/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame containing a local
diff --git a/libc/sysdeps/linux/m68k/jmpbuf-unwind.h b/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
index d87ace3..c5a8886 100644
--- a/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/metag/bits/setjmp.h b/libc/sysdeps/linux/metag/bits/setjmp.h
index 8ad4b12..d80a355 100644
--- a/libc/sysdeps/linux/metag/bits/setjmp.h
+++ b/libc/sysdeps/linux/metag/bits/setjmp.h
@@ -28,17 +28,7 @@
*/
#define _JBLEN 24
-#if defined (__USE_MISC) || defined (_ASM)
-#define JB_SP 0
-#endif
-#ifndef _ASM
typedef int __jmp_buf[_JBLEN] __attribute__((aligned (8)));
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) > (void *) (jmpbuf)[JB_SP])
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/metag/jmpbuf-offsets.h b/libc/sysdeps/linux/metag/jmpbuf-offsets.h
new file mode 100644
index 0000000..e4faf42
--- /dev/null
+++ b/libc/sysdeps/linux/metag/jmpbuf-offsets.h
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define JB_SP 0
diff --git a/libc/sysdeps/linux/metag/jmpbuf-unwind.h b/libc/sysdeps/linux/metag/jmpbuf-unwind.h
index 175cd7a..bf79141 100644
--- a/libc/sysdeps/linux/metag/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/metag/jmpbuf-unwind.h
@@ -1,14 +1,16 @@
/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include <setjmp.h>
+#include <jmpbuf-offsets.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) > (void *) demangle (jmpbuf[JB_SP]))
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) > (void *) jmpbuf[JB_SP])
#ifdef __UCLIBC_HAS_THREADS_NATIVE__
#include <stdint.h>
diff --git a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
index a24cd12..2c1c079 100644
--- a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/mips/jmpbuf-unwind.h b/libc/sysdeps/linux/mips/jmpbuf-unwind.h
index 2c0df95..3242eae 100644
--- a/libc/sysdeps/linux/mips/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/mips/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
index 64cd55f..c22ab24 100644
--- a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h b/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
index 54322b8..d650b32 100644
--- a/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/sh/jmpbuf-unwind.h b/libc/sysdeps/linux/sh/jmpbuf-unwind.h
index 8875cc1..34977df 100644
--- a/libc/sysdeps/linux/sh/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/sh/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
/* Test if longjmp to JMPBUF would unwind the frame
diff --git a/libc/sysdeps/linux/sparc/jmpbuf-unwind.h b/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
index 90efb77..31449d8 100644
--- a/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h b/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
index 1525872..b3f39b5 100644
--- a/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
index 4516d93..13161e9 100644
--- a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
@@ -3,6 +3,7 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+
#include <setjmp.h>
#include <jmpbuf-offsets.h>
diff --git a/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
deleted file mode 100644
index 2f64e7d..0000000
--- a/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
deleted file mode 100644
index 11a043b..0000000
--- a/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
deleted file mode 100644
index 11a043b..0000000
--- a/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
deleted file mode 100644
index 2f64e7d..0000000
--- a/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
deleted file mode 100644
index b3da6bd..0000000
--- a/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) > (void *) demangle (jmpbuf[JB_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) > (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
-
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
deleted file mode 100644
index 9739efd..0000000
--- a/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[0].__sp - (_adj))
diff --git a/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
deleted file mode 100644
index 4a88b04..0000000
--- a/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_GPR1] - (_adj))
diff --git a/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
deleted file mode 100644
index 2f7f852..0000000
--- a/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(jmpbuf, address, adj) \
- ((uintptr_t) (address) - (adj) < (uintptr_t) (jmpbuf)[0].__regs[7] - (adj))
diff --git a/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
deleted file mode 100644
index 2f64e7d..0000000
--- a/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
deleted file mode 100644
index 304bf85..0000000
--- a/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_RSP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
deleted file mode 100644
index bda498b..0000000
--- a/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#undef _JMPBUF_UNWINDS
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
- ((void *) (address) < (void *) demangle (jmpbuf[JB_SP]))
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
--
1.7.10.4
2
1
Hi Maintainers,
How would you like to handle global reorganization patches touching
arch specific parts. Do you would like to be in Cc?
How long should I wait for a comment or veto?
I sent out two patches recently, one today only to the mailinglist.
Thanks for your opinion.
best regards
Waldemar
3
2