[M3devel] FW: "CheckFloatsAndTypes"?

Jay jay.krell at cornell.edu
Thu Feb 26 17:23:49 CET 2009


I assume wedging this tiny bit of code into RTLinker would not be welcome?

I think it'd have by far the most value there -- get it to run and fail clearly before any other harder to debug problems.

 

void Test__CheckFloatsAndTypes(const T* t2, size_t size, size_t jbsize)
{
    if (size != sizeof(t1))
    {
        printf("%x vs. %x\n", (U)size, (U)sizeof(t1));
        assert(size == sizeof(t1));
    }


    if (memcmp(&t1, t2, sizeof(t1)) != 0)
    {
        U i = 0;
        U8* a = (U8*)&t1;
        U8* b = (U8*)t2;
        printf("FD_SETSIZE 0x%x\n", (U)FD_SETSIZE);
        /*printf("offset of max_fdset 0x%x\n", (U)offsetof(T, max_fdset));*/
        for (i = 0; i != sizeof(t1); ++i)
        {
            if (a[i] != b[i])
            {
                printf("different at offset 0x%x\n", i);
            }
        }
        assert(memcmp(&t1, t2, sizeof(t1)) == 0);
    }
#ifdef __CYGWIN__
    assert(jbsize >= (sizeof(jmp_buf) / 4));
#else
    assert(jbsize == sizeof(jmp_buf));
#endif
}


 - Jay


 
> Date: Thu, 26 Feb 2009 17:16:05 +0000
> To: m3commit at elegosoft.com
> From: jkrell at elego.de
> Subject: [M3commit] CVS Update: cm3
> 
> CVSROOT: /usr/cvs
> Changes by: jkrell at birch. 09/02/26 17:16:05
> 
> Modified files:
> cm3/m3-sys/m3tests/src/: Test.i3 m3makefile 
> cm3/m3-sys/m3tests/src/p0/p001/: Main.m3 m3makefile 
> Added files:
> cm3/m3-sys/m3tests/src/: TestC.c 
> 
> Log message:
> nice little test case to verify compilation of floating point constants
> and correctness of Usysdep
> I would really like to have this "run" in RTLinker but suspect that would be rejected.
> Anywhere else, e.g. here, is kind of too late to be valuable, unless we manage
> to get this into boot1.py, and very early in the list of modules that RTLinker
> initializes.
> 
> This reveals some existing possible problems.
> - arrays of odd number of float and/or double don't
> match up between C and Modula-3; probably related to -mno-aligned-floats
> - there are other mismatches here masked by inserting size_t padding
> in particular I think cywin linger_t has 16 bit integers and there is
> disagreement there. But I didn't look into it.
> 
> Luckily the interactions between C and Modula-3 are relatively rare /and/
> relatively conservative and not very likely to hit these issues.
> They do merit further attention though.
> 
> "Running this test case" is merely evaluation three efficient assertions
> plus dedicating the constant static space to two structs (Modula-3
> might run initialization code for its "const static" though?)
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090226/3e1f5576/attachment-0001.html>


More information about the M3devel mailing list