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