Back to index

glibc  2.9
Defines | Functions
lowlevellock.h File Reference
#include <time.h>
#include <sys/param.h>
#include <bits/pthreadtypes.h>
#include <kernel-features.h>
#include <tcb-offsets.h>

Go to the source code of this file.

Defines

#define LOCK_INSTR   "lock;"
#define SYS_futex   202
#define FUTEX_WAIT   0
#define FUTEX_WAKE   1
#define FUTEX_CMP_REQUEUE   4
#define FUTEX_WAKE_OP   5
#define FUTEX_LOCK_PI   6
#define FUTEX_UNLOCK_PI   7
#define FUTEX_TRYLOCK_PI   8
#define FUTEX_PRIVATE_FLAG   128
#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE   ((4 << 24) | 1)
#define LLL_PRIVATE   0
#define LLL_SHARED   FUTEX_PRIVATE_FLAG
#define __lll_private_flag(fl, private)   ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
#define LLL_LOCK_INITIALIZER   (0)
#define LLL_LOCK_INITIALIZER_LOCKED   (1)
#define LLL_LOCK_INITIALIZER_WAITERS   (2)
#define BUSY_WAIT_NOP   asm ("rep; nop")
#define LLL_STUB_UNWIND_INFO_START
#define LLL_STUB_UNWIND_INFO_END
#define LLL_STUB_UNWIND_INFO_5
#define LLL_STUB_UNWIND_INFO_6
#define lll_futex_wait(futex, val, private)   lll_futex_timed_wait(futex, val, NULL, private)
#define lll_futex_timed_wait(futex, val, timeout, private)
#define lll_futex_wake(futex, nr, private)
#define __lll_trylock_asm
#define lll_trylock(futex)
#define lll_robust_trylock(futex, id)
#define lll_cond_trylock(futex)
#define __lll_lock_asm_start
#define lll_lock(futex, private)
#define lll_robust_lock(futex, id, private)
#define lll_cond_lock(futex, private)
#define lll_robust_cond_lock(futex, id, private)
#define lll_timedlock(futex, timeout, private)
#define lll_robust_timedlock(futex, timeout, id, private)
#define __lll_unlock_asm_start
#define lll_unlock(futex, private)
#define lll_robust_unlock(futex, private)
#define lll_robust_dead(futex, private)
#define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val, private)
#define lll_islocked(futex)   (futex != LLL_LOCK_INITIALIZER)
#define lll_wait_tid(tid)
#define lll_timedwait_tid(tid, abstime)

Functions

int __lll_timedwait_tid (int *tid, const struct timespec *abstime) attribute_hidden

Define Documentation

Value:
"cmpl $0, __libc_multiple_threads(%%rip)\n\t"   \
                           "je 0f\n\t"                               \
                           "lock; cmpxchgl %4, %2\n\t"               \
                           "jnz 1f\n\t"                              \
                           "jmp 24f\n"                               \
                           "0:\tcmpxchgl %4, %2\n\t"                        \
                           "jnz 1f\n\t"

Definition at line 278 of file lowlevellock.h.

#define __lll_private_flag (   fl,
  private 
)    ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))

Definition at line 73 of file lowlevellock.h.

Value:
"cmpl $0, __libc_multiple_threads(%%rip)\n\t"      \
                        "je 0f\n\t"                                         \
                        "lock; cmpxchgl %2, %1\n\t"                         \
                        "jmp 1f\n\t"                                        \
                        "0:\tcmpxchgl %2, %1\n\t"                           \
                        "1:"

Definition at line 240 of file lowlevellock.h.

Value:
"cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
                            "je 0f\n\t"                              \
                            "lock; decl %0\n\t"                      \
                            "jne 1f\n\t"                             \
                            "jmp 24f\n\t"                            \
                            "0:\tdecl %0\n\t"                        \
                            "jne 1f\n\t"

Definition at line 448 of file lowlevellock.h.

#define BUSY_WAIT_NOP   asm ("rep; nop")

Definition at line 99 of file lowlevellock.h.

#define FUTEX_CMP_REQUEUE   4

Definition at line 50 of file lowlevellock.h.

#define FUTEX_LOCK_PI   6

Definition at line 52 of file lowlevellock.h.

#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE   ((4 << 24) | 1)

Definition at line 57 of file lowlevellock.h.

#define FUTEX_PRIVATE_FLAG   128

Definition at line 55 of file lowlevellock.h.

