> ```bash
> ~/coreclr$ tests/runtest.sh
-> --testRootDir="~/test/Windows_NT.x64.Debug"
-> --testNativeBinDir="~/coreclr/bin/obj/Linux.x64.Debug/tests"
-> --coreClrBinDir="~/coreclr/bin/Product/Linux.x64.Debug"
-> --mscorlibDir="/media/coreclr/bin/Product/Linux.x64.Debug"
-> --coreFxBinDir="~/corefx/bin/Linux.AnyCPU.Debug"
-> --coreFxNativeBinDir="~/corefx/bin/Linux.x64.Debug"
+> --testRootDir=~/test/Windows_NT.x64.Debug
+> --testNativeBinDir=~/coreclr/bin/obj/Linux.x64.Debug/tests
+> --coreClrBinDir=~/coreclr/bin/Product/Linux.x64.Debug
+> --mscorlibDir=/media/coreclr/bin/Product/Linux.x64.Debug
+> --coreFxBinDir=~/corefx/bin/Linux.AnyCPU.Debug
+> --coreFxNativeBinDir=~/corefx/bin/Linux.x64.Debug
> ```
Test results will go into:
// 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) \
((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
}
#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
misc/error.cpp
misc/errorstrings.cpp
misc/fmtmessage.cpp
- misc/interlock.cpp
misc/miscpalapi.cpp
misc/msgbox.cpp
misc/strutil.cpp
/*++
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.
+++ /dev/null
-//
-// 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
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(
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test1.c
+ test1.cpp
)
add_executable(paltest_rotl_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test1.c
+ test1.cpp
)
add_executable(paltest_rotr_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchangeadd_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedbit_test1
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[]) {
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedbit_test2
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[]) {
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange64_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchangepointer_test1
(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. "
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement64_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchange_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchange64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- InterlockedExchangePointer.c
+ InterlockedExchangePointer.cpp
)
add_executable(paltest_interlockedexchangepointer_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement64_test2
#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
#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()