Replace FSF snail mail address with URLs.
[glibc.git] / nptl / sysdeps / unix / sysv / linux / i386 / lowlevellock.h
blob497d4739bb08d6bc0a2f8f1ffbc5810d90c2bea7
1 /* Copyright (C) 2002-2004, 2006-2008, 2009 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 #ifndef __ASSEMBLER__
23 # include <time.h>
24 # include <sys/param.h>
25 # include <bits/pthreadtypes.h>
26 # include <kernel-features.h>
27 # include <tcb-offsets.h>
29 # ifndef LOCK_INSTR
30 # ifdef UP
31 # define LOCK_INSTR /* nothing */
32 # else
33 # define LOCK_INSTR "lock;"
34 # endif
35 # endif
36 #else
37 # ifndef LOCK
38 # ifdef UP
39 # define LOCK
40 # else
41 # define LOCK lock
42 # endif
43 # endif
44 #endif
46 #define SYS_futex 240
47 #define FUTEX_WAIT 0
48 #define FUTEX_WAKE 1
49 #define FUTEX_CMP_REQUEUE 4
50 #define FUTEX_WAKE_OP 5
51 #define FUTEX_LOCK_PI 6
52 #define FUTEX_UNLOCK_PI 7
53 #define FUTEX_TRYLOCK_PI 8
54 #define FUTEX_WAIT_BITSET 9
55 #define FUTEX_WAKE_BITSET 10
56 #define FUTEX_WAIT_REQUEUE_PI 11
57 #define FUTEX_CMP_REQUEUE_PI 12
58 #define FUTEX_PRIVATE_FLAG 128
59 #define FUTEX_CLOCK_REALTIME 256
61 #define FUTEX_BITSET_MATCH_ANY 0xffffffff
63 #define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
65 /* Values for 'private' parameter of locking macros. Yes, the
66 definition seems to be backwards. But it is not. The bit will be
67 reversed before passing to the system call. */
68 #define LLL_PRIVATE 0
69 #define LLL_SHARED FUTEX_PRIVATE_FLAG
72 #if !defined NOT_IN_libc || defined IS_IN_rtld
73 /* In libc.so or ld.so all futexes are private. */
74 # ifdef __ASSUME_PRIVATE_FUTEX
75 # define __lll_private_flag(fl, private) \
76 ((fl) | FUTEX_PRIVATE_FLAG)
77 # else
78 # define __lll_private_flag(fl, private) \
79 ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
80 # endif
81 #else
82 # ifdef __ASSUME_PRIVATE_FUTEX
83 # define __lll_private_flag(fl, private) \
84 (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
85 # else
86 # define __lll_private_flag(fl, private) \
87 (__builtin_constant_p (private) \
88 ? ((private) == 0 \
89 ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
90 : (fl)) \
91 : ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
92 asm ("andl %%gs:%P1, %0" : "+r" (__fl) \
93 : "i" (offsetof (struct pthread, header.private_futex))); \
94 __fl | (fl); }))
95 # endif
96 #endif
98 #ifndef __ASSEMBLER__
100 /* Initializer for compatibility lock. */
101 #define LLL_LOCK_INITIALIZER (0)
102 #define LLL_LOCK_INITIALIZER_LOCKED (1)
103 #define LLL_LOCK_INITIALIZER_WAITERS (2)
106 #ifdef PIC
107 # define LLL_EBX_LOAD "xchgl %2, %%ebx\n"
108 # define LLL_EBX_REG "D"
109 #else
110 # define LLL_EBX_LOAD
111 # define LLL_EBX_REG "b"
112 #endif
114 #ifdef I386_USE_SYSENTER
115 # ifdef SHARED
116 # define LLL_ENTER_KERNEL "call *%%gs:%P6\n\t"
117 # else
118 # define LLL_ENTER_KERNEL "call *_dl_sysinfo\n\t"
119 # endif
120 #else
121 # define LLL_ENTER_KERNEL "int $0x80\n\t"
122 #endif
124 /* Delay in spinlock loop. */
125 #define BUSY_WAIT_NOP asm ("rep; nop")
128 #define LLL_STUB_UNWIND_INFO_START \
129 ".section .eh_frame,\"a\",@progbits\n" \
130 "5:\t" ".long 7f-6f # Length of Common Information Entry\n" \
131 "6:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
132 ".byte 0x1 # CIE Version\n\t" \
133 ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
134 ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
135 ".sleb128 -4 # CIE Data Alignment Factor\n\t" \
136 ".byte 0x8 # CIE RA Column\n\t" \
137 ".uleb128 0x1 # Augmentation size\n\t" \
138 ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
139 ".byte 0xc # DW_CFA_def_cfa\n\t" \
140 ".uleb128 0x4\n\t" \
141 ".uleb128 0x0\n\t" \
142 ".align 4\n" \
143 "7:\t" ".long 17f-8f # FDE Length\n" \
144 "8:\t" ".long 8b-5b # FDE CIE offset\n\t" \
145 ".long 1b-. # FDE initial location\n\t" \
146 ".long 4b-1b # FDE address range\n\t" \
147 ".uleb128 0x0 # Augmentation size\n\t" \
148 ".byte 0x16 # DW_CFA_val_expression\n\t" \
149 ".uleb128 0x8\n\t" \
150 ".uleb128 10f-9f\n" \
151 "9:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
152 ".sleb128 3b-1b\n"
153 #define LLL_STUB_UNWIND_INFO_END \
154 ".byte 0x16 # DW_CFA_val_expression\n\t" \
155 ".uleb128 0x8\n\t" \
156 ".uleb128 12f-11f\n" \
157 "11:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
158 ".sleb128 3b-2b\n" \
159 "12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t" \
160 ".byte 0x16 # DW_CFA_val_expression\n\t" \
161 ".uleb128 0x8\n\t" \
162 ".uleb128 16f-13f\n" \
163 "13:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
164 ".sleb128 15f-14f\n\t" \
165 ".byte 0x0d # DW_OP_const4s\n" \
166 "14:\t" ".4byte 3b-.\n\t" \
167 ".byte 0x1c # DW_OP_minus\n\t" \
168 ".byte 0x0d # DW_OP_const4s\n" \
169 "15:\t" ".4byte 18f-.\n\t" \
170 ".byte 0x22 # DW_OP_plus\n" \
171 "16:\t" ".align 4\n" \
172 "17:\t" ".previous\n"
174 /* Unwind info for
175 1: lea ..., ...
176 2: call ...
177 3: jmp 18f
179 snippet. */
180 #define LLL_STUB_UNWIND_INFO_3 \
181 LLL_STUB_UNWIND_INFO_START \
182 "10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
183 LLL_STUB_UNWIND_INFO_END
185 /* Unwind info for
186 1: lea ..., ...
187 0: movl ..., ...
188 2: call ...
189 3: jmp 18f
191 snippet. */
192 #define LLL_STUB_UNWIND_INFO_4 \
193 LLL_STUB_UNWIND_INFO_START \
194 "10:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
195 ".byte 0x16 # DW_CFA_val_expression\n\t" \
196 ".uleb128 0x8\n\t" \
197 ".uleb128 20f-19f\n" \
198 "19:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
199 ".sleb128 3b-0b\n" \
200 "20:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
201 LLL_STUB_UNWIND_INFO_END
204 #define lll_futex_wait(futex, val, private) \
205 lll_futex_timed_wait (futex, val, NULL, private)
208 #define lll_futex_timed_wait(futex, val, timeout, private) \
209 ({ \
210 int __status; \
211 register __typeof (val) _val asm ("edx") = (val); \
212 __asm __volatile (LLL_EBX_LOAD \
213 LLL_ENTER_KERNEL \
214 LLL_EBX_LOAD \
215 : "=a" (__status) \
216 : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \
217 "c" (__lll_private_flag (FUTEX_WAIT, private)), \
218 "d" (_val), "i" (offsetof (tcbhead_t, sysinfo)) \
219 : "memory"); \
220 __status; \
224 #define lll_futex_wake(futex, nr, private) \
225 do { \
226 int __ignore; \
227 register __typeof (nr) _nr asm ("edx") = (nr); \
228 __asm __volatile (LLL_EBX_LOAD \
229 LLL_ENTER_KERNEL \
230 LLL_EBX_LOAD \
231 : "=a" (__ignore) \
232 : "0" (SYS_futex), LLL_EBX_REG (futex), \
233 "c" (__lll_private_flag (FUTEX_WAKE, private)), \
234 "d" (_nr), \
235 "i" (0) /* phony, to align next arg's number */, \
236 "i" (offsetof (tcbhead_t, sysinfo))); \
237 } while (0)
240 /* NB: in the lll_trylock macro we simply return the value in %eax
241 after the cmpxchg instruction. In case the operation succeded this
242 value is zero. In case the operation failed, the cmpxchg instruction
243 has loaded the current value of the memory work which is guaranteed
244 to be nonzero. */
245 #if defined NOT_IN_libc || defined UP
246 # define __lll_trylock_asm LOCK_INSTR "cmpxchgl %2, %1"
247 #else
248 # define __lll_trylock_asm "cmpl $0, %%gs:%P5\n\t" \
249 "je 0f\n\t" \
250 "lock\n" \
251 "0:\tcmpxchgl %2, %1"
252 #endif
254 #define lll_trylock(futex) \
255 ({ int ret; \
256 __asm __volatile (__lll_trylock_asm \
257 : "=a" (ret), "=m" (futex) \
258 : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex), \
259 "0" (LLL_LOCK_INITIALIZER), \
260 "i" (MULTIPLE_THREADS_OFFSET) \
261 : "memory"); \
262 ret; })
264 #define lll_robust_trylock(futex, id) \
265 ({ int ret; \
266 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
267 : "=a" (ret), "=m" (futex) \
268 : "r" (id), "m" (futex), \
269 "0" (LLL_LOCK_INITIALIZER) \
270 : "memory"); \
271 ret; })
274 #define lll_cond_trylock(futex) \
275 ({ int ret; \
276 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
277 : "=a" (ret), "=m" (futex) \
278 : "r" (LLL_LOCK_INITIALIZER_WAITERS), \
279 "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
280 : "memory"); \
281 ret; })
283 #if defined NOT_IN_libc || defined UP
284 # define __lll_lock_asm_start LOCK_INSTR "cmpxchgl %1, %2\n\t"
285 #else
286 # define __lll_lock_asm_start "cmpl $0, %%gs:%P6\n\t" \
287 "je 0f\n\t" \
288 "lock\n" \
289 "0:\tcmpxchgl %1, %2\n\t"
290 #endif
292 #define lll_lock(futex, private) \
293 (void) \
294 ({ int ignore1, ignore2; \
295 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
296 __asm __volatile (__lll_lock_asm_start \
297 "jnz _L_lock_%=\n\t" \
298 ".subsection 1\n\t" \
299 ".type _L_lock_%=,@function\n" \
300 "_L_lock_%=:\n" \
301 "1:\tleal %2, %%ecx\n" \
302 "2:\tcall __lll_lock_wait_private\n" \
303 "3:\tjmp 18f\n" \
304 "4:\t.size _L_lock_%=, 4b-1b\n\t" \
305 ".previous\n" \
306 LLL_STUB_UNWIND_INFO_3 \
307 "18:" \
308 : "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
309 : "0" (0), "1" (1), "m" (futex), \
310 "i" (MULTIPLE_THREADS_OFFSET) \
311 : "memory"); \
312 else \
314 int ignore3; \
315 __asm __volatile (__lll_lock_asm_start \
316 "jnz _L_lock_%=\n\t" \
317 ".subsection 1\n\t" \
318 ".type _L_lock_%=,@function\n" \
319 "_L_lock_%=:\n" \
320 "1:\tleal %2, %%edx\n" \
321 "0:\tmovl %8, %%ecx\n" \
322 "2:\tcall __lll_lock_wait\n" \
323 "3:\tjmp 18f\n" \
324 "4:\t.size _L_lock_%=, 4b-1b\n\t" \
325 ".previous\n" \
326 LLL_STUB_UNWIND_INFO_4 \
327 "18:" \
328 : "=a" (ignore1), "=c" (ignore2), \
329 "=m" (futex), "=&d" (ignore3) \
330 : "1" (1), "m" (futex), \
331 "i" (MULTIPLE_THREADS_OFFSET), "0" (0), \
332 "g" ((int) (private)) \
333 : "memory"); \
337 #define lll_robust_lock(futex, id, private) \
338 ({ int result, ignore1, ignore2; \
339 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
340 "jnz _L_robust_lock_%=\n\t" \
341 ".subsection 1\n\t" \
342 ".type _L_robust_lock_%=,@function\n" \
343 "_L_robust_lock_%=:\n" \
344 "1:\tleal %2, %%edx\n" \
345 "0:\tmovl %7, %%ecx\n" \
346 "2:\tcall __lll_robust_lock_wait\n" \
347 "3:\tjmp 18f\n" \
348 "4:\t.size _L_robust_lock_%=, 4b-1b\n\t" \
349 ".previous\n" \
350 LLL_STUB_UNWIND_INFO_4 \
351 "18:" \
352 : "=a" (result), "=c" (ignore1), "=m" (futex), \
353 "=&d" (ignore2) \
354 : "0" (0), "1" (id), "m" (futex), "g" ((int) (private))\
355 : "memory"); \
356 result; })
359 /* Special version of lll_lock which causes the unlock function to
360 always wakeup waiters. */
361 #define lll_cond_lock(futex, private) \
362 (void) \
363 ({ int ignore1, ignore2, ignore3; \
364 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
365 "jnz _L_cond_lock_%=\n\t" \
366 ".subsection 1\n\t" \
367 ".type _L_cond_lock_%=,@function\n" \
368 "_L_cond_lock_%=:\n" \
369 "1:\tleal %2, %%edx\n" \
370 "0:\tmovl %7, %%ecx\n" \
371 "2:\tcall __lll_lock_wait\n" \
372 "3:\tjmp 18f\n" \
373 "4:\t.size _L_cond_lock_%=, 4b-1b\n\t" \
374 ".previous\n" \
375 LLL_STUB_UNWIND_INFO_4 \
376 "18:" \
377 : "=a" (ignore1), "=c" (ignore2), "=m" (futex), \
378 "=&d" (ignore3) \
379 : "0" (0), "1" (2), "m" (futex), "g" ((int) (private))\
380 : "memory"); \
384 #define lll_robust_cond_lock(futex, id, private) \
385 ({ int result, ignore1, ignore2; \
386 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
387 "jnz _L_robust_cond_lock_%=\n\t" \
388 ".subsection 1\n\t" \
389 ".type _L_robust_cond_lock_%=,@function\n" \
390 "_L_robust_cond_lock_%=:\n" \
391 "1:\tleal %2, %%edx\n" \
392 "0:\tmovl %7, %%ecx\n" \
393 "2:\tcall __lll_robust_lock_wait\n" \
394 "3:\tjmp 18f\n" \
395 "4:\t.size _L_robust_cond_lock_%=, 4b-1b\n\t" \
396 ".previous\n" \
397 LLL_STUB_UNWIND_INFO_4 \
398 "18:" \
399 : "=a" (result), "=c" (ignore1), "=m" (futex), \
400 "=&d" (ignore2) \
401 : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex), \
402 "g" ((int) (private)) \
403 : "memory"); \
404 result; })
407 #define lll_timedlock(futex, timeout, private) \
408 ({ int result, ignore1, ignore2, ignore3; \
409 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
410 "jnz _L_timedlock_%=\n\t" \
411 ".subsection 1\n\t" \
412 ".type _L_timedlock_%=,@function\n" \
413 "_L_timedlock_%=:\n" \
414 "1:\tleal %3, %%ecx\n" \
415 "0:\tmovl %8, %%edx\n" \
416 "2:\tcall __lll_timedlock_wait\n" \
417 "3:\tjmp 18f\n" \
418 "4:\t.size _L_timedlock_%=, 4b-1b\n\t" \
419 ".previous\n" \
420 LLL_STUB_UNWIND_INFO_4 \
421 "18:" \
422 : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
423 "=m" (futex), "=S" (ignore3) \
424 : "0" (0), "1" (1), "m" (futex), "m" (timeout), \
425 "4" ((int) (private)) \
426 : "memory"); \
427 result; })
430 #define lll_robust_timedlock(futex, timeout, id, private) \
431 ({ int result, ignore1, ignore2, ignore3; \
432 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
433 "jnz _L_robust_timedlock_%=\n\t" \
434 ".subsection 1\n\t" \
435 ".type _L_robust_timedlock_%=,@function\n" \
436 "_L_robust_timedlock_%=:\n" \
437 "1:\tleal %3, %%ecx\n" \
438 "0:\tmovl %8, %%edx\n" \
439 "2:\tcall __lll_robust_timedlock_wait\n" \
440 "3:\tjmp 18f\n" \
441 "4:\t.size _L_robust_timedlock_%=, 4b-1b\n\t" \
442 ".previous\n" \
443 LLL_STUB_UNWIND_INFO_4 \
444 "18:" \
445 : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
446 "=m" (futex), "=S" (ignore3) \
447 : "0" (0), "1" (id), "m" (futex), "m" (timeout), \
448 "4" ((int) (private)) \
449 : "memory"); \
450 result; })
452 #if defined NOT_IN_libc || defined UP
453 # define __lll_unlock_asm LOCK_INSTR "subl $1, %0\n\t"
454 #else
455 # define __lll_unlock_asm "cmpl $0, %%gs:%P3\n\t" \
456 "je 0f\n\t" \
457 "lock\n" \
458 "0:\tsubl $1,%0\n\t"
459 #endif
461 #define lll_unlock(futex, private) \
462 (void) \
463 ({ int ignore; \
464 if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
465 __asm __volatile (__lll_unlock_asm \
466 "jne _L_unlock_%=\n\t" \
467 ".subsection 1\n\t" \
468 ".type _L_unlock_%=,@function\n" \
469 "_L_unlock_%=:\n" \
470 "1:\tleal %0, %%eax\n" \
471 "2:\tcall __lll_unlock_wake_private\n" \
472 "3:\tjmp 18f\n" \
473 "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
474 ".previous\n" \
475 LLL_STUB_UNWIND_INFO_3 \
476 "18:" \
477 : "=m" (futex), "=&a" (ignore) \
478 : "m" (futex), "i" (MULTIPLE_THREADS_OFFSET) \
479 : "memory"); \
480 else \
482 int ignore2; \
483 __asm __volatile (__lll_unlock_asm \
484 "jne _L_unlock_%=\n\t" \
485 ".subsection 1\n\t" \
486 ".type _L_unlock_%=,@function\n" \
487 "_L_unlock_%=:\n" \
488 "1:\tleal %0, %%eax\n" \
489 "0:\tmovl %5, %%ecx\n" \
490 "2:\tcall __lll_unlock_wake\n" \
491 "3:\tjmp 18f\n" \
492 "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
493 ".previous\n" \
494 LLL_STUB_UNWIND_INFO_4 \
495 "18:" \
496 : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
497 : "i" (MULTIPLE_THREADS_OFFSET), "m" (futex), \
498 "g" ((int) (private)) \
499 : "memory"); \
503 #define lll_robust_unlock(futex, private) \
504 (void) \
505 ({ int ignore, ignore2; \
506 __asm __volatile (LOCK_INSTR "andl %3, %0\n\t" \
507 "jne _L_robust_unlock_%=\n\t" \
508 ".subsection 1\n\t" \
509 ".type _L_robust_unlock_%=,@function\n" \
510 "_L_robust_unlock_%=:\n\t" \
511 "1:\tleal %0, %%eax\n" \
512 "0:\tmovl %5, %%ecx\n" \
513 "2:\tcall __lll_unlock_wake\n" \
514 "3:\tjmp 18f\n" \
515 "4:\t.size _L_robust_unlock_%=, 4b-1b\n\t" \
516 ".previous\n" \
517 LLL_STUB_UNWIND_INFO_4 \
518 "18:" \
519 : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
520 : "i" (FUTEX_WAITERS), "m" (futex), \
521 "g" ((int) (private)) \
522 : "memory"); \
526 #define lll_robust_dead(futex, private) \
527 (void) \
528 ({ int __ignore; \
529 register int _nr asm ("edx") = 1; \
530 __asm __volatile (LOCK_INSTR "orl %5, (%2)\n\t" \
531 LLL_EBX_LOAD \
532 LLL_ENTER_KERNEL \
533 LLL_EBX_LOAD \
534 : "=a" (__ignore) \
535 : "0" (SYS_futex), LLL_EBX_REG (&(futex)), \
536 "c" (__lll_private_flag (FUTEX_WAKE, private)), \
537 "d" (_nr), "i" (FUTEX_OWNER_DIED), \
538 "i" (offsetof (tcbhead_t, sysinfo))); \
541 #define lll_islocked(futex) \
542 (futex != LLL_LOCK_INITIALIZER)
544 /* The kernel notifies a process with uses CLONE_CLEARTID via futex
545 wakeup when the clone terminates. The memory location contains the
546 thread ID while the clone is running and is reset to zero
547 afterwards.
549 The macro parameter must not have any side effect. */
550 #define lll_wait_tid(tid) \
551 do { \
552 int __ignore; \
553 register __typeof (tid) _tid asm ("edx") = (tid); \
554 if (_tid != 0) \
555 __asm __volatile (LLL_EBX_LOAD \
556 "1:\tmovl %1, %%eax\n\t" \
557 LLL_ENTER_KERNEL \
558 "cmpl $0, (%%ebx)\n\t" \
559 "jne 1b\n\t" \
560 LLL_EBX_LOAD \
561 : "=&a" (__ignore) \
562 : "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \
563 "c" (FUTEX_WAIT), "d" (_tid), \
564 "i" (offsetof (tcbhead_t, sysinfo)) \
565 : "memory"); \
566 } while (0)
568 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
569 __attribute__ ((regparm (2))) attribute_hidden;
570 #define lll_timedwait_tid(tid, abstime) \
571 ({ \
572 int __result = 0; \
573 if (tid != 0) \
575 if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \
576 __result = EINVAL; \
577 else \
578 __result = __lll_timedwait_tid (&tid, abstime); \
580 __result; })
582 #endif /* !__ASSEMBLER__ */
584 #endif /* lowlevellock.h */