File: tg-libpthread-gsync-spin.diff

package info (click to toggle)
glibc 2.24-11%2Bdeb9u3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 225,316 kB
  • sloc: ansic: 996,116; asm: 261,826; sh: 10,483; makefile: 9,849; cpp: 4,169; python: 3,971; perl: 2,254; awk: 1,753; pascal: 1,521; yacc: 291; sed: 80
file content (278 lines) | stat: -rw-r--r-- 9,256 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
commit cd7e69c545200949cfd1b3c595568556ff9a76e3
Author: Agustina Arzille <avarzille@riseup.net>
Date:   Tue Oct 18 00:20:45 2016 +0200

    Make pthread_spinlock use gsync

diff --git a/libpthread/pthread/pt-spin-inlines.c b/libpthread/pthread/pt-spin-inlines.c
index cfb21dd..97afb4d 100644
--- a/libpthread/pthread/pt-spin-inlines.c
+++ b/libpthread/pthread/pt-spin-inlines.c
@@ -25,10 +25,9 @@
 
 #include <pthread.h>
 
-/* Weak aliases for the spin lock functions.  Note that
-   pthread_spin_lock is left out deliberately.  We already provide an
-   implementation for it in pt-spin.c.  */
+/* Weak aliases for the spin lock functions.  */
 weak_alias (__pthread_spin_destroy, pthread_spin_destroy);
 weak_alias (__pthread_spin_init, pthread_spin_init);
 weak_alias (__pthread_spin_trylock, pthread_spin_trylock);
+weak_alias (__pthread_spin_lock, pthread_spin_lock);
 weak_alias (__pthread_spin_unlock, pthread_spin_unlock);
diff --git a/libpthread/sysdeps/mach/bits/spin-lock-inline.h b/libpthread/sysdeps/mach/bits/spin-lock-inline.h
index f9f7c29..98e4b3b 100644
--- a/libpthread/sysdeps/mach/bits/spin-lock-inline.h
+++ b/libpthread/sysdeps/mach/bits/spin-lock-inline.h
@@ -22,7 +22,7 @@
 
 #include <features.h>
 #include <bits/spin-lock.h>
-#include <machine-lock.h>	/* This does all the work.  */
+#include <lock-intern.h>   /* This does all the work.  */
 
 __BEGIN_DECLS
 
@@ -60,17 +60,15 @@ __PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
 __PT_SPIN_INLINE int
 __pthread_spin_trylock (__pthread_spinlock_t *__lock)
 {
-  return __spin_try_lock (__lock) ? 0 : __EBUSY;
+  return __spin_try_lock ((__spin_lock_t *) __lock) ? 0 : __EBUSY;
 }
 
-__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
-extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
+__PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock);
 
-__extern_inline int
+__PT_SPIN_INLINE int
 __pthread_spin_lock (__pthread_spinlock_t *__lock)
 {
-  if (__pthread_spin_trylock (__lock))
-    return _pthread_spin_lock (__lock);
+  __spin_lock ((__spin_lock_t *) __lock);
   return 0;
 }
 
@@ -79,7 +77,7 @@ __PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
 __PT_SPIN_INLINE int
 __pthread_spin_unlock (__pthread_spinlock_t *__lock)
 {
-  __spin_unlock (__lock);
+  __spin_unlock ((__spin_lock_t *) __lock);
   return 0;
 }
 
diff --git a/libpthread/sysdeps/mach/bits/spin-lock.h b/libpthread/sysdeps/mach/bits/spin-lock.h
index 537dac9..7574b37 100644
--- a/libpthread/sysdeps/mach/bits/spin-lock.h
+++ b/libpthread/sysdeps/mach/bits/spin-lock.h
@@ -21,17 +21,14 @@
 #define _BITS_SPIN_LOCK_H	1
 
 #include <features.h>
-#include <machine-lock.h>	/* This does all the work.  */
 
 __BEGIN_DECLS
 
 /* The type of a spin lock object.  */
-typedef __spin_lock_t __pthread_spinlock_t;
+typedef volatile int __pthread_spinlock_t;
 
 /* Initializer for a spin lock object.  */
-#ifndef __PTHREAD_SPIN_LOCK_INITIALIZER
-#error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by <lock-intern.h>.
-#endif
+#define __PTHREAD_SPIN_LOCK_INITIALIZER 0
 
 __END_DECLS
 
