557
static void tstASMAtomicXchgU128(void)
561
RTUINT128U u128Dummy0;
563
RTUINT128U u128Dummy1;
569
s.u128Dummy0.s.Lo = s.u128Dummy0.s.Hi = 0x1122334455667788;
572
s.u128Dummy1 = s.u128Dummy0;
576
u128Ret.u = ASMAtomicXchgU128(&s.u128.u, u128Arg.u);
577
CHECKVAL(u128Ret.s.Lo, 0ULL, "%#llx");
578
CHECKVAL(u128Ret.s.Hi, 0ULL, "%#llx");
579
CHECKVAL(s.u128.s.Lo, 1ULL, "%#llx");
580
CHECKVAL(s.u128.s.Hi, 0ULL, "%#llx");
584
u128Ret.u = ASMAtomicXchgU128(&s.u128.u, u128Arg.u);
585
CHECKVAL(u128Ret.s.Lo, 1ULL, "%#llx");
586
CHECKVAL(u128Ret.s.Hi, 0ULL, "%#llx");
587
CHECKVAL(s.u128.s.Lo, 0ULL, "%#llx");
588
CHECKVAL(s.u128.s.Hi, 0ULL, "%#llx");
590
u128Arg.s.Lo = ~0ULL;
591
u128Arg.s.Hi = ~0ULL;
592
u128Ret.u = ASMAtomicXchgU128(&s.u128.u, u128Arg.u);
593
CHECKVAL(u128Ret.s.Lo, 0ULL, "%#llx");
594
CHECKVAL(u128Ret.s.Hi, 0ULL, "%#llx");
595
CHECKVAL(s.u128.s.Lo, ~0ULL, "%#llx");
596
CHECKVAL(s.u128.s.Hi, ~0ULL, "%#llx");
599
u128Arg.s.Lo = 0xfedcba0987654321ULL;
600
u128Arg.s.Hi = 0x8897a6b5c4d3e2f1ULL;
601
u128Ret.u = ASMAtomicXchgU128(&s.u128.u, u128Arg.u);
602
CHECKVAL(u128Ret.s.Lo, ~0ULL, "%#llx");
603
CHECKVAL(u128Ret.s.Hi, ~0ULL, "%#llx");
604
CHECKVAL(s.u128.s.Lo, 0xfedcba0987654321ULL, "%#llx");
605
CHECKVAL(s.u128.s.Hi, 0x8897a6b5c4d3e2f1ULL, "%#llx");
607
CHECKVAL(s.u128Dummy0.s.Lo, 0x1122334455667788, "%#llx");
608
CHECKVAL(s.u128Dummy0.s.Hi, 0x1122334455667788, "%#llx");
609
CHECKVAL(s.u128Dummy1.s.Lo, 0x1122334455667788, "%#llx");
610
CHECKVAL(s.u128Dummy1.s.Hi, 0x1122334455667788, "%#llx");
615
551
static void tstASMAtomicXchgPtr(void)
751
687
if (i32Rc != (rc)) \
753
689
RTPrintf("%s, %d: FAILURE: %s -> %d expected %d\n", __FUNCTION__, __LINE__, #op, i32Rc, rc); \
756
692
if (i32 != (val)) \
758
694
RTPrintf("%s, %d: FAILURE: %s => i32=%d expected %d\n", __FUNCTION__, __LINE__, #op, i32, val); \
762
698
MYCHECK(ASMAtomicAddS32(&i32, 1), 10, 11);
780
716
if (i32Rc != (rc)) \
782
718
RTPrintf("%s, %d: FAILURE: %s -> %d expected %d\n", __FUNCTION__, __LINE__, #op, i32Rc, rc); \
785
721
if (i32 != (rc)) \
787
723
RTPrintf("%s, %d: FAILURE: %s => i32=%d expected %d\n", __FUNCTION__, __LINE__, #op, i32, rc); \
791
727
MYCHECK(ASMAtomicDecS32(&i32), 9);
875
811
|| Buf3.u64Magic2 != UINT64_C(0xffffffffffffffff))
877
813
RTPrintf("tstInlineAsm: ASMMemZeroPage violated one/both magic(s)!\n");
880
816
for (unsigned i = 0; i < sizeof(Buf1.abPage); i++)
881
817
if (Buf1.abPage[i])
883
819
RTPrintf("tstInlineAsm: ASMMemZeroPage didn't clear byte at offset %#x!\n", i);
886
822
for (unsigned i = 0; i < sizeof(Buf2.abPage); i++)
887
823
if (Buf2.abPage[i])
889
825
RTPrintf("tstInlineAsm: ASMMemZeroPage didn't clear byte at offset %#x!\n", i);
892
828
for (unsigned i = 0; i < sizeof(Buf3.abPage); i++)
893
829
if (Buf3.abPage[i])
895
831
RTPrintf("tstInlineAsm: ASMMemZeroPage didn't clear byte at offset %#x!\n", i);
837
void tstASMMemIsZeroPage(RTTEST hTest)
839
RTTestSub(hTest, "ASMMemIsZeroPage");
841
void *pvPage1 = RTTestGuardedAllocHead(hTest, PAGE_SIZE);
842
void *pvPage2 = RTTestGuardedAllocTail(hTest, PAGE_SIZE);
843
RTTESTI_CHECK_RETV(pvPage1 && pvPage2);
845
memset(pvPage1, 0, PAGE_SIZE);
846
memset(pvPage2, 0, PAGE_SIZE);
847
RTTESTI_CHECK(ASMMemIsZeroPage(pvPage1));
848
RTTESTI_CHECK(ASMMemIsZeroPage(pvPage2));
850
memset(pvPage1, 0xff, PAGE_SIZE);
851
memset(pvPage2, 0xff, PAGE_SIZE);
852
RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage1));
853
RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage2));
855
memset(pvPage1, 0, PAGE_SIZE);
856
memset(pvPage2, 0, PAGE_SIZE);
857
for (unsigned off = 0; off < PAGE_SIZE; off++)
859
((uint8_t *)pvPage1)[off] = 1;
860
RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage1));
861
((uint8_t *)pvPage1)[off] = 0;
863
((uint8_t *)pvPage2)[off] = 0x80;
864
RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage2));
865
((uint8_t *)pvPage2)[off] = 0;
868
RTTestSubDone(hTest);
901
872
void tstASMMemZero32(void)
927
898
|| Buf3.u64Magic2 != UINT64_C(0xffffffffffffffff))
929
900
RTPrintf("tstInlineAsm: ASMMemZero32 violated one/both magic(s)!\n");
932
903
for (unsigned i = 0; i < RT_ELEMENTS(Buf1.abPage); i++)
933
904
if (Buf1.abPage[i])
935
906
RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
938
909
for (unsigned i = 0; i < RT_ELEMENTS(Buf2.abPage); i++)
939
910
if (Buf2.abPage[i])
941
912
RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
944
915
for (unsigned i = 0; i < RT_ELEMENTS(Buf3.abPage); i++)
945
916
if (Buf3.abPage[i])
947
918
RTPrintf("tstInlineAsm: ASMMemZero32 didn't clear byte at offset %#x!\n", i);
991
962
|| Buf3.u64Magic2 != UINT64_C(0xffffffffffffffff))
993
964
RTPrintf("tstInlineAsm: ASMMemFill32 violated one/both magic(s)!\n");
996
967
for (unsigned i = 0; i < RT_ELEMENTS(Buf1.au32Page); i++)
997
968
if (Buf1.au32Page[i] != 0xdeadbeef)
999
970
RTPrintf("tstInlineAsm: ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf1.au32Page[i], 0xdeadbeef);
1002
973
for (unsigned i = 0; i < RT_ELEMENTS(Buf2.au32Page); i++)
1003
974
if (Buf2.au32Page[i] != 0xcafeff01)
1005
976
RTPrintf("tstInlineAsm: ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf2.au32Page[i], 0xcafeff01);
1008
979
for (unsigned i = 0; i < RT_ELEMENTS(Buf3.au32Page); i++)
1009
980
if (Buf3.au32Page[i] != 0xf00dd00f)
1011
982
RTPrintf("tstInlineAsm: ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf3.au32Page[i], 0xf00dd00f);