chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / debian / patches / kfreebsd / local-dosavesse.diff
1  unfortunately, it does not work
2  in mean time use local-nosavesse.diff 
3
4 --- a/linuxthreads/descr.h
5 +++ b/linuxthreads/descr.h
6 @@ -114,6 +114,7 @@
7    /* This overlaps tcbhead_t (see tls.h), as used for TLS without threads.  */
8    union
9    {
10 +    tcbhead_t tcbheader;
11      struct
12      {
13        void *tcb;               /* Pointer to the TCB.  This is not always
14 --- a/linuxthreads/sysdeps/x86_64/tcb-offsets.sym
15 +++ b/linuxthreads/sysdeps/x86_64/tcb-offsets.sym
16 @@ -3,3 +3,4 @@
17  
18  MULTIPLE_THREADS_OFFSET                offsetof (tcbhead_t, multiple_threads)
19  POINTER_GUARD                  offsetof (tcbhead_t, pointer_guard)
20 +RTLD_SAVESPACE_SSE             offsetof (tcbhead_t, rtld_savespace_sse)
21 --- a/linuxthreads/sysdeps/x86_64/tls.h
22 +++ b/linuxthreads/sysdeps/x86_64/tls.h
23 @@ -26,6 +26,7 @@
24  # include <stdbool.h>
25  # include <stddef.h>
26  # include <stdint.h>
27 +# include <xmmintrin.h>
28  
29  /* Type for the dtv.  */
30  typedef union dtv
31 @@ -46,6 +47,7 @@
32    dtv_t *dtv;
33    void *self;          /* Pointer to the thread descriptor.  */
34    int multiple_threads;
35 +  int __unused1;
36    uintptr_t sysinfo;
37    uintptr_t stack_guard;
38    uintptr_t pointer_guard;
39 @@ -53,7 +55,13 @@
40    long gscope_flag;
41  # else
42    int gscope_flag;
43 +  int __unused2;
44  # endif
45 +  void *__padding1[7];
46 +  int rtld_must_xmm_save;
47 +  int __unused3;
48 +   /* Have space for the post-AVX register size.  */
49 +  __m128 rtld_savespace_sse[8][4];
50  } tcbhead_t;
51  
52  #else /* __ASSEMBLER__ */
53 @@ -77,13 +85,19 @@
54  #  define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
55  
56  /* Alignment requirements for the initial TCB.  */
57 -#  define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
58 +//#  define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
59 +// Normally the above would be correct  But we have to store post-AVX
60 +// vector registers in the TCB and we want the storage to be aligned.
61 +// unfortunately there isn't yet a type for these values and hence no
62 +// 32-byte alignment requirement.  Make this explicit, for now.
63 +#  define TLS_INIT_TCB_ALIGN 32
64  
65  /* This is the size of the TCB.  */
66  #  define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
67  
68  /* Alignment requirements for the TCB.  */
69  #  define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
70 +// It is already 32B aligned
71  
72  /* The TCB can have any size and the memory following the address the
73     thread pointer points to is unspecified.  Allocate the TCB there.  */
74 @@ -189,7 +203,42 @@
75  #define THREAD_GSCOPE_WAIT() \
76    do { /* GL(dl_wait_lookup_done) () */ } while (0)
77  
78 +
79 +# ifdef SHARED
80 +/* Defined in dl-trampoline.S.  */
81 +extern void _dl_x86_64_save_sse (void);
82 +extern void _dl_x86_64_restore_sse (void);
83 +
84 +# define RTLD_CHECK_FOREIGN_CALL \
85 +  (THREAD_GETMEM (THREAD_SELF, p_header.tcbheader.rtld_must_xmm_save) != 0)
86 +
87 +/* NB: Don't use the xchg operation because that would imply a lock
88 +   prefix which is expensive and unnecessary.  The cache line is also
89 +   not contested at all.  */
90 +#  define RTLD_ENABLE_FOREIGN_CALL \
91 +  int old_rtld_must_xmm_save = THREAD_GETMEM (THREAD_SELF,                   \
92 +                                             p_header.tcbheader.rtld_must_xmm_save); \
93 +  THREAD_SETMEM (THREAD_SELF, p_header.tcbheader.rtld_must_xmm_save, 1)
94 +
95 +#  define RTLD_PREPARE_FOREIGN_CALL \
96 +  do if (THREAD_GETMEM (THREAD_SELF, p_header.tcbheader.rtld_must_xmm_save))  \
97 +    {                                                                        \
98 +      _dl_x86_64_save_sse ();                                                \
99 +      THREAD_SETMEM (THREAD_SELF, p_header.tcbheader.rtld_must_xmm_save, 0);  \
100 +    }                                                                        \
101 +  while (0)
102 +
103 +#  define RTLD_FINALIZE_FOREIGN_CALL \
104 +  do {                                                                       \
105 +    if (THREAD_GETMEM (THREAD_SELF, p_header.tcbheader.rtld_must_xmm_save) == 0) \
106 +      _dl_x86_64_restore_sse ();                                             \
107 +    THREAD_SETMEM (THREAD_SELF, p_header.tcbheader.rtld_must_xmm_save,       \
108 +                  old_rtld_must_xmm_save);                                   \
109 +  } while (0)
110 +# endif
111 +
112  # endif        /* HAVE_TLS_SUPPORT */
113 +
114  #endif /* __ASSEMBLER__ */
115  
116  #endif /* tls.h */