aboutsummaryrefslogtreecommitdiff
path: root/zencore
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-09-16 17:08:01 +0200
committerMartin Ridgers <[email protected]>2021-09-16 17:08:01 +0200
commit8da2c13a34fd6394aecaf19490d65a8a84592e3c (patch)
tree702cb3aec8145209fb5d8e39d8bf6d1432dd1a33 /zencore
parentAnother missing include (diff)
parentCompact binary package caching support (#9) (diff)
downloadzen-8da2c13a34fd6394aecaf19490d65a8a84592e3c.tar.xz
zen-8da2c13a34fd6394aecaf19490d65a8a84592e3c.zip
Merge main into linux-mac
Diffstat (limited to 'zencore')
-rw-r--r--zencore/except.cpp2
-rw-r--r--zencore/include/zencore/atomic.h4
-rw-r--r--zencore/include/zencore/except.h2
-rw-r--r--zencore/include/zencore/intmath.h2
-rw-r--r--zencore/include/zencore/iobuffer.h16
-rw-r--r--zencore/include/zencore/memory.h10
-rw-r--r--zencore/include/zencore/session.h4
-rw-r--r--zencore/include/zencore/zencore.h51
-rw-r--r--zencore/intmath.cpp2
-rw-r--r--zencore/memory.cpp6
-rw-r--r--zencore/session.cpp15
-rw-r--r--zencore/zencore.cpp6
12 files changed, 62 insertions, 58 deletions
diff --git a/zencore/except.cpp b/zencore/except.cpp
index 75d0c8dd1..84e52ab9f 100644
--- a/zencore/except.cpp
+++ b/zencore/except.cpp
@@ -20,7 +20,7 @@ ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string
}
}
-#endif // ZEN_PLATFORM_WINDOWS
+#endif // ZEN_PLATFORM_WINDOWS
void
ThrowLastError(std::string_view Message)
diff --git a/zencore/include/zencore/atomic.h b/zencore/include/zencore/atomic.h
index 7e261771b..bf549e21d 100644
--- a/zencore/include/zencore/atomic.h
+++ b/zencore/include/zencore/atomic.h
@@ -5,9 +5,9 @@
#include <zencore/zencore.h>
#if ZEN_COMPILER_MSC
-#include <intrin.h>
+# include <intrin.h>
#else
-#include <atomic>
+# include <atomic>
#endif
#include <cinttypes>
diff --git a/zencore/include/zencore/except.h b/zencore/include/zencore/except.h
index 90f7d45db..f0e04a795 100644
--- a/zencore/include/zencore/except.h
+++ b/zencore/include/zencore/except.h
@@ -51,7 +51,7 @@ private:
};
ZENCORE_API void ThrowSystemException(HRESULT hRes, std::string_view Message);
-#endif // ZEN_PLATFORM_WINDOWS
+#endif // ZEN_PLATFORM_WINDOWS
ZENCORE_API void ThrowLastError(std::string_view Message);
diff --git a/zencore/include/zencore/intmath.h b/zencore/include/zencore/intmath.h
index 2fdea22b5..7619e1950 100644
--- a/zencore/include/zencore/intmath.h
+++ b/zencore/include/zencore/intmath.h
@@ -179,6 +179,6 @@ Max(auto x, auto y)
//////////////////////////////////////////////////////////////////////////
-void intmath_forcelink(); // internal
+void intmath_forcelink(); // internal
} // namespace zen
diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h
index f3120983e..298952dd6 100644
--- a/zencore/include/zencore/iobuffer.h
+++ b/zencore/include/zencore/iobuffer.h
@@ -15,14 +15,14 @@ struct IoBufferExtendedCore;
enum class ZenContentType : uint8_t
{
- kBinary = 0, // Note that since this is zero, this will be the default value in IoBuffer
- kText = 1,
- kJSON = 2,
- kCbObject = 3,
- kCbPackage = 4,
- kYAML = 5,
- kCbPackageOffer = 6,
- kCompressedBinary = 7,
+ kBinary = 0, // Note that since this is zero, this will be the default value in IoBuffer
+ kText = 1,
+ kJSON = 2,
+ kCbObject = 3,
+ kCbPackage = 4,
+ kYAML = 5,
+ kCbPackageOffer = 6,
+ kCompressedBinary = 7,
kUnknownContentType = 8,
kCOUNT
};
diff --git a/zencore/include/zencore/memory.h b/zencore/include/zencore/memory.h
index 9d6339595..3d4db1081 100644
--- a/zencore/include/zencore/memory.h
+++ b/zencore/include/zencore/memory.h
@@ -83,7 +83,7 @@ struct MutableMemoryView
{
}
- inline bool IsEmpty() const { return m_Data == m_DataEnd; }
+ inline bool IsEmpty() const { return m_Data == m_DataEnd; }
void* GetData() const { return m_Data; }
void* GetDataEnd() const { return m_DataEnd; }
size_t GetSize() const { return reinterpret_cast<uint8_t*>(m_DataEnd) - reinterpret_cast<uint8_t*>(m_Data); }
@@ -194,10 +194,10 @@ struct MemoryView
{
}
- inline bool Contains(const MemoryView& Other) const { return (m_Data <= Other.m_Data) && (m_DataEnd >= Other.m_DataEnd); }
- inline bool IsEmpty() const { return m_Data == m_DataEnd; }
- const void* GetData() const { return m_Data; }
- const void* GetDataEnd() const { return m_DataEnd; }
+ inline bool Contains(const MemoryView& Other) const { return (m_Data <= Other.m_Data) && (m_DataEnd >= Other.m_DataEnd); }
+ inline bool IsEmpty() const { return m_Data == m_DataEnd; }
+ const void* GetData() const { return m_Data; }
+ const void* GetDataEnd() const { return m_DataEnd; }
size_t GetSize() const { return reinterpret_cast<const uint8_t*>(m_DataEnd) - reinterpret_cast<const uint8_t*>(m_Data); }
inline bool operator==(const MemoryView& Rhs) const { return m_Data == Rhs.m_Data && m_DataEnd == Rhs.m_DataEnd; }
diff --git a/zencore/include/zencore/session.h b/zencore/include/zencore/session.h
index e66794704..2da41b2c8 100644
--- a/zencore/include/zencore/session.h
+++ b/zencore/include/zencore/session.h
@@ -1,3 +1,5 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
#pragma once
#include <zencore/zencore.h>
@@ -8,4 +10,4 @@ struct Oid;
ZENCORE_API Oid GetSessionId();
-}
+} // namespace zen
diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h
index 73446b447..54df7e85e 100644
--- a/zencore/include/zencore/zencore.h
+++ b/zencore/include/zencore/zencore.h
@@ -10,39 +10,39 @@
// Platform
//
-#define ZEN_PLATFORM_WINDOWS 0
-#define ZEN_PLATFORM_LINUX 0
-#define ZEN_PLATFORM_MACOS 0
+#define ZEN_PLATFORM_WINDOWS 0
+#define ZEN_PLATFORM_LINUX 0
+#define ZEN_PLATFORM_MACOS 0
#ifdef _WIN32
-# undef ZEN_PLATFORM_WINDOWS
-# define ZEN_PLATFORM_WINDOWS 1
+# undef ZEN_PLATFORM_WINDOWS
+# define ZEN_PLATFORM_WINDOWS 1
#elif defined(__linux__)
-# undef ZEN_PLATFORM_LINUX
-# define ZEN_PLATFORM_LINUX 1
+# undef ZEN_PLATFORM_LINUX
+# define ZEN_PLATFORM_LINUX 1
#elif defined(__APPLE__)
-# undef ZEN_PLATFORM_MACOS
-# define ZEN_PLATFORM_MACOS 1
+# undef ZEN_PLATFORM_MACOS
+# define ZEN_PLATFORM_MACOS 1
#endif
//////////////////////////////////////////////////////////////////////////
// Compiler
//
-#define ZEN_COMPILER_CLANG 0
-#define ZEN_COMPILER_MSC 0
-#define ZEN_COMPILER_GCC 0
+#define ZEN_COMPILER_CLANG 0
+#define ZEN_COMPILER_MSC 0
+#define ZEN_COMPILER_GCC 0
// Clang can define __GNUC__ and/or _MSC_VER so we check for Clang first
#ifdef __clang__
-# undef ZEN_COMPILER_CLANG
-# define ZEN_COMPILER_CLANG 1
+# undef ZEN_COMPILER_CLANG
+# define ZEN_COMPILER_CLANG 1
#elif defined(_MSC_VER)
-# undef ZEN_COMPILER_MSC
-# define ZEN_COMPILER_MSC 1
+# undef ZEN_COMPILER_MSC
+# define ZEN_COMPILER_MSC 1
#elif defined(__GNUC__)
-# undef ZEN_COMPILER_GCC
-# define ZEN_COMPILER_GCC 1
+# undef ZEN_COMPILER_GCC
+# define ZEN_COMPILER_GCC 1
#else
# error Unknown compiler
#endif
@@ -56,17 +56,16 @@
# endif
#endif
-
//////////////////////////////////////////////////////////////////////////
// Architecture
//
#if defined(__amd64__) || defined(_M_X64)
-# define ZEN_ARCH_X64 1
-# define ZEN_ARCH_ARM64 0
+# define ZEN_ARCH_X64 1
+# define ZEN_ARCH_ARM64 0
#elif defined(__arm64__) || defined(_M_ARM64)
-# define ZEN_ARCH_X64 0
-# define ZEN_ARCH_ARM64 1
+# define ZEN_ARCH_X64 0
+# define ZEN_ARCH_ARM64 1
#else
# error Unknown architecture
#endif
@@ -142,13 +141,13 @@ char (&ZenArrayCountHelper(const T (&)[N]))[N + 1];
//////////////////////////////////////////////////////////////////////////
#if ZEN_COMPILER_MSC
-# define ZEN_NOINLINE __declspec(noinline)
+# define ZEN_NOINLINE __declspec(noinline)
#else
-# define ZEN_NOINLINE __attribute__((noinline))
+# define ZEN_NOINLINE __attribute__((noinline))
#endif
#define ZEN_UNUSED(...) ((void)__VA_ARGS__)
-#define ZEN_NOT_IMPLEMENTED(...) ZEN_ASSERT(false)
+#define ZEN_NOT_IMPLEMENTED(...) ZEN_ASSERT(false, __VA_ARGS__)
#define ZENCORE_API // Placeholder to allow DLL configs in the future
ZENCORE_API bool IsPointerToStack(const void* ptr); // Query if pointer is within the stack of the currently executing thread
diff --git a/zencore/intmath.cpp b/zencore/intmath.cpp
index ae65085b6..98c345c79 100644
--- a/zencore/intmath.cpp
+++ b/zencore/intmath.cpp
@@ -58,4 +58,4 @@ TEST_CASE("intmath")
CHECK(ByteSwap(uint64_t(0x214d'6172'7469'6e21ull)) == 0x216e'6974'7261'4d21ull);
}
-} // namespace zen
+} // namespace zen
diff --git a/zencore/memory.cpp b/zencore/memory.cpp
index 9c7fb8333..26c8321e5 100644
--- a/zencore/memory.cpp
+++ b/zencore/memory.cpp
@@ -15,7 +15,8 @@ namespace zen {
//////////////////////////////////////////////////////////////////////////
-static void* AlignedAllocImpl(size_t size, size_t alignment)
+static void*
+AlignedAllocImpl(size_t size, size_t alignment)
{
#if ZEN_PLATFORM_WINDOWS
// return _aligned_malloc(size, alignment); // MSVC alternative
@@ -26,7 +27,8 @@ static void* AlignedAllocImpl(size_t size, size_t alignment)
#endif
}
-void AlignedFreeImpl(void* ptr)
+void
+AlignedFreeImpl(void* ptr)
{
if (ptr == nullptr)
return;
diff --git a/zencore/session.cpp b/zencore/session.cpp
index 195a9d97c..d57d3685b 100644
--- a/zencore/session.cpp
+++ b/zencore/session.cpp
@@ -1,3 +1,5 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
#include "zencore/session.h"
#include <zencore/uid.h>
@@ -6,16 +8,15 @@
namespace zen {
-static Oid GlobalSessionId;
+static Oid GlobalSessionId;
static std::once_flag SessionInitFlag;
-Oid GetSessionId()
+Oid
+GetSessionId()
{
- std::call_once(SessionInitFlag, [&] {
- GlobalSessionId.Generate();
- });
+ std::call_once(SessionInitFlag, [&] { GlobalSessionId.Generate(); });
- return GlobalSessionId;
+ return GlobalSessionId;
}
-} \ No newline at end of file
+} // namespace zen \ No newline at end of file
diff --git a/zencore/zencore.cpp b/zencore/zencore.cpp
index 56bdd2ae8..f9b19ba9d 100644
--- a/zencore/zencore.cpp
+++ b/zencore/zencore.cpp
@@ -3,11 +3,11 @@
#include <zencore/zencore.h>
#if ZEN_PLATFORM_WINDOWS
-#include <zencore/windows.h>
+# include <zencore/windows.h>
#endif
#if ZEN_PLATFORM_LINUX
-#include <pthread.h>
+# include <pthread.h>
#endif
#include <zencore/blake3.h>
@@ -46,7 +46,7 @@ IsPointerToStack(const void* ptr)
pthread_attr_t attr;
pthread_getattr_np(self, &attr);
- void* low;
+ void* low;
size_t size;
pthread_attr_getstack(&attr, &low, &size);