summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKoundinya Veluri <kouvel@users.noreply.github.com>2015-10-22 11:03:04 -0700
committerKoundinya Veluri <kouvel@users.noreply.github.com>2015-10-22 11:03:04 -0700
commit3ddea17fc4e5b0c9ff2cb0651be82594a0eddffb (patch)
treec504e6900840463aab5be204042838c9ba533195 /src
parent545a76e35e4429ed33e9dfcbec3e61ea346afb80 (diff)
parent194d5a41455bda3f348524a1b54f59b5e0c19f0c (diff)
downloadcoreclr-3ddea17fc4e5b0c9ff2cb0651be82594a0eddffb.tar.gz
coreclr-3ddea17fc4e5b0c9ff2cb0651be82594a0eddffb.tar.bz2
coreclr-3ddea17fc4e5b0c9ff2cb0651be82594a0eddffb.zip
Merge pull request #1833 from kouvel/Inline2
Move some functions to allow them to be inlined with clang
Diffstat (limited to 'src')
-rw-r--r--src/pal/inc/pal.h409
-rw-r--r--src/pal/src/CMakeLists.txt1
-rw-r--r--src/pal/src/cruntime/misc.cpp42
-rw-r--r--src/pal/src/misc/interlock.cpp305
-rw-r--r--src/pal/src/misc/miscpalapi.cpp45
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp (renamed from src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.c)0
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.cpp (renamed from src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.c)12
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.c)12
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/test.c)2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/test.c)0
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.cpp (renamed from src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.c)0
-rw-r--r--src/vm/threads.cpp10
-rw-r--r--src/vm/threads.inl22
49 files changed, 394 insertions, 508 deletions
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index fe27b8e8f3..6cc9978857 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -5218,132 +5218,353 @@ typedef EXCEPTION_DISPOSITION (PALAPI *PVECTORED_EXCEPTION_HANDLER)(
// significant set bit, or 0 if if mask is zero.
//
// The same is true for BitScanForward, except that the GCC function is __builtin_ffs.
-
+EXTERN_C
PALIMPORT
+inline
unsigned char
PALAPI
BitScanForward(
- IN OUT PDWORD Index,
- IN UINT qwMask);
+ IN OUT PDWORD Index,
+ IN UINT qwMask)
+{
+ unsigned char bRet = FALSE;
+ int iIndex = __builtin_ffsl(qwMask);
+ if (iIndex != 0)
+ {
+ // Set the Index after deducting unity
+ *Index = (DWORD)(iIndex - 1);
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+EXTERN_C
PALIMPORT
-LONG
+inline
+unsigned char
PALAPI
-InterlockedIncrement(
- IN OUT LONG volatile *lpAddend);
+BitScanForward64(
+ IN OUT PDWORD Index,
+ IN UINT64 qwMask)
+{
+ unsigned char bRet = FALSE;
+ int iIndex = __builtin_ffsl(qwMask);
+ if (iIndex != 0)
+ {
+ // Set the Index after deducting unity
+ *Index = (DWORD)(iIndex - 1);
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+/*++
+Function:
+InterlockedIncrement
+
+The InterlockedIncrement function increments (increases by one) the
+value of the specified variable and checks the resulting value. The
+function prevents more than one thread from using the same variable
+simultaneously.
+
+Parameters
+
+lpAddend
+[in/out] Pointer to the variable to increment.
+
+Return Values
+The return value is the resulting incremented value.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedDecrement(
- IN OUT LONG volatile *lpAddend);
+InterlockedIncrement(
+ IN OUT LONG volatile *lpAddend)
+{
+ return __sync_add_and_fetch(lpAddend, (LONG)1);
+}
+EXTERN_C
PALIMPORT
-LONG
+inline
+LONGLONG
PALAPI
-InterlockedExchange(
- IN OUT LONG volatile *Target,
- IN LONG Value);
+InterlockedIncrement64(
+ IN OUT LONGLONG volatile *lpAddend)
+{
+ return __sync_add_and_fetch(lpAddend, (LONGLONG)1);
+}
+
+/*++
+Function:
+InterlockedDecrement
+
+The InterlockedDecrement function decrements (decreases by one) the
+value of the specified variable and checks the resulting value. The
+function prevents more than one thread from using the same variable
+simultaneously.
+
+Parameters
+lpAddend
+[in/out] Pointer to the variable to decrement.
+
+Return Values
+
+The return value is the resulting decremented value.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedCompareExchange(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand);
+InterlockedDecrement(
+ IN OUT LONG volatile *lpAddend)
+{
+ return __sync_sub_and_fetch(lpAddend, (LONG)1);
+}
+EXTERN_C
PALIMPORT
-LONG
+inline
+LONGLONG
PALAPI
-InterlockedCompareExchangeAcquire(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand);
+InterlockedDecrement64(
+ IN OUT LONGLONG volatile *lpAddend)
+{
+ return __sync_sub_and_fetch(lpAddend, (LONGLONG)1);
+}
+
+/*++
+Function:
+InterlockedExchange
+
+The InterlockedExchange function atomically exchanges a pair of
+values. The function prevents more than one thread from using the same
+variable simultaneously.
+
+Parameters
+
+Target
+[in/out] Pointer to the value to exchange. The function sets
+this variable to Value, and returns its prior value.
+Value
+[in] Specifies a new value for the variable pointed to by Target.
+
+Return Values
+
+The function returns the initial value pointed to by Target.
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedCompareExchangeRelease(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand);
-
+InterlockedExchange(
+ IN OUT LONG volatile *Target,
+ IN LONG Value)
+{
+ return __sync_swap(Target, Value);
+}
+
+EXTERN_C
PALIMPORT
-LONG
+inline
+LONGLONG
PALAPI
-InterlockedExchangeAdd(
- IN OUT LONG volatile *Addend,
- IN LONG Value);
-
+InterlockedExchange64(
+ IN OUT LONGLONG volatile *Target,
+ IN LONGLONG Value)
+{
+ return __sync_swap(Target, Value);
+}
+
+/*++
+Function:
+InterlockedCompareExchange
+
+The InterlockedCompareExchange function performs an atomic comparison
+of the specified values and exchanges the values, based on the outcome
+of the comparison. The function prevents more than one thread from
+using the same variable simultaneously.
+
+If you are exchanging pointer values, this function has been
+superseded by the InterlockedCompareExchangePointer function.
+
+Parameters
+
+Destination [in/out] Specifies the address of the destination value. The sign is ignored.
+Exchange [in] Specifies the exchange value. The sign is ignored.
+Comperand [in] Specifies the value to compare to Destination. The sign is ignored.
+
+Return Values
+
+The return value is the initial value of the destination.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedAnd(
- IN OUT LONG volatile *Destination,
- IN LONG Value);
+InterlockedCompareExchange(
+ IN OUT LONG volatile *Destination,
+ IN LONG Exchange,
+ IN LONG Comperand)
+{
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedOr(
- IN OUT LONG volatile *Destination,
- IN LONG Value);
+InterlockedCompareExchangeAcquire(
+ IN OUT LONG volatile *Destination,
+ IN LONG Exchange,
+ IN LONG Comperand)
+{
+ // TODO: implement the version with only the acquire semantics
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+EXTERN_C
PALIMPORT
-UCHAR
+inline
+LONG
PALAPI
-InterlockedBitTestAndReset(
- IN OUT LONG volatile *Base,
- IN LONG Bit);
+InterlockedCompareExchangeRelease(
+ IN OUT LONG volatile *Destination,
+ IN LONG Exchange,
+ IN LONG Comperand)
+{
+ // TODO: implement the version with only the release semantics
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+// See the 32-bit variant in interlock2.s
+EXTERN_C
PALIMPORT
-UCHAR
+inline
+LONGLONG
PALAPI
-InterlockedBitTestAndSet(
- IN OUT LONG volatile *Base,
- IN LONG Bit);
+InterlockedCompareExchange64(
+ IN OUT LONGLONG volatile *Destination,
+ IN LONGLONG Exchange,
+ IN LONGLONG Comperand)
+{
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+
+/*++
+Function:
+InterlockedExchangeAdd
+
+The InterlockedExchangeAdd function atomically adds the value of 'Value'
+to the variable that 'Addend' points to.
+
+Parameters
+lpAddend
+[in/out] Pointer to the variable to to added.
+
+Return Values
+
+The return value is the original value that 'Addend' pointed to.
+
+--*/
+EXTERN_C
PALIMPORT
-unsigned char
+inline
+LONG
PALAPI
-BitScanForward64(
- IN OUT PDWORD Index,
- IN UINT64 qwMask);
+InterlockedExchangeAdd(
+ IN OUT LONG volatile *Addend,
+ IN LONG Value)
+{
+ return __sync_fetch_and_add(Addend, Value);
+}
+EXTERN_C
PALIMPORT
+inline
LONGLONG
PALAPI
-InterlockedIncrement64(
- IN OUT LONGLONG volatile *lpAddend);
+InterlockedExchangeAdd64(
+ IN OUT LONGLONG volatile *Addend,
+ IN LONGLONG Value)
+{
+ return __sync_fetch_and_add(Addend, Value);
+}
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+LONG
PALAPI
-InterlockedDecrement64(
- IN OUT LONGLONG volatile *lpAddend);
+InterlockedAnd(
+ IN OUT LONG volatile *Destination,
+ IN LONG Value)
+{
+ return __sync_fetch_and_and(Destination, Value);
+}
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+LONG
PALAPI
-InterlockedExchange64(
- IN OUT LONGLONG volatile *Target,
- IN LONGLONG Value);
-
+InterlockedOr(
+ IN OUT LONG volatile *Destination,
+ IN LONG Value)
+{
+ return __sync_fetch_and_or(Destination, Value);
+}
+
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+UCHAR
PALAPI
-InterlockedExchangeAdd64(
- IN OUT LONGLONG volatile *Addend,
- IN LONGLONG Value);
+InterlockedBitTestAndReset(
+ IN OUT LONG volatile *Base,
+ IN LONG Bit)
+{
+ return (InterlockedAnd(Base, ~(1 << Bit)) & (1 << Bit)) != 0;
+}
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+UCHAR
PALAPI
-InterlockedCompareExchange64(
- IN OUT LONGLONG volatile *Destination,
- IN LONGLONG Exchange,
- IN LONGLONG Comperand);
+InterlockedBitTestAndSet(
+ IN OUT LONG volatile *Base,
+ IN LONG Bit)
+{
+ return (InterlockedOr(Base, (1 << Bit)) & (1 << Bit)) != 0;
+}
#if defined(BIT64)
#define InterlockedExchangePointer(Target, Value) \
@@ -5359,11 +5580,23 @@ InterlockedCompareExchange64(
((PVOID)(UINT_PTR)InterlockedCompareExchange((PLONG)(UINT_PTR)(Destination), (LONG)(UINT_PTR)(ExChange), (LONG)(UINT_PTR)(Comperand)))
#endif
+/*++
+Function:
+MemoryBarrier
+
+The MemoryBarrier function creates a full memory barrier.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
VOID
PALAPI
MemoryBarrier(
- VOID);
+ VOID)
+{
+ __sync_synchronize();
+}
PALIMPORT
VOID
@@ -5932,13 +6165,47 @@ inline WCHAR *PAL_wcsstr(WCHAR *_S, const WCHAR *_P)
}
#endif
-PALIMPORT unsigned int __cdecl _rotl(unsigned int, int);
+/*++
+Function:
+_rotl
+
+See MSDN doc.
+--*/
+EXTERN_C
+PALIMPORT
+inline
+unsigned int __cdecl _rotl(unsigned int value, int shift)
+{
+ unsigned int retval = 0;
+
+ shift &= 0x1f;
+ retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
+ return retval;
+}
+
// On 64 bit unix, make the long an int.
#ifdef BIT64
#define _lrotl _rotl
#endif // BIT64
-PALIMPORT unsigned int __cdecl _rotr(unsigned int, int);
+/*++
+Function:
+_rotr
+
+See MSDN doc.
+--*/
+EXTERN_C
+PALIMPORT
+inline
+unsigned int __cdecl _rotr(unsigned int value, int shift)
+{
+ unsigned int retval;
+
+ shift &= 0x1f;
+ retval = (value >> shift) | (value << (sizeof(int) * CHAR_BIT - shift));
+ return retval;
+}
+
PALIMPORT int __cdecl abs(int);
PALIMPORT double __cdecl fabs(double);
#ifndef PAL_STDCPP_COMPAT
diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt
index f1a254687d..03b3ea694b 100644
--- a/src/pal/src/CMakeLists.txt
+++ b/src/pal/src/CMakeLists.txt
@@ -135,7 +135,6 @@ set(SOURCES
misc/error.cpp
misc/errorstrings.cpp
misc/fmtmessage.cpp
- misc/interlock.cpp
misc/miscpalapi.cpp
misc/msgbox.cpp
misc/strutil.cpp
diff --git a/src/pal/src/cruntime/misc.cpp b/src/pal/src/cruntime/misc.cpp
index 2c482145c1..fa8504f726 100644
--- a/src/pal/src/cruntime/misc.cpp
+++ b/src/pal/src/cruntime/misc.cpp
@@ -72,48 +72,6 @@ namespace CorUnix
/*++
Function:
- _rotl
-
-See MSDN doc.
---*/
-unsigned int
-__cdecl
-_rotl( unsigned int value, int shift )
-{
- unsigned int retval = 0;
-
- PERF_ENTRY(_rotl);
- ENTRY("_rotl( value:%u shift=%d )\n", value, shift );
- shift &= 0x1f;
- retval = ( value << shift ) | ( value >> ( sizeof( int ) * CHAR_BIT - shift ));
- LOGEXIT("_rotl returns unsigned int %u\n", retval);
- PERF_EXIT(_rotl);
- return retval;
-}
-
-/*++
-Function:
- _rotr
-
-See MSDN doc.
---*/
-unsigned int
-__cdecl
-_rotr( unsigned int value, int shift )
-{
- unsigned int retval;
-
- PERF_ENTRY(_rotr);
- ENTRY("_rotr( value:%u shift=%d )\n", value, shift );
- shift &= 0x1f;
- retval = ( value >> shift ) | ( value << ( sizeof( int ) * CHAR_BIT - shift ) );
- LOGEXIT("_rotr returns unsigned int %u\n", retval);
- PERF_EXIT(_rotr);
- return retval;
-}
-
-/*++
-Function:
_gcvt_s
See MSDN doc.
diff --git a/src/pal/src/misc/interlock.cpp b/src/pal/src/misc/interlock.cpp
deleted file mode 100644
index c63566a4ce..0000000000
--- a/src/pal/src/misc/interlock.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*++
-
-
-
-Module Name:
-
- interlock.c
-
-Abstract:
-
- Implementation of Interlocked functions for the Intel x86
- platform. These functions are processor dependent.
-
-
-
---*/
-
-#include "pal/palinternal.h"
-
-
-//
-// We need the following methods to have volatile arguments for compatibility with Win32
-//
-#undef volatile
-
-
-/*++
-Function:
- InterlockedIncrement
-
-The InterlockedIncrement function increments (increases by one) the
-value of the specified variable and checks the resulting value. The
-function prevents more than one thread from using the same variable
-simultaneously.
-
-Parameters
-
-lpAddend
- [in/out] Pointer to the variable to increment.
-
-Return Values
-
-The return value is the resulting incremented value.
-
---*/
-LONG
-PALAPI
-InterlockedIncrement(
- IN OUT LONG volatile *lpAddend)
-{
- return __sync_add_and_fetch(lpAddend, (LONG)1);
-}
-
-LONGLONG
-PALAPI
-InterlockedIncrement64(
- IN OUT LONGLONG volatile *lpAddend)
-{
- return __sync_add_and_fetch(lpAddend, (LONGLONG)1);
-}
-
-/*++
-Function:
- InterlockedDecrement
-
-The InterlockedDecrement function decrements (decreases by one) the
-value of the specified variable and checks the resulting value. The
-function prevents more than one thread from using the same variable
-simultaneously.
-
-Parameters
-
-lpAddend
- [in/out] Pointer to the variable to decrement.
-
-Return Values
-
-The return value is the resulting decremented value.
-
---*/
-LONG
-PALAPI
-InterlockedDecrement(
- IN OUT LONG volatile *lpAddend)
-{
- return __sync_sub_and_fetch(lpAddend, (LONG)1);
-}
-
-LONGLONG
-PALAPI
-InterlockedDecrement64(
- IN OUT LONGLONG volatile *lpAddend)
-{
- return __sync_sub_and_fetch(lpAddend, (LONGLONG)1);
-}
-
-/*++
-Function:
- InterlockedExchange
-
-The InterlockedExchange function atomically exchanges a pair of
-values. The function prevents more than one thread from using the same
-variable simultaneously.
-
-Parameters
-
-Target
- [in/out] Pointer to the value to exchange. The function sets
- this variable to Value, and returns its prior value.
-Value
- [in] Specifies a new value for the variable pointed to by Target.
-
-Return Values
-
-The function returns the initial value pointed to by Target.
-
---*/
-LONG
-PALAPI
-InterlockedExchange(
- IN OUT LONG volatile *Target,
- IN LONG Value)
-{
- return __sync_swap(Target, Value);
-}
-
-LONGLONG
-PALAPI
-InterlockedExchange64(
- IN OUT LONGLONG volatile *Target,
- IN LONGLONG Value)
-{
- return __sync_swap(Target, Value);
-}
-
-/*++
-Function:
- InterlockedCompareExchange
-
-The InterlockedCompareExchange function performs an atomic comparison
-of the specified values and exchanges the values, based on the outcome
-of the comparison. The function prevents more than one thread from
-using the same variable simultaneously.
-
-If you are exchanging pointer values, this function has been
-superseded by the InterlockedCompareExchangePointer function.
-
-Parameters
-
-Destination [in/out] Specifies the address of the destination value. The sign is ignored.
-Exchange [in] Specifies the exchange value. The sign is ignored.
-Comperand [in] Specifies the value to compare to Destination. The sign is ignored.
-
-Return Values
-
-The return value is the initial value of the destination.
-
---*/
-LONG
-PALAPI
-InterlockedCompareExchange(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-LONG
-PALAPI
-InterlockedCompareExchangeAcquire(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- // TODO: implement the version with only the acquire semantics
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-LONG
-PALAPI
-InterlockedCompareExchangeRelease(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- // TODO: implement the version with only the release semantics
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-// See the 32-bit variant in interlock2.s
-LONGLONG
-PALAPI
-InterlockedCompareExchange64(
- IN OUT LONGLONG volatile *Destination,
- IN LONGLONG Exchange,
- IN LONGLONG Comperand)
-{
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-/*++
-Function:
-InterlockedExchangeAdd
-
-The InterlockedExchangeAdd function atomically adds the value of 'Value'
-to the variable that 'Addend' points to.
-
-Parameters
-
-lpAddend
-[in/out] Pointer to the variable to to added.
-
-Return Values
-
-The return value is the original value that 'Addend' pointed to.
-
---*/
-LONG
-PALAPI
-InterlockedExchangeAdd(
- IN OUT LONG volatile *Addend,
- IN LONG Value)
-{
- return __sync_fetch_and_add(Addend, Value);
-}
-
-LONGLONG
-PALAPI
-InterlockedExchangeAdd64(
- IN OUT LONGLONG volatile *Addend,
- IN LONGLONG Value)
-{
- return __sync_fetch_and_add(Addend, Value);
-}
-
-LONG
-PALAPI
-InterlockedAnd(
- IN OUT LONG volatile *Destination,
- IN LONG Value)
-{
- return __sync_fetch_and_and(Destination, Value);
-}
-
-LONG
-PALAPI
-InterlockedOr(
- IN OUT LONG volatile *Destination,
- IN LONG Value)
-{
- return __sync_fetch_and_or(Destination, Value);
-}
-
-UCHAR
-PALAPI
-InterlockedBitTestAndReset(
- IN OUT LONG volatile *Base,
- IN LONG Bit)
-{
- return (InterlockedAnd(Base, ~(1 << Bit)) & (1 << Bit)) != 0;
-}
-
-UCHAR
-PALAPI
-InterlockedBitTestAndSet(
- IN OUT LONG volatile *Base,
- IN LONG Bit)
-{
- return (InterlockedOr(Base, (1 << Bit)) & (1 << Bit)) != 0;
-}
-
-/*++
-Function:
-MemoryBarrier
-
-The MemoryBarrier function creates a full memory barrier.
-
---*/
-void
-PALAPI
-MemoryBarrier(
- VOID)
-{
- __sync_synchronize();
-}
-
-#define volatile DoNotUseVolatileKeyword
diff --git a/src/pal/src/misc/miscpalapi.cpp b/src/pal/src/misc/miscpalapi.cpp
index 206a5b7bf1..d225071851 100644
--- a/src/pal/src/misc/miscpalapi.cpp
+++ b/src/pal/src/misc/miscpalapi.cpp
@@ -233,51 +233,6 @@ PAL_GetPALDirectoryA(
return bRet;
}
-// Define _BitScanForward64 and BitScanForward
-// Per MSDN, BitScanForward64 will search the mask data from LSB to MSB for a set bit.
-// If one is found, its bit position is returned in the outPDWORD argument and 1 is returned.
-// Otherwise, 0 is returned.
-//
-// On GCC, the equivalent function is __builtin_ffsl. It returns 1+index of the least
-// significant set bit, or 0 if if mask is zero.
-unsigned char
-PALAPI
-BitScanForward64(
- IN OUT PDWORD Index,
- IN UINT64 qwMask)
-{
- unsigned char bRet = FALSE;
- int iIndex = __builtin_ffsl(qwMask);
- if (iIndex != 0)
- {
- // Set the Index after deducting unity
- *Index = (DWORD)(iIndex-1);
- bRet = TRUE;
- }
-
- return bRet;
-}
-
-// On GCC, the equivalent function is __builtin_ffs. It returns 1+index of the least
-// significant set bit, or 0 if if mask is zero.
-unsigned char
-PALAPI
-BitScanForward(
- IN OUT PDWORD Index,
- IN UINT wMask)
-{
- unsigned char bRet = FALSE;
- int iIndex = __builtin_ffs(wMask);
- if (iIndex != 0)
- {
- // Set the Index after deducting unity
- *Index = (DWORD)(iIndex-1);
- bRet = TRUE;
- }
-
- return bRet;
-}
-
BOOL
PALAPI
PAL_Random(
diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt
index fdf177cfd2..bafaa23732 100644
--- a/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test1.c
+ test1.cpp
)
add_executable(paltest_rotl_test1
diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp
index 3399a74034..3399a74034 100644
--- a/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.c
+++ b/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp
diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt
index 563d66b808..c0c76feb36 100644
--- a/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test1.c
+ test1.cpp
)
add_executable(paltest_rotr_test1
diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.cpp
index 2d65edba29..2d65edba29 100644
--- a/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.c
+++ b/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt
index 6a946236c3..e5ba709c11 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchangeadd_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.cpp
index d0e1eaed31..d0e1eaed31 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt
index 3dc8f29131..a70802ea2d 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedbit_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.cpp
index d7cb0e0d9e..5e09e0e79a 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.cpp
@@ -24,12 +24,12 @@ typedef struct tag_TEST_DATA
TEST_DATA test_data[] =
{
- { 0x00000000, 3, 0x00000000, 0 },
- { 0x12341234, 2, 0x12341230, 1 },
- { 0x12341234, 3, 0x12341234, 0 },
- { 0x12341234, 31, 0x12341234, 0 },
- { 0x12341234, 28, 0x02341234, 1 },
- { 0xffffffff, 28, 0xefffffff, 1 }
+ { (LONG)0x00000000, 3, (LONG)0x00000000, 0 },
+ { (LONG)0x12341234, 2, (LONG)0x12341230, 1 },
+ { (LONG)0x12341234, 3, (LONG)0x12341234, 0 },
+ { (LONG)0x12341234, 31, (LONG)0x12341234, 0 },
+ { (LONG)0x12341234, 28, (LONG)0x02341234, 1 },
+ { (LONG)0xffffffff, 28, (LONG)0xefffffff, 1 }
};
int __cdecl main(int argc, char *argv[]) {
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt
index 64d6581e4b..6b50a755fe 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedbit_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.cpp
index 51fb25c4d7..fa4fc6ef2c 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.cpp
@@ -24,12 +24,12 @@ typedef struct tag_TEST_DATA
TEST_DATA test_data[] =
{
- { 0x00000000, 2, 0x00000004, 0 },
- { 0x12341234, 2, 0x12341234, 1 },
- { 0x12341234, 3, 0x1234123c, 0 },
- { 0x12341234, 31, 0x92341234, 0 },
- { 0x12341234, 28, 0x12341234, 1 },
- { 0xffffffff, 28, 0xffffffff, 1 }
+ { (LONG)0x00000000, 2, (LONG)0x00000004, 0 },
+ { (LONG)0x12341234, 2, (LONG)0x12341234, 1 },
+ { (LONG)0x12341234, 3, (LONG)0x1234123c, 0 },
+ { (LONG)0x12341234, 31, (LONG)0x92341234, 0 },
+ { (LONG)0x12341234, 28, (LONG)0x12341234, 1 },
+ { (LONG)0xffffffff, 28, (LONG)0xffffffff, 1 }
};
int __cdecl main(int argc, char *argv[]) {
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt
index a3f4f741d7..d9e867256a 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.cpp
index c2a1ed284a..c2a1ed284a 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt
index fdf0521b50..038d375273 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.cpp
index 33259f582e..33259f582e 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/CMakeLists.txt
index 6000db2286..722603eb4a 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange64_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/test.cpp
index 2fa6e3232f..2fa6e3232f 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt
index 2a82236f0f..f052ca0b27 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange64_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.cpp
index 272795cba6..272795cba6 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/CMakeLists.txt
index a9fc74bb24..0c48c4e296 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchangepointer_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/test.cpp
index b720479a2e..3a5e5f7171 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/test.cpp
@@ -52,7 +52,7 @@ int __cdecl main(int argc, char *argv[])
(5 in this case)
*/
- if((int)ReturnValue != 5)
+ if((int)(size_t)ReturnValue != 5)
{
Fail("ERROR: The return value should be the value of the "
"variable before the exchange took place, which was 5. "
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt
index 8b6fbfd79f..6cd307d2e8 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.cpp
index 6fe3982334..6fe3982334 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt
index 320019ed77..331d89d5d6 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.cpp
index 04182697fe..04182697fe 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/CMakeLists.txt
index c942a333b1..727a328d07 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement64_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/test.cpp
index 9e1744c71b..9e1744c71b 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt
index d5462ca7dd..ecea6399a7 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement64_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.cpp
index 84c24bc884..84c24bc884 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/CMakeLists.txt
index 39911d2de2..a1a7f862ed 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchange_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/test.cpp
index dd23a223d5..dd23a223d5 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt
index 832868e7b7..3f4cd5e058 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchange64_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.cpp
index 08e7405ab2..08e7405ab2 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt
index e43533d1c1..b0858963a0 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- InterlockedExchangePointer.c
+ InterlockedExchangePointer.cpp
)
add_executable(paltest_interlockedexchangepointer_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.c b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp
index 9fb32f4fb3..9fb32f4fb3 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt
index 258d4bcb9b..f87dc72281 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.cpp
index 04ca9f3bb5..04ca9f3bb5 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt
index 124f95a0a9..e8c5278cbc 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.cpp
index ecc2c0d8ff..ecc2c0d8ff 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/CMakeLists.txt
index 2520ac583a..d7bec46d4e 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement64_test1
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/test.cpp
index c3b427706a..c3b427706a 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/test.cpp
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt
index 4d85e40dfb..be571a535b 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement64_test2
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.c b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.cpp
index 4a85b7fd3f..4a85b7fd3f 100644
--- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.c
+++ b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.cpp
diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp
index 5e4c05f514..2be41fc6a0 100644
--- a/src/vm/threads.cpp
+++ b/src/vm/threads.cpp
@@ -328,16 +328,6 @@ GVAL_IMPL_INIT(DWORD, gAppDomainTLSIndex, TLS_OUT_OF_INDEXES); // index ( (-1)
#ifndef DACCESS_COMPILE
#ifdef FEATURE_IMPLICIT_TLS
-EXTERN_C Thread* STDCALL GetThread()
-{
- return gCurrentThreadInfo.m_pThread;
-}
-
-EXTERN_C AppDomain* STDCALL GetAppDomain()
-{
- return gCurrentThreadInfo.m_pAppDomain;
-}
-
BOOL SetThread(Thread* t)
{
LIMITED_METHOD_CONTRACT
diff --git a/src/vm/threads.inl b/src/vm/threads.inl
index d3d34057ca..db47ce86a8 100644
--- a/src/vm/threads.inl
+++ b/src/vm/threads.inl
@@ -22,6 +22,28 @@
#include "appdomain.hpp"
#include "frames.h"
+#ifndef DACCESS_COMPILE
+#ifdef FEATURE_IMPLICIT_TLS
+
+#ifndef __llvm__
+EXTERN_C __declspec(thread) ThreadLocalInfo gCurrentThreadInfo;
+#else // !__llvm__
+EXTERN_C __thread ThreadLocalInfo gCurrentThreadInfo;
+#endif // !__llvm__
+
+EXTERN_C inline Thread* STDCALL GetThread()
+{
+ return gCurrentThreadInfo.m_pThread;
+}
+
+EXTERN_C inline AppDomain* STDCALL GetAppDomain()
+{
+ return gCurrentThreadInfo.m_pAppDomain;
+}
+
+#endif // FEATURE_IMPLICIT_TLS
+#endif // !DACCESS_COMPILE
+
#ifdef ENABLE_GET_THREAD_GENERIC_FULL_CHECK
// See code:GetThreadGenericFullCheck
inline /* static */ BOOL Thread::ShouldEnforceEEThreadNotRequiredContracts()