diff --git a/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h b/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h
deleted file mode 100644
index e5ed3de..0000000
--- a/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Machine-specific definitions for spin locks.  i386 version.
-   Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-/*
- * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
- */
-
-#ifndef _BITS_SPIN_LOCK_INLINE_H
-#define _BITS_SPIN_LOCK_INLINE_H	1
-
-#include <features.h>
-#include <bits/spin-lock.h>
-
-__BEGIN_DECLS
-
-#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
-
-# ifndef __EBUSY
-#  include <errno.h>
-#  define __EBUSY EBUSY
-# endif
-
-# ifndef __PT_SPIN_INLINE
-#  define __PT_SPIN_INLINE __extern_inline
-# endif
-
-__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock);
-
-__PT_SPIN_INLINE int
-__pthread_spin_destroy (__pthread_spinlock_t *__lock)
-{
-  return 0;
-}
-
-__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock,
-					  int __pshared);
-
-__PT_SPIN_INLINE int
-__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared)
-{
-  *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER;
-  return 0;
-}
-
-__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
-
-__PT_SPIN_INLINE int
-__pthread_spin_trylock (__pthread_spinlock_t *__lock)
-{
-  int __locked;
-  __asm__ __volatile ("xchgl %0, %1"
-		      : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory");
-  return __locked ? __EBUSY : 0;
-}
-
-__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
-extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
-
-__extern_inline int
-__pthread_spin_lock (__pthread_spinlock_t *__lock)
-{
-  if (__pthread_spin_trylock (__lock))
-    return _pthread_spin_lock (__lock);
-  return 0;
-}
-
-__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
-
-__PT_SPIN_INLINE int
-__pthread_spin_unlock (__pthread_spinlock_t *__lock)
-{
-  int __unlocked;
-  __asm__ __volatile ("xchgl %0, %1"
-		      : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory");
-  return 0;
-}
-
-#endif /* Use extern inlines or force inlines.  */
-
-__END_DECLS
-
-#endif /* bits/spin-lock.h */
diff --git a/libpthread/sysdeps/mach/i386/bits/spin-lock.h b/libpthread/sysdeps/mach/i386/bits/spin-lock.h
deleted file mode 100644
index 5ae81e1..0000000
--- a/libpthread/sysdeps/mach/i386/bits/spin-lock.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Machine-specific definitions for spin locks.  i386 version.
-   Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-/*
- * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
- */
-
-#ifndef _BITS_SPIN_LOCK_H
-#define _BITS_SPIN_LOCK_H	1
-
-#include <features.h>
-
-__BEGIN_DECLS
-
-/* The type of a spin lock object.  */
-typedef __volatile int __pthread_spinlock_t;
-
-/* Initializer for a spin lock object.  */
-# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0)
-
-__END_DECLS
-
-#endif /* bits/spin-lock.h */
diff --git a/libpthread/sysdeps/mach/pt-spin.c b/libpthread/sysdeps/mach/pt-spin.c
index d9a2a32..0cf1c49 100644
--- a/libpthread/sysdeps/mach/pt-spin.c
+++ b/libpthread/sysdeps/mach/pt-spin.c
@@ -17,20 +17,16 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <pthread.h>
 #include <machine-lock.h>
 
 /* In glibc.  */
-extern void __spin_lock_solid (__pthread_spinlock_t *lock);
+extern void __spin_lock_solid (__spin_lock_t *lock);
 
 /* Lock the spin lock object LOCK.  If the lock is held by another
    thread spin until it becomes available.  */
 int
-_pthread_spin_lock (__pthread_spinlock_t *lock)
+_pthread_spin_lock (__spin_lock_t *lock)
 {
   __spin_lock_solid (lock);
   return 0;
 }
-
-weak_alias (_pthread_spin_lock, pthread_spin_lock);
-weak_alias (_pthread_spin_lock, __pthread_spin_lock);
diff --git a/libpthread/sysdeps/posix/pt-spin.c b/libpthread/sysdeps/posix/pt-spin.c
index cb809c6..07f8936 100644
--- a/libpthread/sysdeps/posix/pt-spin.c
+++ b/libpthread/sysdeps/posix/pt-spin.c
@@ -49,6 +49,3 @@ _pthread_spin_lock (__pthread_spinlock_t *lock)
       __sched_yield ();
     }
 }
-
-weak_alias (_pthread_spin_lock, pthread_spin_lock);
-weak_alias (_pthread_spin_lock, __pthread_spin_lock);