From 75311719d35dc0c132e46f883beaeb5b3d9eb75a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 28 Aug 1998 14:02:28 +0000 Subject: Update. 1998-08-28 13:58 Ulrich Drepper * internals.h: Also define THREAD_GETMEM_NC and THREAD_SETMEM_NC to access thread data with non-constant offsets. * specific.c: Use THREAD_GETMEM_NC and THREAD_SETMEM_NC where necessary. * sysdeps/i386/useldt.h: Fix typo. Add THREAD_GETMEM_NC and THREAD_SETMEM_NC definitions. * sysdeps/sparc/sparc32/pt-machine.h: Define THREAD_GETMEM_NC and THREAD_SETMEM_NC. * sysdeps/sparc/sparc64/pt-machine.h: Likewise. --- linuxthreads/sysdeps/i386/useldt.h | 50 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'linuxthreads/sysdeps/i386/useldt.h') diff --git a/linuxthreads/sysdeps/i386/useldt.h b/linuxthreads/sysdeps/i386/useldt.h index 53cf522951..1a789e2e0a 100644 --- a/linuxthreads/sysdeps/i386/useldt.h +++ b/linuxthreads/sysdeps/i386/useldt.h @@ -82,7 +82,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t); ({ \ __typeof__ (descr->member) __value; \ if (sizeof (__value) == 1) \ - __asm__ __volatile__ ("movb %%gs:%P1,%b0" \ + __asm__ __volatile__ ("movb %%gs:%P2,%b0" \ : "=r" (__value) \ : "0" (0), \ "i" (offsetof (struct _pthread_descr_struct, \ @@ -101,7 +101,31 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t); __value; \ }) -/* Set member of the thread descriptor directly. */ +/* Same as THREAD_GETMEM, but the member offset can be non-constant. */ +#define THREAD_GETMEM_NC(descr, member) \ +({ \ + __typeof__ (descr->member) __value; \ + if (sizeof (__value) == 1) \ + __asm__ __volatile__ ("movb %%gs:(%2),%b0" \ + : "=r" (__value) \ + : "0" (0), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else \ + { \ + if (sizeof (__value) != 4) \ + /* There should not be any value with a size other than 1 or 4. */ \ + abort (); \ + \ + __asm__ __volatile__ ("movl %%gs:(%1),%0" \ + : "=r" (__value) \ + : "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + } \ + __value; \ +}) + +/* Same as THREAD_SETMEM, but the member offset can be non-constant. */ #define THREAD_SETMEM(descr, member, value) \ ({ \ __typeof__ (descr->member) __value = (value); \ @@ -122,3 +146,25 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t); member))); \ } \ }) + +/* Set member of the thread descriptor directly. */ +#define THREAD_SETMEM_NC(descr, member, value) \ +({ \ + __typeof__ (descr->member) __value = (value); \ + if (sizeof (__value) == 1) \ + __asm__ __volatile__ ("movb %0,%%gs:(%1)" : \ + : "r" (__value), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + else \ + { \ + if (sizeof (__value) != 4) \ + /* There should not be any value with a size other than 1 or 4. */ \ + abort (); \ + \ + __asm__ __volatile__ ("movl %0,%%gs:(%1)" : \ + : "r" (__value), \ + "r" (offsetof (struct _pthread_descr_struct, \ + member))); \ + } \ +}) -- cgit v1.2.3