Ion C
C library for Ion
Loading...
Searching...
No Matches
ion_platform_config.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at:
7 *
8 * http://aws.amazon.com/apache2.0/
9 *
10 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
12 * language governing permissions and limitations under the License.
13 */
14
17//
18// Ion internal header for platform configurations
19//
20
21#ifndef ION_PLATFORM_CONFIG_H_
22#define ION_PLATFORM_CONFIG_H_
23
24// OS Macros
25
26#ifdef _WIN32
27#define ION_PLATFORM_WINDOWS
28#endif
29
30#ifdef __CYGWIN__
31#define ION_PLATFORM_CYGWIN
32#endif
33
34#ifdef __ANDROID__
35#define ION_PLATFORM_ANDROID
36#endif
37
38// Ion Public API Export
39// NB - for gcc/clang -fvisibility=hidden should be used, otherwise, all symbols are exported
40#if (defined(ION_PLATFORM_WINDOWS) || defined(ION_PLATFORM_CYGWIN)) && defined(_WINDLL)
41#define ION_API_EXPORT __declspec(dllexport)
42#elif __GNUC__ >= 4
43#define ION_API_EXPORT __attribute__ ((visibility("default")))
44#else
45#define ION_API_EXPORT
46#endif
47
48// Support for thread local storage across compilers
49#if __STDC_VERSION__ >= 201112L
50#define THREAD_LOCAL_STORAGE _Thread_local
51#elif __GNUC__
52#define THREAD_LOCAL_STORAGE __thread
53#elif defined(_MSC_VER)
54#define THREAD_LOCAL_STORAGE __declspec(thread)
55#else
56#error "Compiler does not support thread local storage"
57#endif
58
59// Support for type alignment specification (`alignas`) across compilers
60#if __STDC_VERSION__ >= 201112L
61#define ALIGN_AS(size) _Alignas(size)
62#elif __GNUC__
63#define ALIGN_AS(size) __attribute__((__aligned__(size)))
64#elif defined(_MSC_VER)
65#define ALIGN_AS(size) __declspec(align(size))
66#else
67#error "Compiler does not support type alignment specification"
68#endif
69
70#endif