diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-09-19 00:15:15 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-09-19 00:15:15 +0100 |
commit | 62bb618911c3bfe11a989ed6397434ca89a628d7 (patch) | |
tree | a34544c4b497dc88b7f4047bca9e6fd010fa9b99 /includes | |
parent | 0176c3f297e58080ae1c308453cf5233f60f1f21 (diff) | |
download | haskell-62bb618911c3bfe11a989ed6397434ca89a628d7.tar.gz |
Add some LDV_* constants to platformConstants
Diffstat (limited to 'includes')
-rw-r--r-- | includes/mkDerivedConstants.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c index c73233288a..62c5ae8f1f 100644 --- a/includes/mkDerivedConstants.c +++ b/includes/mkDerivedConstants.c @@ -314,30 +314,17 @@ void constantBool(char *haskellName, int val) { } } -void constantIntC(char *cName, char *haskellName, intptr_t val) { - /* If the value is larger than 2^28 or smaller than -2^28, then fail. - This test is a bit conservative, but if any constants are roughly - maxBoun or minBound then we probably need them to be Integer - rather than Int so that cross-compiling between 32bit and 64bit - platforms works. */ - if (val > 268435456) { - printf("Value too large for constantInt: %" PRIdPTR "\n", val); - exit(1); - } - if (val < -268435456) { - printf("Value too small for constantInt: %" PRIdPTR "\n", val); - exit(1); - } - +void constantIntegralC(char *haskellType, char *cName, char *haskellName, + intptr_t val) { switch (mode) { case Gen_Haskell_Type: - printf(" , pc_%s :: Int\n", haskellName); + printf(" , pc_%s :: %s\n", haskellName, haskellType); break; case Gen_Haskell_Value: printf(" , pc_%s = %" PRIdPTR "\n", haskellName, val); break; case Gen_Haskell_Wrappers: - printf("%s :: DynFlags -> Int\n", haskellName); + printf("%s :: DynFlags -> %s\n", haskellName, haskellType); printf("%s dflags = pc_%s (sPlatformConstants (settings dflags))\n", haskellName, haskellName); break; @@ -352,8 +339,30 @@ void constantIntC(char *cName, char *haskellName, intptr_t val) { } } +void constantIntC(char *cName, char *haskellName, intptr_t val) { + /* If the value is larger than 2^28 or smaller than -2^28, then fail. + This test is a bit conservative, but if any constants are roughly + maxBoun or minBound then we probably need them to be Integer + rather than Int so that cross-compiling between 32bit and 64bit + platforms works. */ + if (val > 268435456) { + printf("Value too large for constantInt: %" PRIdPTR "\n", val); + exit(1); + } + if (val < -268435456) { + printf("Value too small for constantInt: %" PRIdPTR "\n", val); + exit(1); + } + + constantIntegralC("Int", cName, haskellName, val); +} + void constantInt(char *name, intptr_t val) { - constantIntC (NULL, name, val); + constantIntC(NULL, name, val); +} + +void constantInteger(char *name, intptr_t val) { + constantIntegralC("Integer", NULL, name, val); } int @@ -729,6 +738,11 @@ main(int argc, char *argv[]) #endif ); + constantInt("lDV_SHIFT", LDV_SHIFT); + constantInteger("iLDV_CREATE_MASK", LDV_CREATE_MASK); + constantInteger("iLDV_STATE_CREATE", LDV_STATE_CREATE); + constantInteger("iLDV_STATE_USE", LDV_STATE_USE); + switch (mode) { case Gen_Haskell_Type: printf(" } deriving (Read, Show)\n"); |