[MLton] Re: GMP patch: MinGW/win64 port

Wesley W. Terpstra wesley at terpstra.ca
Tue Mar 4 07:04:49 PST 2008


On Sat, 2008-01-03 at 02:03 -0800, Myria wrote:
> http://msdn2.microsoft.com/en-us/library/ms794533.aspx
> 
> The ABI for Win64 is much more complicated than just the register allocation 
> scheme.

Yes; this is why I made no attempt to fix this. My interest was only in
getting gmp to a working state. It's performance was a very distant
secondary concern to me.

> Brian Gladman ported the x86-64 assembly code to Windows for Visual Studio, 
> but I don't remember whether he added the function markup.

I know nothing about any other ports of gmp to win64.

>   It is necessary to use 'malloc-reentrant' to forbid use of alloca,
>   which appears to be broken under win64.
> Is this something particular to GMP, or does alloca fail to work
> properly also for other programs?

alloca was broken under mingw/win64 in general. There have been posts to
the mingw-w64 mailing list purporting that this is fixed, but I have not
had time to check this.

>   make check succeeds except for the tests t-locale and t-printf.
>   t-locale fails to compile because it tries to replace an imported
>   function with a local copy of localeconv. Probably GMP shouldn't do
>   this.
> 
> Perhaps not.  I din't write that code, and will wait for contributions
> about how to handle this.
> 
>   t-printf fails because the win64 printf ignores the high 32 bits of
>   %llu.
> 
> Can the dos64 printf print 'long long' arguments at all?

It does support 64 bit pointers in printf. At the time I wrote that
patch the relevant headers were broken. They have since been fixed. To
printf a value that is possibly 64 bit, the following will work:

long long x = 34324;
printf("blah: %"PRIdMAX"\n", (uintmax_t)x);

AFAIK, this should be portable to all systems (including mingw/win64).

> I am troubled by your tests/amd64check.c change, since it
> unconditionally changes the constants to 'long long'.  Not all
> compilers might have that type.  Could you please try using the
> CNST_LIMB mechanism instead?

amd64check is only for amd64. What amd64 compiler does not have long
long? AFAIK, none. I doubt such a compiler will ever exist.





More information about the MLton mailing list