#define FUTEX_TRYLOCK_PI   8

Definition at line 54 of file lowlevellock.h.

#define FUTEX_UNLOCK_PI   7

Definition at line 53 of file lowlevellock.h.

#define FUTEX_WAIT   0

Definition at line 48 of file lowlevellock.h.

#define FUTEX_WAKE   1

Definition at line 49 of file lowlevellock.h.

#define FUTEX_WAKE_OP   5

Definition at line 51 of file lowlevellock.h.

#define lll_cond_lock (   futex,
  private 
)
Value:
(void)                                                        \
    ({ int ignore1, ignore2, ignore3;                                       \
       __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t"                   \
                      "jnz 1f\n\t"                                   \
                      ".subsection 1\n\t"                            \
                      ".type _L_cond_lock_%=, @function\n"                  \
                      "_L_cond_lock_%=:\n"                                  \
                      "1:\tleaq %2, %%rdi\n"                                \
                      "2:\tsubq $128, %%rsp\n"                       \
                      "3:\tcallq __lll_lock_wait\n"                         \
                      "4:\taddq $128, %%rsp\n"                       \
                      "5:\tjmp 24f\n"                                \
                      "6:\t.size _L_cond_lock_%=, 6b-1b\n\t"                \
                      ".previous\n"                                         \
                      LLL_STUB_UNWIND_INFO_5                                \
                      "24:"                                          \
                      : "=S" (ignore1), "=D" (ignore2), "=m" (futex),      \
                        "=a" (ignore3)                               \
                      : "1" (2), "m" (futex), "3" (0), "0" (private)        \
                      : "cx", "r11", "cc", "memory");                \
    })

Definition at line 350 of file lowlevellock.h.

#define lll_cond_trylock (   futex)
Value:
({ int ret;                                                          \
     __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1"                         \
                     : "=a" (ret), "=m" (futex)                      \
                     : "r" (LLL_LOCK_INITIALIZER_WAITERS),                  \
                      "m" (futex), "0" (LLL_LOCK_INITIALIZER)        \
                     : "memory");                                    \
     ret; })

Definition at line 265 of file lowlevellock.h.

#define lll_futex_requeue (   ftx,
  nr_wake,
  nr_move,
  mutex,
  val,
  private 
)
Value:
({ int __res;                                                        \
     register int __nr_move __asm ("r10") = nr_move;                        \
     register void *__mutex __asm ("r8") = mutex;                           \
     register int __val __asm ("r9") = val;                                 \
     __asm __volatile ("syscall"                                     \
                     : "=a" (__res)                                         \
                     : "0" (__NR_futex), "D" ((void *) ftx),                \
                      "S" (__lll_private_flag (FUTEX_CMP_REQUEUE,           \
                                            private)), "d" (nr_wake),   \
                      "r" (__nr_move), "r" (__mutex), "r" (__val)           \
                     : "cx", "r11", "cc", "memory");                        \
     __res < 0; })

Definition at line 536 of file lowlevellock.h.

#define lll_futex_timed_wait (   futex,
  val,
  timeout,
  private 
)
Value:
({                                                                   \
    register const struct timespec *__to __asm ("r10") = timeout;           \
    int __status;                                                    \
    register __typeof (val) _val __asm ("edx") = (val);                     \
    __asm __volatile ("syscall"                                             \
                    : "=a" (__status)                                       \
                    : "0" (SYS_futex), "D" (futex),                         \
                     "S" (__lll_private_flag (FUTEX_WAIT, private)),        \
                     "d" (_val), "r" (__to)                                 \
                    : "memory", "cc", "r11", "cx");                         \
    __status;                                                        \
  })

Definition at line 204 of file lowlevellock.h.

#define lll_futex_wait (   futex,
  val,
  private 
)    lll_futex_timed_wait(futex, val, NULL, private)

Definition at line 200 of file lowlevellock.h.

#define lll_futex_wake (   futex,
  nr,
  private 
)
Value:
do {                                                                 \
    int __ignore;                                                    \
    register __typeof (nr) _nr __asm ("edx") = (nr);                        \
    __asm __volatile ("syscall"                                             \
                    : "=a" (__ignore)                                       \
                    : "0" (SYS_futex), "D" (futex),                         \
                     "S" (__lll_private_flag (FUTEX_WAKE, private)),        \
                     "d" (_nr)                                       \
                    : "memory", "cc", "r10", "r11", "cx");                  \
  } while (0)

