diff options
Diffstat (limited to 'src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp')
-rw-r--r-- | src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp new file mode 100644 index 0000000000..9fb32f4fb3 --- /dev/null +++ b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*============================================================= +** +** Source: InterlockedExchangePointer +** +** Purpose: Positive test the InterlockedExchangePointer API. +** Call InterlockedExchangePointer to exchange a pair of +** value +** +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + int i1 = 10; + int i2 = 20; + int *pOldValue = &i1; + int *pNewValue = &i2; + PVOID pReturnValue; + + /*Initialize the PAL environment*/ + err = PAL_Initialize(argc, argv); + if(0 != err) + { + return FAIL; + } + + + + /* + Testing + ======= + */ + + pReturnValue = InterlockedExchangePointer((PVOID)&pOldValue, + (PVOID)pNewValue); + /*check the returned value*/ + if(*(int *)pReturnValue != i1) + { + Fail("\nFailed to call InterlockedExchangePointer API, " + "return pointer does not point to the origional value\n"); + } + + /*check the exchanged value*/ + if(*pOldValue != *pNewValue) + { + Fail("\nFailed to call InterlockedExchangePointer API, " + "exchanged value is not right\n"); + } + + + + /* + Clean Up + */ + PAL_Terminate(); + return PASS; +} |