[MLton-commit] r4407

Stephen Weeks MLton@mlton.org
Mon, 24 Apr 2006 14:45:50 -0700


Ville Laurikari's patch for HP-UX.


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

U   mlton/trunk/basis-library/misc/primitive.sml
U   mlton/trunk/basis-library/mlton/platform.sig
U   mlton/trunk/basis-library/mlton/platform.sml
U   mlton/trunk/basis-library/sml-nj/sml-nj.sml
U   mlton/trunk/bin/platform
U   mlton/trunk/bin/upgrade-basis
U   mlton/trunk/lib/mlton-stubs/mlton.sml
U   mlton/trunk/lib/mlton-stubs/platform.sig
U   mlton/trunk/mlton/main/main.fun
U   mlton/trunk/runtime/Makefile
U   mlton/trunk/runtime/Posix/ProcEnv/Uname.c
U   mlton/trunk/runtime/basis/Int/Word.c
U   mlton/trunk/runtime/gc.c
A   mlton/trunk/runtime/platform/hpux.c
A   mlton/trunk/runtime/platform/hpux.h
A   mlton/trunk/runtime/platform/setenv.putenv.c
U   mlton/trunk/runtime/platform/solaris.c
U   mlton/trunk/runtime/platform.h
U   mlton/trunk/runtime/types.h

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

Modified: mlton/trunk/basis-library/misc/primitive.sml
===================================================================
--- mlton/trunk/basis-library/misc/primitive.sml	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/basis-library/misc/primitive.sml	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -967,6 +967,7 @@
                            Cygwin
                          | Darwin
                          | FreeBSD
+                         | HPUX
                          | Linux
                          | MinGW
                          | NetBSD
@@ -978,6 +979,7 @@
                               "cygwin" => Cygwin
                             | "darwin" => Darwin
                             | "freebsd" => FreeBSD
+                            | "hpux" => HPUX
                             | "linux" => Linux
                             | "mingw" => MinGW
                             | "netbsd" => NetBSD

Modified: mlton/trunk/basis-library/mlton/platform.sig
===================================================================
--- mlton/trunk/basis-library/mlton/platform.sig	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/basis-library/mlton/platform.sig	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2003-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2003-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  *
  * MLton is released under a BSD-style license.
@@ -23,6 +23,7 @@
                Cygwin
              | Darwin
              | FreeBSD
+             | HPUX
              | Linux
              | MinGW
              | NetBSD

Modified: mlton/trunk/basis-library/mlton/platform.sml
===================================================================
--- mlton/trunk/basis-library/mlton/platform.sml	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/basis-library/mlton/platform.sml	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2003-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2003-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  *
  * MLton is released under a BSD-style license.
@@ -46,6 +46,7 @@
             val all = [(Cygwin, "Cygwin"),
                        (Darwin, "Darwin"),
                        (FreeBSD, "FreeBSD"),
+                       (HPUX, "HPUX"),
                        (Linux, "Linux"),
                        (MinGW, "MinGW"),
                        (NetBSD, "NetBSD"),

Modified: mlton/trunk/basis-library/sml-nj/sml-nj.sml
===================================================================
--- mlton/trunk/basis-library/sml-nj/sml-nj.sml	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/basis-library/sml-nj/sml-nj.sml	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -33,6 +33,7 @@
                      Cygwin => UNIX
                    | Darwin => MACOS
                    | FreeBSD => UNIX
+                   | HPUX => UNIX
                    | Linux => UNIX
                    | MinGW => WIN32
                    | NetBSD => UNIX
@@ -68,4 +69,3 @@
              | Original => false
          end
    end
-   

Modified: mlton/trunk/bin/platform
===================================================================
--- mlton/trunk/bin/platform	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/bin/platform	2006-04-24 21:45:47 UTC (rev 4407)
@@ -35,6 +35,9 @@
 FreeBSD*)
         HOST_OS='freebsd'
 ;;
+HP-UX)
+	HOST_OS='hpux'
+;;
 Linux)
         HOST_OS='linux'
 ;;
@@ -74,6 +77,9 @@
 parisc*)
         HOST_ARCH=hppa
 ;;
