CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/Common.h
Views: 1401
1
// Copyright (C) 2003 Dolphin Project.
2
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.
6
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.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official SVN repository and contact information can be found at
16
// http://code.google.com/p/dolphin-emu/
17
18
#pragma once
19
20
// DO NOT EVER INCLUDE <windows.h> directly _or indirectly_ from this file
21
// since it slows down the build a lot.
22
23
#include <stdarg.h>
24
25
#ifdef _MSC_VER
26
#pragma warning(disable:4100)
27
#pragma warning(disable:4244)
28
#endif
29
30
#include "CommonTypes.h"
31
#include "CommonFuncs.h"
32
33
#ifndef DISALLOW_COPY_AND_ASSIGN
34
#define DISALLOW_COPY_AND_ASSIGN(t) \
35
t(const t &other) = delete; \
36
void operator =(const t &other) = delete;
37
#endif
38
39
#ifndef ENUM_CLASS_BITOPS
40
#define ENUM_CLASS_BITOPS(T) \
41
static inline T operator |(const T &lhs, const T &rhs) { \
42
return T((int)lhs | (int)rhs); \
43
} \
44
static inline T &operator |= (T &lhs, const T &rhs) { \
45
lhs = lhs | rhs; \
46
return lhs; \
47
} \
48
static inline bool operator &(const T &lhs, const T &rhs) { \
49
return ((int)lhs & (int)rhs) != 0; \
50
} \
51
static inline T &operator &= (T &lhs, const T &rhs) { \
52
lhs = (T)((int)lhs & (int)rhs); \
53
return lhs; \
54
} \
55
static inline T operator ~(const T &rhs) { \
56
return (T)(~((int)rhs)); \
57
}
58
#endif
59
60
#ifndef ARRAY_SIZE
61
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
62
#endif
63
64
#if defined(_WIN32)
65
66
// Memory leak checks
67
#define CHECK_HEAP_INTEGRITY()
68
69
// Debug definitions
70
#if defined(_DEBUG)
71
#include <crtdbg.h>
72
#undef CHECK_HEAP_INTEGRITY
73
#define CHECK_HEAP_INTEGRITY() {if (!_CrtCheckMemory()) _assert_msg_(false, "Memory corruption detected. See log.");}
74
#endif
75
#else
76
77
#define CHECK_HEAP_INTEGRITY()
78
79
#endif
80
81
// Windows compatibility
82
#ifndef _WIN32
83
#include <limits.h>
84
#ifndef MAX_PATH
85
#define MAX_PATH PATH_MAX
86
#endif
87
88
#define __forceinline inline __attribute__((always_inline))
89
#endif
90
91
#if defined __SSE4_2__
92
# define _M_SSE 0x402
93
#elif defined __SSE4_1__
94
# define _M_SSE 0x401
95
#elif defined __SSSE3__
96
# define _M_SSE 0x301
97
#elif defined __SSE3__
98
# define _M_SSE 0x300
99
#elif defined __SSE2__
100
# define _M_SSE 0x200
101
#elif !defined(__GNUC__) && (defined(_M_X64) || defined(_M_IX86))
102
# define _M_SSE 0x402
103
#endif
104
105