1 | /* graphene-macros.h: Public macros |
2 | * |
3 | * SPDX-License-Identifier: MIT |
4 | * |
5 | * Copyright 2014 Emmanuele Bassi |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * of this software and associated documentation files (the "Software"), to deal |
9 | * in the Software without restriction, including without limitation the rights |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | * copies of the Software, and to permit persons to whom the Software is |
12 | * furnished to do so, subject to the following conditions: |
13 | * |
14 | * The above copyright notice and this permission notice shall be included in |
15 | * all copies or substantial portions of the Software. |
16 | * |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | * THE SOFTWARE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #if !defined(GRAPHENE_H_INSIDE) && !defined(GRAPHENE_COMPILATION) |
29 | #error "Only graphene.h can be included directly." |
30 | #endif |
31 | |
32 | #ifndef _GRAPHENE_PUBLIC |
33 | #define _GRAPHENE_PUBLIC extern |
34 | #endif |
35 | |
36 | #ifdef GRAPHENE_COMPILATION |
37 | # define GRAPHENE_PRIVATE_FIELD(type,name) type name |
38 | #else |
39 | # define GRAPHENE_PRIVATE_FIELD(type,name) type __graphene_private_##name |
40 | #endif |
41 | |
42 | #if defined(__GNUC__) |
43 | # define GRAPHENE_ALIGN16 __attribute__((aligned(16))) |
44 | # define GRAPHENE_ALIGNED_DECL(x,val) x __attribute__((aligned(val))) |
45 | #elif defined(_MSC_VER) |
46 | # define GRAPHENE_ALIGN16 __declspec(align(16)) |
47 | # define GRAPHENE_ALIGNED_DECL(x,val) __declspec(align(val)) x |
48 | #else |
49 | # define GRAPHENE_ALIGN16 |
50 | # define GRAPHENE_ALIGNED_DECL(x,val) x |
51 | #endif |
52 | |
53 | #if defined(_MSC_VER) && (_MSC_VER >= 1910) |
54 | # ifdef _M_IX86 |
55 | /* Use __vectorcall to enable SSE intrinsics on 32-bit builds on MSVC 2013 and later */ |
56 | # define GRAPHENE_VECTORCALL __vectorcall |
57 | # else |
58 | # define GRAPHENE_VECTORCALL |
59 | # endif |
60 | #else |
61 | # define GRAPHENE_VECTORCALL |
62 | #endif |
63 | |
64 | #ifdef _MSC_VER |
65 | # if !defined (__cplusplus) && defined (_MSC_VER) && (_MSC_VER < 1900) |
66 | # define inline __inline |
67 | # endif |
68 | #endif |
69 | |
70 | #ifdef __cplusplus |
71 | # define GRAPHENE_BEGIN_DECLS extern "C" { |
72 | # define GRAPHENE_END_DECLS } |
73 | #else |
74 | # define GRAPHENE_BEGIN_DECLS |
75 | # define GRAPHENE_END_DECLS |
76 | #endif |
77 | |
78 | #if defined(_MSC_VER) && !defined(__bool_true_false_are_defined) && (_MSC_VER < 1800) |
79 | # ifndef __GI_SCANNER__ |
80 | typedef int bool; |
81 | # define false 0 |
82 | # define true 1 |
83 | # endif |
84 | #else |
85 | # include <stdbool.h> |
86 | #endif |
87 | |
88 | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) |
89 | #define _GRAPHENE_DEPRECATED __attribute__((__deprecated__)) |
90 | #elif defined(_MSC_VER) && (_MSC_VER >= 1300) |
91 | #define _GRAPHENE_DEPRECATED __declspec(deprecated) |
92 | #else |
93 | #define _GRAPHENE_DEPRECATED |
94 | #endif |
95 | |
96 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) |
97 | #define _GRAPHENE_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) |
98 | #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) |
99 | #define _GRAPHENE_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) |
100 | #else |
101 | #define _GRAPHENE_DEPRECATED_FOR(f) _GRAPHENE_DEPRECATED |
102 | #endif |
103 | |
104 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) |
105 | #define _GRAPHENE_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min))) |
106 | #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) |
107 | #define _GRAPHENE_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min)) |
108 | #else |
109 | #define _GRAPHENE_UNAVAILABLE(maj,min) _GRAPHENE_DEPRECATED |
110 | #endif |
111 | |
112 | #define GRAPHENE_PI 3.1415926535897932384626434f |
113 | #define GRAPHENE_PI_2 1.5707963267948966192313217f |
114 | |