+9000/*)
+        HOST_ARCH=hppa
+;;
 ia64*)
         HOST_ARCH=ia64
 ;;

Modified: mlton/trunk/bin/upgrade-basis
===================================================================
--- mlton/trunk/bin/upgrade-basis	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/bin/upgrade-basis	2006-04-24 21:45:47 UTC (rev 4407)
@@ -144,6 +144,9 @@
 freebsd)
         os='FreeBSD'
 ;;
+hpux)
+	os="HPUX"
+;;
 linux)
         os='Linux'
 ;;
@@ -206,12 +209,13 @@
 
             structure OS =
                struct
-                  datatype t = Cygwin | Darwin | FreeBSD | Linux | MinGW | NetBSD
-                             | OpenBSD | Solaris
+                  datatype t = Cygwin | Darwin | FreeBSD | HPUX | Linux | MinGW
+		             | NetBSD | OpenBSD | Solaris
 
                   val all = [(Cygwin, "Cygwin"),
                              (Darwin, "Darwin"),
                              (FreeBSD, "FreeBSD"),
+			     (HPUX, "HPUX"),
                              (Linux, "Linux"),
                              (MinGW, "MinGW"),
                              (NetBSD, "NetBSD"),

Modified: mlton/trunk/lib/mlton-stubs/mlton.sml
===================================================================
--- mlton/trunk/lib/mlton-stubs/mlton.sml	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/lib/mlton-stubs/mlton.sml	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -213,6 +213,7 @@
                      Cygwin
                    | Darwin
                    | FreeBSD
+                   | HPUX
                    | Linux
                    | MinGW
                    | NetBSD
@@ -224,6 +225,7 @@
                   val all = [(Cygwin, "Cygwin"),
                              (Darwin, "Darwin"),
                              (FreeBSD, "FreeBSD"),
+                             (HPUX, "HPUX"),
                              (Linux, "Linux"),
                              (MinGW, "MinGW"),
                              (NetBSD, "NetBSD"),

Modified: mlton/trunk/lib/mlton-stubs/platform.sig
===================================================================
--- mlton/trunk/lib/mlton-stubs/platform.sig	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/lib/mlton-stubs/platform.sig	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 2003-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 2003-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  *
  * MLton is released under a BSD-style license.
@@ -23,6 +23,7 @@
                Cygwin
              | Darwin
              | FreeBSD
+             | HPUX
              | Linux
              | MinGW
              | NetBSD

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/mlton/main/main.fun	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -645,6 +645,7 @@
          case targetOS of
             Darwin => ()
           | FreeBSD => ()
+          | HPUX => ()
           | Linux => ()
           | NetBSD => ()
           | OpenBSD => ()

Modified: mlton/trunk/runtime/Makefile
===================================================================
--- mlton/trunk/runtime/Makefile	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/Makefile	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-## Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+## Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  #    Jagannathan, and Stephen Weeks.
  # Copyright (C) 1997-2000 NEC Research Institute.
  #

Modified: mlton/trunk/runtime/Posix/ProcEnv/Uname.c
===================================================================
--- mlton/trunk/runtime/Posix/ProcEnv/Uname.c	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/Posix/ProcEnv/Uname.c	2006-04-24 21:45:47 UTC (rev 4407)
@@ -4,12 +4,12 @@
 #define DEBUG FALSE
 #endif
 
-static struct utsname utsname;
+static struct utsname mlton_utsname;
 
 Int Posix_ProcEnv_Uname_uname () {
         Int res;
         
-        res = uname (&utsname);
+        res = uname (&mlton_utsname);
         if (DEBUG)
                 fprintf (stderr, "%d = Posix_ProcEnv_Uname_uname ()\n",
                                 (int)res);
@@ -17,21 +17,21 @@
 }
 
 Cstring Posix_ProcEnv_Uname_sysname () {
-        return (Cstring)utsname.sysname;
+        return (Cstring)mlton_utsname.sysname;
 }
 
 Cstring Posix_ProcEnv_Uname_nodename () {
-        return (Cstring)utsname.nodename;
+        return (Cstring)mlton_utsname.nodename;
 }
 
 Cstring Posix_ProcEnv_Uname_release () {
-        return (Cstring)utsname.release;
+        return (Cstring)mlton_utsname.release;
 }
 
 Cstring Posix_ProcEnv_Uname_version () {
-        return (Cstring)utsname.version;
+        return (Cstring)mlton_utsname.version;
 }
 
 Cstring Posix_ProcEnv_Uname_machine () {
-        return (Cstring)utsname.machine;
+        return (Cstring)mlton_utsname.machine;
 }

Modified: mlton/trunk/runtime/basis/Int/Word.c
===================================================================
--- mlton/trunk/runtime/basis/Int/Word.c	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/basis/Int/Word.c	2006-04-24 21:45:47 UTC (rev 4407)
@@ -28,7 +28,7 @@
 #define DEBUG FALSE
 #endif
 
-#if ! (defined (__hppa__) || defined (__i386__) || defined (__ppc__) || defined (__powerpc__) || defined (__sparc__))
+#if ! (defined (__hppa__) || defined (__i386__) || defined(__ia64__) || defined (__ppc__) || defined (__powerpc__) || defined (__sparc__))
 #error check that C {/,%} correctly implement {quot,rem} from the basis library
 #endif
 

Modified: mlton/trunk/runtime/gc.c
===================================================================
--- mlton/trunk/runtime/gc.c	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/gc.c	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -332,7 +332,15 @@
 /* ---------------------------------------------------------------- */
 
 void GC_display (GC_state s, FILE *stream) {
-        fprintf (stream, "GC state\n\tcardMap = 0x%08x\n\toldGen = 0x%08x\n\toldGenSize = %s\n\toldGen + oldGenSize = 0x%08x\n\tnursery = 0x%08x\n\tfrontier = 0x%08x\n\tfrontier - nursery = %u\n\tlimitPlusSlop - frontier = %d\n",
+        fprintf (stream, "GC state\n"
+                 "\tcardMap = 0x%08x\n"
+                 "\toldGen = 0x%08x\n"
+                 "\toldGenSize = %s\n"
+                 "\toldGen + oldGenSize = 0x%08x\n"
+                 "\tnursery = 0x%08x\n"
+                 "\tfrontier = 0x%08x\n"
+                 "\tfrontier - nursery = %td\n"
+                 "\tlimitPlusSlop - frontier = %td\n",
                         (uint) s->cardMap,
                         (uint) s->heap.start,
                         uintToCommaString (s->oldGenSize),
@@ -343,7 +351,9 @@
                         s->limitPlusSlop - s->frontier);
         fprintf (stream, "\tcanHandle = %d\n\tsignalsIsPending = %d\n", s->canHandle, s->signalIsPending);
         fprintf (stderr, "\tcurrentThread = 0x%08x\n", (uint) s->currentThread);
-        fprintf (stream, "\tstackBottom = 0x%08x\n\tstackTop - stackBottom = %u\n\tstackLimit - stackTop = %u\n",
+        fprintf (stream, "\tstackBottom = 0x%08x\n"
+                 "\tstackTop - stackBottom = %td\n"
+                 "\tstackLimit - stackTop = %td\n",
                         (uint)s->stackBottom,
                         s->stackTop - s->stackBottom,
                         (s->stackLimit - s->stackTop));
@@ -764,7 +774,7 @@
                         /* Invariant: top points just past a "return address". */
                         returnAddress = *(word*) (top - WORD_SIZE);
                         if (DEBUG) {
-                                fprintf (stderr, "  top = %d  return address = ",
+                                fprintf (stderr, "  top = %td  return address = ",
                                                 top - bottom);
                                 fprintf (stderr, "0x%08x.\n", returnAddress);
                         }
@@ -2323,7 +2333,7 @@
                  */
                 assert (stackBottom (s, (GC_stack)cur) <= top);
                 if (DEBUG_MARK_COMPACT)
-                        fprintf (stderr, "markInStack  top = %d\n",
+                        fprintf (stderr, "markInStack  top = %td\n",
                                         top - stackBottom (s, (GC_stack)cur));
                                         
                 if (top == stackBottom (s, (GC_stack)(cur)))
@@ -2554,7 +2564,8 @@
                                  * busted.
                                  */
                                 if (DEBUG_MARK_COMPACT)
-                                        fprintf (stderr, "compressing from 0x%08x to 0x%08x (length = %u)\n",
+                                        fprintf (stderr, "compressing from 0x%08x to 0x%08x "
+                                                 "(length = %td)\n",
                                                         (uint)endOfLastMarked,
                                                         (uint)front,
                                                         front - endOfLastMarked);
@@ -3378,7 +3389,7 @@
         from = s->savedThread;
         s->savedThread = BOGUS_THREAD;
         if (DEBUG_THREADS) {
-                fprintf (stderr, "free space = %u\n",
+                fprintf (stderr, "free space = %td\n",
                                 s->limitPlusSlop - s->frontier);
                 fprintf (stderr, "0x%08x = copyThread (0x%08x)\n", 
                                 (uint)to, (uint)from);

Added: mlton/trunk/runtime/platform/hpux.c
===================================================================
--- mlton/trunk/runtime/platform/hpux.c	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/platform/hpux.c	2006-04-24 21:45:47 UTC (rev 4407)
@@ -0,0 +1,110 @@
+#include "platform.h"
+
+#include <sys/mman.h>
+#define MAP_ANON MAP_ANONYMOUS
+
+#include <sys/param.h>
+#include <sys/pstat.h>
+#include <sys/newsig.h>
+
+#include "ssmmap.c"
+#include "getrusage.c"
+#include "use-mmap.c"
+#include "mkdir2.c"
+#include "setenv.putenv.c"
+
+W32 totalRam (GC_state s) {
+        struct pst_static buf;
+
+        if (pstat_getstatic (&buf, sizeof(buf), 1, 0) < 0)
+                diee ("failed to get physical memory size");
+        return buf.physical_memory * buf.page_size;
+}
+
+
+struct pstnames {
+        int type;
+        char *name;
+};
+
+static struct pstnames pst_type_names[] =
+        {{ PS_NOTUSED,      "unused" },
+         { PS_USER_AREA,    "user" },
+         { PS_TEXT,         "text" },
+         { PS_DATA,         "data" },
+         { PS_STACK,        "stack" },
+         { PS_SHARED,       "shared" },
+         { PS_NULLDEREF,    "null" },
+         { PS_IO,           "io" },
+         { PS_MMF,          "mmap" },
+         { PS_GRAPHICS,     "gfx" },
+         { PS_GRAPHICS_DMA, "gfxdma" },
+#ifdef PS_RSESTACK
+         { PS_RSESTACK,     "rsestack" },
+#endif
+         { 0, NULL }};
+
+static const char *
+pst_type_name(int type)
+{
+        int i;
+
+        for (i = 0; pst_type_names[i].name; i++)
+                if (pst_type_names[i].type == type)
+                        return pst_type_names[i].name;
+        return "unknown";
+}
+
+static const char*
+pst_filename(struct pst_vm_status vm)
+{
+        static char fname[256];
+#ifdef PSTAT_FILEDETAILS
+        if (pstat_getpathname(fname, sizeof(fname), &vm.pst_fid) < 0)
+#endif
+                strcpy(fname, "unknown");
+        return fname;
+}
+
+void showMem () {
+        int i;
+        struct pst_vm_status buf;
+        size_t page_size = sysconf(_SC_PAGE_SIZE);
+
+        printf("va_start  va_end  perms   type   phys   filename\n");
+        printf("--------+--------+-----+-------+------+-----------\n");
+        for (i = 0;; i++) {
+                if (pstat_getprocvm (&buf, sizeof(buf), 0, i) < 0)
+                        break;
+                printf("%p %p  %s%s%s  %-8s %4d   %s\n",
+                       (void*)buf.pst_vaddr,
+                       (void*)buf.pst_vaddr + buf.pst_length * page_size - 1,
+                       (buf.pst_flags & PS_PROT_READ) ? "-" : "r",
+                       (buf.pst_flags & PS_PROT_WRITE) ? "-" : "w",
+                       (buf.pst_flags & PS_PROT_EXECUTE) ? "-" : "x",
+                       pst_type_name(buf.pst_type),
+                       buf.pst_phys_pages,
+                       pst_filename(buf));
+        }
+}
+
+
+static void catcher (int sig, siginfo_t* sip, void* mystery) {
+        ucontext_t* ucp = (ucontext_t*)mystery;
+        GC_handleSigProf ((pointer) (ucp->uc_link));
+}
+
+void setSigProfHandler (struct sigaction *sa) {
+        sa->sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
+        sa->sa_sigaction = (void (*)(int, siginfo_t*, void*))catcher;
+}
+
+extern void *__text_start;
+extern void *etext;
+
+void *getTextStart () {
+        return &__text_start;
+}
+void *getTextEnd () {
+        return &etext;
+}

Added: mlton/trunk/runtime/platform/hpux.h
===================================================================
--- mlton/trunk/runtime/platform/hpux.h	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/platform/hpux.h	2006-04-24 21:45:47 UTC (rev 4407)
@@ -0,0 +1,43 @@
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+
+#include <math.h>
+#include <signal.h>
+#include <sys/ptrace.h>
+#include <sys/poll.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/times.h>
+#include <sys/utsname.h>
+#include <termios.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netdb.h>
+#include <grp.h>
+#include <fenv.h>
+#include <syslog.h>
+
+#include "setenv.h"
+
+#define HAS_FEROUND TRUE
+#define HAS_FPCLASSIFY TRUE
+#define HAS_PTRACE FALSE
+#define HAS_REMAP FALSE
+#define HAS_SIGALTSTACK TRUE
+#define HAS_SIGNBIT TRUE
+#define HAS_SPAWN FALSE
+#define HAS_TIME_PROFILING TRUE
+
+#define MLton_Platform_OS_host "hpux"
+
+#define LOG_PERROR 0
+#define LOG_AUTHPRIV LOG_AUTH
+
+#define MSG_DONTWAIT 0
+
+#ifndef PF_INET6
+/* Old versions of HP-UX don't have IPv6 support. */
+struct sockaddr_in6 {};
+#define PF_INET6 0
+#endif

Added: mlton/trunk/runtime/platform/setenv.putenv.c
===================================================================
--- mlton/trunk/runtime/platform/setenv.putenv.c	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/platform/setenv.putenv.c	2006-04-24 21:45:47 UTC (rev 4407)
@@ -0,0 +1,13 @@
+/* This implementation of setenv has a space leak, but I don't see how to avoid
+ * it, since the specification of putenv is that it uses the memory for its arg.
+ */
+int setenv (const char *name, const char *value, int overwrite) {
+        char *b;
+
+        if (!overwrite && getenv (name))
+                return 0;
+
+        b = malloc (strlen (name) + strlen (value) + 2 /* = and \000 */);
+        sprintf (b, "%s=%s", name, value);
+        return putenv (b);
+}

Modified: mlton/trunk/runtime/platform/solaris.c
===================================================================
--- mlton/trunk/runtime/platform/solaris.c	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/platform/solaris.c	2006-04-24 21:45:47 UTC (rev 4407)
@@ -9,6 +9,7 @@
 #include "signbit.c"
 #include "ssmmap.c"
 #include "totalRam.sysconf.c"
+#include "setenv.putenv.c"
 
 static void catcher (int sig, siginfo_t *sip, ucontext_t *ucp) {
         GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[REG_PC]);
@@ -85,17 +86,6 @@
         smunmap (base, length);
 }
 
-/* This implementation of setenv has a space leak, but I don't see how to avoid 
- * it, since the specification of putenv is that it uses the memory for its arg.
- */
-int setenv (const char *name, const char *value, int overwrite) {
-        char *b;
-
-        b = malloc (strlen (name) + strlen (value) + 2 /* = and \000 */);
-        sprintf (b, "%s=%s", name, value);
-        return putenv (b);
-}
-
 void showMem () {
         static char buffer[256];
         sprintf (buffer, "pmap %d\n", (int)(getpid ()));

Modified: mlton/trunk/runtime/platform.h
===================================================================
--- mlton/trunk/runtime/platform.h	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/platform.h	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -64,6 +64,8 @@
 #include "platform/darwin.h"
 #elif (defined (__FreeBSD__))
 #include "platform/freebsd.h"
+#elif (defined (__hpux__))
+#include "platform/hpux.h"
 #elif (defined (__linux__))
 #include "platform/linux.h"
 #elif (defined (__MINGW32__))
@@ -271,8 +273,8 @@
 void swrite (int fd, const void *buf, size_t count);
 void swriteUint (int fd, uint n);
 /*
- * totalRam returns the amount of physical memory on the machine.
- */
+ * totalRam returns the amount of physical memory on the machine (in
+ * bytes).  */
 Word32 totalRam (GC_state s);
 string uintToCommaString (uint n);
 string ullongToCommaString (ullong n);

Modified: mlton/trunk/runtime/types.h
===================================================================
--- mlton/trunk/runtime/types.h	2006-04-24 21:21:40 UTC (rev 4406)
+++ mlton/trunk/runtime/types.h	2006-04-24 21:45:47 UTC (rev 4407)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 2004-2006 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  *
  * MLton is released under a BSD-style license.
@@ -16,7 +16,7 @@
 #ifndef _ISOC99_SOURCE
 #define _ISOC99_SOURCE
 #endif
-#if (defined (__OpenBSD__))
+#if (defined(__hpux__) || defined (__OpenBSD__))
 #include <inttypes.h>
 #elif (defined (__sun__))
 #include <sys/int_types.h>