From 0c8c2d6f3168a56474b222c919b051641948b3bf Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Mon, 9 Dec 2024 17:41:47 -0500 Subject: [PATCH 2/4] Porting to Cygwin, second attempt Use GCC with the Windows interface. The MPS builds, but I don't know yet if it works well in Emacs. --- code/config.h | 2 +- code/lockix.c | 5 ++--- code/mps.c | 32 ++++++++++++++++++++++---------- code/mpstd.h | 22 ++++++++++++++++++++-- code/prmcix.c | 4 ++-- code/protix.c | 5 ++--- code/protsgix.c | 4 ++-- code/pthrdext.c | 4 ++-- code/spw3i6.c | 5 +++++ code/testlib.h | 2 +- code/testthr.h | 3 +-- code/th.h | 6 ++++++ code/thix.c | 4 ++-- code/vmix.c | 5 ++--- 14 files changed, 70 insertions(+), 33 deletions(-) diff --git a/code/config.h b/code/config.h index 5abf6c982596..0201094a0e15 100644 --- a/code/config.h +++ b/code/config.h @@ -616,7 +616,7 @@ /* POSIX thread extensions configuration -- see */ -#if defined(MPS_OS_LI) || defined(MPS_OS_FR) || defined(MPS_OS_CY) +#if defined(MPS_OS_LI) || defined(MPS_OS_FR) /* PTHREADEXT_SIGSUSPEND -- signal used to suspend a thread * diff --git a/code/lockix.c b/code/lockix.c index 3c4e1939c739..a6555f5bb360 100644 --- a/code/lockix.c +++ b/code/lockix.c @@ -31,9 +31,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_XC) \ - && !defined(MPS_OS_CY) -#error "lockix.c is specific to MPS_OS_FR, MPS_OS_LI, MPS_OS_XC, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_XC) +#error "lockix.c is specific to MPS_OS_FR, MPS_OS_LI or MPS_OS_XC" #endif #include "lock.h" diff --git a/code/mps.c b/code/mps.c index a2bb7f003f5d..2b4f13885001 100644 --- a/code/mps.c +++ b/code/mps.c @@ -260,16 +260,28 @@ #elif defined(MPS_PF_CYI6GC) -#include "lockix.c" /* Posix locks */ -#include "thix.c" /* Posix threading */ -#include "pthrdext.c" /* Posix thread extensions */ -#include "vmix.c" /* Posix virtual memory */ -#include "protix.c" /* Posix protection */ -#include "protsgix.c" /* Posix signal handling */ -#include "prmcanan.c" /* generic architecture mutator context */ -#include "prmcix.c" /* Posix mutator context */ -#include "prmccyi6.c" /* x86-64 for Cygwin mutator context */ -#include "span.c" /* generic stack probe */ +/* #include "lockix.c" /\* Posix locks *\/ */ +/* #include "thix.c" /\* Posix threading *\/ */ +/* #include "pthrdext.c" /\* Posix thread extensions *\/ */ +/* #include "vmix.c" /\* Posix virtual memory *\/ */ +/* #include "protix.c" /\* Posix protection *\/ */ +/* #include "protsgix.c" /\* Posix signal handling *\/ */ +/* #include "prmcanan.c" /\* generic architecture mutator context *\/ */ +/* #include "prmcix.c" /\* Posix mutator context *\/ */ +/* #include "prmccyi6.c" /\* x86-64 for Cygwin mutator context *\/ */ +/* #include "span.c" /\* generic stack probe *\/ */ + +/* Use the Windows interface. */ + +#include "lockw3.c" /* Windows locks */ +#include "thw3.c" /* Windows threading */ +#include "vmw3.c" /* Windows virtual memory */ +#include "protw3.c" /* Windows protection */ +#include "prmci6.c" /* x86-64 mutator context */ +#include "prmcw3.c" /* Windows mutator context */ +#include "prmcw3i6.c" /* Windows on x86-64 mutator context */ +#include "spw3i6.c" /* Windows on x86-64 stack probe */ +#include "mpsiw3.c" /* Windows interface layer extras */ #else diff --git a/code/mpstd.h b/code/mpstd.h index d2c21d263064..8730282abeb9 100644 --- a/code/mpstd.h +++ b/code/mpstd.h @@ -394,6 +394,24 @@ /* GCC 12.4.0, gcc -E -dM */ +/* #elif defined(__CYGWIN__) && defined(__x86_64__) && defined(__GNUC__) \ */ +/* && !defined(__clang__) */ +/* #if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_CYI6GC) */ +/* #error "specified CONFIG_PF_... inconsistent with detected cyi6gc" */ +/* #endif */ +/* #define MPS_PF_CYI6GC */ +/* #define MPS_PF_STRING "cyi6gc" */ +/* #define MPS_OS_CY */ +/* #define MPS_ARCH_I6 */ +/* #define MPS_BUILD_GC */ +/* #define MPS_T_WORD unsigned long */ +/* #define MPS_T_ULONGEST unsigned long */ +/* #define MPS_WORD_WIDTH 64 */ +/* #define MPS_WORD_SHIFT 6 */ +/* #define MPS_PF_ALIGN 8 */ + +/* Use Cygwin GCC on Windows interface. */ + #elif defined(__CYGWIN__) && defined(__x86_64__) && defined(__GNUC__) \ && !defined(__clang__) #if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_CYI6GC) @@ -402,14 +420,14 @@ #define MPS_PF_CYI6GC #define MPS_PF_STRING "cyi6gc" #define MPS_OS_CY +#define MPS_OS_W3 #define MPS_ARCH_I6 #define MPS_BUILD_GC #define MPS_T_WORD unsigned long #define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 64 #define MPS_WORD_SHIFT 6 -#define MPS_PF_ALIGN 8 - +#define MPS_PF_ALIGN 16 #else #error "The MPS Kit does not have a configuration for this platform out of the box; see manual/build.txt" diff --git a/code/prmcix.c b/code/prmcix.c index 0af391eb45c7..8529405ae9c7 100644 --- a/code/prmcix.c +++ b/code/prmcix.c @@ -14,8 +14,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_CY) -#error "prmcix.c is specific to MPS_OS_FR, MPS_OS_LI, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) +#error "prmcix.c is specific to MPS_OS_FR or MPS_OS_LI" #endif #include "prmcix.h" diff --git a/code/protix.c b/code/protix.c index 18f29430e07d..fa6541913b71 100644 --- a/code/protix.c +++ b/code/protix.c @@ -35,9 +35,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_XC) \ - && !defined(MPS_OS_CY) -#error "protix.c is specific to MPS_OS_FR, MPS_OS_LI, MPS_OS_XC, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_XC) +#error "protix.c is specific to MPS_OS_FR, MPS_OS_LI or MPS_OS_XC" #endif #include "vm.h" diff --git a/code/protsgix.c b/code/protsgix.c index 9540908300d8..966569c92934 100644 --- a/code/protsgix.c +++ b/code/protsgix.c @@ -22,8 +22,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_CY) -#error "protsgix.c is specific to MPS_OS_FR, MPS_OS_LI, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) +#error "protsgix.c is specific to MPS_OS_FR or MPS_OS_LI" #endif #include "prmcix.h" diff --git a/code/pthrdext.c b/code/pthrdext.c index c143b5cf4db2..7619468a1872 100644 --- a/code/pthrdext.c +++ b/code/pthrdext.c @@ -16,8 +16,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_CY) -#error "pthrdext.c is specific to MPS_OS_FR, MPS_OS_LI, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) +#error "pthrdext.c is specific to MPS_OS_FR or MPS_OS_LI" #endif #include "pthrdext.h" diff --git a/code/spw3i6.c b/code/spw3i6.c index d06b4afcab03..ef2e49fb2a38 100644 --- a/code/spw3i6.c +++ b/code/spw3i6.c @@ -16,7 +16,12 @@ #error "spw3i6.c is specific to MPS_OS_W3" #endif +#ifndef MPS_OS_CY #include /* _alloca */ +#else +#include +#define _alloca alloca +#endif void StackProbe(Size depth) diff --git a/code/testlib.h b/code/testlib.h index 9a414f2b5dd0..085681e033ea 100644 --- a/code/testlib.h +++ b/code/testlib.h @@ -71,7 +71,7 @@ * */ -#if defined(MPS_OS_W3) +#if defined(MPS_OS_W3) && !defined(MPS_OS_CY) #define alloca _alloca diff --git a/code/testthr.h b/code/testthr.h index 13dcb3fc8924..a50dad1e5d09 100644 --- a/code/testthr.h +++ b/code/testthr.h @@ -45,8 +45,7 @@ typedef struct testthr_t { void *result; /* result returned from start */ } testthr_t; -#elif defined(MPS_OS_FR) || defined(MPS_OS_LI) || defined(MPS_OS_XC) \ - || defined(MPS_OS_CY) +#elif defined(MPS_OS_FR) || defined(MPS_OS_LI) || defined(MPS_OS_XC) #include diff --git a/code/th.h b/code/th.h index 08e01d6cc3d3..c939e371bc39 100644 --- a/code/th.h +++ b/code/th.h @@ -68,9 +68,15 @@ extern Thread ThreadRingThread(Ring threadRing); extern Arena ThreadArena(Thread thread); +#ifdef MP_OS_W3 extern Res ThreadScan(ScanState ss, Thread thread, void *stackCold, mps_area_scan_t scan_area, void *closure); +#else +extern Res ThreadScan(ScanState ss, Thread thread, Word *stackCold, + mps_area_scan_t scan_area, + void *closure); +#endif extern void ThreadSetup(void); diff --git a/code/thix.c b/code/thix.c index b89a6b4f43ab..c47f82ad3b87 100644 --- a/code/thix.c +++ b/code/thix.c @@ -34,8 +34,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_CY) -#error "thix.c is specific to MPS_OS_FR, MPS_OS_LI, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) +#error "thix.c is specific to MPS_OS_FR or MPS_OS_LI" #endif #include "prmcix.h" diff --git a/code/vmix.c b/code/vmix.c index 8fce9389e742..4bdd0caefadc 100644 --- a/code/vmix.c +++ b/code/vmix.c @@ -40,9 +40,8 @@ #include "mpm.h" -#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_XC) \ - && !defined(MPS_OS_CY) -#error "vmix.c is specific to MPS_OS_FR, MPS_OS_LI, MPS_OS_XC, or MPS_OS_CY" +#if !defined(MPS_OS_FR) && !defined(MPS_OS_LI) && !defined(MPS_OS_XC) +#error "vmix.c is specific to MPS_OS_FR, MPS_OS_LI or MPS_OS_XC" #endif #include "vm.h" -- 2.45.1