[MLton] x86_64 port status

Matthew Fluet fluet@cs.cornell.edu
Sun, 7 May 2006 00:11:49 -0400 (EDT)


>> It would be very helpful if individuals on other platforms (BSD and
>> Darwin and Solaris particularly) could checkout the x86_64 branch and
>> try to compile the runtime:
>
> On Solaris, I get a lot of errors like the following.
>
> basis/Net/Socket/INetSock.c: In function `Socket_INetSock_toAddr':
> basis/Net/Socket/INetSock.c:6: warning: cast increases required alignment of target type
> basis/Net/Socket/INetSock.c:10: warning: cast increases required alignment of target type
> basis/Net/Socket/INetSock.c:11: warning: cast increases required alignment of target type
>
> Any idea what to do about these?

I'm hoping that they are benign.  What's going on is that we are 
allocating space for a C struct in ML as a Word8.word array or a 
Word8.word vector.  These are passed through the FFI as pointers:

   typedef unsigned char* Pointer;
   #define Array(t) Pointer
   #define Ref(t) Pointer
   #define Vector(t) const Pointer

An 'unsigned char*' admits byte alignment, but we know that all ML objects 
will be at least 4-byte aligned.

What we would need to determine is the alignment of a
'struct sockaddr_in*' and a 'struct in_addr*'; if it is 4-byte aligned, 
then we can safely ignore the warning.

Perhaps a better approach would be to define the following:

   struct PointerAux { unsigned char[4]; } __attribute__ ((aligned (4));
   typedef struct PointerAux* Pointer;
   #define Array(t) Pointer
   #define Ref(t) Pointer
   #define Vector(t) const Pointer

We should always be casting from Pointer to the actual type expected by 
the C-side of the Basis Library.