/** @file\r
GCC inline implementation of BaseSynchronizationLib processor specific functions.\r
- \r
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
\r
Performs an atomic increment of the 32-bit unsigned integer specified by\r
Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
+ performed using MP safe mechanisms.\r
\r
@param Value A pointer to the 32-bit value to increment.\r
\r
UINT32 Result;\r
\r
__asm__ __volatile__ (\r
+ "movl $1, %%eax \n\t"\r
"lock \n\t"\r
- "incl %2 \n\t"\r
- "movl %2, %%eax "\r
+ "xadd %%eax, %2 \n\t"\r
+ "inc %%eax "\r
: "=a" (Result), // %0\r
"=m" (*Value) // %1\r
- : "m" (*Value) // %2 \r
+ : "m" (*Value) // %2\r
: "memory",\r
"cc"\r
);\r
- \r
- return Result; \r
+\r
+ return Result;\r
\r
}\r
\r
\r
Performs an atomic decrement of the 32-bit unsigned integer specified by\r
Value and returns the decremented value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
+ performed using MP safe mechanisms.\r
\r
@param Value A pointer to the 32-bit value to decrement.\r
\r
)\r
{\r
UINT32 Result;\r
- \r
+\r
__asm__ __volatile__ (\r
- "lock \n\t"\r
- "decl %2 \n\t"\r
- "movl %2, %%eax "\r
+ "movl $-1, %%eax \n\t"\r
+ "lock \n\t"\r
+ "xadd %%eax, %2 \n\t"\r
+ "dec %%eax "\r
: "=a" (Result), // %0\r
"=m" (*Value) // %1\r
- : "m" (*Value) // %2 \r
+ : "m" (*Value) // %2\r
: "memory",\r
"cc"\r
);\r
- \r
+\r
return Result;\r
}\r
\r
: "=a" (CompareValue) // %0\r
: "q" (ExchangeValue), // %1\r
"m" (*Value), // %2\r
- "0" (CompareValue) // %4 \r
+ "0" (CompareValue) // %4\r
: "memory",\r
"cc"\r
);\r
{\r
__asm__ __volatile__ (\r
" \n\t"\r
- "push %%ebx \n\t" \r
- "movl %2,%%ebx \n\t" \r
+ "push %%ebx \n\t"\r
+ "movl %2,%%ebx \n\t"\r
"lock \n\t"\r
"cmpxchg8b (%1) \n\t"\r
"pop %%ebx \n\t"\r
: "memory",\r
"cc"\r
);\r
- \r
+\r
return CompareValue;\r
}\r