Definition at line 219 of file lowlevellock.h.

#define lll_islocked (   futex)    (futex != LLL_LOCK_INITIALIZER)

Definition at line 550 of file lowlevellock.h.

#define lll_lock (   futex,
  private 
)

Definition at line 287 of file lowlevellock.h.

#define LLL_LOCK_INITIALIZER   (0)

Definition at line 94 of file lowlevellock.h.

#define LLL_LOCK_INITIALIZER_LOCKED   (1)

Definition at line 95 of file lowlevellock.h.

#define LLL_LOCK_INITIALIZER_WAITERS   (2)

Definition at line 96 of file lowlevellock.h.

#define LLL_PRIVATE   0

Definition at line 62 of file lowlevellock.h.

#define lll_robust_cond_lock (   futex,
  id,
  private 
)
Value:
({ int result, ignore1, ignore2;                                     \
    __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t"                      \
                    "jnz 1f\n\t"                                     \
                    ".subsection 1\n\t"                              \
                    ".type _L_robust_cond_lock_%=, @function\n"             \
                    "_L_robust_cond_lock_%=:\n"                      \
                    "1:\tleaq %2, %%rdi\n"                                  \
                    "2:\tsubq $128, %%rsp\n"                                \
                    "3:\tcallq __lll_robust_lock_wait\n"                    \
                    "4:\taddq $128, %%rsp\n"                                \
                    "5:\tjmp 24f\n"                                         \
                    "6:\t.size _L_robust_cond_lock_%=, 6b-1b\n\t"           \
                    ".previous\n"                                    \
                    LLL_STUB_UNWIND_INFO_5                                  \
                    "24:"                                            \
                    : "=S" (ignore1), "=D" (ignore2), "=m" (futex),         \
                     "=a" (result)                                   \
                    : "1" (id | FUTEX_WAITERS), "m" (futex), "3" (0),       \
                     "0" (private)                                   \
                    : "cx", "r11", "cc", "memory");                         \
    result; })

Definition at line 373 of file lowlevellock.h.

#define lll_robust_dead (   futex,
  private 
)
Value:
do                                                                   \
    {                                                                \
      int ignore;                                                    \
      __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t"                       \
                     "syscall"                                       \
                     : "=m" (futex), "=a" (ignore)                          \
                     : "D" (&(futex)), "i" (FUTEX_OWNER_DIED),       \
                       "S" (__lll_private_flag (FUTEX_WAKE, private)),     \
                       "1" (__NR_futex), "d" (1)                     \
                     : "cx", "r11", "cc", "memory");                        \
    }                                                                \
  while (0)

Definition at line 521 of file lowlevellock.h.

#define lll_robust_lock (   futex,
  id,
  private 
)
Value:
({ int result, ignore1, ignore2;                                     \
    __asm __volatile (LOCK_INSTR "cmpxchgl %4, %2\n\t"                      \
                    "jnz 1f\n\t"                                     \
                    ".subsection 1\n\t"                              \
                    ".type _L_robust_lock_%=, @function\n"                  \
                    "_L_robust_lock_%=:\n"                                  \
                    "1:\tleaq %2, %%rdi\n"                                  \
                    "2:\tsubq $128, %%rsp\n"                                \
                    "3:\tcallq __lll_robust_lock_wait\n"                    \
                    "4:\taddq $128, %%rsp\n"                                \
                    "5:\tjmp 24f\n"                                         \
                    "6:\t.size _L_robust_lock_%=, 6b-1b\n\t"                \
                    ".previous\n"                                    \
                    LLL_STUB_UNWIND_INFO_5                                  \
                    "24:"                                            \
                    : "=S" (ignore1), "=D" (ignore2), "=m" (futex),         \
                     "=a" (result)                                   \
                    : "1" (id), "m" (futex), "3" (0), "0" (private)         \
                    : "cx", "r11", "cc", "memory");                         \
    result; })

Definition at line 328 of file lowlevellock.h.

#define lll_robust_timedlock (   futex,
  timeout,
  id,
  private 
)
Value:
({ int result, ignore1, ignore2, ignore3;                            \
     __asm __volatile (LOCK_INSTR "cmpxchgl %1, %4\n\t"                     \
                     "jnz 1f\n\t"                                    \
                     ".subsection 1\n\t"                             \
                     ".type _L_robust_timedlock_%=, @function\n"            \
                     "_L_robust_timedlock_%=:\n"                     \
                     "1:\tleaq %4, %%rdi\n"                                 \
                     "0:\tmovq %8, %%rdx\n"                                 \
                     "2:\tsubq $128, %%rsp\n"                               \
                     "3:\tcallq __lll_robust_timedlock_wait\n"       \
                     "4:\taddq $128, %%rsp\n"                               \
                     "5:\tjmp 24f\n"                                        \
                     "6:\t.size _L_robust_timedlock_%=, 6b-1b\n\t"          \
                     ".previous\n"                                   \
                     LLL_STUB_UNWIND_INFO_6                                 \
                     "24:"                                           \
                     : "=a" (result), "=D" (ignore1), "=S" (ignore2),       \
                      "=&d" (ignore3), "=m" (futex)                         \
                     : "0" (0), "1" (id), "m" (futex), "m" (timeout),       \
                      "2" (private)                                         \
                     : "memory", "cx", "cc", "r10", "r11");                 \
     result; })

