... | ... | @@ -41,20 +41,11 @@ layout of these structures to the parts of the system that are not |
|
|
written in C, such as the compiler itself, or the C-- code in the RTS?
|
|
|
|
|
|
|
|
|
Our solution is the C program
|
|
|
[ mkDerivedConstants.c](http://darcs.haskell.org/ghc/includes/mkDerivedConstants.c).
|
|
|
It `#includes` the C header files containing the structure
|
|
|
definitions, and emits a new C header file containing only `#define`s
|
|
|
that give the byte offsets of important fields in those structures.
|
|
|
The program generates the following files:
|
|
|
Our solution is the Haskell program in utils/deriveConstants/DeriveConstants.hs.
|
|
|
It determines the sizes and fields offsets from the C header files by invoking the C compiler for the target platform, and then looking at the resulting object file (we can't *run* the code generated by the target C compiler, because this is the host platform).
|
|
|
|
|
|
- `DerivedConstants.h`
|
|
|
- `GHCConstants.h`
|
|
|
|
|
|
|
|
|
Take a look at those files in a build tree to see exactly what is
|
|
|
generated. These new headers can then be `#included` into Haskell
|
|
|
code or C-- code.
|
|
|
The DeriveConstants program generates a few header files, notably `includes/dist-derivedconstants/header/DerivedConstants.h`, which contains C `#define`s for each of the derived constants; this file is used by C-- code in the RTS. It also generates a few files of Haskell code which are included into GHC itself, in the `DynFlags` module.
|
|
|
|
|
|
## Used when compiling via C
|
|
|
|
... | ... | @@ -105,10 +96,6 @@ Declarations for closures & info tables built-in to the RTS |
|
|
<td>
|
|
|
Atomic memory operations for SMP support
|
|
|
</td></tr>
|
|
|
<tr><th>[ stg/TailCalls.h](http://darcs.haskell.org/ghc/includes/stg/TailCalls.h)</th>
|
|
|
<td>
|
|
|
Tail calls in `.hc` code.
|
|
|
</td></tr>
|
|
|
<tr><th>[ stg/Ticky.h](http://darcs.haskell.org/ghc/includes/stg/Ticky.h)</th>
|
|
|
<td>
|
|
|
Declarations for ticky-ticky counters
|
... | ... | |