| 17 | | The top-level interface to the RTS ({{{rts_evalIO()}}}, etc.) |
| 18 | | [http://darcs.haskell.org/ghc/includes/SchedAPI.h SchedAPI.h]:: |
| 19 | | External API to the RTS scheduler |
| 20 | | [http://darcs.haskell.org/ghc/includes/RtsFlags.h RtsFlags.h]:: |
| 21 | | External API to the RTS runtime flags |
| 22 | | [http://darcs.haskell.org/ghc/includes/Linker.h Linker.h]:: |
| 23 | | External API to the linker |
| | 19 | The API for calling into the RTS. Used by the implementation |
| | 20 | of `foreign export` calls, but may also be used by external |
| | 21 | clients. |
| | 22 | |
| | 23 | [http://darcs.haskell.org/ghc/includes/Rts.h Rts.h]:: |
| | 24 | This header file defines everything that is visible |
| | 25 | externally to the RTS. It includes `Stg.h` and everything |
| | 26 | in the `rts` subdirectory. |
| | 27 | |
| | 28 | == Derived Constants == |
| | 29 | |
| | 30 | The canonical definition of certain structures are in C header files. |
| | 31 | For example, the layout of closures and info tables are defined in the |
| | 32 | headers [http://darcs.haskell.org/ghc/includes/rts/storage/Closures.h |
| | 33 | Closures.h] and |
| | 34 | [http://darcs.haskell.org/ghc/includes/rts/storage/InfoTables.h |
| | 35 | InfoTables.h] respectivesly. How do we get the information about the |
| | 36 | layout of these structures to the parts of the system that are not |
| | 37 | written in C, such as the compiler itself, or the C-- code in the RTS? |
| | 38 | |
| | 39 | Our solution is the C program |
| | 40 | [http://darcs.haskell.org/ghc/includes/mkDerivedConstants.c mkDerivedConstants.c]. |
| | 41 | It `#includes` the C header files containing the structure |
| | 42 | definitions, and emits a new C header file containing only `#define`s |
| | 43 | that give the byte offsets of important fields in those structures. |
| | 44 | The program generates the following files: |
| | 45 | |
| | 46 | * `DerivedConstants.h` |
| | 47 | * `GHCConstants.h` |
| | 48 | |
| | 49 | Take a look at those files in a build tree to see exactly what is |
| | 50 | generated. |
| 43 | | Sizes of various basic types. |
| 44 | | [http://darcs.haskell.org/ghc/includes/StgTypes.h StgTypes.h]:: |
| 45 | | Basic types specific to the virtual machine (eg. {{{StgWord}}}). |
| 46 | | [http://darcs.haskell.org/ghc/includes/TailCalls.h TailCalls.h]:: |
| 47 | | Tail calls in {{{.hc}}} code. |
| 48 | | [http://darcs.haskell.org/ghc/includes/StgDLL.h StgDLL.h]:: |
| | 71 | Sizes of various basic types (should be in the `stg` subdirectory, |
| | 72 | but left here for backwards-compatibility reasons). |
| | 73 | [http://darcs.haskell.org/ghc/includes/stg/DLL.h stg/DLL.h]:: |
| 54 | | [http://darcs.haskell.org/ghc/includes/StgProf.h StgProf.h]:: |
| 55 | | Profiling gubbins. |
| 56 | | [http://darcs.haskell.org/ghc/includes/StgMiscClosures.h StgMiscClosures.h]:: |
| 57 | | Declarations for closures & info tables built-in to the RTS |
| 58 | | [http://darcs.haskell.org/ghc/includes/RtsExternal.h RtsExternal.h]:: |
| 59 | | Declarations for RTS things referred to by {{{.hc}}} code. (NOTE: |
| 60 | | also includes {{{RtsAPI.h}}} and {{{HsFFI.h}}}. |
| | 81 | [http://darcs.haskell.org/ghc/includes/stg/SMP.h stg/SMP.h]:: |
| | 82 | Atomic memory operations for SMP support |
| | 83 | [http://darcs.haskell.org/ghc/includes/stg/TailCalls.h stg/TailCalls.h]:: |
| | 84 | Tail calls in `.hc` code. |
| | 85 | [http://darcs.haskell.org/ghc/includes/stg/Ticky.h stg/Ticky.h]:: |
| | 86 | Declarations for ticky-ticky counters |
| | 87 | [http://darcs.haskell.org/ghc/includes/stg/Types.h stg/Types.h]:: |
| | 88 | Basic types specific to the virtual machine (eg. `StgWord`). |
| 73 | | [http://darcs.haskell.org/ghc/includes/Rts.h Rts.h]:: |
| 74 | | [http://darcs.haskell.org/ghc/includes/RtsTypes.h RtsTypes.h]:: |
| 75 | | Types used in the RTS |
| 76 | | [http://darcs.haskell.org/ghc/includes/Constants.h Constants.h]:: |
| 77 | | Build-time constants |
| 78 | | [http://darcs.haskell.org/ghc/includes/StgLdvProf.h StgLdvProf.h]:: |
| 79 | | [http://darcs.haskell.org/ghc/includes/StgFun.h StgFun.h]:: |
| 80 | | [http://darcs.haskell.org/ghc/includes/Closures.h Closures.h]:: |
| 81 | | The layout of closures. |
| 82 | | [http://darcs.haskell.org/ghc/includes/Liveness.h Liveness.h]:: |
| 83 | | macros for constructing RET_DYN liveness masks |
| 84 | | [http://darcs.haskell.org/ghc/includes/ClosureMacros.h ClosureMacros.h]:: |
| 85 | | [http://darcs.haskell.org/ghc/includes/ClosureTypes.h ClosureTypes.h]:: |
| 86 | | [http://darcs.haskell.org/ghc/includes/InfoTables.h InfoTables.h]:: |
| 87 | | The layout of info tables. |
| 88 | | [http://darcs.haskell.org/ghc/includes/TSO.h TSO.h]:: |
| 89 | | The structure of Thread State Objects. |
| 90 | | [http://darcs.haskell.org/ghc/includes/Updates.h Updates.h]:: |
| 91 | | Macros for performing updates. |
| 92 | | [http://darcs.haskell.org/ghc/includes/GranSim.h GranSim.h]:: |
| 93 | | [http://darcs.haskell.org/ghc/includes/Parallel.h Parallel.h]:: |
| 94 | | [http://darcs.haskell.org/ghc/includes/SMP.h SMP.h]:: |
| 95 | | Macros for multiprocessor support, eg. {{{cas()}}}. |
| 96 | | [http://darcs.haskell.org/ghc/includes/Block.h Block.h]:: |
| 97 | | The block allocator, block descriptors, {{{Bdescr()}}}. |
| 98 | | [http://darcs.haskell.org/ghc/includes/StgTicky.h StgTicky.h]:: |
| 99 | | Ticky-ticky profiling. |
| 100 | | [http://darcs.haskell.org/ghc/includes/Stable.h Stable.h]:: |
| 101 | | Stable pointers, stable names. |
| 102 | | [http://darcs.haskell.org/ghc/includes/Hooks.h Hooks.h]:: |
| 103 | | Hooks for changing RTS behaviour. |
| 104 | | [http://darcs.haskell.org/ghc/includes/Signals.h Signals.h]:: |
| 105 | | The API for using Signals from Haskell. |
| 106 | | [http://darcs.haskell.org/ghc/includes/DNInvoke.h DNInvoke.h]:: |
| 107 | | .NET stuff (bitrotted). |
| | 99 | * [http://darcs.haskell.org/ghc/includes/rts includes/rts]: Most of |
| | 100 | the external RTS APIs, in separate header files per-subsystem |
| 109 | | == Included into C-- code == |
| | 102 | * [http://darcs.haskell.org/ghc/includes/rts/storage includes/rts/storage]: Definitions of the layout of heap and stack |
| | 103 | objects, info tables, structures that define memory areas managed |
| | 104 | by the GC, and memory management APIs. |
| | 105 | |
| | 106 | * [http://darcs.haskell.org/ghc/includes/rts/prof includes/rts/prof]: |
| | 107 | Interfaces and definitions for profiling. |
| | 108 | |
| | 109 | == Included into C-- (`.cmm`) code == |
| 112 | | included into .cmm source only |
| 113 | | !DerivedConstants.h:: |
| 114 | | generated by [[GhcFile(includes/mkDerivedConstants.c)]] from other .h files, see |
| 115 | | [wiki:Commentary/Compiler/CodeGen#Storagemanagerrepresentations]. |
| 116 | | [http://darcs.haskell.org/ghc/includes/Block.h Block.h]:: |
| 117 | | also included into `.cmm` code. |
| 118 | | |
| 119 | | == Included into various non-C source code == |
| 120 | | |
| 121 | | Some of these header files are {{{#included}}} into Haskell code or |
| 122 | | C-- ({{{.cmm}}}) code, so that we can have one place for defining constants and |
| 123 | | configuration settings. Files in this category therefore must contain |
| 124 | | {{{#defines}}} only, no C code or declarations. |
| 125 | | |
| 126 | | The following headers are in this category: |
| 127 | | |
| 128 | | [http://darcs.haskell.org/ghc/includes/config.h config.h]:: |
| 129 | | [http://darcs.haskell.org/ghc/includes/RtsConfig.h RtsConfig.h]:: |
| 130 | | [http://darcs.haskell.org/ghc/includes/Constants.h Constants.h]:: |
| 131 | | !DerivedConstants.h:: |
| 132 | | [http://darcs.haskell.org/ghc/includes/ClosureTypes.h ClosureTypes.h]:: |
| 133 | | [http://darcs.haskell.org/ghc/includes/StgFun.h StgFun.h]:: |
| 134 | | [http://darcs.haskell.org/ghc/includes/MachRegs.h MachRegs.h]:: |
| 135 | | [http://darcs.haskell.org/ghc/includes/Liveness.h Liveness.h]:: |
| 136 | | [http://darcs.haskell.org/ghc/includes/StgLdvProf.h StgLdvProf.h]:: |
| 137 | | |
| 138 | | |
| 139 | | == Miscellaneous == |
| 140 | | |
| 141 | | [http://darcs.haskell.org/ghc/includes/Bytecodes.h Bytecodes.h]:: |
| 142 | | Bytecode definitions for the interpreter |
| 143 | | [http://darcs.haskell.org/ghc/includes/ieee-flpt.h ieee-flpt.h]:: |
| 144 | | !ToDo: needed? |
| | 112 | included into `.cmm` source only; provides useful macros for writing |
| | 113 | low-level C-- code for GHC. |