From 0300ffec3cd6e4ec21fd933a8a42e3fd47ebe0af Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Tue, 21 Oct 2008 17:44:17 +0100 Subject: [PATCH] Mps br/vc9: mpstd.h: - fix broken behaviour if CONFIG_PF_* is set (result depends on order of the various platform elifs!); change it to always use platform detection by looking at preprocessor symbols, and then (if CONFIG_PF_STRING *and* CONFIG_PF_* are set) check that CONFIG and detection match; - write design notes about interaction of CONFIG_PF_* and platform detection. w3i3m[v9].nmk: define both CONFIG_PF_STRING and CONFIG_PF_*. Copied from Perforce Change: 166512 ServerID: perforce.ravenbrook.com --- mps/code/mpstd.h | 55 ++++++++++++++++++++++++++++++++++++--------- mps/code/w3i3m9.nmk | 3 ++- mps/code/w3i3mv.nmk | 3 ++- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h index 005c8b69d56..e8da6a0c904 100644 --- a/mps/code/mpstd.h +++ b/mps/code/mpstd.h @@ -16,6 +16,44 @@ #ifndef mpstd_h #define mpstd_h +/* DESIGN NOTES + * ------------ + * [These should be moved to a proper buildsys design doc. RHSK] + * + * mpstd.h does two main things: + * 1. platform detection by looking at preprocessor symbols; + * 2. setting variables (eg. MPS_PF_STRING, MPS_WORD_WIDTH). + * + * Sometimes the platform is *already* known by the buildsystem: + * - the Global Graphics buildsystem always sets CONFIG_PF_*. + * - the Ravenbrook buildsystem knows the platform and may (but + * typically does not) set CONFIG_PF_*. + * + * Regardless of this, mpstd.h still attempts to detect the platform. + * (This is intentional). However if both CONFIG_PF_* and + * CONFIG_PF_STRING are set, then mpstd.h performs a third function: + * 3. checking that the detected platform corresponds to that + * specified by CONFIG_PF_*. + * + * Sometimes no MPS buildsystem is in use, so the platform *must* + * be detected. For example, when client software #includes mps.h, + * we want it to just work out of the box with whatever compiler is + * being used. In other words we do not require the client to define + * CONFIG_PF_*. + * (This is the case that justifes mpstd.h doing platform detection + * by looking at preprocessor symbols; otherwise we'd simply use + * CONFIG_PF_*). + * + * mpstd.h fails if it cannot detect the platform (even if CONFIG_PF_* + * is specified). This is intentional. mpstd.h does *not* allow + * CONFIG_PF_* to override the platform as detected from preprocessor + * symbols. This is intentional. + * + * References: + * GG buildsys use of CONFIG_PF_*: + * + */ + /* Irix 5/6 man cc and man abi. We can't check for _ABIO32 (see * os.i5), as we have to support Irix 5.2, which doesn't define it. We @@ -85,11 +123,9 @@ * and compiler options. */ -#elif defined(CONFIG_PF_W3I3M9) \ - || defined(_MSC_VER) && (_MSC_VER >= 1500) && defined(_WIN32) && defined(_M_IX86) -#if defined(CONFIG_PF_W3I3M9) \ - && ! ( defined(_MSC_VER) && (_MSC_VER >= 1500) && defined(_WIN32) && defined(_M_IX86) ) -#error "CONFIG_PF_W3I3M9 inconsistent with target platform detected" +#elif defined(_MSC_VER) && (_MSC_VER >= 1500) && defined(_WIN32) && defined(_M_IX86) +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_W3I3M9) +#error "specified CONFIG_PF_... inconsistent with detected w3i3m9" #endif #define MPS_PF_W3I3MV #define MPS_PF_STRING "w3i3m9" @@ -108,12 +144,9 @@ * VC malloc is 16! */ -#elif defined(CONFIG_PF_W3I3MV) \ - || defined(_MSC_VER) && defined(_WIN32) && defined(_M_IX86) -#if defined(CONFIG_PF_W3I3MV) \ - && ! ( defined(_MSC_VER) && (_MSC_VER < 1500) && defined(_WIN32) && defined(_M_IX86) ) -#error "CONFIG_PF_W3I3MV inconsistent with target platform detected" -/* (See w3i3m9 clone-platform, above) */ +#elif defined(_MSC_VER) && defined(_WIN32) && defined(_M_IX86) +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_W3I3MV) +#error "specified CONFIG_PF_... inconsistent with detected w3i3mv" #endif #define MPS_PF_W3I3MV #define MPS_PF_STRING "w3i3mv" diff --git a/mps/code/w3i3m9.nmk b/mps/code/w3i3m9.nmk index 852b640f0ad..f1ea0c0f557 100644 --- a/mps/code/w3i3m9.nmk +++ b/mps/code/w3i3m9.nmk @@ -23,7 +23,8 @@ DONGLELIB = $(RAINBOWPATH)\spromeps.lib # /Gs appears to be necessary to suppress stack checks. Stack checks # (if not suppressed) generate a dependency on the C library, __chkesp, # which causes the linker step to fail when building the DLL, mpsdy.dll. -PFMDEFS = /DCONFIG_PF_W3I3M9 /DWIN32 /D_WINDOWS /Gs /I$(RAINBOWPATH) +PFMDEFS = /DCONFIG_PF_STRING="w3i3m9" /DCONFIG_PF_W3I3M9 \ + /DWIN32 /D_WINDOWS /Gs /I$(RAINBOWPATH) MPM = \ \ diff --git a/mps/code/w3i3mv.nmk b/mps/code/w3i3mv.nmk index daac11abd89..9c3e6cee6b5 100644 --- a/mps/code/w3i3mv.nmk +++ b/mps/code/w3i3mv.nmk @@ -11,7 +11,8 @@ DONGLELIB = $(RAINBOWPATH)\spromeps.lib # /Gs appears to be necessary to suppress stack checks. Stack checks # (if not suppressed) generate a dependency on the C library, __chkesp, # which causes the linker step to fail when building the DLL, mpsdy.dll. -PFMDEFS = /DCONFIG_PF_W3I3MV /DWIN32 /D_WINDOWS /Gs /I$(RAINBOWPATH) +PFMDEFS = /DCONFIG_PF_STRING="w3i3mv" /DCONFIG_PF_W3I3MV \ + /DWIN32 /D_WINDOWS /Gs /I$(RAINBOWPATH) MPM = \ \