Definition at line 420 of file lowlevellock.h.

#define lll_robust_trylock (   futex,
  id 
)
Value:
({ int ret;                                                          \
     __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1"                         \
                     : "=a" (ret), "=m" (futex)                      \
                     : "r" (id), "m" (futex),    "0" (LLL_LOCK_INITIALIZER)    \
                     : "memory");                                    \
     ret; })

Definition at line 257 of file lowlevellock.h.

#define lll_robust_unlock (   futex,
  private 
)
Value:
do                                                                   \
    {                                                                \
      int ignore;                                                    \
      __asm __volatile (LOCK_INSTR "andl %2, %0\n\t"                        \
                     "jne 1f\n\t"                                    \
                     ".subsection 1\n\t"                             \
                     ".type _L_robust_unlock_%=, @function\n"        \
                     "_L_robust_unlock_%=:\n"                        \
                     "1:\tleaq %0, %%rdi\n"                                 \
                     "2:\tsubq $128, %%rsp\n"                        \
                     "3:\tcallq __lll_unlock_wake\n"                        \
                     "4:\taddq $128, %%rsp\n"                        \
                     "5:\tjmp 24f\n"                                        \
                     "6:\t.size _L_robust_unlock_%=, 6b-1b\n\t"             \
                     ".previous\n"                                   \
                     LLL_STUB_UNWIND_INFO_5                                 \
                     "24:"                                           \
                     : "=m" (futex), "=&D" (ignore)                         \
                     : "i" (FUTEX_WAITERS), "m" (futex),                    \
                       "S" (private)                                        \
                     : "ax", "cx", "r11", "cc", "memory");                  \
    }                                                                \
  while (0)

Definition at line 496 of file lowlevellock.h.

Definition at line 63 of file lowlevellock.h.

Value:
LLL_STUB_UNWIND_INFO_START                              \
"12:\t"       ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t"  \
LLL_STUB_UNWIND_INFO_END

Definition at line 174 of file lowlevellock.h.

Value:
LLL_STUB_UNWIND_INFO_START                              \
"12:\t"       ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t"  \
       ".byte 0x16   # DW_CFA_val_expression\n\t"              \
       ".uleb128 0x10\n\t"                              \
       ".uleb128 26f-25f\n"                                    \
"25:\t"       ".byte 0x80   # DW_OP_breg16\n\t"                \
       ".sleb128 4b-0b\n"                               \
"26:\t"       ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t"  \
LLL_STUB_UNWIND_INFO_END

Definition at line 188 of file lowlevellock.h.

Definition at line 127 of file lowlevellock.h.

Value:
".section     .eh_frame,\"a\",@progbits\n"              \
"7:\t" ".long 9f-8f  # Length of Common Information Entry\n" \
"8:\t" ".long 0x0    # CIE Identifier Tag\n\t"          \
       ".byte 0x1    # CIE Version\n\t"                 \
       ".ascii \"zR\\0\"    # CIE Augmentation\n\t"     \
       ".uleb128 0x1 # CIE Code Alignment Factor\n\t"   \
       ".sleb128 -8  # CIE Data Alignment Factor\n\t"   \
       ".byte 0x10   # CIE RA Column\n\t"                      \
       ".uleb128 0x1 # Augmentation size\n\t"           \
       ".byte 0x1b   # FDE Encoding (pcrel sdata4)\n\t"        \
       ".byte 0x12   # DW_CFA_def_cfa_sf\n\t"           \
       ".uleb128 0x7\n\t"                               \
       ".sleb128 16\n\t"                                \
       ".align 8\n"                                     \
"9:\t" ".long 23f-10f       # FDE Length\n"                    \
"10:\t"       ".long 10b-7b # FDE CIE offset\n\t"                     \
       ".long 1b-.   # FDE initial location\n\t"               \
       ".long 6b-1b  # FDE address range\n\t"           \
       ".uleb128 0x0 # Augmentation size\n\t"           \
       ".byte 0x16   # DW_CFA_val_expression\n\t"              \
       ".uleb128 0x10\n\t"                              \
       ".uleb128 12f-11f\n"                                    \
"11:\t"       ".byte 0x80   # DW_OP_breg16\n\t"                \
       ".sleb128 4b-1b\n"

Definition at line 102 of file lowlevellock.h.

#define lll_timedlock (   futex,
  timeout,
  private 
)
Value:
({ int result, ignore1, ignore2, ignore3;                            \
     __asm __volatile (LOCK_INSTR "cmpxchgl %1, %4\n\t"                     \
                     "jnz 1f\n\t"                                    \
                     ".subsection 1\n\t"                             \
                     ".type _L_timedlock_%=, @function\n"                   \
                     "_L_timedlock_%=:\n"                            \
                     "1:\tleaq %4, %%rdi\n"                                 \
                     "0:\tmovq %8, %%rdx\n"                                 \
                     "2:\tsubq $128, %%rsp\n"                               \
                     "3:\tcallq __lll_timedlock_wait\n"              \
                     "4:\taddq $128, %%rsp\n"                               \
                     "5:\tjmp 24f\n"                                        \
                     "6:\t.size _L_timedlock_%=, 6b-1b\n\t"                 \
                     ".previous\n"                                   \
                     LLL_STUB_UNWIND_INFO_6                                 \
                     "24:"                                           \
                     : "=a" (result), "=D" (ignore1), "=S" (ignore2),       \
                      "=&d" (ignore3), "=m" (futex)                         \
                     : "0" (0), "1" (1), "m" (futex), "m" (timeout),        \
                      "2" (private)                                         \
                     : "memory", "cx", "cc", "r10", "r11");                 \
     result; })

