fix some warnings and use the damn FORCE_INLINE macro otherwise what's it there for

This commit is contained in:
SimoneN64
2023-06-05 20:54:34 +02:00
parent 776634a293
commit 32c66fdf5f
25 changed files with 139 additions and 133 deletions

View File

@@ -3,7 +3,7 @@
#include <log.hpp>
namespace Util {
inline auto ReadFileBinary(const std::string& path, u32** buf) {
FORCE_INLINE auto ReadFileBinary(const std::string& path, u32** buf) {
std::ifstream file(path, std::ios::binary);
file.unsetf(std::ios::skipws);
if(!file.is_open()) {
@@ -20,7 +20,7 @@ inline auto ReadFileBinary(const std::string& path, u32** buf) {
return size;
}
inline size_t NextPow2(size_t num) {
FORCE_INLINE size_t NextPow2(size_t num) {
// Taken from "Bit Twiddling Hacks" by Sean Anderson:
// https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
--num;

View File

@@ -6,7 +6,7 @@
namespace Util {
template<typename T>
inline T ReadAccess(u8 *data, u32 index) {
FORCE_INLINE T ReadAccess(u8 *data, u32 index) {
if constexpr (sizeof(T) == 1) { //
return data[index];
} else if constexpr (sizeof(T) == 2 || sizeof(T) == 4) {
@@ -25,7 +25,7 @@ inline T ReadAccess(u8 *data, u32 index) {
}
template<typename T>
inline void WriteAccess(u8 *data, u32 index, T val) {
FORCE_INLINE void WriteAccess(u8 *data, u32 index, T val) {
if constexpr (sizeof(T) == 1) {
data[index] = val;
return;
@@ -40,21 +40,21 @@ inline void WriteAccess(u8 *data, u32 index, T val) {
}
}
inline void SwapBuffer32(size_t size, u8 *data) {
FORCE_INLINE void SwapBuffer32(size_t size, u8 *data) {
for (int i = 0; i < size; i += 4) {
u32 original = *(u32 *) &data[i];
*(u32 *) &data[i] = bswap_32(original);
}
}
inline void SwapBuffer16(size_t size, u8 *data) {
FORCE_INLINE void SwapBuffer16(size_t size, u8 *data) {
for (int i = 0; i < size; i += 2) {
u16 original = *(u16 *) &data[i];
*(u16 *) &data[i] = bswap_16(original);
}
}
inline u32 crc32(u32 crc, const u8 *buf, size_t len) {
FORCE_INLINE u32 crc32(u32 crc, const u8 *buf, size_t len) {
static u32 table[256];
static int have_table = 0;
u32 rem;
@@ -87,19 +87,19 @@ inline u32 crc32(u32 crc, const u8 *buf, size_t len) {
}
#ifdef _WIN32
inline void* aligned_alloc(size_t alignment, size_t size) {
FORCE_INLINE void* aligned_alloc(size_t alignment, size_t size) {
return _aligned_malloc(size, alignment);
}
inline void aligned_free(void* ptr) {
FORCE_INLINE void aligned_free(void* ptr) {
_aligned_free(ptr);
}
#else
inline void* aligned_alloc(size_t alignment, size_t size) {
FORCE_INLINE void* aligned_alloc(size_t alignment, size_t size) {
return std::aligned_alloc(alignment, size);
}
inline void aligned_free(void* ptr) {
FORCE_INLINE void aligned_free(void* ptr) {
std::free(ptr);
}
#endif