summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ShizZy2013-09-15 22:18:16 -0400
committerGravatar ShizZy2013-09-15 22:18:16 -0400
commit71d4fa9d3fb60bc4b0fa1b51e8f6fb2a28ed5e49 (patch)
tree0be0ae198df33c2ee0cbbd0b8dee76caa41b836b
parentrenamed project to 'citrus' (diff)
downloadyuzu-71d4fa9d3fb60bc4b0fa1b51e8f6fb2a28ed5e49.tar.gz
yuzu-71d4fa9d3fb60bc4b0fa1b51e8f6fb2a28ed5e49.tar.xz
yuzu-71d4fa9d3fb60bc4b0fa1b51e8f6fb2a28ed5e49.zip
added file platform.h
-rw-r--r--src/common/common.vcxproj1
-rw-r--r--src/common/common.vcxproj.filters1
-rw-r--r--src/common/src/common.h1
-rw-r--r--src/common/src/platform.h134
4 files changed, 137 insertions, 0 deletions
diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj
index 1e149d32b..48a7d5afa 100644
--- a/src/common/common.vcxproj
+++ b/src/common/common.vcxproj
@@ -166,6 +166,7 @@
166 <ClInclude Include="src\memory_util.h" /> 166 <ClInclude Include="src\memory_util.h" />
167 <ClInclude Include="src\mem_arena.h" /> 167 <ClInclude Include="src\mem_arena.h" />
168 <ClInclude Include="src\msg_handler.h" /> 168 <ClInclude Include="src\msg_handler.h" />
169 <ClInclude Include="src\platform.h" />
169 <ClInclude Include="src\scm_rev.h" /> 170 <ClInclude Include="src\scm_rev.h" />
170 <ClInclude Include="src\std_condition_variable.h" /> 171 <ClInclude Include="src\std_condition_variable.h" />
171 <ClInclude Include="src\std_mutex.h" /> 172 <ClInclude Include="src\std_mutex.h" />
diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters
index ddfb609e4..5bc11e5c5 100644
--- a/src/common/common.vcxproj.filters
+++ b/src/common/common.vcxproj.filters
@@ -53,6 +53,7 @@
53 <ClInclude Include="src\atomic_gcc.h" /> 53 <ClInclude Include="src\atomic_gcc.h" />
54 <ClInclude Include="src\atomic_win32.h" /> 54 <ClInclude Include="src\atomic_win32.h" />
55 <ClInclude Include="src\emu_window.h" /> 55 <ClInclude Include="src\emu_window.h" />
56 <ClInclude Include="src\platform.h" />
56 </ItemGroup> 57 </ItemGroup>
57 <ItemGroup> 58 <ItemGroup>
58 <None Include="CMakeLists.txt" /> 59 <None Include="CMakeLists.txt" />
diff --git a/src/common/src/common.h b/src/common/src/common.h
index b61e77686..0e5bf1cd3 100644
--- a/src/common/src/common.h
+++ b/src/common/src/common.h
@@ -48,6 +48,7 @@ private:
48#include "msg_handler.h" 48#include "msg_handler.h"
49#include "common_funcs.h" 49#include "common_funcs.h"
50#include "common_paths.h" 50#include "common_paths.h"
51#include "platform.h"
51 52
52#ifdef __APPLE__ 53#ifdef __APPLE__
53// The Darwin ABI requires that stack frames be aligned to 16-byte boundaries. 54// The Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
diff --git a/src/common/src/platform.h b/src/common/src/platform.h
new file mode 100644
index 000000000..d610b418a
--- /dev/null
+++ b/src/common/src/platform.h
@@ -0,0 +1,134 @@
1/**
2 * Copyright (C) 2005-2012 Gekko Emulator
3 *
4 * @file platform.h
5 * @author ShizZy <shizzy247@gmail.com>
6 * @date 2012-02-11
7 * @brief Platform detection macros for portable compilation
8 *
9 * @section LICENSE
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details at
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * Official project repository can be found at:
22 * http://code.google.com/p/gekko-gc-emu/
23 */
24
25#ifndef COMMON_PLATFORM_H_
26#define COMMON_PLATFORM_H_
27
28#include "common_types.h"
29
30////////////////////////////////////////////////////////////////////////////////////////////////////
31// Platform definitions
32
33/// Enumeration for defining the supported platforms
34#define PLATFORM_NULL 0
35#define PLATFORM_WINDOWS 1
36#define PLATFORM_MACOSX 2
37#define PLATFORM_LINUX 3
38#define PLATFORM_ANDROID 4
39#define PLATFORM_IOS 5
40
41////////////////////////////////////////////////////////////////////////////////////////////////////
42// Platform detection
43
44#ifndef EMU_PLATFORM
45
46#if defined( __WIN32__ ) || defined( _WIN32 )
47#define EMU_PLATFORM PLATFORM_WINDOWS
48
49#elif defined( __APPLE__ ) || defined( __APPLE_CC__ )
50#define EMU_PLATFORM PLATFORM_MAXOSX
51
52#elif defined(__linux__)
53#define EMU_PLATFORM PLATFORM_LINUX
54
55#else // Assume linux otherwise
56#define EMU_PLATFORM PLATFORM_LINUX
57
58#endif
59
60#endif
61
62#if defined(__x86_64__) || defined(_M_X64) || defined(__alpha__) || defined(__ia64__)
63#define EMU_ARCHITECTURE_X64
64#else
65#define EMU_ARCHITECTURE_X86
66#endif
67
68////////////////////////////////////////////////////////////////////////////////////////////////////
69// Compiler-Specific Definitions
70
71#if EMU_PLATFORM == PLATFORM_WINDOWS
72
73#define NOMINMAX
74#define EMU_FASTCALL __fastcall
75
76#else
77
78#define EMU_FASTCALL __attribute__((fastcall))
79#define __stdcall
80#define __cdecl
81
82#define LONG long
83#define BOOL bool
84#define DWORD u32
85
86#endif
87
88#if EMU_PLATFORM != PLATFORM_WINDOWS
89
90// TODO: Hacks..
91#include <limits.h>
92#define MAX_PATH PATH_MAX
93
94#include <strings.h>
95#define stricmp(str1, str2) strcasecmp(str1, str2)
96#define _stricmp(str1, str2) strcasecmp(str1, str2)
97#define _snprintf snprintf
98#define _getcwd getcwd
99#define _tzset tzset
100
101typedef void EXCEPTION_POINTERS;
102
103inline u32 _rotl(u32 x, int shift) {
104 shift &= 31;
105 if (0 == shift) {
106 return x;
107 }
108 return (x << shift) | (x >> (32 - shift));
109}
110
111inline u64 _rotl64(u64 x, u32 shift){
112 u32 n = shift % 64;
113 return (x << n) | (x >> (64 - n));
114}
115
116inline u32 _rotr(u32 x, int shift) {
117 shift &= 31;
118 if (0 == shift) {
119 return x;
120 }
121 return (x >> shift) | (x << (32 - shift));
122}
123
124inline u64 _rotr64(u64 x, u32 shift){
125 u32 n = shift % 64;
126 return (x >> n) | (x << (64 - n));
127}
128
129#endif
130
131#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \
132 (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
133
134#endif // COMMON_PLATFORM_H_