summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-11-10 23:28:58 +0000
committerIan Lynagh <ian@well-typed.com>2012-11-12 22:37:55 +0000
commitf49271c06434cace6f955c7b651295f0f1db3a03 (patch)
treee1a595dd621388cd36b1ecdbe595d7e126e2c92d /includes
parentb78b6b3472511c7e39d5c91b0449a59e0f361dcf (diff)
downloadhaskell-f49271c06434cace6f955c7b651295f0f1db3a03.tar.gz
Replace mkDerivedConstants.c with DeriveConstants.hs
DeriveConstants.hs works in a cross-compilation-friendly way. Rather than running a C program that prints out the constants, we just compile a C file which has the constants are encoded in symbol sizes. We then parse the output of 'nm' to find out what the constants are. Based on work by Gabor Greif <ggreif@gmail.com>.
Diffstat (limited to 'includes')
-rw-r--r--includes/ghc.mk78
-rw-r--r--includes/mkDerivedConstants.c829
-rw-r--r--includes/mkDerivedConstants.cross.awk350
-rw-r--r--includes/mkSizeMacros.cross.awk82
4 files changed, 22 insertions, 1317 deletions
diff --git a/includes/ghc.mk b/includes/ghc.mk
index 85df1da8b9..ac5200d17c 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -143,79 +143,45 @@ includes_GHCCONSTANTS_HASKELL_VALUE = includes/dist-derivedconstants/header/plat
includes_GHCCONSTANTS_HASKELL_WRAPPERS = includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs
includes_GHCCONSTANTS_HASKELL_EXPORTS = includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs
-INSTALL_LIBS += includes/dist-derivedconstants/header/platformConstants
+INSTALL_LIBS += $(includes_GHCCONSTANTS_HASKELL_VALUE)
-ifeq "$(PORTING_HOST)-$(AlienScript)" "YES-"
-
-DerivedConstants.h :
- @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
- @exit 1
-
-else
-
-includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
-includes_dist-derivedconstants_PROG = mkDerivedConstants$(exeext)
-includes_dist-derivedconstants_INSTALL_INPLACE = YES
-
-$(eval $(call build-prog,includes,dist-derivedconstants,0))
-
-$(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
-includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
-
-ifneq "$(AlienScript)" ""
-$(INPLACE_BIN)/mkDerivedConstants$(exeext): includes/$(includes_dist-derivedconstants_C_SRCS) | $$(dir $$@)/.
- $(WhatGccIsCalled) -o $@ $< $(CFLAGS) $(includes_CC_OPTS)
-endif
+DERIVE_CONSTANTS_FLAGS += --gcc-program "$(WhatGccIsCalled)"
+DERIVE_CONSTANTS_FLAGS += $(addprefix --gcc-flag$(space),$(includes_CC_OPTS) -fcommon)
+DERIVE_CONSTANTS_FLAGS += --nm-program "$(NM)"
ifneq "$(BINDIST)" "YES"
-$(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
-ifeq "$(AlienScript)" ""
- ./$< >$@
-else
- $(AlienScript) run ./$< >$@
-endif
+$(includes_DERIVEDCONSTANTS): $$(includes_H_CONFIG) $$(includes_H_PLATFORM) $$(includes_H_FILES) $$(rts_H_FILES)
+$(includes_GHCCONSTANTS_HASKELL_VALUE): $$(includes_H_CONFIG) $$(includes_H_PLATFORM) $$(includes_H_FILES) $$(rts_H_FILES)
-$(includes_GHCCONSTANTS_HASKELL_TYPE) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
-ifeq "$(AlienScript)" ""
- ./$< --gen-haskell-type >$@
-else
- $(AlienScript) run ./$< --gen-haskell-type >$@
-endif
+$(includes_DERIVEDCONSTANTS): $(INPLACE_BIN)/deriveConstants$(exeext) | $$(dir $$@)/.
+ $< --gen-header -o $@ --tmpdir $(dir $@) $(DERIVE_CONSTANTS_FLAGS)
-$(includes_GHCCONSTANTS_HASKELL_VALUE) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
-ifeq "$(AlienScript)" ""
- ./$< --gen-haskell-value >$@
-else
- $(AlienScript) run ./$< --gen-haskell-value >$@
-endif
+$(includes_GHCCONSTANTS_HASKELL_TYPE): $(INPLACE_BIN)/deriveConstants$(exeext) | $$(dir $$@)/.
+ $< --gen-haskell-type -o $@ --tmpdir $(dir $@) $(DERIVE_CONSTANTS_FLAGS)
-$(includes_GHCCONSTANTS_HASKELL_WRAPPERS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
-ifeq "$(AlienScript)" ""
- ./$< --gen-haskell-wrappers >$@
-else
- $(AlienScript) run ./$< --gen-haskell-wrappers >$@
-endif
+$(includes_GHCCONSTANTS_HASKELL_VALUE): $(INPLACE_BIN)/deriveConstants$(exeext) | $$(dir $$@)/.
+ $< --gen-haskell-value -o $@ --tmpdir $(dir $@) $(DERIVE_CONSTANTS_FLAGS)
-$(includes_GHCCONSTANTS_HASKELL_EXPORTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
-ifeq "$(AlienScript)" ""
- ./$< --gen-haskell-exports >$@
-else
- $(AlienScript) run ./$< --gen-haskell-exports >$@
-endif
-endif
+$(includes_GHCCONSTANTS_HASKELL_WRAPPERS): $(INPLACE_BIN)/deriveConstants$(exeext) | $$(dir $$@)/.
+ $< --gen-haskell-wrappers -o $@ --tmpdir $(dir $@) $(DERIVE_CONSTANTS_FLAGS)
+$(includes_GHCCONSTANTS_HASKELL_EXPORTS): $(INPLACE_BIN)/deriveConstants$(exeext) | $$(dir $$@)/.
+ $< --gen-haskell-exports -o $@ --tmpdir $(dir $@) $(DERIVE_CONSTANTS_FLAGS)
endif
# ---------------------------------------------------------------------------
# Install all header files
$(eval $(call clean-target,includes,,\
- $(includes_H_CONFIG) $(includes_H_PLATFORM) \
- $(includes_GHCCONSTANTS_HASKELL_TYPE) $(includes_GHCCONSTANTS_HASKELL_VALUE) $(includes_DERIVEDCONSTANTS)))
+ $(includes_H_CONFIG) $(includes_H_PLATFORM)))
$(eval $(call all-target,includes,,\
$(includes_H_CONFIG) $(includes_H_PLATFORM) \
- $(includes_GHCCONSTANTS_HASKELL_TYPE) $(includes_GHCCONSTANTS_HASKELL_VALUE) $(includes_DERIVEDCONSTANTS)))
+ $(includes_GHCCONSTANTS_HASKELL_TYPE) \
+ $(includes_GHCCONSTANTS_HASKELL_VALUE) \
+ $(includes_GHCCONSTANTS_HASKELL_WRAPPERS) \
+ $(includes_GHCCONSTANTS_HASKELL_EXPORTS) \
+ $(includes_DERIVEDCONSTANTS)))
install: install_includes
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
deleted file mode 100644
index dedb386fb9..0000000000
--- a/includes/mkDerivedConstants.c
+++ /dev/null
@@ -1,829 +0,0 @@
-/* --------------------------------------------------------------------------
- *
- * (c) The GHC Team, 1992-2012
- *
- * mkDerivedConstants.c
- *
- * Basically this is a C program that extracts information from the C
- * declarations in the header files (primarily struct field offsets)
- * and generates a header file that can be #included into non-C source
- * containing this information.
- *
- * ------------------------------------------------------------------------*/
-
-#define IN_STG_CODE 0
-
-/*
- * We need offsets of profiled things... better be careful that this
- * doesn't affect the offsets of anything else.
- */
-
-#define PROFILING
-#define THREADED_RTS
-
-#include "PosixSource.h"
-#include "Rts.h"
-#include "Stable.h"
-#include "Capability.h"
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-
-#if !defined(PRIdPTR)
-#if SIZEOF_VOID_P == SIZEOF_INT
-/* compiling for 32bit target */
-#define PRIdPTR "d"
-#elif SIZEOF_VOID_P == SIZEOF_LONG
-/* compiling for 64bit target */
-#define PRIdPTR "ld"
-#else
-#error Cannot find definition for PRIdPTR
-#endif
-#endif
-
-enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haskell_Exports, Gen_Header } mode;
-
-#define str(a,b) #a "_" #b
-
-#define OFFSET(s_type, field) ((size_t)&(((s_type*)0)->field))
-#define FIELD_SIZE(s_type, field) ((size_t)sizeof(((s_type*)0)->field))
-#define TYPE_SIZE(type) (sizeof(type))
-
-#pragma GCC poison sizeof
-
-#define def_offset(str, offset) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- printf(" , pc_OFFSET_" str " :: Int\n"); \
- break; \
- case Gen_Haskell_Value: \
- printf(" , pc_OFFSET_" str " = %" PRIdPTR "\n", (intptr_t)(offset)); \
- break; \
- case Gen_Haskell_Wrappers: \
- printf("oFFSET_" str " :: DynFlags -> Int\n"); \
- printf("oFFSET_" str " dflags = pc_OFFSET_" str " (sPlatformConstants (settings dflags))\n"); \
- break; \
- case Gen_Haskell_Exports: \
- printf(" oFFSET_" str ",\n"); \
- break; \
- case Gen_Header: \
- printf("#define OFFSET_" str " %" PRIdPTR "\n", (intptr_t)(offset)); \
- break; \
- }
-
-#define ctype(type) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define SIZEOF_" #type " %" FMT_SizeT "\n", \
- (size_t)TYPE_SIZE(type)); \
- break; \
- }
-
-/* Defining REP_x to be b32 etc
- These are both the C-- types used in a load
- e.g. b32[addr]
- and the names of the CmmTypes in the compiler
- b32 :: CmmType
-*/
-#define field_type_(want_haskell, str, s_type, field) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- if (want_haskell) { \
- printf(" , pc_REP_" str " :: Int\n"); \
- break; \
- } \
- case Gen_Haskell_Value: \
- if (want_haskell) { \
- printf(" , pc_REP_" str " = %" PRIdPTR "\n", (intptr_t)(FIELD_SIZE(s_type, field))); \
- break; \
- } \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define REP_" str " b"); \
- printf("%" FMT_SizeT "\n", FIELD_SIZE(s_type, field) * 8); \
- break; \
- }
-
-#define field_type_gcptr_(str, s_type, field) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define REP_" str " gcptr\n"); \
- break; \
- }
-
-#define field_type(want_haskell, s_type, field) \
- field_type_(want_haskell,str(s_type,field),s_type,field);
-
-#define field_offset_(str, s_type, field) \
- def_offset(str, OFFSET(s_type,field));
-
-#define field_offset(s_type, field) \
- field_offset_(str(s_type,field),s_type,field);
-
-/* An access macro for use in C-- sources. */
-#define struct_field_macro(str) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define " str "(__ptr__) REP_" str "[__ptr__+OFFSET_" str "]\n"); \
- break; \
- }
-
-/* Outputs the byte offset and MachRep for a field */
-#define struct_field_helper(want_haskell, s_type, field) \
- field_offset(s_type, field); \
- field_type(want_haskell, s_type, field); \
- struct_field_macro(str(s_type,field))
-
-#define struct_field(s_type, field) \
- struct_field_helper(0, s_type, field)
-
-#define struct_field_h(s_type, field) \
- struct_field_helper(1, s_type, field)
-
-#define struct_field_(str, s_type, field) \
- field_offset_(str, s_type, field); \
- field_type_(0,str, s_type, field); \
- struct_field_macro(str)
-
-#define def_size(str, size) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- printf(" , pc_SIZEOF_" str " :: Int\n"); \
- break; \
- case Gen_Haskell_Value: \
- printf(" , pc_SIZEOF_" str " = %" FMT_SizeT "\n", (size_t)size); \
- break; \
- case Gen_Haskell_Wrappers: \
- printf("sIZEOF_" str " :: DynFlags -> Int\n"); \
- printf("sIZEOF_" str " dflags = pc_SIZEOF_" str " (sPlatformConstants (settings dflags))\n"); \
- break; \
- case Gen_Haskell_Exports: \
- printf(" sIZEOF_" str ",\n"); \
- break; \
- case Gen_Header: \
- printf("#define SIZEOF_" str " %" FMT_SizeT "\n", (size_t)size); \
- break; \
- }
-
-#define def_closure_size(str, size) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define SIZEOF_" str " (SIZEOF_StgHeader+%" FMT_SizeT ")\n", (size_t)size); \
- break; \
- }
-
-#define struct_size(s_type) \
- def_size(#s_type, TYPE_SIZE(s_type));
-
-/*
- * Size of a closure type, minus the header, named SIZEOF_<type>_NoHdr
- * Also, we #define SIZEOF_<type> to be the size of the whole closure for .cmm.
- */
-#define closure_size(s_type) \
- def_size(#s_type "_NoHdr", TYPE_SIZE(s_type) - TYPE_SIZE(StgHeader)); \
- def_closure_size(#s_type, TYPE_SIZE(s_type) - TYPE_SIZE(StgHeader));
-
-#define thunk_size(s_type) \
- def_size(#s_type "_NoThunkHdr", TYPE_SIZE(s_type) - TYPE_SIZE(StgThunkHeader)); \
- closure_size(s_type)
-
-/* An access macro for use in C-- sources. */
-#define closure_field_macro(str) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define " str "(__ptr__) REP_" str "[__ptr__+SIZEOF_StgHeader+OFFSET_" str "]\n"); \
- break; \
- }
-
-#define closure_field_offset_(str, s_type,field) \
- def_offset(str, OFFSET(s_type,field) - TYPE_SIZE(StgHeader));
-
-#define closure_field_offset(s_type,field) \
- closure_field_offset_(str(s_type,field),s_type,field)
-
-#define closure_payload_macro(str) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define " str "(__ptr__,__ix__) W_[__ptr__+SIZEOF_StgHeader+OFFSET_" str " + WDS(__ix__)]\n"); \
- break; \
- }
-
-#define closure_payload(s_type,field) \
- closure_field_offset_(str(s_type,field),s_type,field); \
- closure_payload_macro(str(s_type,field));
-
-/* Byte offset and MachRep for a closure field, minus the header */
-#define closure_field_(str, s_type, field) \
- closure_field_offset_(str,s_type,field) \
- field_type_(0, str, s_type, field); \
- closure_field_macro(str)
-
-#define closure_field(s_type, field) \
- closure_field_(str(s_type,field),s_type,field)
-
-/* Byte offset and MachRep for a closure field, minus the header */
-#define closure_field_gcptr_(str, s_type, field) \
- closure_field_offset_(str,s_type,field) \
- field_type_gcptr_(str, s_type, field); \
- closure_field_macro(str)
-
-#define closure_field_gcptr(s_type, field) \
- closure_field_gcptr_(str(s_type,field),s_type,field)
-
-/* Byte offset for a TSO field, minus the header and variable prof bit. */
-#define tso_payload_offset(s_type, field) \
- def_offset(str(s_type,field), OFFSET(s_type,field) - TYPE_SIZE(StgHeader) - TYPE_SIZE(StgTSOProfInfo));
-
-/* Full byte offset for a TSO field, for use from Cmm */
-#define tso_field_offset_macro(str) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define TSO_OFFSET_" str " (SIZEOF_StgHeader+SIZEOF_OPT_StgTSOProfInfo+OFFSET_" str ")\n"); \
- break; \
- }
-
-#define tso_field_offset(s_type, field) \
- tso_payload_offset(s_type, field); \
- tso_field_offset_macro(str(s_type,field));
-
-#define tso_field_macro(str) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#define " str "(__ptr__) REP_" str "[__ptr__+TSO_OFFSET_" str "]\n") \
- break; \
- }
-
-#define tso_field(s_type, field) \
- field_type(0, s_type, field); \
- tso_field_offset(s_type,field); \
- tso_field_macro(str(s_type,field))
-
-#define opt_struct_size(s_type, option) \
- switch (mode) { \
- case Gen_Haskell_Type: \
- case Gen_Haskell_Value: \
- case Gen_Haskell_Wrappers: \
- case Gen_Haskell_Exports: \
- break; \
- case Gen_Header: \
- printf("#ifdef " #option "\n"); \
- printf("#define SIZEOF_OPT_" #s_type " SIZEOF_" #s_type "\n"); \
- printf("#else\n"); \
- printf("#define SIZEOF_OPT_" #s_type " 0\n"); \
- printf("#endif\n\n"); \
- break; \
- }
-
-#define FUN_OFFSET(sym) (OFFSET(Capability,f.sym) - OFFSET(Capability,r))
-
-void constantBool(char *haskellName, int val) {
- switch (mode) {
- case Gen_Haskell_Type:
- printf(" , pc_%s :: Bool\n", haskellName);
- break;
- case Gen_Haskell_Value:
- printf(" , pc_%s = %s\n", haskellName, val ? "True" : "False");
- break;
- case Gen_Haskell_Wrappers:
- printf("%s :: DynFlags -> Bool\n", haskellName);
- printf("%s dflags = pc_%s (sPlatformConstants (settings dflags))\n",
- haskellName, haskellName);
- break;
- case Gen_Haskell_Exports:
- printf(" %s,\n", haskellName);
- break;
- case Gen_Header:
- break;
- }
-}
-
-void constantIntegralC(char *haskellType, char *cName, char *haskellName,
- intptr_t val) {
- switch (mode) {
- case Gen_Haskell_Type:
- 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 -> %s\n", haskellName, haskellType);
- printf("%s dflags = pc_%s (sPlatformConstants (settings dflags))\n",
- haskellName, haskellName);
- break;
- case Gen_Haskell_Exports:
- printf(" %s,\n", haskellName);
- break;
- case Gen_Header:
- if (cName != NULL) {
- printf("#define %s %" PRIdPTR "\n", cName, val);
- }
- break;
- }
-}
-
-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);
-}
-
-void constantInteger(char *name, intptr_t val) {
- constantIntegralC("Integer", NULL, name, val);
-}
-
-int
-main(int argc, char *argv[])
-{
- if (argc == 1) {
- mode = Gen_Header;
- }
- else if (argc == 2) {
- if (0 == strcmp("--gen-haskell-type", argv[1])) {
- mode = Gen_Haskell_Type;
- }
- else if (0 == strcmp("--gen-haskell-value", argv[1])) {
- mode = Gen_Haskell_Value;
- }
- else if (0 == strcmp("--gen-haskell-wrappers", argv[1])) {
- mode = Gen_Haskell_Wrappers;
- }
- else if (0 == strcmp("--gen-haskell-exports", argv[1])) {
- mode = Gen_Haskell_Exports;
- }
- else {
- printf("Bad args\n");
- exit(1);
- }
- }
- else {
- printf("Bad args\n");
- exit(1);
- }
-
- switch (mode) {
- case Gen_Haskell_Type:
- printf("data PlatformConstants = PlatformConstants {\n");
- /* Now a kludge that allows the real entries to all start with a
- comma, which makes life a little easier */
- printf(" pc_platformConstants :: ()\n");
- break;
- case Gen_Haskell_Value:
- printf("PlatformConstants {\n");
- printf(" pc_platformConstants = ()\n");
- break;
- case Gen_Haskell_Wrappers:
- case Gen_Haskell_Exports:
- break;
- case Gen_Header:
- printf("/* This file is created automatically. Do not edit by hand.*/\n\n");
-
- break;
- }
-
- // Closure header sizes.
- constantIntC("STD_HDR_SIZE", "sTD_HDR_SIZE",
- sizeofW(StgHeader) - sizeofW(StgProfHeader));
- /* grrr.. PROFILING is on so we need to subtract sizeofW(StgProfHeader) */
- constantIntC("PROF_HDR_SIZE", "pROF_HDR_SIZE", sizeofW(StgProfHeader));
-
- // Size of a storage manager block (in bytes).
- constantIntC("BLOCK_SIZE", "bLOCK_SIZE", BLOCK_SIZE);
- if (mode == Gen_Header) {
- constantIntC("MBLOCK_SIZE", "mBLOCK_SIZE", MBLOCK_SIZE);
- }
- // blocks that fit in an MBlock, leaving space for the block descriptors
- constantIntC("BLOCKS_PER_MBLOCK", "bLOCKS_PER_MBLOCK", BLOCKS_PER_MBLOCK);
- // could be derived, but better to save doing the calculation twice
-
-
- field_offset(StgRegTable, rR1);
- field_offset(StgRegTable, rR2);
- field_offset(StgRegTable, rR3);
- field_offset(StgRegTable, rR4);
- field_offset(StgRegTable, rR5);
- field_offset(StgRegTable, rR6);
- field_offset(StgRegTable, rR7);
- field_offset(StgRegTable, rR8);
- field_offset(StgRegTable, rR9);
- field_offset(StgRegTable, rR10);
- field_offset(StgRegTable, rF1);
- field_offset(StgRegTable, rF2);
- field_offset(StgRegTable, rF3);
- field_offset(StgRegTable, rF4);
- field_offset(StgRegTable, rF5);
- field_offset(StgRegTable, rF6);
- field_offset(StgRegTable, rD1);
- field_offset(StgRegTable, rD2);
- field_offset(StgRegTable, rD3);
- field_offset(StgRegTable, rD4);
- field_offset(StgRegTable, rD5);
- field_offset(StgRegTable, rD6);
- field_offset(StgRegTable, rL1);
- field_offset(StgRegTable, rSp);
- field_offset(StgRegTable, rSpLim);
- field_offset(StgRegTable, rHp);
- field_offset(StgRegTable, rHpLim);
- field_offset(StgRegTable, rCCCS);
- field_offset(StgRegTable, rCurrentTSO);
- field_offset(StgRegTable, rCurrentNursery);
- field_offset(StgRegTable, rHpAlloc);
- if (mode == Gen_Header) {
- struct_field(StgRegTable, rRet);
- struct_field(StgRegTable, rNursery);
- }
-
- def_offset("stgEagerBlackholeInfo", FUN_OFFSET(stgEagerBlackholeInfo));
- def_offset("stgGCEnter1", FUN_OFFSET(stgGCEnter1));
- def_offset("stgGCFun", FUN_OFFSET(stgGCFun));
-
- field_offset(Capability, r);
- if (mode == Gen_Header) {
- field_offset(Capability, lock);
- struct_field(Capability, no);
- struct_field(Capability, mut_lists);
- struct_field(Capability, context_switch);
- struct_field(Capability, interrupt);
- struct_field(Capability, sparks);
- }
-
- struct_field(bdescr, start);
- struct_field(bdescr, free);
- struct_field(bdescr, blocks);
- if (mode == Gen_Header) {
- struct_field(bdescr, gen_no);
- struct_field(bdescr, link);
-
- struct_size(generation);
- struct_field(generation, n_new_large_words);
- }
-
- struct_size(CostCentreStack);
- if (mode == Gen_Header) {
- struct_field(CostCentreStack, ccsID);
- }
- struct_field_h(CostCentreStack, mem_alloc);
- struct_field_h(CostCentreStack, scc_count);
- if (mode == Gen_Header) {
- struct_field(CostCentreStack, prevStack);
-
- struct_field(CostCentre, ccID);
- struct_field(CostCentre, link);
-
- struct_field(StgHeader, info);
- }
- struct_field_("StgHeader_ccs", StgHeader, prof.ccs);
- struct_field_("StgHeader_ldvw", StgHeader, prof.hp.ldvw);
-
- struct_size(StgSMPThunkHeader);
-
- if (mode == Gen_Header) {
- closure_payload(StgClosure,payload);
- }
-
- struct_field_h(StgEntCounter, allocs);
- struct_field(StgEntCounter, registeredp);
- struct_field(StgEntCounter, link);
- struct_field(StgEntCounter, entry_count);
-
- closure_size(StgUpdateFrame);
- if (mode == Gen_Header) {
- closure_size(StgCatchFrame);
- closure_size(StgStopFrame);
- }
-
- closure_size(StgMutArrPtrs);
- closure_field(StgMutArrPtrs, ptrs);
- closure_field(StgMutArrPtrs, size);
-
- closure_size(StgArrWords);
- if (mode == Gen_Header) {
- closure_field(StgArrWords, bytes);
- closure_payload(StgArrWords, payload);
-
- closure_field(StgTSO, _link);
- closure_field(StgTSO, global_link);
- closure_field(StgTSO, what_next);
- closure_field(StgTSO, why_blocked);
- closure_field(StgTSO, block_info);
- closure_field(StgTSO, blocked_exceptions);
- closure_field(StgTSO, id);
- closure_field(StgTSO, cap);
- closure_field(StgTSO, saved_errno);
- closure_field(StgTSO, trec);
- closure_field(StgTSO, flags);
- closure_field(StgTSO, dirty);
- closure_field(StgTSO, bq);
- }
- closure_field_("StgTSO_cccs", StgTSO, prof.cccs);
- closure_field(StgTSO, stackobj);
-
- closure_field(StgStack, sp);
- closure_field_offset(StgStack, stack);
- if (mode == Gen_Header) {
- closure_field(StgStack, stack_size);
- closure_field(StgStack, dirty);
-
- struct_size(StgTSOProfInfo);
-
- opt_struct_size(StgTSOProfInfo,PROFILING);
- }
-
- closure_field(StgUpdateFrame, updatee);
-
- if (mode == Gen_Header) {
- closure_field(StgCatchFrame, handler);
- closure_field(StgCatchFrame, exceptions_blocked);
-
- closure_size(StgPAP);
- closure_field(StgPAP, n_args);
- closure_field_gcptr(StgPAP, fun);
- closure_field(StgPAP, arity);
- closure_payload(StgPAP, payload);
-
- thunk_size(StgAP);
- closure_field(StgAP, n_args);
- closure_field_gcptr(StgAP, fun);
- closure_payload(StgAP, payload);
-
- thunk_size(StgAP_STACK);
- closure_field(StgAP_STACK, size);
- closure_field_gcptr(StgAP_STACK, fun);
- closure_payload(StgAP_STACK, payload);
-
- thunk_size(StgSelector);
-
- closure_field_gcptr(StgInd, indirectee);
-
- closure_size(StgMutVar);
- closure_field(StgMutVar, var);
-
- closure_size(StgAtomicallyFrame);
- closure_field(StgAtomicallyFrame, code);
- closure_field(StgAtomicallyFrame, next_invariant_to_check);
- closure_field(StgAtomicallyFrame, result);
-
- closure_field(StgInvariantCheckQueue, invariant);
- closure_field(StgInvariantCheckQueue, my_execution);
- closure_field(StgInvariantCheckQueue, next_queue_entry);
-
- closure_field(StgAtomicInvariant, code);
-
- closure_field(StgTRecHeader, enclosing_trec);
-
- closure_size(StgCatchSTMFrame);
- closure_field(StgCatchSTMFrame, handler);
- closure_field(StgCatchSTMFrame, code);
-
- closure_size(StgCatchRetryFrame);
- closure_field(StgCatchRetryFrame, running_alt_code);
- closure_field(StgCatchRetryFrame, first_code);
- closure_field(StgCatchRetryFrame, alt_code);
-
- closure_field(StgTVarWatchQueue, closure);
- closure_field(StgTVarWatchQueue, next_queue_entry);
- closure_field(StgTVarWatchQueue, prev_queue_entry);
-
- closure_size(StgTVar);
- closure_field(StgTVar, current_value);
- closure_field(StgTVar, first_watch_queue_entry);
- closure_field(StgTVar, num_updates);
-
- closure_size(StgWeak);
- closure_field(StgWeak,link);
- closure_field(StgWeak,key);
- closure_field(StgWeak,value);
- closure_field(StgWeak,finalizer);
- closure_field(StgWeak,cfinalizer);
-
- closure_size(StgDeadWeak);
- closure_field(StgDeadWeak,link);
-
- closure_size(StgMVar);
- closure_field(StgMVar,head);
- closure_field(StgMVar,tail);
- closure_field(StgMVar,value);
-
- closure_size(StgMVarTSOQueue);
- closure_field(StgMVarTSOQueue, link);
- closure_field(StgMVarTSOQueue, tso);
-
- closure_size(StgBCO);
- closure_field(StgBCO, instrs);
- closure_field(StgBCO, literals);
- closure_field(StgBCO, ptrs);
- closure_field(StgBCO, arity);
- closure_field(StgBCO, size);
- closure_payload(StgBCO, bitmap);
-
- closure_size(StgStableName);
- closure_field(StgStableName,sn);
-
- closure_size(StgBlockingQueue);
- closure_field(StgBlockingQueue, bh);
- closure_field(StgBlockingQueue, owner);
- closure_field(StgBlockingQueue, queue);
- closure_field(StgBlockingQueue, link);
-
- closure_size(MessageBlackHole);
- closure_field(MessageBlackHole, link);
- closure_field(MessageBlackHole, tso);
- closure_field(MessageBlackHole, bh);
-
- struct_field_("RtsFlags_ProfFlags_showCCSOnException",
- RTS_FLAGS, ProfFlags.showCCSOnException);
- struct_field_("RtsFlags_DebugFlags_apply",
- RTS_FLAGS, DebugFlags.apply);
- struct_field_("RtsFlags_DebugFlags_sanity",
- RTS_FLAGS, DebugFlags.sanity);
- struct_field_("RtsFlags_DebugFlags_weak",
- RTS_FLAGS, DebugFlags.weak);
- struct_field_("RtsFlags_GcFlags_initialStkSize",
- RTS_FLAGS, GcFlags.initialStkSize);
- struct_field_("RtsFlags_MiscFlags_tickInterval",
- RTS_FLAGS, MiscFlags.tickInterval);
-
- struct_size(StgFunInfoExtraFwd);
- struct_field(StgFunInfoExtraFwd, slow_apply);
- struct_field(StgFunInfoExtraFwd, fun_type);
- struct_field(StgFunInfoExtraFwd, arity);
- struct_field_("StgFunInfoExtraFwd_bitmap", StgFunInfoExtraFwd, b.bitmap);
- }
-
- struct_size(StgFunInfoExtraRev);
- if (mode == Gen_Header) {
- struct_field(StgFunInfoExtraRev, slow_apply_offset);
- struct_field(StgFunInfoExtraRev, fun_type);
- struct_field(StgFunInfoExtraRev, arity);
- struct_field_("StgFunInfoExtraRev_bitmap", StgFunInfoExtraRev, b.bitmap);
-
- struct_field(StgLargeBitmap, size);
- field_offset(StgLargeBitmap, bitmap);
-
- struct_size(snEntry);
- struct_field(snEntry,sn_obj);
- struct_field(snEntry,addr);
- }
-
-#ifdef mingw32_HOST_OS
- /* Note that this conditional part only affects the C headers.
- That's important, as it means we get the same PlatformConstants
- type on all platforms. */
- if (mode == Gen_Header) {
- struct_size(StgAsyncIOResult);
- struct_field(StgAsyncIOResult, reqID);
- struct_field(StgAsyncIOResult, len);
- struct_field(StgAsyncIOResult, errCode);
- }
-#endif
-
- // pre-compiled thunk types
- constantInt("mAX_SPEC_SELECTEE_SIZE", MAX_SPEC_SELECTEE_SIZE);
- constantInt("mAX_SPEC_AP_SIZE", MAX_SPEC_AP_SIZE);
-
- // closure sizes: these do NOT include the header (see below for
- // header sizes)
- constantInt("mIN_PAYLOAD_SIZE", MIN_PAYLOAD_SIZE);
-
- constantInt("mIN_INTLIKE", MIN_INTLIKE);
- constantInt("mAX_INTLIKE", MAX_INTLIKE);
-
- constantInt("mIN_CHARLIKE", MIN_CHARLIKE);
- constantInt("mAX_CHARLIKE", MAX_CHARLIKE);
-
- constantInt("mUT_ARR_PTRS_CARD_BITS", MUT_ARR_PTRS_CARD_BITS);
-
- // A section of code-generator-related MAGIC CONSTANTS.
- constantInt("mAX_Vanilla_REG", MAX_VANILLA_REG);
- constantInt("mAX_Float_REG", MAX_FLOAT_REG);
- constantInt("mAX_Double_REG", MAX_DOUBLE_REG);
- constantInt("mAX_Long_REG", MAX_LONG_REG);
- constantInt("mAX_SSE_REG", MAX_SSE_REG);
- constantInt("mAX_Real_Vanilla_REG", MAX_REAL_VANILLA_REG);
- constantInt("mAX_Real_Float_REG", MAX_REAL_FLOAT_REG);
- constantInt("mAX_Real_Double_REG", MAX_REAL_DOUBLE_REG);
- constantInt("mAX_Real_SSE_REG", MAX_REAL_SSE_REG);
- constantInt("mAX_Real_Long_REG", MAX_REAL_LONG_REG);
-
- // This tells the native code generator the size of the spill
- // area is has available.
- constantInt("rESERVED_C_STACK_BYTES", RESERVED_C_STACK_BYTES);
- // The amount of (Haskell) stack to leave free for saving registers when
- // returning to the scheduler.
- constantInt("rESERVED_STACK_WORDS", RESERVED_STACK_WORDS);
- // Continuations that need more than this amount of stack should do their
- // own stack check (see bug #1466).
- constantInt("aP_STACK_SPLIM", AP_STACK_SPLIM);
-
- // Size of a word, in bytes
- constantInt("wORD_SIZE", SIZEOF_HSWORD);
-
- // Size of a double in StgWords.
- constantInt("dOUBLE_SIZE", SIZEOF_DOUBLE);
-
- // Size of a C int, in bytes. May be smaller than wORD_SIZE.
- constantInt("cINT_SIZE", SIZEOF_INT);
- constantInt("cLONG_SIZE", SIZEOF_LONG);
- constantInt("cLONG_LONG_SIZE", SIZEOF_LONG_LONG);
-
- // Number of bits to shift a bitfield left by in an info table.
- constantInt("bITMAP_BITS_SHIFT", BITMAP_BITS_SHIFT);
-
- // Amount of pointer bits used for semi-tagging constructor closures
- constantInt("tAG_BITS", TAG_BITS);
-
- constantBool("wORDS_BIGENDIAN",
-#ifdef WORDS_BIGENDIAN
- 1
-#else
- 0
-#endif
- );
-
- constantBool("dYNAMIC_BY_DEFAULT",
-#ifdef DYNAMIC_BY_DEFAULT
- 1
-#else
- 0
-#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\n");
- break;
- case Gen_Haskell_Value:
- printf(" }\n");
- break;
- case Gen_Haskell_Wrappers:
- case Gen_Haskell_Exports:
- case Gen_Header:
- break;
- }
-
- return 0;
-}
diff --git a/includes/mkDerivedConstants.cross.awk b/includes/mkDerivedConstants.cross.awk
deleted file mode 100644
index c66655e922..0000000000
--- a/includes/mkDerivedConstants.cross.awk
+++ /dev/null
@@ -1,350 +0,0 @@
-## This script rewrites normal C structs into successively
-## greater ones so that field offset computation becomes a
-## sizeof lookup and thus amenable to compile-time computations.
-
-## Usage: pipe stg/Regs.h into 'awk' running this script
-## to obtain a .c file that can be compiled to .o
-## with the gcc from the cross toolchain. Then
-## use another 'awk' script to process the 'nm'
-## output of the object file.
-
-## Motivation: since in general we can not run executables
-## created by the cross toolchain, we need another
-## way of finding out field offsets and type sizes
-## of the target platform.
-
-BEGIN {
- interesting = 0
- seed = 0
- print "/* this file is generated by mkDerivedConstants.cross.awk, do not touch */"
- print "/* needs to be compiled with the target gcc */"
- print ""
- print "#include \"Rts.h\""
- print "#include \"Capability.h\""
- print ""
- ## these do not have a proper typedef; supply them here
- print "#define FLAG_STRUCT_TYPE(IT) typedef struct IT ## _FLAGS IT ## _FLAGS"
- print "FLAG_STRUCT_TYPE(GC);"
- print "FLAG_STRUCT_TYPE(DEBUG);"
- print "FLAG_STRUCT_TYPE(COST_CENTRE);"
- print "FLAG_STRUCT_TYPE(PROFILING);"
- print "FLAG_STRUCT_TYPE(TRACE);"
- print "FLAG_STRUCT_TYPE(CONCURRENT);"
- print "FLAG_STRUCT_TYPE(MISC);"
- print "FLAG_STRUCT_TYPE(PAR);"
- print "FLAG_STRUCT_TYPE(TICKY);"
- ## these we do know how to get the field size,
- ## so do not bother mining it
- print "#define DO_NOT_MINE_UNION_MEMBER(STRUCT, NESTED_MEMBER, ID) char nestedfieldsize$ ## STRUCT ## $ ## ID [sizeof ((STRUCT*)0)->NESTED_MEMBER]"
- print "DO_NOT_MINE_UNION_MEMBER(StgHeader, prof.hp.ldvw, prof_hp_ldvw);"
- print "DO_NOT_MINE_UNION_MEMBER(StgFunInfoExtraFwd, b.bitmap, b_bitmap);"
- print "DO_NOT_MINE_UNION_MEMBER(StgFunInfoExtraRev, b.bitmap, b_bitmap);"
-}
-
-## pass through embedded unions
-eat_union && /^[ \t]*}[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t]*;[ \t]*$/ {
- sub(/^[ \t]*}[ \t]*/, "")
- sub(/[ \t]*;[ \t]*$/, "")
- new_offset_struct_name = struct_name $0
- print ""
-
- eat_union = 0
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " $0 ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " $0 ") ? 1 : -1];"
- }
-
- offset_struct_name = new_offset_struct_name
- next
-}
-
-eat_union {
- next
-}
-
-/# [0-9]* "rts\// {
- ours = 1
- next
-}
-
-/# [0-9]* "includes\// {
- ours = 1
- next
-}
-
-## filter out non-ghc headers
-/# [0-9]* "/ {
- ours = 0
- next
-}
-
-!ours {
- next
-}
-
-!interesting {
- struct_name = "$" seed "$"
- offset_struct_name = ""
- known_struct_name = ""
- eat_union = 0
- assumptions = ""
-}
-
-## kill empty line
-/^[ \t]*$/ {
- next
-}
-
-/^# [0-9]/ {
- print
- next
-}
-
-/^typedef struct[ \t][ \t]*[_0-9a-zA-Z]*[ \t]*{[ \t]*$/ {
- if (interesting) error "previous struct not closed?"
- interesting = 1
- print ""
- print "/* ### Creating offset structs for " $3 " ### */"
- next
-}
-
-/^struct[ \t][ \t]*[_0-9a-zA-Z]*[ \t]*{[ \t]*$/ {
- if (interesting) error "previous struct not closed?"
- interesting = 1
- known_struct_name = $2
- sub(/_$/, "", known_struct_name);
- print ""
- print "/* ### Creating offset structs for " known_struct_name " ### */"
- print "char associate$" known_struct_name "$" seed ";"
- next
-}
-
-## end of struct
-##
-interesting && /^[ \t]*}[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t]*;[ \t]*$/{
- sub(/;$/, "", $2)
-
- print "char associate$" $2 "$" seed ";"
- print "char SIZEOF$" seed "[sizeof(" $2 ")];"
- print ""
- print ""
- gsub(/\^\^\^/, $2, assumptions);
- print assumptions
- ++seed
- interesting = 0
- next
-}
-
-## Ptr-typedef
-interesting && /^[ \t]*}[ \t]*\*[_0-9a-zA-Z][_0-9a-zA-Z]*Ptr[ \t]*;[ \t]*$/{
- sub(/Ptr;$/, "", $2)
- sub(/^\*/, "", $2)
-
- print "char associate$" $2 "$" seed ";"
- print "char SIZEOF$" seed "[sizeof(" $2 ")];"
- print ""
- print ""
- gsub(/\^\^\^/, $2, assumptions);
- print assumptions
- ++seed
- interesting = 0
- next
-}
-
-interesting && /^[ \t]*}[; \t]*$/ {
- print "char SIZEOF$" seed "[sizeof(" known_struct_name ")];"
- print ""
- print ""
- gsub(/\^\^\^/, known_struct_name, assumptions);
- print assumptions
- ++seed
- interesting = 0
-}
-
-# collapse whitespace after '*'
-interesting {
- # normalize some types
- sub(/struct StgClosure_[ \t]*\*/, "StgClosure *")
- gsub(/\*[ \t]*volatile/, "*")
- # group stars together
- gsub(/\*[ \t]*/, "*")
- sub(/\*/, " *")
- print "// " $0
- # remove volatile
- sub(/[ \t]volatile[ \t]/, " ")
- # remove const
- sub(/[ \t]const[ \t]/, " ")
-}
-
-## (pointer to struct) member of struct
-##
-interesting && /^[ \t]*struct[ \t][ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t]*\*[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t]*;[ \t]*$/ {
- if (!$4) {
- sub(/^\*/, "", $3)
- $4 = $3
- }
- sub(/;$/, "", $4)
-
- new_offset_struct_name = struct_name $4
- print ""
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " $4 ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " $4 ") ? 1 : -1];"
- }
- print "char fieldsize" new_offset_struct_name "[sizeof(struct " $2 "*)];"
- print ""
- print ""
- offset_struct_name = new_offset_struct_name
- next
-}
-
-## (simple pointer) member of struct
-##
-interesting && /^[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*\*\**[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t]*;[ \t]*$/ {
- sub(/;$/, "", $2)
- sub(/^\**/, "", $2)
-
- new_offset_struct_name = struct_name $2
- print ""
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " $2 ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " $2 ") ? 1 : -1];"
- }
- print "char fieldsize" new_offset_struct_name "[sizeof(" $1 "*)];"
- print ""
- print ""
- offset_struct_name = new_offset_struct_name
- next
-}
-
-## member of struct
-##
-interesting && /^[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*;[ \t]*$/ {
- sub(/;$/, "", $2)
-
- new_offset_struct_name = struct_name $2
- print ""
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " $2 ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " $2 ") ? 1 : -1];"
- }
- print "char fieldsize" new_offset_struct_name "[sizeof(" $1 ")];"
- print ""
- print ""
- offset_struct_name = new_offset_struct_name
- next
-}
-
-## struct member of struct
-##
-interesting && /^[ \t]*struct[ \t][ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*;[ \t]*$/ {
- sub(/;$/, "", $3)
-
- new_offset_struct_name = struct_name $3
- print ""
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " $3 ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " $3 ") ? 1 : -1];"
- }
- print "char fieldsize" new_offset_struct_name "[sizeof(struct " $2 ")];"
- print ""
- print ""
- offset_struct_name = new_offset_struct_name
- next
-}
-
-## embedded union
-interesting && /^[ \t]*union[ \t]*{[ \t]*$/ {
- eat_union = 1
- next
-}
-
-## array member
-interesting && /^[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*\**[_0-9a-zA-Z][_0-9a-zA-Z]*\[.*\];[ \t]*$/ {
- sub(/;[ \t]*$/, "", $0)
-
- full = $0
- sub(/^[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*/, "", full)
- split(full, parts, "[")
- mname = parts[1]
- sub(/^\**/, "", mname)
-
- new_offset_struct_name = struct_name mname
- print ""
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " mname ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " mname ") ? 1 : -1];"
- }
-
- print ""
- print ""
- offset_struct_name = new_offset_struct_name
- next
-}
-
-
-## padded member of struct
-## of this form: StgHalfInt slow_apply_offset; StgHalfWord __pad_slow_apply_offset;;
-##
-interesting && /^[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*;[ \t]*[_0-9a-zA-Z][_0-9a-zA-Z]*[ \t][ \t]*__pad_[a-zA-Z][_0-9a-zA-Z]*;;*[ \t]*$/ {
- mname = $2
- sub(/;$/, "", mname)
-
- new_offset_struct_name = struct_name mname
- print ""
-
- if (!offset_struct_name)
- {
- print "char starting" new_offset_struct_name "[2];"
- }
- else
- {
- assumptions = assumptions "\n" "char sizeof" new_offset_struct_name "[offsetof(^^^, " mname ")];"
- assumptions = assumptions "\n" "typedef char verify_size" new_offset_struct_name "[sizeof sizeof" new_offset_struct_name " == offsetof(^^^, " mname ") ? 1 : -1];"
- }
- print ""
- print ""
- offset_struct_name = new_offset_struct_name
- next
-}
-
-interesting && /;[ \t]*$/ {
- print "Member not recognized: " $0 > "/dev/stderr"
- exit 1
-} \ No newline at end of file
diff --git a/includes/mkSizeMacros.cross.awk b/includes/mkSizeMacros.cross.awk
deleted file mode 100644
index e33e4ff4e5..0000000000
--- a/includes/mkSizeMacros.cross.awk
+++ /dev/null
@@ -1,82 +0,0 @@
-BEGIN {
- print "#define OFFSET(s_type, field) OFFSET_ ## s_type ## _ ## field"
- print "#define FIELD_SIZE(s_type, field) FIELD_SIZE_ ## s_type ## _ ## field"
- print "#define TYPE_SIZE(type) TYPE_SIZE_ ## type"
- print ""
-}
-
-/^0[0-9a-zA-Z]* C _*associate\$/ {
- sub(/_*associate\$/, "", $3)
- split($3, arr, "$")
- assoc[arr[2]] = arr[1]
- next
-}
-
-/^00*2 C _*starting\$[0-9]*\$[_0-9a-zA-Z]*$/ {
- sub(/_*starting\$/, "", $3)
- split($3, arr, "$")
- sub(/^0*/, "", $1)
- print "#define OFFSET_" assoc[arr[1]] "_" arr[2] " 0x0"
- next
-}
-
-/^0[0-9a-zA-Z]* C _*sizeof\$[0-9]*\$[_0-9a-zA-Z]*$/ {
- sub(/_*sizeof\$/, "", $3)
- split($3, arr, "$")
- sub(/^0*/, "", $1)
- print "#define OFFSET_" assoc[arr[1]] "_" arr[2] " 0x" $1
- next
-}
-
-/^0[0-9a-zA-Z]* C _*fieldsize\$[0-9]*\$[_0-9a-zA-Z]*$/ {
- sub(/_*fieldsize\$/, "", $3)
- split($3, arr, "$")
- sub(/^0*/, "", $1)
- print "#define FIELD_SIZE_" assoc[arr[1]] "_" arr[2] " 0x" $1 "UL"
- next
-}
-
-/^0[0-9a-zA-Z]* C _*nestedfieldsize\$[_0-9a-zA-Z]*\$[_0-9a-zA-Z]*$/ {
- sub(/_*nestedfieldsize\$/, "", $3)
- split($3, arr, "$")
- sub(/^0*/, "", $1)
- print "#define FIELD_SIZE_" arr[1] "_" arr[2] " 0x" $1 "UL"
- next
-}
-
-/^0[0-9a-zA-Z]* C _*SIZEOF\$[0-9]*$/ {
- sub(/_*SIZEOF\$/, "", $3)
- sub(/^0*/, "", $1)
- print "#define TYPE_SIZE_" assoc[$3] " 0x" $1
- next
-}
-
-{ print "// " $0 }
-
-END {
- ## some indirect offsets
- print "#define OFFSET_StgHeader_prof_ccs (OFFSET_StgHeader_prof + OFFSET_StgProfHeader_ccs)"
- print "#define OFFSET_StgHeader_prof_hp_ldvw (OFFSET_StgHeader_prof + OFFSET_StgProfHeader_hp + 0)"
- print "#define OFFSET_StgTSO_prof_cccs (OFFSET_StgTSO_prof + OFFSET_StgTSOProfInfo_cccs)"
- print "#define OFFSET_RTS_FLAGS_ProfFlags_showCCSOnException (OFFSET_RTS_FLAGS_ProfFlags + OFFSET_PROFILING_FLAGS_showCCSOnException)"
-
-
- print "#define OFFSET_RTS_FLAGS_DebugFlags_apply (OFFSET_RTS_FLAGS_DebugFlags + OFFSET_DEBUG_FLAGS_apply)"
- print "#define OFFSET_RTS_FLAGS_DebugFlags_sanity (OFFSET_RTS_FLAGS_DebugFlags + OFFSET_DEBUG_FLAGS_sanity)"
- print "#define OFFSET_RTS_FLAGS_DebugFlags_weak (OFFSET_RTS_FLAGS_DebugFlags + OFFSET_DEBUG_FLAGS_weak)"
- print "#define OFFSET_RTS_FLAGS_GcFlags_initialStkSize (OFFSET_RTS_FLAGS_GcFlags + OFFSET_GC_FLAGS_initialStkSize)"
- print "#define OFFSET_RTS_FLAGS_MiscFlags_tickInterval (OFFSET_RTS_FLAGS_MiscFlags + OFFSET_MISC_FLAGS_tickInterval)"
-
- print "#define OFFSET_StgFunInfoExtraFwd_b_bitmap (OFFSET_StgFunInfoExtraFwd_b + 0)"
- print "#define OFFSET_StgFunInfoExtraRev_b_bitmap (OFFSET_StgFunInfoExtraRev_b + 0)"
-
- ## some indirect field sizes
- print "#define FIELD_SIZE_StgHeader_prof_ccs FIELD_SIZE_StgProfHeader_ccs"
- print "#define FIELD_SIZE_StgTSO_prof_cccs FIELD_SIZE_StgTSOProfInfo_cccs"
- print "#define FIELD_SIZE_RTS_FLAGS_ProfFlags_showCCSOnException FIELD_SIZE_PROFILING_FLAGS_showCCSOnException"
- print "#define FIELD_SIZE_RTS_FLAGS_DebugFlags_apply FIELD_SIZE_DEBUG_FLAGS_apply"
- print "#define FIELD_SIZE_RTS_FLAGS_DebugFlags_sanity FIELD_SIZE_DEBUG_FLAGS_sanity"
- print "#define FIELD_SIZE_RTS_FLAGS_DebugFlags_weak FIELD_SIZE_DEBUG_FLAGS_weak"
- print "#define FIELD_SIZE_RTS_FLAGS_GcFlags_initialStkSize FIELD_SIZE_GC_FLAGS_initialStkSize"
- print "#define FIELD_SIZE_RTS_FLAGS_MiscFlags_tickInterval FIELD_SIZE_MISC_FLAGS_tickInterval"
-}