[MLton] x86_64 port status + powerpc

Wesley W. Terpstra terpstra@gkec.informatik.tu-darmstadt.de
Tue, 9 May 2006 18:24:33 +0200


--Apple-Mail-2--766534402
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

On May 7, 2006, at 1:57 AM, Wesley W. Terpstra wrote:
> I will take a look at ppc osx ...

So far, I've needed the attached patch for the runtime.
After these minor fixes, I got the attached c-types.sml.

This leads to a problem when type-checking the basis (after the first  
MLton compile):

Error: <basis>/posix/proc-env.sml 231.30.
   Function applied to incorrect argument.
     expects: [LargeInt.int] * _
     but got: [SysWord.t] * _
     in: LargeInt.*  (C_Clock.toLarge ticks, Time.ticksPerSecond)
Error: <basis>/posix/file-sys.sml 286.23.
   Undefined variable C_Dev.fromLargeWord.
Error: <basis>/posix/file-sys.sml 287.47.
   Undefined variable C_Dev.toLargeWord.
compilation aborted: elaborate reported errors
Error: <basis>/posix/proc-env.sml 231.30.
   Function applied to incorrect argument.
     expects: [LargeInt.int] * _
     but got: [SysWord.t] * _
     in: LargeInt.*  (C_Clock.toLarge ticks, Time.ticksPerSecond)
Error: <basis>/posix/file-sys.sml 286.23.
   Undefined variable C_Dev.fromLargeWord.
Error: <basis>/posix/file-sys.sml 287.47.
   Undefined variable C_Dev.toLargeWord.
compilation aborted: elaborate reported errors
Error: <basis>/posix/proc-env.sml 231.30.
   Function applied to incorrect argument.
     expects: [LargeInt.int] * _
     but got: [SysWord.t] * _
     in: LargeInt.*  (C_Clock.toLarge ticks, Time.ticksPerSecond)
Error: <basis>/posix/file-sys.sml 286.23.
   Undefined variable C_Dev.fromLargeWord.
Error: <basis>/posix/file-sys.sml 287.47.
   Undefined variable C_Dev.toLargeWord.
compilation aborted: elaborate reported errors
Error: <basis>/posix/proc-env.sml 231.30.
   Function applied to incorrect argument.
     expects: [LargeInt.int] * _
     but got: [SysWord.t] * _
     in: LargeInt.*  (C_Clock.toLarge ticks, Time.ticksPerSecond)
Error: <basis>/posix/file-sys.sml 286.23.
   Undefined variable C_Dev.fromLargeWord.
Error: <basis>/posix/file-sys.sml 287.47.
   Undefined variable C_Dev.toLargeWord.
compilation aborted: elaborate reported errors
Error: <basis>/posix/proc-env.sml 231.30.
   Function applied to incorrect argument.
     expects: [LargeInt.int] * _
     but got: [SysWord.t] * _
     in: LargeInt.*  (C_Clock.toLarge ticks, Time.ticksPerSecond)
Error: <basis>/posix/file-sys.sml 286.23.
   Undefined variable C_Dev.fromLargeWord.
Error: <basis>/posix/file-sys.sml 287.47.
   Undefined variable C_Dev.toLargeWord.
compilation aborted: elaborate reported errors
Error: <basis>/posix/proc-env.sml 231.30.
   Function applied to incorrect argument.
     expects: [LargeInt.int] * _
     but got: [SysWord.t] * _
     in: LargeInt.*  (C_Clock.toLarge ticks, Time.ticksPerSecond)
Error: <basis>/posix/file-sys.sml 286.23.
   Undefined variable C_Dev.fromLargeWord.
Error: <basis>/posix/file-sys.sml 287.47.
   Undefined variable C_Dev.toLargeWord.
compilation aborted: elaborate reported errors

--Apple-Mail-2--766534402
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="ppc.patch"
Content-Disposition: attachment;
	filename=ppc.patch

Index: runtime/platform/getText.c
===================================================================
--- runtime/platform/getText.c	(revision 4501)
+++ runtime/platform/getText.c	(working copy)
@@ -2,9 +2,9 @@
 extern char _start;
 extern char etext;
 
