cf857a8682889790d9cb7eeb70efe94e8cab56ed
[ghc.git] / includes / stg / DLL.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2009
4 *
5 * Support for Windows DLLs.
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(COMPILING_WINDOWS_DLL)
17 # if defined(x86_64_HOST_ARCH)
18 # define DLL_IMPORT_DATA_REF(x) (__imp_##x)
19 # define DLL_IMPORT_DATA_VARNAME(x) *__imp_##x
20 # else
21 # define DLL_IMPORT_DATA_REF(x) (_imp__##x)
22 # define DLL_IMPORT_DATA_VARNAME(x) *_imp__##x
23 # endif
24 # if __GNUC__ && !defined(__declspec)
25 # define DLLIMPORT
26 # else
27 # define DLLIMPORT __declspec(dllimport)
28 # if defined(x86_64_HOST_ARCH)
29 # define DLLIMPORT_DATA(x) __imp_##x
30 # else
31 # define DLLIMPORT_DATA(x) _imp__##x
32 # endif
33 # endif
34 #else
35 # define DLL_IMPORT_DATA_REF(x) (&(x))
36 # define DLL_IMPORT_DATA_VARNAME(x) x
37 # define DLLIMPORT
38 #endif
39
40 /* The view of the ghc/includes/ header files differ ever so
41 slightly depending on whether the RTS is being compiled
42 or not - so we're forced to distinguish between two.
43 [oh, you want details :) : Data symbols defined by the RTS
44 have to be accessed through an extra level of indirection
45 when compiling generated .hc code compared to when the RTS
46 sources are being processed. This is only the case when
47 using Win32 DLLs. ]
48 */
49 #ifdef COMPILING_RTS
50 #define DLL_IMPORT DLLIMPORT
51 #define DLL_IMPORT_RTS
52 #define DLL_IMPORT_DATA_VAR(x) x
53 #else
54 #define DLL_IMPORT
55 #define DLL_IMPORT_RTS DLLIMPORT
56 # if defined(COMPILING_WINDOWS_DLL)
57 # if defined(x86_64_HOST_ARCH)
58 # define DLL_IMPORT_DATA_VAR(x) __imp_##x
59 # else
60 # define DLL_IMPORT_DATA_VAR(x) _imp__##x
61 # endif
62 # else
63 # define DLL_IMPORT_DATA_VAR(x) x
64 # endif
65 #endif
66
67
68 #ifdef COMPILING_STDLIB
69 #define DLL_IMPORT_STDLIB
70 #else
71 #define DLL_IMPORT_STDLIB DLLIMPORT
72 #endif