shithub: MicroHs

Download patch

ref: 08dc58255a0e2579f4004c9b9efa2d7f0accda9a
parent: c49596156383aa003cb8ed12fcebd588a1000624
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Nov 27 13:43:36 EST 2023

Add 32 bit conf.

--- a/.github/workflows/c-cpp.yml
+++ b/.github/workflows/c-cpp.yml
@@ -42,3 +42,18 @@
       run: nmake -f Makefile.windows
     - name: nmake exampletest
       run: nmake -f Makefile.windows exampletest
+
+  build-linux-32:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: jirutka/setup-alpine@v1
+      with:
+        branch: v3.15
+    - name: checkout repo
+      uses: actions/checkout@v3
+    - name: make
+      run: make CONF=unix-32
+      shell: alpine.sh {0}
+    - name: make everytestmhs
+      run: make CONF=unix-32 everytestmhs
+      shell: alpine.sh {0}
--- a/Example.hs
+++ b/Example.hs
@@ -7,6 +7,7 @@
 
 main :: IO ()
 main = do
+  putStrLn $ "word size=" ++ show _wordSize ++ ", os=" ++ if _isWindows then "Windows" else "Unix-like"
   let
     rs = map fac [1,2,3,10]
   putStrLn "Some factorials"
--- /dev/null
+++ b/src/runtime/config-unix-32.h
@@ -1,0 +1,7 @@
+#include "config-unix-64.h"
+
+#undef WORD_SIZE
+#define WORD_SIZE 32
+
+#undef FFS
+#define FFS ffs
--- a/src/runtime/config-unix-64.h
+++ b/src/runtime/config-unix-64.h
@@ -118,12 +118,12 @@
  * Get time since some epoch in milliseconds.
  */
 #include <sys/time.h>
-uint64_t
+uintptr_t
 gettimemilli(void)
 {
   struct timeval tv;
   (void)gettimeofday(&tv, NULL);
-  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+  return (int)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
 }
 #define GETTIMEMILLI gettimemilli
 
--- /dev/null
+++ b/src/runtime/eval-unix-32.c
@@ -1,0 +1,6 @@
+/* Copyright 2023 Lennart Augustsson
+ * See LICENSE file for full license.
+ */
+#include "config-unix-32.h"
+
+#include "eval.c"
--