* sysdeps/unix/sysv/linux/i386/lowlevellock.h
[glibc.git] / nptl / sysdeps / unix / sysv / linux / i386 / lowlevellock.h
blob23e81f4e4b6d04584eb28ef9e47adc12b0706c60
1 /* Copyright (C) 2002, 2003, 2004, 2006 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 #include <time.h>
24 #include <sys/param.h>
25 #include <bits/pthreadtypes.h>
27 #ifndef LOCK_INSTR
28 # ifdef UP
29 # define LOCK_INSTR /* nothing */
30 # else
31 # define LOCK_INSTR "lock;"
32 # endif
33 #endif
35 #define SYS_futex 240
36 #define FUTEX_WAIT 0
37 #define FUTEX_WAKE 1
40 /* Initializer for compatibility lock. */
41 #define LLL_MUTEX_LOCK_INITIALIZER (0)
42 #define LLL_MUTEX_LOCK_INITIALIZER_LOCKED (1)
43 #define LLL_MUTEX_LOCK_INITIALIZER_WAITERS (2)
46 #ifdef PIC
47 # define LLL_EBX_LOAD "xchgl %2, %%ebx\n"
48 # define LLL_EBX_REG "D"
49 #else
50 # define LLL_EBX_LOAD
51 # define LLL_EBX_REG "b"
52 #endif
54 #ifdef I386_USE_SYSENTER
55 # ifdef SHARED
56 # define LLL_ENTER_KERNEL "call *%%gs:%P6\n\t"
57 # else
58 # define LLL_ENTER_KERNEL "call *_dl_sysinfo\n\t"
59 # endif
60 #else
61 # define LLL_ENTER_KERNEL "int $0x80\n\t"
62 #endif
64 /* Delay in spinlock loop. */
65 #define BUSY_WAIT_NOP asm ("rep; nop")
68 #ifdef USE_CFA_VAL_EXPRESSION
69 # define LLL_STUB_UNWIND_INFO_START \
70 ".section .eh_frame,\"a\",@progbits\n" \
71 "5:\t" ".long 7f-6f # Length of Common Information Entry\n" \
72 "6:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
73 ".byte 0x1 # CIE Version\n\t" \
74 ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
75 ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
76 ".sleb128 -4 # CIE Data Alignment Factor\n\t" \
77 ".byte 0x8 # CIE RA Column\n\t" \
78 ".uleb128 0x1 # Augmentation size\n\t" \
79 ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
80 ".byte 0xc # DW_CFA_def_cfa\n\t" \
81 ".uleb128 0x4\n\t" \
82 ".uleb128 0x0\n\t" \
83 ".align 4\n" \
84 "7:\t" ".long 17f-8f # FDE Length\n" \
85 "8:\t" ".long 8b-5b # FDE CIE offset\n\t" \
86 ".long 1b-. # FDE initial location\n\t" \
87 ".long 4b-1b # FDE address range\n\t" \
88 ".uleb128 0x0 # Augmentation size\n\t" \
89 ".byte 0x16 # DW_CFA_val_expression\n\t" \
90 ".uleb128 0x8\n\t" \
91 ".uleb128 10f-9f\n" \
92 "9:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
93 ".sleb128 3b-1b\n"
94 # define LLL_STUB_UNWIND_INFO_END \
95 ".byte 0x16 # DW_CFA_val_expression\n\t" \
96 ".uleb128 0x8\n\t" \
97 ".uleb128 12f-11f\n" \
98 "11:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
99 ".sleb128 3b-2b\n" \
100 "12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t" \
101 ".byte 0x16 # DW_CFA_val_expression\n\t" \
102 ".uleb128 0x8\n\t" \
103 ".uleb128 16f-13f\n" \
104 "13:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
105 ".sleb128 15f-14f\n\t" \
106 ".byte 0x0d # DW_OP_const4s\n" \
107 "14:\t" ".4byte 3b-.\n\t" \
108 ".byte 0x1c # DW_OP_minus\n\t" \
109 ".byte 0x0d # DW_OP_const4s\n" \
110 "15:\t" ".4byte 18f-.\n\t" \
111 ".byte 0x22 # DW_OP_plus\n" \
112 "16:\t" ".align 4\n" \
113 "17:\t" ".previous\n"
115 /* Unwind info for
116 1: lea ..., ...
117 2: call ...
118 3: jmp 18f
120 snippet. */
121 # define LLL_STUB_UNWIND_INFO_3 \
122 LLL_STUB_UNWIND_INFO_START \
123 "10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
124 LLL_STUB_UNWIND_INFO_END
126 /* Unwind info for
127 1: lea ..., ...
128 0: movl ..., ...
129 2: call ...
130 3: jmp 18f
132 snippet. */
133 # define LLL_STUB_UNWIND_INFO_4 \
134 LLL_STUB_UNWIND_INFO_START \
135 "10:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
136 ".byte 0x16 # DW_CFA_val_expression\n\t" \
137 ".uleb128 0x8\n\t" \
138 ".uleb128 20f-19f\n" \
139 "19:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
140 ".sleb128 3b-0b\n" \
141 "20:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
142 LLL_STUB_UNWIND_INFO_END
144 #else
145 # define LLL_STUB_UNWIND_INFO_3
146 # define LLL_STUB_UNWIND_INFO_4
147 #endif
150 #define lll_futex_wait(futex, val) \
151 ({ \
152 int __status; \
153 register __typeof (val) _val asm ("edx") = (val); \
154 __asm __volatile (LLL_EBX_LOAD \
155 LLL_ENTER_KERNEL \
156 LLL_EBX_LOAD \
157 : "=a" (__status) \
158 : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (0), \
159 "c" (FUTEX_WAIT), "d" (_val), \
160 "i" (offsetof (tcbhead_t, sysinfo)) \
161 : "memory"); \
162 __status; \
166 #define lll_futex_timed_wait(futex, val, timeout) \
167 ({ \
168 int __status; \
169 register __typeof (val) _val asm ("edx") = (val); \
170 __asm __volatile (LLL_EBX_LOAD \
171 LLL_ENTER_KERNEL \
172 LLL_EBX_LOAD \
173 : "=a" (__status) \
174 : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \
175 "c" (FUTEX_WAIT), "d" (_val), \
176 "i" (offsetof (tcbhead_t, sysinfo)) \
177 : "memory"); \
178 __status; \
182 #define lll_futex_wake(futex, nr) \
183 do { \
184 int __ignore; \
185 register __typeof (nr) _nr asm ("edx") = (nr); \
186 __asm __volatile (LLL_EBX_LOAD \
187 LLL_ENTER_KERNEL \
188 LLL_EBX_LOAD \
189 : "=a" (__ignore) \
190 : "0" (SYS_futex), LLL_EBX_REG (futex), \
191 "c" (FUTEX_WAKE), "d" (_nr), \
192 "i" (0) /* phony, to align next arg's number */, \
193 "i" (offsetof (tcbhead_t, sysinfo))); \
194 } while (0)
197 /* Does not preserve %eax and %ecx. */
198 extern int __lll_mutex_lock_wait (int val, int *__futex)
199 __attribute ((regparm (2))) attribute_hidden;
200 /* Does not preserve %eax, %ecx, and %edx. */
201 extern int __lll_mutex_timedlock_wait (int val, int *__futex,
202 const struct timespec *abstime)
203 __attribute ((regparm (3))) attribute_hidden;
204 /* Preserves all registers but %eax. */
205 extern int __lll_mutex_unlock_wake (int *__futex)
206 __attribute ((regparm (1))) attribute_hidden;
209 /* NB: in the lll_mutex_trylock macro we simply return the value in %eax
210 after the cmpxchg instruction. In case the operation succeded this
211 value is zero. In case the operation failed, the cmpxchg instruction
212 has loaded the current value of the memory work which is guaranteed
213 to be nonzero. */
214 #define lll_mutex_trylock(futex) \
215 ({ int ret; \
216 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
217 : "=a" (ret), "=m" (futex) \
218 : "r" (LLL_MUTEX_LOCK_INITIALIZER_LOCKED), "m" (futex),\
219 "0" (LLL_MUTEX_LOCK_INITIALIZER) \
220 : "memory"); \
221 ret; })
224 #define lll_robust_mutex_trylock(futex, id) \
225 ({ int ret; \
226 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
227 : "=a" (ret), "=m" (futex) \
228 : "r" (id), "m" (futex), \
229 "0" (LLL_MUTEX_LOCK_INITIALIZER) \
230 : "memory"); \
231 ret; })
234 #define lll_mutex_cond_trylock(futex) \
235 ({ int ret; \
236 __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
237 : "=a" (ret), "=m" (futex) \
238 : "r" (LLL_MUTEX_LOCK_INITIALIZER_WAITERS), \
239 "m" (futex), "0" (LLL_MUTEX_LOCK_INITIALIZER) \
240 : "memory"); \
241 ret; })
244 #define lll_mutex_lock(futex) \
245 (void) ({ int ignore1, ignore2; \
246 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
247 "jnz _L_mutex_lock_%=\n\t" \
248 ".subsection 1\n\t" \
249 ".type _L_mutex_lock_%=,@function\n" \
250 "_L_mutex_lock_%=:\n" \
251 "1:\tleal %2, %%ecx\n" \
252 "2:\tcall __lll_mutex_lock_wait\n" \
253 "3:\tjmp 18f\n" \
254 "4:\t.size _L_mutex_lock_%=, 4b-1b\n\t" \
255 ".previous\n" \
256 LLL_STUB_UNWIND_INFO_3 \
257 "18:" \
258 : "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
259 : "0" (0), "1" (1), "m" (futex) \
260 : "memory"); })
263 #define lll_robust_mutex_lock(futex, id) \
264 ({ int result, ignore; \
265 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
266 "jnz _L_robust_mutex_lock_%=\n\t" \
267 ".subsection 1\n\t" \
268 ".type _L_robust_mutex_lock_%=,@function\n" \
269 "_L_robust_mutex_lock_%=:\n" \
270 "1:\tleal %2, %%ecx\n" \
271 "2:\tcall __lll_robust_mutex_lock_wait\n" \
272 "3:\tjmp 18f\n" \
273 "4:\t.size _L_robust_mutex_lock_%=, 4b-1b\n\t" \
274 ".previous\n" \
275 LLL_STUB_UNWIND_INFO_3 \
276 "18:" \
277 : "=a" (result), "=c" (ignore), "=m" (futex) \
278 : "0" (0), "1" (id), "m" (futex) \
279 : "memory"); \
280 result; })
283 /* Special version of lll_mutex_lock which causes the unlock function to
284 always wakeup waiters. */
285 #define lll_mutex_cond_lock(futex) \
286 (void) ({ int ignore1, ignore2; \
287 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
288 "jnz _L_mutex_cond_lock_%=\n\t" \
289 ".subsection 1\n\t" \
290 ".type _L_mutex_cond_lock_%=,@function\n" \
291 "_L_mutex_cond_lock_%=:\n" \
292 "1:\tleal %2, %%ecx\n" \
293 "2:\tcall __lll_mutex_lock_wait\n" \
294 "3:\tjmp 18f\n" \
295 "4:\t.size _L_mutex_cond_lock_%=, 4b-1b\n\t" \
296 ".previous\n" \
297 LLL_STUB_UNWIND_INFO_3 \
298 "18:" \
299 : "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
300 : "0" (0), "1" (2), "m" (futex) \
301 : "memory"); })
304 #define lll_robust_mutex_cond_lock(futex, id) \
305 ({ int result, ignore; \
306 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
307 "jnz _L_robust_mutex_cond_lock_%=\n\t" \
308 ".subsection 1\n\t" \
309 ".type _L_robust_mutex_cond_lock_%=,@function\n" \
310 "_L_robust_mutex_cond_lock_%=:\n" \
311 "1:\tleal %2, %%ecx\n" \
312 "2:\tcall __lll_robust_mutex_lock_wait\n" \
313 "3:\tjmp 18f\n" \
314 "4:\t.size _L_robust_mutex_cond_lock_%=, 4b-1b\n\t" \
315 ".previous\n" \
316 LLL_STUB_UNWIND_INFO_3 \
317 "18:" \
318 : "=a" (result), "=c" (ignore), "=m" (futex) \
319 : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex) \
320 : "memory"); \
321 result; })
324 #define lll_mutex_timedlock(futex, timeout) \
325 ({ int result, ignore1, ignore2; \
326 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
327 "jnz _L_mutex_timedlock_%=\n\t" \
328 ".subsection 1\n\t" \
329 ".type _L_mutex_timedlock_%=,@function\n" \
330 "_L_mutex_timedlock_%=:\n" \
331 "1:\tleal %3, %%ecx\n" \
332 "0:\tmovl %7, %%edx\n" \
333 "2:\tcall __lll_mutex_timedlock_wait\n" \
334 "3:\tjmp 18f\n" \
335 "4:\t.size _L_mutex_timedlock_%=, 4b-1b\n\t" \
336 ".previous\n" \
337 LLL_STUB_UNWIND_INFO_4 \
338 "18:" \
339 : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
340 "=m" (futex) \
341 : "0" (0), "1" (1), "m" (futex), "m" (timeout) \
342 : "memory"); \
343 result; })
346 #define lll_robust_mutex_timedlock(futex, timeout, id) \
347 ({ int result, ignore1, ignore2; \
348 __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
349 "jnz _L_robust_mutex_timedlock_%=\n\t" \
350 ".subsection 1\n\t" \
351 ".type _L_robust_mutex_timedlock_%=,@function\n" \
352 "_L_robust_mutex_timedlock_%=:\n" \
353 "1:\tleal %3, %%ecx\n" \
354 "0:\tmovl %7, %%edx\n" \
355 "2:\tcall __lll_robust_mutex_timedlock_wait\n" \
356 "3:\tjmp 18f\n" \
357 "4:\t.size _L_robust_mutex_timedlock_%=, 4b-1b\n\t" \
358 ".previous\n" \
359 LLL_STUB_UNWIND_INFO_4 \
360 "18:" \
361 : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
362 "=m" (futex) \
363 : "0" (0), "1" (id), "m" (futex), "m" (timeout) \
364 : "memory"); \
365 result; })
368 #define lll_mutex_unlock(futex) \
369 (void) ({ int ignore; \
370 __asm __volatile (LOCK_INSTR "subl $1, %0\n\t" \
371 "jne _L_mutex_unlock_%=\n\t" \
372 ".subsection 1\n\t" \
373 ".type _L_mutex_unlock_%=,@function\n" \
374 "_L_mutex_unlock_%=:\n" \
375 "1:\tleal %0, %%eax\n" \
376 "2:\tcall __lll_mutex_unlock_wake\n" \
377 "3:\tjmp 18f\n" \
378 "4:\t.size _L_mutex_unlock_%=, 4b-1b\n\t" \
379 ".previous\n" \
380 LLL_STUB_UNWIND_INFO_3 \
381 "18:" \
382 : "=m" (futex), "=&a" (ignore) \
383 : "m" (futex) \
384 : "memory"); })
387 #define lll_robust_mutex_unlock(futex) \
388 (void) ({ int ignore; \
389 __asm __volatile (LOCK_INSTR "andl %2, %0\n\t" \
390 "jne _L_robust_mutex_unlock_%=\n\t" \
391 ".subsection 1\n\t" \
392 ".type _L_robust_mutex_unlock_%=,@function\n" \
393 "_L_robust_mutex_unlock_%=:\n\t" \
394 "1:\tleal %0, %%eax\n" \
395 "2:\tcall __lll_mutex_unlock_wake\n" \
396 "3:\tjmp 18f\n" \
397 "4:\t.size _L_robust_mutex_unlock_%=, 4b-1b\n\t"\
398 ".previous\n" \
399 LLL_STUB_UNWIND_INFO_3 \
400 "18:" \
401 : "=m" (futex), "=&a" (ignore) \
402 : "i" (FUTEX_WAITERS), "m" (futex) \
403 : "memory"); })
406 #define lll_robust_mutex_dead(futex) \
407 (void) ({ int __ignore; \
408 register int _nr asm ("edx") = 1; \
409 __asm __volatile (LOCK_INSTR "orl %5, (%2)\n\t" \
410 LLL_EBX_LOAD \
411 LLL_ENTER_KERNEL \
412 LLL_EBX_LOAD \
413 : "=a" (__ignore) \
414 : "0" (SYS_futex), LLL_EBX_REG (&(futex)), \
415 "c" (FUTEX_WAKE), "d" (_nr), \
416 "i" (FUTEX_OWNER_DIED), \
417 "i" (offsetof (tcbhead_t, sysinfo))); })
420 #define lll_futex_wake(futex, nr) \
421 do { \
422 int __ignore; \
423 register __typeof (nr) _nr asm ("edx") = (nr); \
424 __asm __volatile (LLL_EBX_LOAD \
425 LLL_ENTER_KERNEL \
426 LLL_EBX_LOAD \
427 : "=a" (__ignore) \
428 : "0" (SYS_futex), LLL_EBX_REG (futex), \
429 "c" (FUTEX_WAKE), "d" (_nr), \
430 "i" (0) /* phony, to align next arg's number */, \
431 "i" (offsetof (tcbhead_t, sysinfo))); \
432 } while (0)
435 #define lll_mutex_islocked(futex) \
436 (futex != 0)
439 /* We have a separate internal lock implementation which is not tied
440 to binary compatibility. */
442 /* Type for lock object. */
443 typedef int lll_lock_t;
445 /* Initializers for lock. */
446 #define LLL_LOCK_INITIALIZER (0)
447 #define LLL_LOCK_INITIALIZER_LOCKED (1)
450 extern int __lll_lock_wait (int val, int *__futex)
451 __attribute ((regparm (2))) attribute_hidden;
452 extern int __lll_unlock_wake (int *__futex)
453 __attribute ((regparm (1))) attribute_hidden;
454 extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
457 /* The states of a lock are:
458 0 - untaken
459 1 - taken by one user
460 2 - taken by more users */
463 #if defined NOT_IN_libc || defined UP
464 # define lll_trylock(futex) lll_mutex_trylock (futex)
465 # define lll_lock(futex) lll_mutex_lock (futex)
466 # define lll_unlock(futex) lll_mutex_unlock (futex)
467 #else
468 /* Special versions of the macros for use in libc itself. They avoid
469 the lock prefix when the thread library is not used.
471 XXX In future we might even want to avoid it on UP machines. */
472 # include <tls.h>
474 # define lll_trylock(futex) \
475 ({ unsigned char ret; \
476 __asm __volatile ("cmpl $0, %%gs:%P5\n\t" \
477 "je,pt 0f\n\t" \
478 "lock\n" \
479 "0:\tcmpxchgl %2, %1; setne %0" \
480 : "=a" (ret), "=m" (futex) \
481 : "r" (LLL_MUTEX_LOCK_INITIALIZER_LOCKED), "m" (futex),\
482 "0" (LLL_MUTEX_LOCK_INITIALIZER), \
483 "i" (offsetof (tcbhead_t, multiple_threads)) \
484 : "memory"); \
485 ret; })
488 # define lll_lock(futex) \
489 (void) ({ int ignore1, ignore2; \
490 __asm __volatile ("cmpl $0, %%gs:%P6\n\t" \
491 "je,pt 0f\n\t" \
492 "lock\n" \
493 "0:\tcmpxchgl %1, %2\n\t" \
494 "jnz _L_lock_%=\n\t" \
495 ".subsection 1\n\t" \
496 ".type _L_lock_%=,@function\n" \
497 "_L_lock_%=:\n" \
498 "1:\tleal %2, %%ecx\n" \
499 "2:\tcall __lll_mutex_lock_wait\n" \
500 "3:\tjmp 18f\n" \
501 "4:\t.size _L_lock_%=, 4b-1b\n\t" \
502 ".previous\n" \
503 LLL_STUB_UNWIND_INFO_3 \
504 "18:" \
505 : "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
506 : "0" (0), "1" (1), "m" (futex), \
507 "i" (offsetof (tcbhead_t, multiple_threads)) \
508 : "memory"); })
511 # define lll_unlock(futex) \
512 (void) ({ int ignore; \
513 __asm __volatile ("cmpl $0, %%gs:%P3\n\t" \
514 "je,pt 0f\n\t" \
515 "lock\n" \
516 "0:\tsubl $1,%0\n\t" \
517 "jne _L_unlock_%=\n\t" \
518 ".subsection 1\n\t" \
519 ".type _L_unlock_%=,@function\n" \
520 "_L_unlock_%=:\n" \
521 "1:\tleal %0, %%eax\n" \
522 "2:\tcall __lll_mutex_unlock_wake\n" \
523 "3:\tjmp 18f\n\t" \
524 "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
525 ".previous\n" \
526 LLL_STUB_UNWIND_INFO_3 \
527 "18:" \
528 : "=m" (futex), "=&a" (ignore) \
529 : "m" (futex), \
530 "i" (offsetof (tcbhead_t, multiple_threads)) \
531 : "memory"); })
532 #endif
535 #define lll_islocked(futex) \
536 (futex != LLL_LOCK_INITIALIZER)
539 /* The kernel notifies a process with uses CLONE_CLEARTID via futex
540 wakeup when the clone terminates. The memory location contains the
541 thread ID while the clone is running and is reset to zero
542 afterwards.
544 The macro parameter must not have any side effect. */
545 #define lll_wait_tid(tid) \
546 do { \
547 int __ignore; \
548 register __typeof (tid) _tid asm ("edx") = (tid); \
549 if (_tid != 0) \
550 __asm __volatile (LLL_EBX_LOAD \
551 "1:\tmovl %1, %%eax\n\t" \
552 LLL_ENTER_KERNEL \
553 "cmpl $0, (%%ebx)\n\t" \
554 "jne,pn 1b\n\t" \
555 LLL_EBX_LOAD \
556 : "=&a" (__ignore) \
557 : "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \
558 "c" (FUTEX_WAIT), "d" (_tid), \
559 "i" (offsetof (tcbhead_t, sysinfo)) \
560 : "memory"); \
561 } while (0)
563 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
564 __attribute__ ((regparm (2))) attribute_hidden;
565 #define lll_timedwait_tid(tid, abstime) \
566 ({ \
567 int __result = 0; \
568 if (tid != 0) \
570 if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \
571 __result = EINVAL; \
572 else \
573 __result = __lll_timedwait_tid (&tid, abstime); \
575 __result; })
578 /* Conditional variable handling. */
580 extern void __lll_cond_wait (pthread_cond_t *cond)
581 __attribute ((regparm (1))) attribute_hidden;
582 extern int __lll_cond_timedwait (pthread_cond_t *cond,
583 const struct timespec *abstime)
584 __attribute ((regparm (2))) attribute_hidden;
585 extern void __lll_cond_wake (pthread_cond_t *cond)
586 __attribute ((regparm (1))) attribute_hidden;
587 extern void __lll_cond_broadcast (pthread_cond_t *cond)
588 __attribute ((regparm (1))) attribute_hidden;
591 #define lll_cond_wait(cond) \
592 __lll_cond_wait (cond)
593 #define lll_cond_timedwait(cond, abstime) \
594 __lll_cond_timedwait (cond, abstime)
595 #define lll_cond_wake(cond) \
596 __lll_cond_wake (cond)
597 #define lll_cond_broadcast(cond) \
598 __lll_cond_broadcast (cond)
601 #endif /* lowlevellock.h */