bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] linuxthreads/sysdeps/i386/useldt.h


From: Ed Connell
Subject: [PATCH] linuxthreads/sysdeps/i386/useldt.h
Date: Fri, 23 Feb 2001 18:55:42 -0500

Hi

This header is only included when '__ASSUME_LDT_WORKS' is defined (as far as I 
can tell, by hand).  I'm interested in using a segment register to always point 
to the thread structure of the current thread.

This patch forces gcc to use an 8-bit register (i.e. %cl) for one byte values 
and a 32-bit register (i.e. %ecx) for 4 byte values.  Otherwise gcc complains 
that the wrong register type is used in the branch that is not taken.

Cheers,
Ed Connell

--- linuxthreads/sysdeps/i386/useldt.h.old      Fri Feb 23 18:13:54 2001
+++ linuxthreads/sysdeps/i386/useldt.h  Fri Feb 23 17:39:26 2001
@@ -82,22 +82,22 @@
 #define THREAD_GETMEM(descr, member) \
 ({                                                                           \
   __typeof__ (descr->member) __value;                                        \
   if (sizeof (__value) == 1)                                                 \
     __asm__ __volatile__ ("movb %%gs:%P2,%b0"                                \
-                         : "=q" (__value)                                    \
+                         : "=q" ((int8_t)(__value))                          \
                          : "0" (0),                                          \
                            "i" (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:%P1,%0"                               \
-                           : "=r" (__value)                                  \
+                           : "=r" ((int32_t)(__value))                       \
                            : "i" (offsetof (struct _pthread_descr_struct,    \
                                             member)));                       \
     }                                                                        \
   __value;                                                                   \
 })
@@ -106,22 +106,22 @@
 #define THREAD_GETMEM_NC(descr, member) \
 ({                                                                           \
   __typeof__ (descr->member) __value;                                        \
   if (sizeof (__value) == 1)                                                 \
     __asm__ __volatile__ ("movb %%gs:(%2),%b0"                               \
-                         : "=q" (__value)                                    \
+                         : "=q" ((int8_t)(__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" ((int32_t)(__value))                       \
                            : "r" (offsetof (struct _pthread_descr_struct,    \
                                             member)));                       \
     }                                                                        \
   __value;                                                                   \
 })
@@ -130,21 +130,21 @@
 #define THREAD_SETMEM(descr, member, value) \
 ({                                                                           \
   __typeof__ (descr->member) __value = (value);                                
      \
   if (sizeof (__value) == 1)                                                 \
     __asm__ __volatile__ ("movb %0,%%gs:%P1" :                               \
-                         : "q" (__value),                                    \
+                         : "q" ((int8_t)(__value)),                          \
                            "i" (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:%P1" :                             \
-                           : "r" (__value),                                  \
+                           : "r" ((int32_t)(__value)),                       \
                              "i" (offsetof (struct _pthread_descr_struct,    \
                                             member)));                       \
     }                                                                        \
 })
 
@@ -152,21 +152,21 @@
 #define THREAD_SETMEM_NC(descr, member, value) \
 ({                                                                           \
   __typeof__ (descr->member) __value = (value);                                
      \
   if (sizeof (__value) == 1)                                                 \
     __asm__ __volatile__ ("movb %0,%%gs:(%1)" :                                
      \
-                         : "q" (__value),                                    \
+                         : "q" ((int8_t)(__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" ((int32_t)(__value)),                       \
                              "r" (offsetof (struct _pthread_descr_struct,    \
                                             member)));                       \
     }                                                                        \
 })
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]