Imported Upstream version 1.46.0
[platform/upstream/nghttp2.git] / third-party / mruby / include / mruby / common.h
1 /**
2 ** @file common.h - mruby common platform definition"
3 **
4 ** See Copyright Notice in mruby.h
5 */
6
7 #ifndef MRUBY_COMMON_H
8 #define MRUBY_COMMON_H
9
10 #ifdef __APPLE__
11   #ifndef __TARGETCONDITIONALS__
12   #include "TargetConditionals.h"
13   #endif
14 #endif
15
16 #ifdef __cplusplus
17 #ifdef MRB_ENABLE_CXX_ABI
18 #define MRB_BEGIN_DECL
19 #define MRB_END_DECL
20 #else
21 # define MRB_BEGIN_DECL extern "C" {
22 # define MRB_END_DECL }
23 #endif
24 #else
25 /** Start declarations in C mode */
26 # define MRB_BEGIN_DECL
27 /** End declarations in C mode */
28 # define MRB_END_DECL
29 #endif
30
31 /**
32  * Shared compiler macros
33  */
34 MRB_BEGIN_DECL
35
36 /** Declare a function that never returns. */
37 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
38 # define mrb_noreturn _Noreturn
39 #elif defined __GNUC__ && !defined __STRICT_ANSI__
40 # define mrb_noreturn __attribute__((noreturn))
41 #elif defined _MSC_VER
42 # define mrb_noreturn __declspec(noreturn)
43 #else
44 # define mrb_noreturn
45 #endif
46
47 /** Mark a function as deprecated. */
48 #if defined __GNUC__ && !defined __STRICT_ANSI__
49 # define mrb_deprecated __attribute__((deprecated))
50 #elif defined _MSC_VER
51 # define mrb_deprecated __declspec(deprecated)
52 #else
53 # define mrb_deprecated
54 #endif
55
56 /** Declare a function as always inlined. */
57 #if defined _MSC_VER && _MSC_VER < 1900
58 # ifndef __cplusplus
59 #  define inline __inline
60 # endif
61 #endif
62 #define MRB_INLINE static inline
63
64 /** Declare a public MRuby API function. */
65 #ifndef MRB_API
66 #if defined(MRB_BUILD_AS_DLL)
67 #if defined(MRB_CORE) || defined(MRB_LIB)
68 # define MRB_API __declspec(dllexport)
69 #else
70 # define MRB_API __declspec(dllimport)
71 #endif
72 #else
73 # define MRB_API extern
74 #endif
75 #endif
76
77 /** Declare mingw versions */
78 #if defined(__MINGW32__) || defined(__MINGW64__)
79 # include <_mingw.h>
80 # if defined(__MINGW64_VERSION_MAJOR)
81 #  define MRB_MINGW64_VERSION  (__MINGW64_VERSION_MAJOR * 1000 + __MINGW64_VERSION_MINOR)
82 # elif defined(__MINGW32_MAJOR_VERSION)
83 #  define MRB_MINGW32_VERSION  (__MINGW32_MAJOR_VERSION * 1000 + __MINGW32_MINOR_VERSION)
84 # endif
85 #endif
86
87 MRB_END_DECL
88
89 #endif  /* MRUBY_COMMON_H */