Main Page
Namespaces
Classes
Files
File List
File Members
Gosu
Platform.hpp
Go to the documentation of this file.
1
2
3
4
#ifndef GOSU_PLATFORM_HPP
5
#define GOSU_PLATFORM_HPP
6
7
#ifdef __BIG_ENDIAN__
8
# define GOSU_IS_BIG_ENDIAN
9
# define IDENTITY_FUN bigToNative
10
# define IDENTITY_FUN2 nativeToBig
11
# define CONV_FUN littleToNative
12
# define CONV_FUN2 nativeToLittle
13
#else
14
# define GOSU_IS_LITTLE_ENDIAN
15
# define IDENTITY_FUN littleToNative
16
# define IDENTITY_FUN2 nativeToLittle
17
# define CONV_FUN bigToNative
18
# define CONV_FUN2 nativeToBig
19
#endif
20
21
#include <algorithm>
22
23
namespace
Gosu
24
{
25
template
<
typename
T> T IDENTITY_FUN(T t) {
return
t; }
26
template
<
typename
T> T IDENTITY_FUN2(T t) {
return
t; }
27
28
template
<
typename
T>
29
T CONV_FUN(T t)
30
{
31
char
* begin =
reinterpret_cast<
char
*
>
(&t);
32
std::reverse(begin, begin +
sizeof
t);
33
return
t;
34
}
35
36
template
<
typename
T> T CONV_FUN2(T t) {
return
CONV_FUN(t); }
37
}
38
39
#undef IDENTITY_FUN
40
#undef IDENTITY_FUN2
41
#undef CONV_FUN
42
#undef CONV_FUN2
43
44
#if defined(_MSC_VER)
45
# define GOSU_NORETURN __declspec(noreturn)
46
#elif defined(__GNUC__)
47
# define GOSU_NORETURN __attribute__ ((noreturn))
48
#endif
49
50
#if defined(WIN32)
51
# define GOSU_IS_WIN
52
#else
53
# define GOSU_IS_UNIX
54
# if defined(__linux) || defined(__FreeBSD__)
55
# define GOSU_IS_X
56
# else
57
# define GOSU_IS_MAC
58
# include <TargetConditionals.h>
59
# if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
60
# define GOSU_IS_IPHONE
61
# endif
62
# endif
63
#endif
64
65
#if defined(GOSU_IS_WIN)
66
# define GOSU_DEPRECATED __declspec(deprecated)
67
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
68
# define GOSU_DEPRECATED __attribute__((__deprecated__))
69
#else
70
# define GOSU_DEPRECATED
71
#endif
72
73
#endif