Merge https://github.com/hrydgard/ppsspp
[libretro-ppsspp.git] / Globals.h
blob356744660e5008880387f1041d70f36b6c114ada
1 // Copyright (c) 2012- PPSSPP Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
18 #pragma once
20 #include <cstdio>
21 #include <cstring>
22 #include <vector>
23 #include <string>
24 #include <utility>
26 #include "Log.h"
28 #include "CommonTypes.h"
30 #define IS_LITTLE_ENDIAN (*(const u16 *)"\0\xff" >= 0x100)
31 #define IS_BIG_ENDIAN (*(const u16 *)"\0\xff" < 0x100)
33 static inline u8 clamp_u8(int i) {
34 #ifdef ARM
35 asm("usat %0, #8, %1" : "=r"(i) : "r"(i));
36 #else
37 if (i > 255)
38 return 255;
39 if (i < 0)
40 return 0;
41 #endif
42 return i;
45 static inline s16 clamp_s16(int i) {
46 #ifdef ARM
47 asm("ssat %0, #16, %1" : "=r"(i) : "r"(i));
48 #else
49 if (i > 32767)
50 return 32767;
51 if (i < -32768)
52 return -32768;
53 #endif
54 return i;
57 #ifndef DISALLOW_COPY_AND_ASSIGN
58 #define DISALLOW_COPY_AND_ASSIGN(t) \
59 private: \
60 t(const t &other); \
61 void operator =(const t &other);
62 #endif