* [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion
2020-02-17 0:20 [hurd,commited 1/2] htl: Link internal htl tests against libpthread Samuel Thibault
@ 2020-02-17 0:20 ` Samuel Thibault
2020-02-17 9:43 ` Florian Weimer
0 siblings, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2020-02-17 0:20 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
sysdeps/i386/nptl/tls.h | 46 ++++++++++++++++--------------------
sysdeps/mach/hurd/i386/tls.h | 46 ++++++++++++++++--------------------
sysdeps/x86_64/nptl/tls.h | 46 ++++++++++++++++--------------------
3 files changed, 60 insertions(+), 78 deletions(-)
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
index ffead90857..28053a77f3 100644
--- a/sysdeps/i386/nptl/tls.h
+++ b/sysdeps/i386/nptl/tls.h
@@ -255,6 +255,9 @@ tls_fill_user_desc (union user_desc_init *desc,
/* Read member of the thread descriptor directly. */
# define THREAD_GETMEM(descr, member) \
({ __typeof (descr->member) __value; \
+ _Static_assert (sizeof (__value) == 1 \
+ || sizeof (__value) == 4 \
+ || sizeof (__value) == 8); \
if (sizeof (__value) == 1) \
asm volatile ("movb %%gs:%P2,%b0" \
: "=q" (__value) \
@@ -263,13 +266,8 @@ tls_fill_user_desc (union user_desc_init *desc,
asm volatile ("movl %%gs:%P1,%0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member))); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (__value) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%gs:%P1,%%eax\n\t" \
"movl %%gs:%P2,%%edx" \
: "=A" (__value) \
@@ -282,6 +280,9 @@ tls_fill_user_desc (union user_desc_init *desc,
/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
# define THREAD_GETMEM_NC(descr, member, idx) \
({ __typeof (descr->member[0]) __value; \
+ _Static_assert (sizeof (__value) == 1 \
+ || sizeof (__value) == 4 \
+ || sizeof (__value) == 8); \
if (sizeof (__value) == 1) \
asm volatile ("movb %%gs:%P2(%3),%b0" \
: "=q" (__value) \
@@ -292,13 +293,8 @@ tls_fill_user_desc (union user_desc_init *desc,
: "=r" (__value) \
: "i" (offsetof (struct pthread, member[0])), \
"r" (idx)); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (__value) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%gs:%P1(,%2,8),%%eax\n\t" \
"movl %%gs:4+%P1(,%2,8),%%edx" \
: "=&A" (__value) \
@@ -311,7 +307,11 @@ tls_fill_user_desc (union user_desc_init *desc,
/* Set member of the thread descriptor directly. */
# define THREAD_SETMEM(descr, member, value) \
- ({ if (sizeof (descr->member) == 1) \
+ ({ \
+ _Static_assert (sizeof (descr->member) == 1 \
+ || sizeof (descr->member) == 4 \
+ || sizeof (descr->member) == 8); \
+ if (sizeof (descr->member) == 1) \
asm volatile ("movb %b0,%%gs:%P1" : \
: "iq" (value), \
"i" (offsetof (struct pthread, member))); \
@@ -319,13 +319,8 @@ tls_fill_user_desc (union user_desc_init *desc,
asm volatile ("movl %0,%%gs:%P1" : \
: "ir" (value), \
"i" (offsetof (struct pthread, member))); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (descr->member) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%eax,%%gs:%P1\n\t" \
"movl %%edx,%%gs:%P2" : \
: "A" ((uint64_t) cast_to_integer (value)), \
@@ -336,7 +331,11 @@ tls_fill_user_desc (union user_desc_init *desc,
/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
# define THREAD_SETMEM_NC(descr, member, idx, value) \
- ({ if (sizeof (descr->member[0]) == 1) \
+ ({ \
+ _Static_assert (sizeof (descr->member[0]) == 1 \
+ || sizeof (descr->member[0]) == 4 \
+ || sizeof (descr->member[0]) == 8); \
+ if (sizeof (descr->member[0]) == 1) \
asm volatile ("movb %b0,%%gs:%P1(%2)" : \
: "iq" (value), \
"i" (offsetof (struct pthread, member)), \
@@ -346,13 +345,8 @@ tls_fill_user_desc (union user_desc_init *desc,
: "ir" (value), \
"i" (offsetof (struct pthread, member)), \
"r" (idx)); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (descr->member[0]) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%eax,%%gs:%P1(,%2,8)\n\t" \
"movl %%edx,%%gs:4+%P1(,%2,8)" : \
: "A" ((uint64_t) cast_to_integer (value)), \
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
index 7ec8c81a76..ed3d8fd1f2 100644
--- a/sysdeps/mach/hurd/i386/tls.h
+++ b/sysdeps/mach/hurd/i386/tls.h
@@ -166,6 +166,9 @@ out:
/* Read member of the thread descriptor directly. */
# define THREAD_GETMEM(descr, member) \
({ __typeof (descr->member) __value; \
+ _Static_assert (sizeof (__value) == 1 \
+ || sizeof (__value) == 4 \
+ || sizeof (__value) == 8); \
if (sizeof (__value) == 1) \
asm volatile ("movb %%gs:%P2,%b0" \
: "=q" (__value) \
@@ -174,13 +177,8 @@ out:
asm volatile ("movl %%gs:%P1,%0" \
: "=r" (__value) \
: "i" (offsetof (tcbhead_t, member))); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (__value) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%gs:%P1,%%eax\n\t" \
"movl %%gs:%P2,%%edx" \
: "=A" (__value) \
@@ -193,6 +191,9 @@ out:
/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
# define THREAD_GETMEM_NC(descr, member, idx) \
({ __typeof (descr->member[0]) __value; \
+ _Static_assert (sizeof (__value) == 1 \
+ || sizeof (__value) == 4 \
+ || sizeof (__value) == 8); \
if (sizeof (__value) == 1) \
asm volatile ("movb %%gs:%P2(%3),%b0" \
: "=q" (__value) \
@@ -203,13 +204,8 @@ out:
: "=r" (__value) \
: "i" (offsetof (tcbhead_t, member[0])), \
"r" (idx)); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (__value) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%gs:%P1(,%2,8),%%eax\n\t" \
"movl %%gs:4+%P1(,%2,8),%%edx" \
: "=&A" (__value) \
@@ -222,7 +218,11 @@ out:
/* Set member of the thread descriptor directly. */
# define THREAD_SETMEM(descr, member, value) \
- ({ if (sizeof (descr->member) == 1) \
+ ({ \
+ _Static_assert (sizeof (descr->member) == 1 \
+ || sizeof (descr->member) == 4 \
+ || sizeof (descr->member) == 8); \
+ if (sizeof (descr->member) == 1) \
asm volatile ("movb %b0,%%gs:%P1" : \
: "iq" (value), \
"i" (offsetof (tcbhead_t, member))); \
@@ -230,13 +230,8 @@ out:
asm volatile ("movl %0,%%gs:%P1" : \
: "ir" (value), \
"i" (offsetof (tcbhead_t, member))); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (descr->member) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%eax,%%gs:%P1\n\t" \
"movl %%edx,%%gs:%P2" : \
: "A" ((uint64_t) cast_to_integer (value)), \
@@ -247,7 +242,11 @@ out:
/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
# define THREAD_SETMEM_NC(descr, member, idx, value) \
- ({ if (sizeof (descr->member[0]) == 1) \
+ ({ \
+ _Static_assert (sizeof (descr->member[0]) == 1 \
+ || sizeof (descr->member[0]) == 4 \
+ || sizeof (descr->member[0]) == 8); \
+ if (sizeof (descr->member[0]) == 1) \
asm volatile ("movb %b0,%%gs:%P1(%2)" : \
: "iq" (value), \
"i" (offsetof (tcbhead_t, member)), \
@@ -257,13 +256,8 @@ out:
: "ir" (value), \
"i" (offsetof (tcbhead_t, member)), \
"r" (idx)); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (descr->member[0]) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movl %%eax,%%gs:%P1(,%2,8)\n\t" \
"movl %%edx,%%gs:4+%P1(,%2,8)" : \
: "A" ((uint64_t) cast_to_integer (value)), \
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
index e7c1416eec..5255ff8509 100644
--- a/sysdeps/x86_64/nptl/tls.h
+++ b/sysdeps/x86_64/nptl/tls.h
@@ -199,6 +199,9 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
/* Read member of the thread descriptor directly. */
# define THREAD_GETMEM(descr, member) \
({ __typeof (descr->member) __value; \
+ _Static_assert (sizeof (__value) == 1 \
+ || sizeof (__value) == 4 \
+ || sizeof (__value) == 8); \
if (sizeof (__value) == 1) \
asm volatile ("movb %%fs:%P2,%b0" \
: "=q" (__value) \
@@ -207,13 +210,8 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
asm volatile ("movl %%fs:%P1,%0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member))); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (__value) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movq %%fs:%P1,%q0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member))); \
@@ -224,6 +222,9 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
# define THREAD_GETMEM_NC(descr, member, idx) \
({ __typeof (descr->member[0]) __value; \
+ _Static_assert (sizeof (__value) == 1 \
+ || sizeof (__value) == 4 \
+ || sizeof (__value) == 8); \
if (sizeof (__value) == 1) \
asm volatile ("movb %%fs:%P2(%q3),%b0" \
: "=q" (__value) \
@@ -233,13 +234,8 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
asm volatile ("movl %%fs:%P1(,%q2,4),%0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member[0])), "r" (idx));\
- else \
+ else /* 8 */ \
{ \
- if (sizeof (__value) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movq %%fs:%P1(,%q2,8),%q0" \
: "=r" (__value) \
: "i" (offsetof (struct pthread, member[0])), \
@@ -259,7 +255,11 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
/* Set member of the thread descriptor directly. */
# define THREAD_SETMEM(descr, member, value) \
- ({ if (sizeof (descr->member) == 1) \
+ ({ \
+ _Static_assert (sizeof (descr->member) == 1 \
+ || sizeof (descr->member) == 4 \
+ || sizeof (descr->member) == 8); \
+ if (sizeof (descr->member) == 1) \
asm volatile ("movb %b0,%%fs:%P1" : \
: "iq" (value), \
"i" (offsetof (struct pthread, member))); \
@@ -267,13 +267,8 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
asm volatile ("movl %0,%%fs:%P1" : \
: IMM_MODE (value), \
"i" (offsetof (struct pthread, member))); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (descr->member) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movq %q0,%%fs:%P1" : \
: IMM_MODE ((uint64_t) cast_to_integer (value)), \
"i" (offsetof (struct pthread, member))); \
@@ -282,7 +277,11 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
# define THREAD_SETMEM_NC(descr, member, idx, value) \
- ({ if (sizeof (descr->member[0]) == 1) \
+ ({ \
+ _Static_assert (sizeof (descr->member[0]) == 1 \
+ || sizeof (descr->member[0]) == 4 \
+ || sizeof (descr->member[0]) == 8); \
+ if (sizeof (descr->member[0]) == 1) \
asm volatile ("movb %b0,%%fs:%P1(%q2)" : \
: "iq" (value), \
"i" (offsetof (struct pthread, member[0])), \
@@ -292,13 +291,8 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
: IMM_MODE (value), \
"i" (offsetof (struct pthread, member[0])), \
"r" (idx)); \
- else \
+ else /* 8 */ \
{ \
- if (sizeof (descr->member[0]) != 8) \
- /* There should not be any value with a size other than 1, \
- 4 or 8. */ \
- abort (); \
- \
asm volatile ("movq %q0,%%fs:%P1(,%q2,8)" : \
: IMM_MODE ((uint64_t) cast_to_integer (value)), \
"i" (offsetof (struct pthread, member[0])), \
--
2.24.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [hurd,commited 1/2] htl: Link internal htl tests against libpthread
@ 2020-02-17 0:20 Samuel Thibault
2020-02-17 0:20 ` [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion Samuel Thibault
0 siblings, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2020-02-17 0:20 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
---
htl/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htl/Makefile b/htl/Makefile
index 39294c64d1..11cf87adc0 100644
--- a/htl/Makefile
+++ b/htl/Makefile
@@ -208,7 +208,7 @@ ifeq (yes,$(build-shared))
$(addprefix $(objpfx), \
$(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
$(tests-nolibpthread), \
- $(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so
+ $(tests) $(tests-internal) $(xtests) $(test-srcs))): $(objpfx)libpthread.so
endif
$(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
--
2.24.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion
2020-02-17 0:20 ` [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion Samuel Thibault
@ 2020-02-17 9:43 ` Florian Weimer
2020-02-17 11:52 ` Samuel Thibault
0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2020-02-17 9:43 UTC (permalink / raw)
To: Samuel Thibault; +Cc: libc-alpha, commit-hurd
* Samuel Thibault:
> ---
> sysdeps/i386/nptl/tls.h | 46 ++++++++++++++++--------------------
> sysdeps/mach/hurd/i386/tls.h | 46 ++++++++++++++++--------------------
> sysdeps/x86_64/nptl/tls.h | 46 ++++++++++++++++--------------------
> 3 files changed, 60 insertions(+), 78 deletions(-)
>
> diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
> index ffead90857..28053a77f3 100644
> --- a/sysdeps/i386/nptl/tls.h
> +++ b/sysdeps/i386/nptl/tls.h
> @@ -255,6 +255,9 @@ tls_fill_user_desc (union user_desc_init *desc,
> /* Read member of the thread descriptor directly. */
> # define THREAD_GETMEM(descr, member) \
> ({ __typeof (descr->member) __value; \
> + _Static_assert (sizeof (__value) == 1 \
> + || sizeof (__value) == 4 \
> + || sizeof (__value) == 8); \
> if (sizeof (__value) == 1) \
This (and the other changes) broke the x86_64-linux-gnu build. I'm
testing a fix.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion
2020-02-17 9:43 ` Florian Weimer
@ 2020-02-17 11:52 ` Samuel Thibault
2020-02-17 12:25 ` Florian Weimer
0 siblings, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2020-02-17 11:52 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha, commit-hurd
Florian Weimer, le lun. 17 févr. 2020 10:41:49 +0100, a ecrit:
> > ---
> > sysdeps/i386/nptl/tls.h | 46 ++++++++++++++++--------------------
> > sysdeps/mach/hurd/i386/tls.h | 46 ++++++++++++++++--------------------
> > sysdeps/x86_64/nptl/tls.h | 46 ++++++++++++++++--------------------
> > 3 files changed, 60 insertions(+), 78 deletions(-)
> >
> > diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
> > index ffead90857..28053a77f3 100644
> > --- a/sysdeps/i386/nptl/tls.h
> > +++ b/sysdeps/i386/nptl/tls.h
> > @@ -255,6 +255,9 @@ tls_fill_user_desc (union user_desc_init *desc,
> > /* Read member of the thread descriptor directly. */
> > # define THREAD_GETMEM(descr, member) \
> > ({ __typeof (descr->member) __value; \
> > + _Static_assert (sizeof (__value) == 1 \
> > + || sizeof (__value) == 4 \
> > + || sizeof (__value) == 8); \
> > if (sizeof (__value) == 1) \
>
> This (and the other changes) broke the x86_64-linux-gnu build.
Uh?
It built successfully on my box, I wonder what difference we have.
Samuel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion
2020-02-17 11:52 ` Samuel Thibault
@ 2020-02-17 12:25 ` Florian Weimer
0 siblings, 0 replies; 5+ messages in thread
From: Florian Weimer @ 2020-02-17 12:25 UTC (permalink / raw)
To: Samuel Thibault; +Cc: libc-alpha, commit-hurd
* Samuel Thibault:
> Florian Weimer, le lun. 17 févr. 2020 10:41:49 +0100, a ecrit:
>> > ---
>> > sysdeps/i386/nptl/tls.h | 46 ++++++++++++++++--------------------
>> > sysdeps/mach/hurd/i386/tls.h | 46 ++++++++++++++++--------------------
>> > sysdeps/x86_64/nptl/tls.h | 46 ++++++++++++++++--------------------
>> > 3 files changed, 60 insertions(+), 78 deletions(-)
>> >
>> > diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
>> > index ffead90857..28053a77f3 100644
>> > --- a/sysdeps/i386/nptl/tls.h
>> > +++ b/sysdeps/i386/nptl/tls.h
>> > @@ -255,6 +255,9 @@ tls_fill_user_desc (union user_desc_init *desc,
>> > /* Read member of the thread descriptor directly. */
>> > # define THREAD_GETMEM(descr, member) \
>> > ({ __typeof (descr->member) __value; \
>> > + _Static_assert (sizeof (__value) == 1 \
>> > + || sizeof (__value) == 4 \
>> > + || sizeof (__value) == 8); \
>> > if (sizeof (__value) == 1) \
>>
>> This (and the other changes) broke the x86_64-linux-gnu build.
>
> Uh?
>
> It built successfully on my box, I wonder what difference we have.
I think single-argument _Static_assert is only available with GCC 9
and later.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-17 12:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 0:20 [hurd,commited 1/2] htl: Link internal htl tests against libpthread Samuel Thibault
2020-02-17 0:20 ` [hurd,commited 2/2] x86 tls: Use _Static_assert for TLS access size assertion Samuel Thibault
2020-02-17 9:43 ` Florian Weimer
2020-02-17 11:52 ` Samuel Thibault
2020-02-17 12:25 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).