summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorGravatar bunnei2017-10-09 23:56:20 -0400
committerGravatar bunnei2017-10-09 23:56:20 -0400
commitb1d5db1cf60344b6b081c9d03cb6ccc3264326cd (patch)
treefde377c4ba3c0f92c032e6f5ec8627aae37270ef /src/common
parentloader: Various improvements for NSO/NRO loaders. (diff)
parentMerge pull request #2996 from MerryMage/split-travis (diff)
downloadyuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.gz
yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.xz
yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.zip
Merge remote-tracking branch 'upstream/master' into nx
# Conflicts: # src/core/CMakeLists.txt # src/core/arm/dynarmic/arm_dynarmic.cpp # src/core/arm/dyncom/arm_dyncom.cpp # src/core/hle/kernel/process.cpp # src/core/hle/kernel/thread.cpp # src/core/hle/kernel/thread.h # src/core/hle/kernel/vm_manager.cpp # src/core/loader/3dsx.cpp # src/core/loader/elf.cpp # src/core/loader/ncch.cpp # src/core/memory.cpp # src/core/memory.h # src/core/memory_setup.h
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common_types.h4
-rw-r--r--src/common/quaternion.h5
-rw-r--r--src/common/scm_rev.cpp.in2
-rw-r--r--src/common/scm_rev.h1
-rw-r--r--src/common/string_util.cpp2
-rw-r--r--src/common/string_util.h2
-rw-r--r--src/common/vector_math.h29
7 files changed, 27 insertions, 18 deletions
diff --git a/src/common/common_types.h b/src/common/common_types.h
index e8f7ac6be..844d34965 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -24,6 +24,7 @@
24 24
25#pragma once 25#pragma once
26 26
27#include <array>
27#include <cstdint> 28#include <cstdint>
28 29
29#ifdef _MSC_VER 30#ifdef _MSC_VER
@@ -50,6 +51,9 @@ typedef double f64; ///< 64-bit floating point
50typedef u64 VAddr; ///< Represents a pointer in the userspace virtual address space. 51typedef u64 VAddr; ///< Represents a pointer in the userspace virtual address space.
51typedef u64 PAddr; ///< Represents a pointer in the ARM11 physical address space. 52typedef u64 PAddr; ///< Represents a pointer in the ARM11 physical address space.
52 53
54using u128 = std::array<std::uint64_t, 2>;
55static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide");
56
53// An inheritable class to disallow the copy constructor and operator= functions 57// An inheritable class to disallow the copy constructor and operator= functions
54class NonCopyable { 58class NonCopyable {
55protected: 59protected:
diff --git a/src/common/quaternion.h b/src/common/quaternion.h
index 84ac82ed3..77f626bcb 100644
--- a/src/common/quaternion.h
+++ b/src/common/quaternion.h
@@ -30,6 +30,11 @@ public:
30 return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz), 30 return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz),
31 w * other.w - Dot(xyz, other.xyz)}; 31 w * other.w - Dot(xyz, other.xyz)};
32 } 32 }
33
34 Quaternion<T> Normalized() const {
35 T length = std::sqrt(xyz.Length2() + w * w);
36 return {xyz / length, w / length};
37 }
33}; 38};
34 39
35template <typename T> 40template <typename T>
diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in
index 0080db5d5..4083095d5 100644
--- a/src/common/scm_rev.cpp.in
+++ b/src/common/scm_rev.cpp.in
@@ -8,6 +8,7 @@
8#define GIT_BRANCH "@GIT_BRANCH@" 8#define GIT_BRANCH "@GIT_BRANCH@"
9#define GIT_DESC "@GIT_DESC@" 9#define GIT_DESC "@GIT_DESC@"
10#define BUILD_NAME "@REPO_NAME@" 10#define BUILD_NAME "@REPO_NAME@"
11#define BUILD_DATE "@BUILD_DATE@"
11 12
12namespace Common { 13namespace Common {
13 14
@@ -15,6 +16,7 @@ const char g_scm_rev[] = GIT_REV;
15const char g_scm_branch[] = GIT_BRANCH; 16const char g_scm_branch[] = GIT_BRANCH;
16const char g_scm_desc[] = GIT_DESC; 17const char g_scm_desc[] = GIT_DESC;
17const char g_build_name[] = BUILD_NAME; 18const char g_build_name[] = BUILD_NAME;
19const char g_build_date[] = BUILD_DATE;
18 20
19} // namespace 21} // namespace
20 22
diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h
index e22389803..18aaa1735 100644
--- a/src/common/scm_rev.h
+++ b/src/common/scm_rev.h
@@ -10,5 +10,6 @@ extern const char g_scm_rev[];
10extern const char g_scm_branch[]; 10extern const char g_scm_branch[];
11extern const char g_scm_desc[]; 11extern const char g_scm_desc[];
12extern const char g_build_name[]; 12extern const char g_build_name[];
13extern const char g_build_date[];
13 14
14} // namespace 15} // namespace
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index bad311793..6959915fa 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -117,7 +117,7 @@ std::string StringFromFormat(const char* format, ...) {
117} 117}
118 118
119// For Debugging. Read out an u8 array. 119// For Debugging. Read out an u8 array.
120std::string ArrayToString(const u8* data, u32 size, int line_len, bool spaces) { 120std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces) {
121 std::ostringstream oss; 121 std::ostringstream oss;
122 oss << std::setfill('0') << std::hex; 122 oss << std::setfill('0') << std::hex;
123 123
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 075bf4ecb..259360aec 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -33,7 +33,7 @@ inline void CharArrayFromFormat(char (&out)[Count], const char* format, ...) {
33} 33}
34 34
35// Good 35// Good
36std::string ArrayToString(const u8* data, u32 size, int line_len = 20, bool spaces = true); 36std::string ArrayToString(const u8* data, size_t size, int line_len = 20, bool spaces = true);
37 37
38std::string StripSpaces(const std::string& s); 38std::string StripSpaces(const std::string& s);
39std::string StripQuotes(const std::string& s); 39std::string StripQuotes(const std::string& s);
diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index c7a461a1e..3f0057d9e 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -90,8 +90,9 @@ public:
90 x -= other.x; 90 x -= other.x;
91 y -= other.y; 91 y -= other.y;
92 } 92 }
93 template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type> 93
94 Vec2<decltype(-T{})> operator-() const { 94 template <typename U = T>
95 Vec2<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const {
95 return MakeVec(-x, -y); 96 return MakeVec(-x, -y);
96 } 97 }
97 Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const { 98 Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const {
@@ -103,8 +104,7 @@ public:
103 } 104 }
104 template <typename V> 105 template <typename V>
105 void operator*=(const V& f) { 106 void operator*=(const V& f) {
106 x *= f; 107 *this = *this * f;
107 y *= f;
108 } 108 }
109 template <typename V> 109 template <typename V>
110 Vec2<decltype(T{} / V{})> operator/(const V& f) const { 110 Vec2<decltype(T{} / V{})> operator/(const V& f) const {
@@ -247,8 +247,9 @@ public:
247 y -= other.y; 247 y -= other.y;
248 z -= other.z; 248 z -= other.z;
249 } 249 }
250 template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type> 250
251 Vec3<decltype(-T{})> operator-() const { 251 template <typename U = T>
252 Vec3<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const {
252 return MakeVec(-x, -y, -z); 253 return MakeVec(-x, -y, -z);
253 } 254 }
254 Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const { 255 Vec3<decltype(T{} * T{})> operator*(const Vec3& other) const {
@@ -260,9 +261,7 @@ public:
260 } 261 }
261 template <typename V> 262 template <typename V>
262 void operator*=(const V& f) { 263 void operator*=(const V& f) {
263 x *= f; 264 *this = *this * f;
264 y *= f;
265 z *= f;
266 } 265 }
267 template <typename V> 266 template <typename V>
268 Vec3<decltype(T{} / V{})> operator/(const V& f) const { 267 Vec3<decltype(T{} / V{})> operator/(const V& f) const {
@@ -462,8 +461,9 @@ public:
462 z -= other.z; 461 z -= other.z;
463 w -= other.w; 462 w -= other.w;
464 } 463 }
465 template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type> 464
466 Vec4<decltype(-T{})> operator-() const { 465 template <typename U = T>
466 Vec4<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const {
467 return MakeVec(-x, -y, -z, -w); 467 return MakeVec(-x, -y, -z, -w);
468 } 468 }
469 Vec4<decltype(T{} * T{})> operator*(const Vec4& other) const { 469 Vec4<decltype(T{} * T{})> operator*(const Vec4& other) const {
@@ -475,10 +475,7 @@ public:
475 } 475 }
476 template <typename V> 476 template <typename V>
477 void operator*=(const V& f) { 477 void operator*=(const V& f) {
478 x *= f; 478 *this = *this * f;
479 y *= f;
480 z *= f;
481 w *= f;
482 } 479 }
483 template <typename V> 480 template <typename V>
484 Vec4<decltype(T{} / V{})> operator/(const V& f) const { 481 Vec4<decltype(T{} / V{})> operator/(const V& f) const {
@@ -721,4 +718,4 @@ static inline Vec4<T> MakeVec(const T& x, const Vec3<T>& yzw) {
721 return MakeVec(x, yzw[0], yzw[1], yzw[2]); 718 return MakeVec(x, yzw[0], yzw[1], yzw[2]);
722} 719}
723 720
724} // namespace 721} // namespace Math