⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lowlevellock.h

📁 glibc 2.9,最新版的C语言库函数
💻 H
📖 第 1 页 / 共 2 页
字号:
			   "jnz _L_lock_%=\n\t"				      \			   ".subsection 1\n\t"				      \			   ".type _L_lock_%=,@function\n"		      \			   "_L_lock_%=:\n"				      \			   "1:\tleal %2, %%ecx\n"			      \			   "2:\tcall __lll_lock_wait_private\n" 	      \			   "3:\tjmp 18f\n"				      \			   "4:\t.size _L_lock_%=, 4b-1b\n\t"		      \			   ".previous\n"				      \			   LLL_STUB_UNWIND_INFO_3			      \			   "18:"					      \			   : "=a" (ignore1), "=c" (ignore2), "=m" (futex)     \			   : "0" (0), "1" (1), "m" (futex),		      \			     "i" (MULTIPLE_THREADS_OFFSET)		      \			   : "memory");					      \       else								      \	 {								      \	   int ignore3;							      \	   __asm __volatile (__lll_lock_asm_start			      \			     "jnz _L_lock_%=\n\t"			      \			     ".subsection 1\n\t"			      \			     ".type _L_lock_%=,@function\n"		      \			     "_L_lock_%=:\n"				      \			     "1:\tleal %2, %%edx\n"			      \			     "0:\tmovl %8, %%ecx\n"			      \			     "2:\tcall __lll_lock_wait\n"		      \			     "3:\tjmp 18f\n"				      \			     "4:\t.size _L_lock_%=, 4b-1b\n\t"		      \			     ".previous\n"				      \			     LLL_STUB_UNWIND_INFO_4			      \			     "18:"					      \			     : "=a" (ignore1), "=c" (ignore2),		      \			       "=m" (futex), "=&d" (ignore3) 		      \			     : "1" (1), "m" (futex),			      \			       "i" (MULTIPLE_THREADS_OFFSET), "0" (0),	      \			       "g" ((int) (private))			      \			     : "memory");				      \	 }								      \    })#define lll_robust_lock(futex, id, private) \  ({ int result, ignore1, ignore2;					      \     __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t"			      \		       "jnz _L_robust_lock_%=\n\t"			      \		       ".subsection 1\n\t"				      \		       ".type _L_robust_lock_%=,@function\n"		      \		       "_L_robust_lock_%=:\n"				      \		       "1:\tleal %2, %%edx\n"				      \		       "0:\tmovl %7, %%ecx\n"				      \		       "2:\tcall __lll_robust_lock_wait\n"		      \		       "3:\tjmp 18f\n"					      \		       "4:\t.size _L_robust_lock_%=, 4b-1b\n\t"		      \		       ".previous\n"					      \		       LLL_STUB_UNWIND_INFO_4				      \		       "18:"						      \		       : "=a" (result), "=c" (ignore1), "=m" (futex),	      \			 "=&d" (ignore2)				      \		       : "0" (0), "1" (id), "m" (futex), "g" ((int) (private))\		       : "memory");					      \     result; })/* Special version of lll_lock which causes the unlock function to   always wakeup waiters.  */#define lll_cond_lock(futex, private) \  (void)								      \    ({ int ignore1, ignore2, ignore3;					      \       __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t"		      \			 "jnz _L_cond_lock_%=\n\t"			      \			 ".subsection 1\n\t"				      \			 ".type _L_cond_lock_%=,@function\n"		      \			 "_L_cond_lock_%=:\n"				      \			 "1:\tleal %2, %%edx\n"				      \			 "0:\tmovl %7, %%ecx\n"				      \			 "2:\tcall __lll_lock_wait\n"			      \			 "3:\tjmp 18f\n"				      \			 "4:\t.size _L_cond_lock_%=, 4b-1b\n\t"		      \			 ".previous\n"					      \			 LLL_STUB_UNWIND_INFO_4				      \			 "18:"						      \			 : "=a" (ignore1), "=c" (ignore2), "=m" (futex),      \			   "=&d" (ignore3)				      \			 : "0" (0), "1" (2), "m" (futex), "g" ((int) (private))\			 : "memory");					      \    })#define lll_robust_cond_lock(futex, id, private) \  ({ int result, ignore1, ignore2;					      \     __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t"			      \		       "jnz _L_robust_cond_lock_%=\n\t"			      \		       ".subsection 1\n\t"				      \		       ".type _L_robust_cond_lock_%=,@function\n"	      \		       "_L_robust_cond_lock_%=:\n"			      \		       "1:\tleal %2, %%edx\n"				      \		       "0:\tmovl %7, %%ecx\n"				      \		       "2:\tcall __lll_robust_lock_wait\n"		      \		       "3:\tjmp 18f\n"					      \		       "4:\t.size _L_robust_cond_lock_%=, 4b-1b\n\t"	      \		       ".previous\n"					      \		       LLL_STUB_UNWIND_INFO_4				      \		       "18:"						      \		       : "=a" (result), "=c" (ignore1), "=m" (futex),	      \			 "=&d" (ignore2)				      \		       : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex),      \			 "g" ((int) (private))				      \		       : "memory");					      \     result; })#define lll_timedlock(futex, timeout, private) \  ({ int result, ignore1, ignore2, ignore3;				      \     __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t"			      \		       "jnz _L_timedlock_%=\n\t"			      \		       ".subsection 1\n\t"				      \		       ".type _L_timedlock_%=,@function\n"		      \		       "_L_timedlock_%=:\n"				      \		       "1:\tleal %3, %%ecx\n"				      \		       "0:\tmovl %8, %%edx\n"				      \		       "2:\tcall __lll_timedlock_wait\n"		      \		       "3:\tjmp 18f\n"					      \		       "4:\t.size _L_timedlock_%=, 4b-1b\n\t"		      \		       ".previous\n"					      \		       LLL_STUB_UNWIND_INFO_4				      \		       "18:"						      \		       : "=a" (result), "=c" (ignore1), "=&d" (ignore2),      \			 "=m" (futex), "=S" (ignore3)			      \		       : "0" (0), "1" (1), "m" (futex), "m" (timeout),	      \			 "4" ((int) (private))				      \		       : "memory");					      \     result; })#define lll_robust_timedlock(futex, timeout, id, private) \  ({ int result, ignore1, ignore2, ignore3;				      \     __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t"			      \		       "jnz _L_robust_timedlock_%=\n\t"			      \		       ".subsection 1\n\t"				      \		       ".type _L_robust_timedlock_%=,@function\n"	      \		       "_L_robust_timedlock_%=:\n"			      \		       "1:\tleal %3, %%ecx\n"				      \		       "0:\tmovl %8, %%edx\n"				      \		       "2:\tcall __lll_robust_timedlock_wait\n"		      \		       "3:\tjmp 18f\n"					      \		       "4:\t.size _L_robust_timedlock_%=, 4b-1b\n\t"	      \		       ".previous\n"					      \		       LLL_STUB_UNWIND_INFO_4				      \		       "18:"						      \		       : "=a" (result), "=c" (ignore1), "=&d" (ignore2),      \			 "=m" (futex), "=S" (ignore3)			      \		       : "0" (0), "1" (id), "m" (futex), "m" (timeout),	      \			 "4" ((int) (private))				      \		       : "memory");					      \     result; })#if defined NOT_IN_libc || defined UP# define __lll_unlock_asm LOCK_INSTR "subl $1, %0\n\t"#else# define __lll_unlock_asm "cmpl $0, %%gs:%P3\n\t"			      \			  "je 0f\n\t"					      \			  "lock\n"					      \			  "0:\tsubl $1,%0\n\t"#endif#define lll_unlock(futex, private) \  (void)								      \    ({ int ignore;							      \       if (__builtin_constant_p (private) && (private) == LLL_PRIVATE)	      \	 __asm __volatile (__lll_unlock_asm				      \			   "jne _L_unlock_%=\n\t"			      \			   ".subsection 1\n\t"				      \			   ".type _L_unlock_%=,@function\n"		      \			   "_L_unlock_%=:\n"				      \			   "1:\tleal %0, %%eax\n"			      \			   "2:\tcall __lll_unlock_wake_private\n"	      \			   "3:\tjmp 18f\n"				      \			   "4:\t.size _L_unlock_%=, 4b-1b\n\t"		      \			   ".previous\n"				      \			   LLL_STUB_UNWIND_INFO_3			      \			   "18:"					      \			   : "=m" (futex), "=&a" (ignore)		      \			   : "m" (futex), "i" (MULTIPLE_THREADS_OFFSET)	      \			   : "memory");					      \       else								      \	 {								      \	   int ignore2;							      \	   __asm __volatile (__lll_unlock_asm				      \			     "jne _L_unlock_%=\n\t"			      \			     ".subsection 1\n\t"			      \			     ".type _L_unlock_%=,@function\n"		      \			     "_L_unlock_%=:\n"				      \			     "1:\tleal %0, %%eax\n"			      \			     "0:\tmovl %5, %%ecx\n"			      \			     "2:\tcall __lll_unlock_wake\n"		      \			     "3:\tjmp 18f\n"				      \			     "4:\t.size _L_unlock_%=, 4b-1b\n\t"	      \			     ".previous\n"				      \			     LLL_STUB_UNWIND_INFO_4			      \			     "18:"					      \			     : "=m" (futex), "=&a" (ignore), "=&c" (ignore2)  \			     : "i" (MULTIPLE_THREADS_OFFSET), "m" (futex),    \			       "g" ((int) (private))			      \			     : "memory");				      \	 }								      \    })#define lll_robust_unlock(futex, private) \  (void)								      \    ({ int ignore, ignore2;						      \       __asm __volatile (LOCK_INSTR "andl %3, %0\n\t"			      \			 "jne _L_robust_unlock_%=\n\t"			      \			 ".subsection 1\n\t"				      \			 ".type _L_robust_unlock_%=,@function\n"	      \			 "_L_robust_unlock_%=:\n\t"			      \			 "1:\tleal %0, %%eax\n"				      \			 "0:\tmovl %5, %%ecx\n"				      \			 "2:\tcall __lll_unlock_wake\n"			      \			 "3:\tjmp 18f\n"				      \			 "4:\t.size _L_robust_unlock_%=, 4b-1b\n\t"	      \			 ".previous\n"					      \			 LLL_STUB_UNWIND_INFO_4				      \			 "18:"						      \			 : "=m" (futex), "=&a" (ignore), "=&c" (ignore2)      \			 : "i" (FUTEX_WAITERS), "m" (futex),		      \			   "g" ((int) (private))			      \			 : "memory");					      \    })#define lll_robust_dead(futex, private) \  (void)								      \    ({ int __ignore;							      \       register int _nr asm ("edx") = 1;				      \       __asm __volatile (LOCK_INSTR "orl %5, (%2)\n\t"			      \			 LLL_EBX_LOAD					      \			 LLL_ENTER_KERNEL				      \			 LLL_EBX_LOAD					      \			 : "=a" (__ignore)				      \			 : "0" (SYS_futex), LLL_EBX_REG (&(futex)),	      \			   "c" (__lll_private_flag (FUTEX_WAKE, private)),    \			   "d" (_nr), "i" (FUTEX_OWNER_DIED),		      \			   "i" (offsetof (tcbhead_t, sysinfo)));	      \    })#define lll_islocked(futex) \  (futex != LLL_LOCK_INITIALIZER)/* The kernel notifies a process with uses CLONE_CLEARTID via futex   wakeup when the clone terminates.  The memory location contains the   thread ID while the clone is running and is reset to zero   afterwards.   The macro parameter must not have any side effect.  */#define lll_wait_tid(tid) \  do {									      \    int __ignore;							      \    register __typeof (tid) _tid asm ("edx") = (tid);			      \    if (_tid != 0)							      \      __asm __volatile (LLL_EBX_LOAD					      \			"1:\tmovl %1, %%eax\n\t"			      \			LLL_ENTER_KERNEL				      \			"cmpl $0, (%%ebx)\n\t"				      \			"jne 1b\n\t"					      \			LLL_EBX_LOAD					      \			: "=&a" (__ignore)				      \			: "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0),	      \			  "c" (FUTEX_WAIT), "d" (_tid),			      \			  "i" (offsetof (tcbhead_t, sysinfo))		      \			: "memory");					      \  } while (0)extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)     __attribute__ ((regparm (2))) attribute_hidden;#define lll_timedwait_tid(tid, abstime) \  ({									      \    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; })#endif  /* !__ASSEMBLER__ */#endif	/* lowlevellock.h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -