[MLton] x86_64 port status

Matthew Fluet fluet@cs.cornell.edu
Sun, 7 May 2006 21:18:06 -0400 (EDT)


> On Sat, May 06, 2006 at 06:30:42PM -0400, Matthew Fluet wrote:
>> I'm specifically interested in the files c-types.h and c-types.sml
>> (automatically copied to
>> basis-library/config/c/$(TARGET_ARCH)-$(TARGET_OS)/), where the sizes
>> and signedness of the C typedefs might be different from x86-linux.
>
> The `basis-library/config/c/hppa-hpux' directory was missing and I had
> to manually create it.  Could the directory be created automatically
> if it does not already exist?

It could, but there are reasons not to:
  * the dir needs to be created only once for each target arch/os port
  * the dir and file should be under source control

>> Second, I'm interested in any constants that aren't present on
>> different platforms.  I've been following the Single UNIX
>> Specification (as a superset of Posix, XOpen, and other standards).
>> I'm guessing that we'll have to drop a few more things to get to the
>> intersection of our platforms.
>
> HP-UX 11.00 doesn't have the following types/constants:

> suseconds_t

This type seems to be missing from a number of platforms.  It should be 
typedef-ed (presumably now somewhere in the appropriate platform file) to 
the type of the 'usec' component of the 'struct timeval' type.

> PRIxPTR

This has been discussed, but it needs to take into account the pointer 
size of the target platform.

> SIZE_MAX

I'm surprised this isn't defined, as it should be in <stdint.h>.

> struct sockaddr_storage

This is supposed to be defined in <sys/socket.h>
This struct is only used to compute the maximum size of any socket address 
structure.

> _SC_HOST_NAME_MAX
...

I see that Stephen has added #ifdef's for _SC and _PC constants.

> Additionally, IPv6 support in general is missing completely from HP-UX
> 11.00.

Too bad.  In general, I don't know that taking the intersection of the 
available features on all of our platforms is the right way to go. 
Unfortunately, we don't as of yet have a good way of conditionally 
including things in the ML Basis Library.

> After some small patches, I managed to compile the runtime on
> HPPA/HPUX.  At the moment I get loads and loads of warnings.  These
> were a bit mystical:
>
> ./util/read_write.h: In function 'writeUint32U':
> ./util/read_write.h:57: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'uint32_t'
> ./util/read_write.h: In function 'writeUint32X':
> ./util/read_write.h:71: warning: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'uint32_t'
>
> It would seem that the formatting macros used (PRIu32 and PRIx32) are
> correct for uint32_t.  However, on HP-UX inttypes.h contains
>
>  #ifndef __L64_MODE__
>  #define PRIx32                          "lx"
>  #else
>  #define PRIx32                          "x"
>  #endif
>
> and apparently I'm getting "lx" since __L64_MODE__ is not defined.  I
> don't quite understand why this is so.

I don't have any insight.

> Other warnings include 143 counts of the "cast increases required
> alignment of target type" warning from various files.

I've proposed one possible solution to this.  Alternatively, we could 
simply turn off the -Wcast-align warning.

> Here are some others:
>
> basis/MLton/Process/spawne.c: In function 'MLton_Process_spawne':
> basis/MLton/Process/spawne.c:33: warning: function might be possible candidate for attribute 'noreturn'
>
> basis/MLton/Process/spawnp.c: In function 'MLton_Process_spawnp':
> basis/MLton/Process/spawnp.c:23: warning: function might be possible candidate for attribute 'noreturn'

Stephen has figured out the right syntax to include the 'noreturn' 
attribute.

> Posix/FileSys/open2.c: In function 'Posix_FileSys_open2':
> /usr/include/sys/fcntl.h:237: warning: 'c' is used uninitialized in this function

Well, we don't control "/usr/include/sys/fcntl.h", so we'll have to 
assume its o.k. to ignore.

> In file included from gc.c:22: gc/array-allocate.c: In function 'GC_arrayAllocate':
> gc/array-allocate.c:30: warning: comparison of unsigned expression >= 0 is always true

I think this follows from the missing SIZE_MAX constant.

> In file included from gc.c:44:
> gc/init.c: In function 'stringToFloat':
> gc/init.c:27: warning: implicit declaration of function 'strtof'
> gc/init.c:27: warning: nested extern declaration of 'strtof'

'strtof' should be in <stdlib.h> for a C99 system.  If they don't exist on 
HPPA/HPUX, then I would define

float strtof(const char * restrict nptr, char ** restrict endptr) {
    double res = strtod(nptr, endptr);
    return (float)res;
}

in a platform specific file.

> In file included from gc.c:45:
> gc/int-inf.c: In function 'fillIntInfArg':
> gc/int-inf.c:68: warning: right shift count >= width of type

Safe to ignore.