Update copyright notices with scripts/update-copyrights.
[glibc.git] / nptl / sysdeps / unix / sysv / linux / i386 / lowlevellock.h
blobf51f650927357936e1f4381def8979690bf0e89e
1 /* Copyright (C) 2002-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LOWLEVELLOCK_H
20 #define _LOWLEVELLOCK_H 1
22 #include <stap-probe.h>
24 #ifndef __ASSEMBLER__
25 # include <time.h>
26 # include <sys/param.h>
27 # include <bits/pthreadtypes.h>
28 # include <kernel-features.h>
29 # include <tcb-offsets.h>
31 # ifndef LOCK_INSTR
32 # ifdef UP
33 # define LOCK_INSTR /* nothing */
34 # else
35 # define LOCK_INSTR "lock;"
36 # endif
37 # endif
38 #else
39 # ifndef LOCK
40 # ifdef UP
41 # define LOCK
42 # else
43 # define LOCK lock
44 # endif
45 # endif
46 #endif
48 #define SYS_futex 240
49 #define FUTEX_WAIT 0
50 #define FUTEX_WAKE 1
51 #define FUTEX_CMP_REQUEUE 4
52 #define FUTEX_WAKE_OP 5
53 #define FUTEX_LOCK_PI 6
54 #define FUTEX_UNLOCK_PI 7
55 #define FUTEX_TRYLOCK_PI 8
56 #define FUTEX_WAIT_BITSET 9
57 #define FUTEX_WAKE_BITSET 10
58 #define FUTEX_WAIT_REQUEUE_PI 11
59 #define FUTEX_CMP_REQUEUE_PI 12
60 #define FUTEX_PRIVATE_FLAG 128
61 #define FUTEX_CLOCK_REALTIME 256
63 #define FUTEX_BITSET_MATCH_ANY 0xffffffff
65 #define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
67 /* Values for 'private' parameter of locking macros. Yes, the
68 definition seems to be backwards. But it is not. The bit will be
69 reversed before passing to the system call. */
70 #define LLL_PRIVATE 0
71 #define LLL_SHARED FUTEX_PRIVATE_FLAG
74 #if !defined NOT_IN_libc || defined IS_IN_rtld
75 /* In libc.so or ld.so all futexes are private. */
76 # ifdef __ASSUME_PRIVATE_FUTEX
77 # define __lll_private_flag(fl, private) \
78 ((fl) | FUTEX_PRIVATE_FLAG)
79 # else
80 # define __lll_private_flag(fl, private) \
81 ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
82 # endif
83 #else
84 # ifdef __ASSUME_PRIVATE_FUTEX
85 # define __lll_private_flag(fl, private) \
86 (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
87 # else
88 # define __lll_private_flag(fl, private) \
89 (__builtin_constant_p (private) \
90 ? ((private) == 0 \
91 ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
92 : (fl)) \
93 : ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
94 asm ("andl %%gs:%P1, %0" : "+r" (__fl) \
95 : "i" (offsetof (struct pthread, header.private_futex))); \
96 __fl | (fl); }))
97 # endif
98 #endif
100 #ifndef __ASSEMBLER__
102 /* Initializer for compatibility lock. */
103 #define LLL_LOCK_INITIALIZER (0)
104 #define LLL_LOCK_INITIALIZER_LOCKED (1)
105 #define LLL_LOCK_INITIALIZER_WAITERS (2)
108 #ifdef PIC
109 # define LLL_EBX_LOAD "xchgl %2, %%ebx\n"
110 # define LLL_EBX_REG "D"
111 #else
112 # define LLL_EBX_LOAD
113 # define LLL_EBX_REG "b"
114 #endif
116 #ifdef I386_USE_SYSENTER
117 # ifdef SHARED
118 # define LLL_ENTER_KERNEL "call *%%gs:%P6\n\t"
119 # else
120 # define LLL_ENTER_KERNEL "call *_dl_sysinfo\n\t"
121 # endif
122 #else
123 # define LLL_ENTER_KERNEL "int $0x80\n\t"
124 #endif
126 /* Delay in spinlock loop. */
127 #define BUSY_WAIT_NOP asm ("rep; nop")
130 #define LLL_STUB_UNWIND_INFO_START \
131 ".section .eh_frame,\"a\",@progbits\n" \
132 "5:\t" ".long 7f-6f # Length of Common Information Entry\n" \
133 "6:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
134 ".byte 0x1 # CIE Version\n\t" \
135 ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
136 ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
137 ".sleb128 -4 # CIE Data Alignment Factor\n\t" \
138 ".byte 0x8 # CIE RA Column\n\t" \
139 ".uleb128 0x1 # Augmentation size\n\t" \
140 ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
141 ".byte 0xc # DW_CFA_def_cfa\n\t" \
142 ".uleb128 0x4\n\t" \
143 ".uleb128 0x0\n\t" \
144 ".align 4\n" \
145 "7:\t" ".long 17f-8f # FDE Length\n" \
146 "8:\t" ".long 8b-5b # FDE CIE offset\n\t" \
147 ".long 1b-. # FDE initial location\n\t" \
148 ".long 4b-1b # FDE address range\n\t" \
149 ".uleb128 0x0 # Augmentation size\n\t" \
150 ".byte 0x16 # DW_CFA_val_expression\n\t" \
151 ".uleb128 0x8\n\t" \
152 ".uleb128 10f-9f\n" \
153 "9:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
154 ".sleb128 3b-1b\n"
155 #define LLL_STUB_UNWIND_INFO_END \
156 ".byte 0x16 # DW_CFA_val_expression\n\t" \
157 ".uleb128 0x8\n\t" \
158 ".uleb128 12f-11f\n" \
159 "11:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
160 ".sleb128 3b-2b\n" \
161 "12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t" \
162 ".byte 0x16 # DW_CFA_val_expression\n\t" \
163 ".uleb128 0x8\n\t" \
164 ".uleb128 16f-13f\n" \
165 "13:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
166 ".sleb128 15f-14f\n\t" \
167 ".byte 0x0d # DW_OP_const4s\n" \
168 "14:\t" ".4byte 3b-.\n\t" \
169 ".byte 0x1c # DW_OP_minus\n\t" \
170 ".byte 0x0d # DW_OP_const4s\n" \
171 "15:\t" ".4byte 18f-.\n\t" \
172 ".byte 0x22 # DW_OP_plus\n" \
173 "16:\t" ".align 4\n" \
174 "17:\t" ".previous\n"
176 /* Unwind info for
177 1: lea ..., ...
178 2: call ...
179 3: jmp 18f
181 snippet. */
182 #define LLL_STUB_UNWIND_INFO_3 \
183 LLL_STUB_UNWIND_INFO_START \
184 "10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
185 LLL_STUB_UNWIND_INFO_END
187 /* Unwind info for
188 1: lea ..., ...
189 0: movl ..., ...
190 2: call ...
191 3: jmp 18f
193 snippet. */
194 #define LLL_STUB_UNWIND_INFO_4 \
195 LLL_STUB_UNWIND_INFO_START \
196 "10:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
197 ".byte 0x16 # DW_CFA_val_expression\n\t" \
198 ".uleb128 0x8\n\t" \
199 ".uleb128 20f-19f\n" \
200 "19:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
201 ".sleb128 3b-0b\n" \
202 "20:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
203 LLL_STUB_UNWIND_INFO_END
206 #define lll_futex_wait(futex, val, private) \
207 lll_futex_timed_wait (futex, val, NULL, private)
210 #define lll_futex_timed_wait(futex, val, timeout, private) \
211 ({ \
212 int __status; \
213 register __typeof (val) _val asm ("edx") = (val); \
214 __asm __volatile (LLL_EBX_LOAD \
215 LLL_ENTER_KERNEL \
216 LLL_EBX_LOAD \
217 : "=a" (__status) \
218 : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \
219 "c" (__lll_private_flag (FUTEX_WAIT, private)), \
220 "d" (_val), "i" (offsetof (tcbhead_t, sysinfo)) \
221 : "memory"); \
222 __status; \
226 #define lll_futex_wake(futex, nr, private) \
227 do { \
228 int __ignore; \
229 register __typeof (nr) _nr asm ("edx") = (nr); \
230 LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
231 __asm __volatile (LLL_EBX_LOAD \
232 LLL_ENTER_KERNEL \
233 LLL_EBX_LOAD \
234 : "=a" (__ignore) \
235 : "0" (SYS_futex), LLL_EBX_REG (futex), \
236 "c" (__lll_private_flag (FUTEX_WAKE, private)), \
237 "d" (_nr), \
238 "i" (0) /* phony, to align next arg's number */, \
239 "i" (offsetof (tcbhead_t, sysinfo))); \
240 } while (0)
243 /* NB: in the lll_trylock macro we simply return the value in %eax
244 after the cmpxchg instruction. In case the operation succeded this
245 value is zero. In case the operation failed, the cmpxchg instruction
246 has loaded the current value of the memory work which is guaranteed
247 to be nonzero. */
248 #if defined NOT_IN_libc || defined UP
249 # define __lll_trylock_asm LOCK_INSTR "cmpxchgl %2, %1"
250 #else
251 # define __lll_trylock_asm "cmpl $0, %%gs:%P5\n\t" \
252 "je 0f\n\t" \
253 "lock\n" \
254 "0:\tcmpxchgl %2, %1"
255 #endif
257 #define lll_trylock(futex) \
258 ({ int ret; \
259 __asm __volatile (__lll_trylock_asm \
260 : "=a" (ret), "=m" (futex) \
261 : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex), \
262 "0" (LLL_LOCK_INITIALIZER), \
263 "i" (MULTIPLE_THREADS_OFFSET) \
264 : "memory"); \
265 ret; })
267 #define lll_robust_trylock(futex, id) \
268 ({ int ret; \
269 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
270 : "=a" (ret), "=m" (futex) \
271 : "r" (id), "m" (futex), \
272 "0" (LLL_LOCK_INITIALIZER) \
273 : "memory"); \
274 ret; })
277 #define lll_cond_trylock(futex) \
278 ({ int ret; \
279 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
280 : "=a" (ret), "=m" (futex) \
281 : "r" (LLL_LOCK_INITIALIZER_WAITERS), \
282 "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
283 : "memory"); \
284 ret; })
286 #if defined NOT_IN_libc || defined UP
287 # define __lll_lock_asm_start LOCK_INSTR "cmpxchgl %1, %2\n\t"
288 #else
289 # define __lll_lock_asm_start "cmpl $0, %%gs:%P6\n\t" \
290 "je 0f\n\t" \
291 "lock\n" \
292 "0:\tcmpxchgl %1, %2\n\t"
293 #endif
295 #define lll_lock(futex, private) \
296 (void) \
297 ({ int ignore1, ignore2; \
298 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
299 __asm __volatile (__lll_lock_asm_start \
300 "jnz _L_lock_%=\n\t" \
301 ".subsection 1\n\t" \
302 ".type _L_lock_%=,@function\n" \
303 "_L_lock_%=:\n" \
304 "1:\tleal %2, %%ecx\n" \
305 "2:\tcall __lll_lock_wait_private\n" \
306 "3:\tjmp 18f\n" \
307 "4:\t.size _L_lock_%=, 4b-1b\n\t" \
308 ".previous\n" \
309 LLL_STUB_UNWIND_INFO_3 \
310 "18:" \
311 : "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
312 : "0" (0), "1" (1), "m" (futex), \
313 "i" (MULTIPLE_THREADS_OFFSET) \
314 : "memory"); \
315 else \
317 int ignore3; \
318 __asm __volatile (__lll_lock_asm_start \
319 "jnz _L_lock_%=\n\t" \
320 ".subsection 1\n\t" \
321 ".type _L_lock_%=,@function\n" \
322 "_L_lock_%=:\n" \
323 "1:\tleal %2, %%edx\n" \
324 "0:\tmovl %8, %%ecx\n" \
325 "2:\tcall __lll_lock_wait\n" \
326 "3:\tjmp 18f\n" \
327 "4:\t.size _L_lock_%=, 4b-1b\n\t" \
328 ".previous\n" \
329 LLL_STUB_UNWIND_INFO_4 \
330 "18:" \
331 : "=a" (ignore1), "=c" (ignore2), \
332 "=m" (futex), "=&d" (ignore3) \
333 : "1" (1), "m" (futex), \
334 "i" (MULTIPLE_THREADS_OFFSET), "0" (0), \
335 "g" ((int) (private)) \
336 : "memory"); \
340 #define lll_robust_lock(futex, id, private) \
341 ({ int result, ignore1, ignore2; \
342 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
343 "jnz _L_robust_lock_%=\n\t" \
344 ".subsection 1\n\t" \
345 ".type _L_robust_lock_%=,@function\n" \
346 "_L_robust_lock_%=:\n" \
347 "1:\tleal %2, %%edx\n" \
348 "0:\tmovl %7, %%ecx\n" \
349 "2:\tcall __lll_robust_lock_wait\n" \
350 "3:\tjmp 18f\n" \
351 "4:\t.size _L_robust_lock_%=, 4b-1b\n\t" \
352 ".previous\n" \
353 LLL_STUB_UNWIND_INFO_4 \
354 "18:" \
355 : "=a" (result), "=c" (ignore1), "=m" (futex), \
356 "=&d" (ignore2) \
357 : "0" (0), "1" (id), "m" (futex), "g" ((int) (private))\
358 : "memory"); \
359 result; })
362 /* Special version of lll_lock which causes the unlock function to
363 always wakeup waiters. */
364 #define lll_cond_lock(futex, private) \
365 (void) \
366 ({ int ignore1, ignore2, ignore3; \
367 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
368 "jnz _L_cond_lock_%=\n\t" \
369 ".subsection 1\n\t" \
370 ".type _L_cond_lock_%=,@function\n" \
371 "_L_cond_lock_%=:\n" \
372 "1:\tleal %2, %%edx\n" \
373 "0:\tmovl %7, %%ecx\n" \
374 "2:\tcall __lll_lock_wait\n" \
375 "3:\tjmp 18f\n" \
376 "4:\t.size _L_cond_lock_%=, 4b-1b\n\t" \
377 ".previous\n" \
378 LLL_STUB_UNWIND_INFO_4 \
379 "18:" \
380 : "=a" (ignore1), "=c" (ignore2), "=m" (futex), \
381 "=&d" (ignore3) \
382 : "0" (0), "1" (2), "m" (futex), "g" ((int) (private))\
383 : "memory"); \
387 #define lll_robust_cond_lock(futex, id, private) \
388 ({ int result, ignore1, ignore2; \
389 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
390 "jnz _L_robust_cond_lock_%=\n\t" \
391 ".subsection 1\n\t" \
392 ".type _L_robust_cond_lock_%=,@function\n" \
393 "_L_robust_cond_lock_%=:\n" \
394 "1:\tleal %2, %%edx\n" \
395 "0:\tmovl %7, %%ecx\n" \
396 "2:\tcall __lll_robust_lock_wait\n" \
397 "3:\tjmp 18f\n" \
398 "4:\t.size _L_robust_cond_lock_%=, 4b-1b\n\t" \
399 ".previous\n" \
400 LLL_STUB_UNWIND_INFO_4 \
401 "18:" \
402 : "=a" (result), "=c" (ignore1), "=m" (futex), \
403 "=&d" (ignore2) \
404 : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex), \
405 "g" ((int) (private)) \
406 : "memory"); \
407 result; })
410 #define lll_timedlock(futex, timeout, private) \
411 ({ int result, ignore1, ignore2, ignore3; \
412 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
413 "jnz _L_timedlock_%=\n\t" \
414 ".subsection 1\n\t" \
415 ".type _L_timedlock_%=,@function\n" \
416 "_L_timedlock_%=:\n" \
417 "1:\tleal %3, %%ecx\n" \
418 "0:\tmovl %8, %%edx\n" \
419 "2:\tcall __lll_timedlock_wait\n" \
420 "3:\tjmp 18f\n" \
421 "4:\t.size _L_timedlock_%=, 4b-1b\n\t" \
422 ".previous\n" \
423 LLL_STUB_UNWIND_INFO_4 \
424 "18:" \
425 : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
426 "=m" (futex), "=S" (ignore3) \
427 : "0" (0), "1" (1), "m" (futex), "m" (timeout), \
428 "4" ((int) (private)) \
429 : "memory"); \
430 result; })
433 #define lll_robust_timedlock(futex, timeout, id, private) \
434 ({ int result, ignore1, ignore2, ignore3; \
435 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
436 "jnz _L_robust_timedlock_%=\n\t" \
437 ".subsection 1\n\t" \
438 ".type _L_robust_timedlock_%=,@function\n" \
439 "_L_robust_timedlock_%=:\n" \
440 "1:\tleal %3, %%ecx\n" \
441 "0:\tmovl %8, %%edx\n" \
442 "2:\tcall __lll_robust_timedlock_wait\n" \
443 "3:\tjmp 18f\n" \
444 "4:\t.size _L_robust_timedlock_%=, 4b-1b\n\t" \
445 ".previous\n" \
446 LLL_STUB_UNWIND_INFO_4 \
447 "18:" \
448 : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
449 "=m" (futex), "=S" (ignore3) \
450 : "0" (0), "1" (id), "m" (futex), "m" (timeout), \
451 "4" ((int) (private)) \
452 : "memory"); \
453 result; })
455 #if defined NOT_IN_libc || defined UP
456 # define __lll_unlock_asm LOCK_INSTR "subl $1, %0\n\t"
457 #else
458 # define __lll_unlock_asm "cmpl $0, %%gs:%P3\n\t" \
459 "je 0f\n\t" \
460 "lock\n" \
461 "0:\tsubl $1,%0\n\t"
462 #endif
464 #define lll_unlock(futex, private) \
465 (void) \
466 ({ int ignore; \
467 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
468 __asm __volatile (__lll_unlock_asm \
469 "jne _L_unlock_%=\n\t" \
470 ".subsection 1\n\t" \
471 ".type _L_unlock_%=,@function\n" \
472 "_L_unlock_%=:\n" \
473 "1:\tleal %0, %%eax\n" \
474 "2:\tcall __lll_unlock_wake_private\n" \
475 "3:\tjmp 18f\n" \
476 "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
477 ".previous\n" \
478 LLL_STUB_UNWIND_INFO_3 \
479 "18:" \
480 : "=m" (futex), "=&a" (ignore) \
481 : "m" (futex), "i" (MULTIPLE_THREADS_OFFSET) \
482 : "memory"); \
483 else \
485 int ignore2; \
486 __asm __volatile (__lll_unlock_asm \
487 "jne _L_unlock_%=\n\t" \
488 ".subsection 1\n\t" \
489 ".type _L_unlock_%=,@function\n" \
490 "_L_unlock_%=:\n" \
491 "1:\tleal %0, %%eax\n" \
492 "0:\tmovl %5, %%ecx\n" \
493 "2:\tcall __lll_unlock_wake\n" \
494 "3:\tjmp 18f\n" \
495 "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
496 ".previous\n" \
497 LLL_STUB_UNWIND_INFO_4 \
498 "18:" \
499 : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
500 : "i" (MULTIPLE_THREADS_OFFSET), "m" (futex), \
501 "g" ((int) (private)) \
502 : "memory"); \
506 #define lll_robust_unlock(futex, private) \
507 (void) \
508 ({ int ignore, ignore2; \
509 __asm __volatile (LOCK_INSTR "andl %3, %0\n\t" \
510 "jne _L_robust_unlock_%=\n\t" \
511 ".subsection 1\n\t" \
512 ".type _L_robust_unlock_%=,@function\n" \
513 "_L_robust_unlock_%=:\n\t" \
514 "1:\tleal %0, %%eax\n" \
515 "0:\tmovl %5, %%ecx\n" \
516 "2:\tcall __lll_unlock_wake\n" \
517 "3:\tjmp 18f\n" \
518 "4:\t.size _L_robust_unlock_%=, 4b-1b\n\t" \
519 ".previous\n" \
520 LLL_STUB_UNWIND_INFO_4 \
521 "18:" \
522 : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
523 : "i" (FUTEX_WAITERS), "m" (futex), \
524 "g" ((int) (private)) \
525 : "memory"); \
529 #define lll_robust_dead(futex, private) \
530 (void) \
531 ({ int __ignore; \
532 register int _nr asm ("edx") = 1; \
533 __asm __volatile (LOCK_INSTR "orl %5, (%2)\n\t" \
534 LLL_EBX_LOAD \
535 LLL_ENTER_KERNEL \
536 LLL_EBX_LOAD \
537 : "=a" (__ignore) \
538 : "0" (SYS_futex), LLL_EBX_REG (&(futex)), \
539 "c" (__lll_private_flag (FUTEX_WAKE, private)), \
540 "d" (_nr), "i" (FUTEX_OWNER_DIED), \
541 "i" (offsetof (tcbhead_t, sysinfo))); \
544 #define lll_islocked(futex) \
545 (futex != LLL_LOCK_INITIALIZER)
547 /* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
548 wakeup when the clone terminates. The memory location contains the
549 thread ID while the clone is running and is reset to zero
550 afterwards.
552 The macro parameter must not have any side effect. */
553 #define lll_wait_tid(tid) \
554 do { \
555 int __ignore; \
556 register __typeof (tid) _tid asm ("edx") = (tid); \
557 if (_tid != 0) \
558 __asm __volatile (LLL_EBX_LOAD \
559 "1:\tmovl %1, %%eax\n\t" \
560 LLL_ENTER_KERNEL \
561 "cmpl $0, (%%ebx)\n\t" \
562 "jne 1b\n\t" \
563 LLL_EBX_LOAD \
564 : "=&a" (__ignore) \
565 : "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \
566 "c" (FUTEX_WAIT), "d" (_tid), \
567 "i" (offsetof (tcbhead_t, sysinfo)) \
568 : "memory"); \
569 } while (0)
571 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
572 __attribute__ ((regparm (2))) attribute_hidden;
573 #define lll_timedwait_tid(tid, abstime) \
574 ({ \
575 int __result = 0; \
576 if (tid != 0) \
578 if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \
579 __result = EINVAL; \
580 else \
581 __result = __lll_timedwait_tid (&tid, abstime); \
583 __result; })
585 #endif /* !__ASSEMBLER__ */
587 #endif /* lowlevellock.h */