Definition at line 396 of file lowlevellock.h.

#define lll_timedwait_tid (   tid,
  abstime 
)
Value:
({                                                                   \
    int __result = 0;                                                       \
    if (tid != 0)                                                    \
      {                                                                     \
       if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)          \
         __result = EINVAL;                                          \
       else                                                          \
         __result = __lll_timedwait_tid (&tid, abstime);                    \
      }                                                                     \
    __result; })

Definition at line 578 of file lowlevellock.h.

#define lll_trylock (   futex)
Value:
({ int ret;                                                          \
     __asm __volatile (__lll_trylock_asm                             \
                     : "=a" (ret), "=m" (futex)                      \
                     : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex),      \
                      "0" (LLL_LOCK_INITIALIZER)                     \
                     : "memory");                                    \
     ret; })

Definition at line 248 of file lowlevellock.h.

#define lll_unlock (   futex,
  private 
)

Definition at line 457 of file lowlevellock.h.

#define lll_wait_tid (   tid)
Value:
do {                                                                 \
    int __ignore;                                                    \
    register __typeof (tid) _tid asm ("edx") = (tid);                       \
    if (_tid != 0)                                                   \
      __asm __volatile ("xorq %%r10, %%r10\n\t"                             \
                     "1:\tmovq %2, %%rax\n\t"                        \
                     "syscall\n\t"                                   \
                     "cmpl $0, (%%rdi)\n\t"                                 \
                     "jne 1b"                                        \
                     : "=&a" (__ignore)                              \
                     : "S" (FUTEX_WAIT), "i" (SYS_futex), "D" (&tid),      \
                       "d" (_tid)                                    \
                     : "memory", "cc", "r10", "r11", "cx");                 \
  } while (0)

Definition at line 560 of file lowlevellock.h.

#define LOCK_INSTR   "lock;"

Definition at line 34 of file lowlevellock.h.

#define SYS_futex   202

Definition at line 47 of file lowlevellock.h.


Function Documentation

int __lll_timedwait_tid ( int tid,
const struct timespec abstime 
)