public static unsafe int test_0_ldobj() { byte *ptr = stackalloc byte [20]; for (int i = 0; i < 20; ++i) { ptr [i] = (byte)i; } if (Intrinsics.UnalignedLdobj <short> (ptr + 0) != 0x0100) { return(1); } if (Intrinsics.UnalignedLdobj <short> (ptr + 1) != 0x0201) { return(2); } if (Intrinsics.UnalignedLdobj <short> (ptr + 2) != 0x0302) { return(3); } if (Intrinsics.UnalignedLdobj <int> (ptr + 1) != 0x04030201) { return(4); } if (Intrinsics.UnalignedLdobj <int> (ptr + 2) != 0x05040302) { return(5); } if (Intrinsics.UnalignedLdobj <long> (ptr + 1) != 0x0807060504030201) { return(6); } if (Intrinsics.UnalignedLdobj <long> (ptr + 6) != 0xD0C0B0A09080706) { return(7); } return(0); }
public static unsafe int test_0_ldobj_r8() { byte * ptr = stackalloc byte [32]; double f = 34423.44f; *(double *)ptr = (double)f; long expected = *(long *)ptr; Intrinsics.UnalignedStobj <long> (ptr + 3, expected); if (Intrinsics.UnalignedLdobj <double> (ptr + 3) != f) { return(1); } return(0); }
public static unsafe int test_0_ldobj_r4() { byte *ptr = stackalloc byte [32]; float f = (float)123.44f; *(float *)ptr = (float)f; int expected = *(int *)ptr; Intrinsics.UnalignedStobj <int> (ptr + 1, expected); /* we can loose some precision due to r4<->r8 conversions */ if (Math.Abs(Intrinsics.UnalignedLdobj <float> (ptr + 1) - f) > 0.01f) { return(1); } return(0); }
public static unsafe int test_0_ldobj() { byte *ptr = stackalloc byte [20]; for (int i = 0; i < 20; ++i) { ptr [i] = (byte)i; } if (BitConverter.IsLittleEndian) { if (Intrinsics.UnalignedLdobj <short> (ptr + 0) != 0x0100) { return(1); } if (Intrinsics.UnalignedLdobj <short> (ptr + 1) != 0x0201) { return(2); } if (Intrinsics.UnalignedLdobj <short> (ptr + 2) != 0x0302) { return(3); } if (Intrinsics.UnalignedLdobj <int> (ptr + 1) != 0x04030201) { return(4); } if (Intrinsics.UnalignedLdobj <int> (ptr + 2) != 0x05040302) { return(5); } if (Intrinsics.UnalignedLdobj <long> (ptr + 1) != 0x0807060504030201) { return(6); } if (Intrinsics.UnalignedLdobj <long> (ptr + 6) != 0xD0C0B0A09080706) { return(7); } } else { if (Intrinsics.UnalignedLdobj <short> (ptr + 0) != 0x0001) { return(1); } if (Intrinsics.UnalignedLdobj <short> (ptr + 1) != 0x0102) { return(2); } if (Intrinsics.UnalignedLdobj <short> (ptr + 2) != 0x0203) { return(3); } if (Intrinsics.UnalignedLdobj <int> (ptr + 1) != 0x01020304) { return(4); } if (Intrinsics.UnalignedLdobj <int> (ptr + 2) != 0x02030405) { return(5); } if (Intrinsics.UnalignedLdobj <long> (ptr + 1) != 0x0102030405060708) { return(6); } if (Intrinsics.UnalignedLdobj <long> (ptr + 6) != 0x60708090A0B0C0D) { return(7); } } return(0); }