Merge branch 'master' of win:c:/ghc/git/cygwin/.
[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://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef __STGDLL_H__
15 #define __STGDLL_H__ 1
16
17 #if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
18 # define DLL_IMPORT_DATA_REF(x) (_imp__##x)
19 # define DLL_IMPORT_DATA_VARNAME(x) *_imp__##x
20 # if __GNUC__ && !defined(__declspec)
21 # define DLLIMPORT
22 # else
23 # define DLLIMPORT __declspec(dllimport)
24 # define DLLIMPORT_DATA(x) _imp__##x
25 # endif
26 #else
27 # define DLL_IMPORT_DATA_REF(x) (&(x))
28 # define DLL_IMPORT_DATA_VARNAME(x) x
29 # define DLLIMPORT
30 #endif
31
32 /* The view of the ghc/includes/ header files differ ever so
33 slightly depending on whether the RTS is being compiled
34 or not - so we're forced to distinguish between two.
35 [oh, you want details :) : Data symbols defined by the RTS
36 have to be accessed through an extra level of indirection
37 when compiling generated .hc code compared to when the RTS
38 sources are being processed. This is only the case when
39 using Win32 DLLs. ]
40 */
41 #ifdef COMPILING_RTS
42 #define DLL_IMPORT DLLIMPORT
43 #define DLL_IMPORT_RTS
44 #define DLL_IMPORT_DATA_VAR(x) x
45 #else
46 #define DLL_IMPORT
47 #define DLL_IMPORT_RTS DLLIMPORT
48 # if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
49 # define DLL_IMPORT_DATA_VAR(x) _imp__##x
50 # else
51 # define DLL_IMPORT_DATA_VAR(x) x
52 # endif
53 #endif
54
55
56 #ifdef COMPILING_STDLIB
57 #define DLL_IMPORT_STDLIB
58 #else
59 #define DLL_IMPORT_STDLIB DLLIMPORT
60 #endif
61
62 #endif /* __STGDLL_H__ */