Ruby: include/ruby/internal/dllexport.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

dllexport.h
Go to the documentation of this file.
1#ifndef RBIMPL_DLLEXPORT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_DLLEXPORT_H
23#include "ruby/internal/config.h"
24#include "ruby/internal/compiler_is.h"
25
26/* For MinGW, we need __declspec(dllimport) for RUBY_EXTERN on MJIT.
27 mswin's RUBY_EXTERN already has that. See also: win32/Makefile.sub */
28#undef RUBY_EXTERN
29#if defined(MJIT_HEADER) && defined(_WIN32)
30# define RUBY_EXTERN extern __declspec(dllimport)
31#elif defined(RUBY_EXPORT)
32# define RUBY_EXTERN extern
33#elif defined(_WIN32)
34# define RUBY_EXTERN extern __declspec(dllimport)
35#else
36# define RUBY_EXTERN extern
37#endif
38
39#ifndef RUBY_SYMBOL_EXPORT_BEGIN
40# define RUBY_SYMBOL_EXPORT_BEGIN /* begin */
41#endif
42
43#ifndef RUBY_SYMBOL_EXPORT_END
44# define RUBY_SYMBOL_EXPORT_END /* end */
45#endif
46
47#ifndef RUBY_FUNC_EXPORTED
48# define RUBY_FUNC_EXPORTED /* void */
49#endif
50
51/* These macros are used for functions which are exported only for MJIT
52 and NOT ensured to be exported in future versions. */
53
54#if ! defined(MJIT_HEADER)
55# define MJIT_FUNC_EXPORTED RUBY_FUNC_EXPORTED
56#elif ! RBIMPL_COMPILER_IS(MSVC)
57# define MJIT_FUNC_EXPORTED RUBY_FUNC_EXPORTED
58#else
59# define MJIT_FUNC_EXPORTED static
60#endif
61
62#define MJIT_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN
63#define MJIT_SYMBOL_EXPORT_END RUBY_SYMBOL_EXPORT_END
64
65/* On mswin, MJIT header transformation can't be used since cl.exe can't output
66 preprocessed output preserving macros. So this `MJIT_STATIC` is needed
67 to force non-static function to static on MJIT header to avoid symbol conflict. */
68#ifdef MJIT_HEADER
69# define MJIT_STATIC static
70#else
71# define MJIT_STATIC
72#endif
73
76#if defined(__DOXYGEN__)
77# define RBIMPL_SYMBOL_EXPORT_BEGIN() /* void */
78#elif defined(__cplusplus)
79# define RBIMPL_SYMBOL_EXPORT_BEGIN() RUBY_SYMBOL_EXPORT_BEGIN extern "C" {
80#else
81# define RBIMPL_SYMBOL_EXPORT_BEGIN() RUBY_SYMBOL_EXPORT_BEGIN
82#endif
83
85#if defined(__DOXYGEN__)
86# define RBIMPL_SYMBOL_EXPORT_END() /* void */
87#elif defined(__cplusplus)
88# define RBIMPL_SYMBOL_EXPORT_END() } RUBY_SYMBOL_EXPORT_END
89#else
90# define RBIMPL_SYMBOL_EXPORT_END() RUBY_SYMBOL_EXPORT_END
91#endif
92#endif /* RBIMPL_DLLEXPORT_H */
compiler_is.h
Defines RBIMPL_COMPILER_IS.
config.h
Thin wrapper to ruby/config.h.