Debian Codegraph @

vendor/mruby-include/mruby/common.h

raw
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_USE_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 #include <sys/types.h>
32 #if defined _MSC_VER
33 #include <BaseTsd.h>
34 typedef SSIZE_T ssize_t;
35 #endif
36
37 /**
38 * Shared compiler macros
39 */
40 MRB_BEGIN_DECL
41
42 /** Declare a function that never returns. */
43 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
44 # define mrb_noreturn _Noreturn
45 #elif defined __GNUC__ && !defined __STRICT_ANSI__
46 # define mrb_noreturn __attribute__((noreturn))
47 #elif defined _MSC_VER
48 # define mrb_noreturn __declspec(noreturn)
49 #else
50 # define mrb_noreturn
51 #endif
52
53 /** Mark a function as deprecated. */
54 #if defined __GNUC__ && !defined __STRICT_ANSI__
55 # define mrb_deprecated __attribute__((deprecated))
56 #elif defined _MSC_VER
57 # define mrb_deprecated __declspec(deprecated)
58 #else
59 # define mrb_deprecated
60 #endif
61
62 /** Declare a function as always inlined. */
63 #if defined _MSC_VER && _MSC_VER < 1900
64 # ifndef __cplusplus
65 # define inline __inline
66 # endif
67 #endif
68 #define MRB_INLINE static inline
69
70 /** Declare a public mruby API function. */
71 #ifndef MRB_API
72 #if defined(MRB_BUILD_AS_DLL)
73 #if defined(MRB_CORE) || defined(MRB_LIB)
74 # define MRB_API __declspec(dllexport)
75 #else
76 # define MRB_API __declspec(dllimport)
77 #endif
78 #else
79 # define MRB_API extern
80 #endif
81 #endif
82
83 /** Declare mingw versions */
84 #if defined(__MINGW32__) || defined(__MINGW64__)
85 # include <_mingw.h>
86 # if defined(__MINGW64_VERSION_MAJOR)
87 # define MRB_MINGW64_VERSION (__MINGW64_VERSION_MAJOR * 1000 + __MINGW64_VERSION_MINOR)
88 # elif defined(__MINGW32_MAJOR_VERSION)
89 # define MRB_MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 1000 + __MINGW32_MINOR_VERSION)
90 # endif
91 # if defined(__MINGW32__) && !defined(__MINGW64__)
92 # define MRB_MINGW32_LEGACY
93 # endif
94 #endif
95
96 MRB_END_DECL
97
98 #endif /* MRUBY_COMMON_H */