[RFC PATCH 9/9] hurd, htl: Add some more x86_64-specific code
Samuel Thibault
samuel.thibault@gnu.org
Mon Feb 20 00:30:00 GMT 2023
Sergey Bugaev, le sam. 18 févr. 2023 23:37:17 +0300, a ecrit:
> diff --git a/sysdeps/mach/hurd/x86_64/tls.h b/sysdeps/mach/hurd/x86_64/tls.h
> new file mode 100644
> index 00000000..644dcb1a
> --- /dev/null
> +++ b/sysdeps/mach/hurd/x86_64/tls.h
> @@ -0,0 +1,257 @@
> +# define TCB_ALIGNMENT 64
Please copy the comment about the penalty of non-64-aligned accesses.
> +# define TLS_INIT_TP(descr) _hurd_tls_init ((tcbhead_t *) (descr))
> +
> +# if __GNUC_PREREQ (6, 0)
> +
> +# define THREAD_SELF \
> + (*(tcbhead_t * __seg_fs *) offsetof (tcbhead_t, tcb))
> +# define THREAD_GETMEM(descr, member) \
> + (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member))
> +# define THREAD_SETMEM(descr, member, value) \
> + (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member) = value)
> +
> +# else
I'd say don't bother keeping the non-gcc-6 case, since x86_64-gnu got
added to gcc only recently.
> +/* Set the stack guard field in TCB head. */
> +# define THREAD_SET_STACK_GUARD(value) \
> + THREAD_SETMEM (THREAD_SELF, stack_guard, value)
> +# define THREAD_COPY_STACK_GUARD(descr) \
> + ((descr)->stack_guard \
> + = THREAD_GETMEM (THREAD_SELF, stack_guard))
> +
> +/* Set the pointer guard field in the TCB head. */
> +# define THREAD_SET_POINTER_GUARD(value) \
> + THREAD_SETMEM (THREAD_SELF, pointer_guard, value)
> +# define THREAD_COPY_POINTER_GUARD(descr) \
> + ((descr)->pointer_guard \
> + = THREAD_GETMEM (THREAD_SELF, pointer_guard))
> +
> +/* Install new dtv for current thread. */
> +# define INSTALL_NEW_DTV(dtvp) THREAD_SETMEM (THREAD_SELF, dtv, dtvp)
> +
> +/* Return the address of the dtv for the current thread. */
> +# define THREAD_DTV() THREAD_GETMEM (THREAD_SELF, dtv)
Please keep #define order coherent with i386/tls.h
> diff --git a/sysdeps/x86_64/htl/pt-machdep.h b/sysdeps/x86_64/htl/pt-machdep.h
> new file mode 100644
> index 00000000..2e2846fa
> --- /dev/null
> +++ b/sysdeps/x86_64/htl/pt-machdep.h
I don't think this is needed since we already have sysdeps/x86/htl/pt-machdep.h
?
Samuel
More information about the Libc-alpha
mailing list