Ejemplo n.º 1
0
    public static unsafe int test_0_stobj()
    {
        byte *ptr = stackalloc byte [20];

        Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
        if (ptr [0] != 0x88 || ptr [1] != 0x66)
        {
            return(1);
        }

        Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
        if (ptr [1] != 0x89 || ptr [2] != 0x65)
        {
            return(2);
        }

        Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
        if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
        {
            return(3);
        }

        Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
        if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
        {
            return(4);
        }

        return(0);
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
0
    public static unsafe int test_0_stobj()
    {
        byte *ptr = stackalloc byte [20];

        if (BitConverter.IsLittleEndian)
        {
            Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
            if (ptr [0] != 0x88 || ptr [1] != 0x66)
            {
                return(1);
            }

            Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
            if (ptr [1] != 0x89 || ptr [2] != 0x65)
            {
                return(2);
            }

            Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
            if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
            {
                return(3);
            }

            Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
            if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 ||
                ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
            {
                return(4);
            }
        }
        else
        {
            Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
            if (ptr [0] != 0x66 || ptr [1] != 0x88)
            {
                return(1);
            }

            Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
            if (ptr [1] != 0x65 || ptr [2] != 0x89)
            {
                return(2);
            }

            Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
            if (ptr [1] != 0x60 || ptr [2] != 0x70 || ptr [3] != 0x80 || ptr [4] != 0x90)
            {
                return(3);
            }

            Intrinsics.UnalignedStobj <long> (ptr + 1, 0x2030405060708090);
            if (ptr [1] != 0x20 || ptr [2] != 0x30 || ptr [3] != 0x40 ||
                ptr [4] != 0x50 || ptr [5] != 0x60 || ptr [6] != 0x70)
            {
                return(4);
            }
        }

        return(0);
    }