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