Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#ifndef CRITERION_COMMON_H_
25#define CRITERION_COMMON_H_
26
27#if defined (_MSC_VER)
28# if _MSC_VER < 1900
29# error \
30 Your version of MSVC++ is too old, please compile your tests using \
31 a c99 compiler, like MinGW or MSVC 14.0+ (Included in visual studio \
32 2015)
33# endif
34#endif
35
36#ifndef CR_IS_MSVC
37# ifdef _MSC_VER
38# define CR_IS_MSVC _MSC_VER
39# else
40# define CR_IS_MSVC 0
41# endif
42#endif
43
44#ifdef __cplusplus
45# ifdef __GNUC__
46# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
47# else
48# define CR_ATTRIBUTE(Arg) [[gnu::Arg]]
49# endif
50# define CR_BEGIN_C_API extern "C" {
51# define CR_END_C_API }
52#else
53# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
54# define CR_BEGIN_C_API
55# define CR_END_C_API
56#endif
57
58#ifdef __APPLE__
59# define CR_SECTION_START_SUFFIX(Name) __asm("section$start$__DATA$" Name)
60# define CR_SECTION_END_SUFFIX(Name) __asm("section$end$__DATA$" Name)
61# define CR_SECTION_(Name) CR_ATTRIBUTE(section("__DATA," Name))
62# define CR_SECTION_SUFFIX_
63#elif CR_IS_MSVC
64# define CR_SECTION_START_SUFFIX(Name)
65# define CR_SECTION_END_SUFFIX(Name)
66# define CR_SECTION_(Name) \
67 __pragma(data_seg(push)) \
68 __pragma(section(Name, read)) \
69 __declspec(allocate(Name))
70# define CR_SECTION_SUFFIX_ \
71 __pragma(data_seg(pop))
72#else
73# define CR_SECTION_START_SUFFIX(Name)
74# define CR_SECTION_END_SUFFIX(Name)
75# define CR_SECTION_(Name) CR_ATTRIBUTE(section(Name))
76# define CR_SECTION_SUFFIX_
77#endif
78
79#define CR_MAKE_IDENTIFIER_(Prefix, Id) CR_MAKE_IDENTIFIER__(Prefix, Id)
80#define CR_MAKE_IDENTIFIER__(Prefix, Id) Prefix ## _ ## Id
81
82#ifdef __GNUC__
83# define CR_UNUSED CR_ATTRIBUTE(unused)
84# define CR_NORETURN CR_ATTRIBUTE(noreturn)
85# define CR_INLINE CR_ATTRIBUTE(always_inline) inline
86#elif CR_IS_MSVC
87# define CR_UNUSED __pragma(warning(suppress: 4100))
88# define CR_NORETURN __declspec(noreturn)
89# define CR_INLINE __forceinline
90#else
91# define CR_UNUSED
92# define CR_NORETURN
93# define CR_INLINE inline
94#endif
95
96#if defined(_MSC_VER) && _MSC_VER < 1900
97# define CRI_PRIuSIZE "Iu"
98#else
99# define CRI_PRIuSIZE "zu"
100#endif
101
102#ifdef __GNUC__
103# define CR_FORMAT(Archetype, Index, Ftc) CR_ATTRIBUTE(format(Archetype, Index, Ftc))
104#else
105# define CR_FORMAT(Archetype, Index, Ftc)
106#endif
107
108#if defined _WIN32 || defined __CYGWIN__
109# ifdef CRITERION_BUILDING_DLL
110# ifdef __GNUC__
111# define CR_API CR_ATTRIBUTE(dllexport)
112# else
113# define CR_API __declspec(dllexport)
114# endif
115# else
116# ifdef __GNUC__
117# define CR_API CR_ATTRIBUTE(dllimport)
118# else
119# define CR_API __declspec(dllimport)
120# endif
121# endif
122# define CR_LOCAL
123#else
124# if __GNUC__ >= 4
125# define CR_API CR_ATTRIBUTE(visibility("default"))
126# define CR_LOCAL CR_ATTRIBUTE(visibility("hidden"))
127# else
128# define CR_API
129# define CR_LOCAL
130# endif
131#endif
132
133#ifdef __cplusplus
134# define CR_STDN std::
135#else
136# define CR_STDN
137#endif
138
139#endif /* !CRITERION_COMMON_H_ */