cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / includes / rts / Linker.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2009
4 *
5 * RTS Object Linker
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #pragma once
15
16 #if defined(mingw32_HOST_OS)
17 typedef wchar_t pathchar;
18 #define PATH_FMT "ls"
19 #else
20 typedef char pathchar;
21 #define PATH_FMT "s"
22 #endif
23
24 /* Initialize the object linker. Equivalent to initLinker_(1). */
25 void initLinker (void);
26
27 /* Initialize the object linker.
28 * The retain_cafs argument is:
29 *
30 * non-zero => Retain CAFs unconditionally in linked Haskell code.
31 * Note that this prevents any code from being unloaded.
32 * It should not be necessary unless you are GHCi or
33 * hs-plugins, which needs to be able call any function
34 * in the compiled code.
35 *
36 * zero => Do not retain CAFs. Everything reachable from foreign
37 * exports will be retained, due to the StablePtrs
38 * created by the module initialisation code. unloadObj
39 * frees these StablePtrs, which will allow the CAFs to
40 * be GC'd and the code to be removed.
41 */
42 void initLinker_ (int retain_cafs);
43
44 /* insert a symbol in the hash table */
45 HsInt insertSymbol(pathchar* obj_name, char* key, void* data);
46
47 /* lookup a symbol in the hash table */
48 void *lookupSymbol( char *lbl );
49
50 /* delete an object from the pool */
51 HsInt unloadObj( pathchar *path );
52
53 /* purge an object's symbols from the symbol table, but don't unload it */
54 HsInt purgeObj( pathchar *path );
55
56 /* add an obj (populate the global symbol table, but don't resolve yet) */
57 HsInt loadObj( pathchar *path );
58
59 /* add an arch (populate the global symbol table, but don't resolve yet) */
60 HsInt loadArchive( pathchar *path );
61
62 /* resolve all the currently unlinked objects in memory */
63 HsInt resolveObjs( void );
64
65 /* load a dynamic library */
66 const char *addDLL( pathchar* dll_name );
67
68 /* add a path to the library search path */
69 HsPtr addLibrarySearchPath(pathchar* dll_path);
70
71 /* removes a directory from the search path,
72 path must have been added using addLibrarySearchPath */
73 HsBool removeLibrarySearchPath(HsPtr dll_path_index);
74
75 /* give a warning about missing Windows patches that would make
76 the linker work better */
77 void warnMissingKBLibraryPaths( void );
78
79 /* -----------------------------------------------------------------------------
80 * Searches the system directories to determine if there is a system DLL that
81 * satisfies the given name. This prevent GHCi from linking against a static
82 * library if a DLL is available.
83 */
84 pathchar* findSystemLibrary(pathchar* dll_name);
85
86 /* called by the initialization code for a module, not a user API */
87 StgStablePtr foreignExportStablePtr (StgPtr p);