Mercurial > hg > forks > bilotrip-mj12
comparison src/platform.h @ 45:d85542c96791
Clean up the build some more, move platform specifics again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 06 Aug 2013 00:23:45 +0300 |
parents | 785057719d9b |
children |
comparison
equal
deleted
inserted
replaced
44:f0073a47c31d | 45:d85542c96791 |
---|---|
1 /* ============================================================================ | 1 #ifndef MPLATFORM_H |
2 * Freetype GL - A C OpenGL Freetype engine | 2 #define MPLATFORM_H 1 |
3 * Platform: Any | |
4 * WWW: http://code.google.com/p/freetype-gl/ | |
5 * ---------------------------------------------------------------------------- | |
6 * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved. | |
7 * | |
8 * Redistribution and use in source and binary forms, with or without | |
9 * modification, are permitted provided that the following conditions are met: | |
10 * | |
11 * 1. Redistributions of source code must retain the above copyright notice, | |
12 * this list of conditions and the following disclaimer. | |
13 * | |
14 * 2. Redistributions in binary form must reproduce the above copyright | |
15 * notice, this list of conditions and the following disclaimer in the | |
16 * documentation and/or other materials provided with the distribution. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR | |
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
21 * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 * | |
29 * The views and conclusions contained in the software and documentation are | |
30 * those of the authors and should not be interpreted as representing official | |
31 * policies, either expressed or implied, of Nicolas P. Rougier. | |
32 * ============================================================================ | |
33 */ | |
34 #ifndef __PLATFORM_H__ | |
35 #define __PLATFORM_H__ | |
36 | 3 |
37 #include <stdlib.h> | 4 #include <stdlib.h> |
5 #ifndef __APPLE__ | |
6 #include <malloc.h> | |
7 #endif | |
38 | 8 |
39 //------------------------------------------------- | 9 |
40 // stdint.h is not available on VS2008 or lower | 10 /* Some platform specifics |
41 //------------------------------------------------- | 11 */ |
42 #ifdef _MSC_VER | 12 #if defined(_WIN32) || defined(_WIN64) |
43 typedef __int32 int32_t; | 13 # define wcpncpy wcsncpy |
44 typedef unsigned __int32 uint32_t; | 14 # define wcpcpy wcscpy |
45 typedef __int64 int64_t; | 15 #endif |
46 typedef unsigned __int64 uint64_t; | 16 |
17 | |
18 /* Sized integer types | |
19 */ | |
20 #ifdef _WIN32 | |
21 #include <wtypes.h> | |
22 typedef unsigned __int8 Uint8; | |
23 typedef unsigned __int16 Uint16; | |
24 typedef unsigned __int32 Uint32; | |
25 typedef unsigned __int64 Uint64; | |
26 | |
27 typedef unsigned __int8 int8_t; | |
28 typedef unsigned __int16 int16_t; | |
29 typedef unsigned __int32 int32_t; | |
30 typedef unsigned __int64 int64_t; | |
47 #else | 31 #else |
48 #include <stdint.h> | 32 #include <stdint.h> |
49 #endif // _MSC_VER | 33 typedef uint8_t Uint8; |
34 typedef uint16_t Uint16; | |
35 typedef uint32_t Uint32; | |
36 typedef uint64_t Uint64; | |
37 #endif | |
38 | |
39 | |
40 /* Define a boolean type | |
41 */ | |
42 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) | |
43 typedef enum { FALSE = 0, TRUE = 1 } BOOL; | |
44 #endif | |
45 | |
46 #ifndef BOOL | |
47 # ifdef bool | |
48 # define BOOL bool | |
49 # else | |
50 # define BOOL int | |
51 # endif | |
52 #endif | |
53 | |
54 | |
55 /* Endianess swapping macros | |
56 */ | |
57 #define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ | |
58 (Uint16) ((Uint16) (value) >> 8) | \ | |
59 (Uint16) ((Uint16) (value) << 8)) ) | |
60 | |
61 | |
62 #define DM_SWAP_32_LE_BE(value) ((Uint32) ( \ | |
63 (((Uint32) (value) & (Uint32) 0x000000ffU) << 24) | \ | |
64 (((Uint32) (value) & (Uint32) 0x0000ff00U) << 8) | \ | |
65 (((Uint32) (value) & (Uint32) 0x00ff0000U) >> 8) | \ | |
66 (((Uint32) (value) & (Uint32) 0xff000000U) >> 24))) | |
67 | |
68 | |
69 /* Macros that swap only when needed ... | |
70 */ | |
71 #if (BYTEORDER == BIG_ENDIAN) | |
72 # define DM_LE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) | |
73 # define DM_LE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
74 # define DM_NATIVE_TO_LE16(value) DM_SWAP_16_LE_BE(value) | |
75 # define DM_NATIVE_TO_LE32(value) DM_SWAP_32_LE_BE(value) | |
76 | |
77 # define DM_BE16_TO_NATIVE(value) ((Uint16) (value)) | |
78 # define DM_BE32_TO_NATIVE(value) ((Uint32) (value)) | |
79 # define DM_NATIVE_TO_BE16(value) ((Uint16) (value)) | |
80 # define DM_NATIVE_TO_BE32(value) ((Uint32) (value)) | |
81 | |
82 #elif (BYTEORDER == LIL_ENDIAN) | |
83 | |
84 # define DM_LE16_TO_NATIVE(value) ((Uint16) (value)) | |
85 # define DM_LE32_TO_NATIVE(value) ((Uint32) (value)) | |
86 # define DM_NATIVE_TO_LE16(value) ((Uint16) (value)) | |
87 # define DM_NATIVE_TO_LE32(value) ((Uint32) (value)) | |
88 | |
89 # define DM_BE16_TO_NATIVE(value) DM_SWAP_16_LE_BE(value) | |
90 # define DM_BE32_TO_NATIVE(value) DM_SWAP_32_LE_BE(value) | |
91 # define DM_NATIVE_TO_BE16(value) DM_SWAP_16_LE_BE(value) | |
92 # define DM_NATIVE_TO_BE32(value) DM_SWAP_32_LE_BE(value) | |
93 | |
94 #endif | |
95 | |
50 | 96 |
51 #ifdef __cplusplus | 97 #ifdef __cplusplus |
52 extern "C" { | 98 extern "C" { |
53 #endif | 99 #endif |
54 | 100 |
55 #ifdef __APPLE__ | 101 #if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64) |
56 /* strndup() was only added in OSX lion */ | 102 char * strndup(const char *s, size_t n); |
57 char * strndup( const char *s1, size_t n); | 103 # pragma warning (disable: 4244) |
58 #elif defined(_WIN32) || defined(_WIN64) | 104 #endif |
59 /* does not exist on windows */ | 105 |
60 char * strndup( const char *s1, size_t n); | 106 #if defined(_WIN32) || defined(_WIN64) |
61 // double round (float v); | 107 double round(float v); |
62 # pragma warning (disable: 4244) // suspend warnings | 108 #endif |
63 #endif // _WIN32 || _WIN64 | |
64 | 109 |
65 #ifdef __cplusplus | 110 #ifdef __cplusplus |
66 } | 111 } |
67 #endif // __cplusplus | 112 #endif // __cplusplus |
68 | 113 |
69 #endif /* __PLATFORM_H__ */ | 114 |
115 #endif // MPLATFORM_H |