-void *GC_getTextStart (void) {
+const void *GC_getTextStart (void) {
         return &_start;
 }
-void *GC_getTextEnd (void) {
+const void *GC_getTextEnd (void) {
         return &etext;
 }
Index: runtime/platform/darwin.c
===================================================================
--- runtime/platform/darwin.c	(revision 4501)
+++ runtime/platform/darwin.c	(working copy)
@@ -8,21 +8,20 @@
 #include "mmap-protect.c"
 #include "use-mmap.c"
 
-void *getTextEnd () {
-        return (void*)(get_etext ());
+const void *GC_getTextEnd (void) {
+        return (const void*)(long)(get_etext ());
 }
 
-void *getTextStart () {
-        unsigned long address;
-        void *module;
-        struct mach_header *mh;
+const void *GC_getTextStart (void) {
+        void *address;
+        const struct mach_header *mh;
 
-        _dyld_lookup_and_bind ("_main", &address, &module);
+        _dyld_lookup_and_bind ("_main", &address, 0);
         mh = _dyld_get_image_header_containing_address (address);
         return mh;
 }
 
-void GC_displayMem () {
+void GC_displayMem (void) {
         /* FIXME: this won't actually work. */
         static char buffer[256];
 
@@ -41,7 +40,7 @@
         sa->sa_sigaction = (void (*)(int, siginfo_t*, void*))catcher;
 }
 
-W32 GC_totalRam (GC_state s) {
+size_t GC_totalRam (void) {
         int mem;
         size_t len;
 
Index: runtime/platform/darwin.h
===================================================================
--- runtime/platform/darwin.h	(revision 4501)
+++ runtime/platform/darwin.h	(working copy)
@@ -32,3 +32,18 @@
 #define HAS_TIME_PROFILING TRUE
 
 #define MLton_Platform_OS_host "darwin"
+
+// MacOS doesn't support these... yet.
+#ifndef O_RSYNC
+#define O_RSYNC O_SYNC
+#endif
+#ifndef O_DSYNC
+#define O_DSYNC O_SYNC
+#endif
+
+// MacOS only defines this if POSIX_C_SOURCE is defined.
+// However, defining that breaks half the osx system headers.
+// They couldn't possibly change the number at this point anyways.
+#ifndef SIGPOLL
+#define SIGPOLL 7
+#endif
Index: runtime/gc/objptr.c
===================================================================
--- runtime/gc/objptr.c	(revision 4501)
+++ runtime/gc/objptr.c	(working copy)
@@ -23,7 +23,7 @@
   uintptr_t P_;
   pointer P;
 
-  if GC_MODEL_USEBASE {
+  if (GC_MODEL_USEBASE) {
     B_ = (uintptr_t)B;
   } else {
     B_ = 0;
@@ -44,7 +44,7 @@
   uintptr_t O_;
   objptr O;
 
-  if GC_MODEL_USEBASE {
+  if (GC_MODEL_USEBASE) {
     B_ = (uintptr_t)B;
   } else {
     B_ = 0;
Index: runtime/Posix/ProcEnv/sysconf-consts.c
===================================================================
--- runtime/Posix/ProcEnv/sysconf-consts.c	(revision 4501)
+++ runtime/Posix/ProcEnv/sysconf-consts.c	(working copy)
@@ -489,7 +489,7 @@
 #define _SC_XOPEN_SHM -1
 #endif
 const C_Int_t Posix_ProcEnv_SC_XOPEN_SHM = _SC_XOPEN_SHM;
-#ifndef __SC_XOPEN_STREAMS
+#ifndef _SC_XOPEN_STREAMS
 #define _SC_XOPEN_STREAMS -1
 #endif
 #ifndef _SC_XOPEN_STREAMS
Index: runtime/platform.h
===================================================================
--- runtime/platform.h	(revision 4501)
+++ runtime/platform.h	(working copy)
@@ -156,8 +156,8 @@
 /*                Text Segment                       */
 /* ------------------------------------------------- */
 
-void *GC_getTextEnd (void);
-void *GC_getTextStart (void);
+const void *GC_getTextEnd (void);
+const void *GC_getTextStart (void);
 
 /* ------------------------------------------------- */
 /*                SigProf Handler                    */
Index: runtime/util/Makefile
===================================================================
--- runtime/util/Makefile	(revision 4501)
+++ runtime/util/Makefile	(working copy)
@@ -71,10 +71,10 @@
 DEBUGFLAGS = $(CFLAGS) -Wunused -gstabs+ -g2
 
 CFILES = 							\
-	$(shell find -type f | grep '\.c$$')
+	$(shell find . -type f | grep '\.c$$')
 
 HFILES = 							\
-	$(shell find -type f | grep '\.h$$')
+	$(shell find . -type f | grep '\.h$$')
 
 all: libgc.o libgc-gdb.o
 

--Apple-Mail-2--766534402
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0600;
	name="c-types.sml"
Content-Disposition: attachment;
	filename=c-types.sml

(* Copyright (C) 2004-2006 Henry Cejtin, Matthew Fluet, Suresh
 *    Jagannathan, and Stephen Weeks.
 *
 * MLton is released under a BSD-style license.
 * See the file MLton-LICENSE for details.
 *)


(* C *)
structure C_Char = struct open Int8 type t = int end
functor C_Char_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int8 (A)
structure C_SChar = struct open Int8 type t = int end
functor C_SChar_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int8 (A)
structure C_UChar = struct open Word8 type t = word end
functor C_UChar_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word8 (A)
structure C_Short = struct open Int16 type t = int end
functor C_Short_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int16 (A)
structure C_SShort = struct open Int16 type t = int end
functor C_SShort_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int16 (A)
structure C_UShort = struct open Word16 type t = word end
functor C_UShort_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word16 (A)
structure C_Int = struct open Int32 type t = int end
functor C_Int_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_SInt = struct open Int32 type t = int end
functor C_SInt_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_UInt = struct open Word32 type t = word end
functor C_UInt_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_Long = struct open Int32 type t = int end
functor C_Long_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_SLong = struct open Int32 type t = int end
functor C_SLong_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_ULong = struct open Word32 type t = word end
functor C_ULong_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_LongLong = struct open Int64 type t = int end
functor C_LongLong_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int64 (A)
structure C_SLongLong = struct open Int64 type t = int end
functor C_SLongLong_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int64 (A)
structure C_ULongLong = struct open Word64 type t = word end
functor C_ULongLong_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word64 (A)
structure C_Float = struct open Real32 type t = real end
functor C_Float_ChooseRealN (A: CHOOSE_REALN_ARG) = ChooseRealN_Real32 (A)
structure C_Double = struct open Real64 type t = real end
functor C_Double_ChooseRealN (A: CHOOSE_REALN_ARG) = ChooseRealN_Real64 (A)
structure C_Size = struct open Word32 type t = word end
functor C_Size_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

structure C_Pointer = struct open Word32 type t = word end
functor C_Pointer_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_String = struct open Word32 type t = word end
functor C_String_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_StringArray = struct open Word32 type t = word end
functor C_StringArray_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* Generic integers *)
structure C_Fd = C_Int
functor C_Fd_ChooseIntN (A: CHOOSE_INTN_ARG) = C_Int_ChooseIntN (A)
structure C_Signal = C_Int
functor C_Signal_ChooseIntN (A: CHOOSE_INTN_ARG) = C_Int_ChooseIntN (A)
structure C_Status = C_Int
functor C_Status_ChooseIntN (A: CHOOSE_INTN_ARG) = C_Int_ChooseIntN (A)
structure C_Sock = C_Int
functor C_Sock_ChooseIntN (A: CHOOSE_INTN_ARG) = C_Int_ChooseIntN (A)

(* C99 *)
structure C_Ptrdiff = struct open Int32 type t = int end
functor C_Ptrdiff_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_Intmax = struct open Int64 type t = int end
functor C_Intmax_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int64 (A)
structure C_UIntmax = struct open Word64 type t = word end
functor C_UIntmax_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word64 (A)
structure C_Intptr = struct open Int32 type t = int end
functor C_Intptr_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_UIntptr = struct open Word32 type t = word end
functor C_UIntptr_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* from <dirent.h> *)
structure C_DirP = struct open Word32 type t = word end
functor C_DirP_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* from <poll.h> *)
structure C_NFds = struct open Word32 type t = word end
functor C_NFds_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* from <resource.h> *)
structure C_RLim = struct open Int64 type t = int end
functor C_RLim_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int64 (A)

(* from <sys/types.h> *)
structure C_Clock = struct open Word32 type t = word end
functor C_Clock_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_Dev = struct open Int32 type t = int end
functor C_Dev_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_GId = struct open Word32 type t = word end
functor C_GId_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_Id = struct open Word32 type t = word end
functor C_Id_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_INo = struct open Word32 type t = word end
functor C_INo_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)
structure C_Mode = struct open Word16 type t = word end
functor C_Mode_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word16 (A)
structure C_NLink = struct open Word16 type t = word end
functor C_NLink_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word16 (A)
structure C_Off = struct open Int64 type t = int end
functor C_Off_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int64 (A)
structure C_PId = struct open Int32 type t = int end
functor C_PId_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_SSize = struct open Int32 type t = int end
functor C_SSize_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_SUSeconds = struct open Int32 type t = int end
functor C_SUSeconds_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_Time = struct open Int32 type t = int end
functor C_Time_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_UId = struct open Word32 type t = word end
functor C_UId_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* from <sys/socket.h> *)
structure C_Socklen = struct open Word32 type t = word end
functor C_Socklen_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* from <termios.h> *)
structure C_CC = struct open Word8 type t = word end
functor C_CC_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word8 (A)
structure C_Speed = struct open Int32 type t = int end
functor C_Speed_ChooseIntN (A: CHOOSE_INTN_ARG) = ChooseIntN_Int32 (A)
structure C_TCFlag = struct open Word32 type t = word end
functor C_TCFlag_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)

(* from "gmp.h" *)
structure C_MPLimb = struct open Word32 type t = word end
functor C_MPLimb_ChooseWordN (A: CHOOSE_WORDN_ARG) = ChooseWordN_Word32 (A)


--Apple-Mail-2--766534402--