[MLton-commit] r7033

Ville Laurikari ville at mlton.org
Sat Apr 4 10:02:03 PST 2009


Changed hard coded (non-portable) values for RTLD_GLOBAL, RTLD_LAZY,
RTLD_LOCAL, and RTLD_NOW.  Use the "make constants" mechanism instead.

----------------------------------------------------------------------

U   mlton/trunk/lib/mlnlffi/memory/linkage-libdl.sml
U   mlton/trunk/lib/mlnlffi/memory/memory.unix.mlb
U   mlton/trunk/runtime/gen/basis-ffi.def
U   mlton/trunk/runtime/platform.c

----------------------------------------------------------------------

Modified: mlton/trunk/lib/mlnlffi/memory/linkage-libdl.sml
===================================================================
--- mlton/trunk/lib/mlnlffi/memory/linkage-libdl.sml	2009-04-04 17:22:06 UTC (rev 7032)
+++ mlton/trunk/lib/mlnlffi/memory/linkage-libdl.sml	2009-04-04 18:02:02 UTC (rev 7033)
@@ -17,9 +17,9 @@
 structure DynLinkage :> DYN_LINKAGE = struct
 
     exception DynLinkError of string
-    val () = 
-       MLton.Exn.addExnMessager 
-       (fn DynLinkError s => SOME (concat ["DynLinkError: ", s]) 
+    val () =
+       MLton.Exn.addExnMessager
+       (fn DynLinkError s => SOME (concat ["DynLinkError: ", s])
          | _ => NONE)
 
     local
@@ -36,10 +36,10 @@
 
     type mode = C_UInt.word
     local
-       val RTLD_LAZY   = 0wx00001
-       val RTLD_NOW    = 0wx00002
-       val RTLD_GLOBAL = 0wx00100
-       val RTLD_LOCAL  = 0wx00000
+       val RTLD_LAZY   = _const "DynLinkage_RTLD_LAZY"   : C_UInt.t;
+       val RTLD_NOW    = _const "DynLinkage_RTLD_NOW"    : C_UInt.t;
+       val RTLD_GLOBAL = _const "DynLinkage_RTLD_GLOBAL" : C_UInt.t;
+       val RTLD_LOCAL  = _const "DynLinkage_RTLD_LOCAL"  : C_UInt.t;
     in
        fun mk_mode {lazy: bool, global: bool} : mode=
           C_UInt.orb

Modified: mlton/trunk/lib/mlnlffi/memory/memory.unix.mlb
===================================================================
--- mlton/trunk/lib/mlnlffi/memory/memory.unix.mlb	2009-04-04 17:22:06 UTC (rev 7032)
+++ mlton/trunk/lib/mlnlffi/memory/memory.unix.mlb	2009-04-04 18:02:02 UTC (rev 7033)
@@ -10,7 +10,10 @@
    in
       local
          linkage.sig
-         ann "allowFFI true" in
+         ann 
+            "allowFFI true"
+            "allowConstant true"
+         in
             linkage-libdl.sml
          end
          bitop-fn.sml

Modified: mlton/trunk/runtime/gen/basis-ffi.def
===================================================================
--- mlton/trunk/runtime/gen/basis-ffi.def	2009-04-04 17:22:06 UTC (rev 7032)
+++ mlton/trunk/runtime/gen/basis-ffi.def	2009-04-04 18:02:02 UTC (rev 7033)
@@ -25,6 +25,10 @@
 Date.localTime = _import PRIVATE : C_Time.t ref -> C_Int.t C_Errno.t
 Date.mkTime = _import PRIVATE : unit -> C_Time.t C_Errno.t
 Date.strfTime = _import PRIVATE : Char8.t array * C_Size.t * NullString8.t -> C_Size.t
+DynLinkage.RTLD_GLOBAL = _const : C_UInt.t
+DynLinkage.RTLD_LAZY = _const : C_UInt.t
+DynLinkage.RTLD_LOCAL = _const : C_UInt.t
+DynLinkage.RTLD_NOW = _const : C_UInt.t
 IEEEReal.FloatClass.FP_INFINITE = _const : C_Int.t
 IEEEReal.FloatClass.FP_NAN = _const : C_Int.t
 IEEEReal.FloatClass.FP_NORMAL = _const : C_Int.t

Modified: mlton/trunk/runtime/platform.c
===================================================================
--- mlton/trunk/runtime/platform.c	2009-04-04 17:22:06 UTC (rev 7032)
+++ mlton/trunk/runtime/platform.c	2009-04-04 18:02:02 UTC (rev 7033)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2008 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 2004-2009 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  *
  * MLton is released under a BSD-style license.
@@ -6,9 +6,16 @@
  */
 
 #include "platform.h"
+#include <dlfcn.h>
 
 Bool MLton_Platform_CygwinUseMmap = FALSE;
 
+/* These are needed in the DynLinkage structure in mlnlffi-lib. */
+const C_UInt_t DynLinkage_RTLD_GLOBAL = RTLD_GLOBAL;
+const C_UInt_t DynLinkage_RTLD_LAZY   = RTLD_LAZY;
+const C_UInt_t DynLinkage_RTLD_LOCAL  = RTLD_LOCAL;
+const C_UInt_t DynLinkage_RTLD_NOW    = RTLD_NOW;
+
 void GC_setCygwinUseMmap (bool b) {
   MLton_Platform_CygwinUseMmap = b;
 }




More information about the MLton-commit mailing list