summaryrefslogtreecommitdiff
path: root/include/gras/gras.hpp
blob: bbeffbae1dd110f71a05f3c3754d9157b3d4fefb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Copyright 2012 Josh Blum
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef INCLUDED_GRAS_GRAS_HPP
#define INCLUDED_GRAS_GRAS_HPP

#include <ciso646>

// http://gcc.gnu.org/wiki/Visibility
// Generic helper definitions for shared library support
#if defined _WIN32 || defined __CYGWIN__
  #define GRAS_HELPER_DLL_IMPORT __declspec(dllimport)
  #define GRAS_HELPER_DLL_EXPORT __declspec(dllexport)
  #define GRAS_HELPER_DLL_LOCAL
#else
  #if __GNUC__ >= 4
    #define GRAS_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
    #define GRAS_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
    #define GRAS_HELPER_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
  #else
    #define GRAS_HELPER_DLL_IMPORT
    #define GRAS_HELPER_DLL_EXPORT
    #define GRAS_HELPER_DLL_LOCAL
  #endif
#endif

// Now we use the generic helper definitions above to define GRAS_API and GRAS_LOCAL.
// GRAS_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build)
// GRAS_LOCAL is used for non-api symbols.

#ifdef GRAS_DLL // defined if GRAS is compiled as a DLL
  #ifdef GRAS_DLL_EXPORTS // defined if we are building the GRAS DLL (instead of using it)
    #define GRAS_API GRAS_HELPER_DLL_EXPORT
  #else
    #define GRAS_API GRAS_HELPER_DLL_IMPORT
  #endif // GRAS_DLL_EXPORTS
  #define GRAS_LOCAL GRAS_HELPER_DLL_LOCAL
#else // GRAS_DLL is not defined: this means GRAS is a static lib.
  #define GRAS_API
  #define GRAS_LOCAL
#endif // GRAS_DLL

#define GRAS_MAX_ALIGNMENT 32

//define cross platform attribute macros
#if defined(GRAS_DEBUG)
    #define GRAS_FORCE_INLINE         inline
#elif defined(BOOST_MSVC)
    #define GRAS_FORCE_INLINE         __forceinline
#elif defined(__GNUG__) && __GNUG__ >= 4
    #define GRAS_FORCE_INLINE         inline __attribute__((always_inline))
#else
    #define GRAS_FORCE_INLINE         inline
#endif

#endif /*INCLUDED_GRAS_GRAS_HPP*/