Merge branch 'master' into LinuxProcess

This commit is contained in:
nothingTVatYT
2021-10-21 04:14:04 +02:00
committed by GitHub
24 changed files with 282 additions and 134 deletions

View File

@@ -2,19 +2,9 @@
#pragma once
#if PLATFORM_WINDOWS
#if PLATFORM_WINDOWS || PLATFORM_UWP || PLATFORM_XBOX_ONE || PLATFORM_XBOX_SCARLETT
#include "Win32/Win32ConditionVariable.h"
#elif PLATFORM_UWP
#include "Win32/Win32ConditionVariable.h"
#elif PLATFORM_LINUX
#include "Unix/UnixConditionVariable.h"
#elif PLATFORM_PS4
#include "Unix/UnixConditionVariable.h"
#elif PLATFORM_XBOX_ONE
#include "Win32/Win32ConditionVariable.h"
#elif PLATFORM_XBOX_SCARLETT
#include "Win32/Win32ConditionVariable.h"
#elif PLATFORM_ANDROID
#elif PLATFORM_LINUX || PLATFORM_ANDROID || PLATFORM_PS4 || PLATFORM_PS5
#include "Unix/UnixConditionVariable.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchConditionVariable.h"

View File

@@ -22,7 +22,6 @@ void* UnixPlatform::Allocate(uint64 size, uint64 alignment)
{
uint32_t pad = sizeof(offset_t) + (alignment - 1);
void* p = malloc(size + pad);
if (p)
{
// Add the offset size to malloc's pointer
@@ -31,8 +30,10 @@ void* UnixPlatform::Allocate(uint64 size, uint64 alignment)
// Calculate the offset and store it behind aligned pointer
*((offset_t*)ptr - 1) = (offset_t)((uintptr_t)ptr - (uintptr_t)p);
}
#if COMPILE_WITH_PROFILER
OnMemoryAlloc(ptr, size);
#endif
}
return ptr;
}
@@ -40,11 +41,14 @@ void UnixPlatform::Free(void* ptr)
{
if (ptr)
{
#if COMPILE_WITH_PROFILER
OnMemoryFree(ptr);
#endif
// Walk backwards from the passed-in pointer to get the pointer offset
offset_t offset = *((offset_t*)ptr - 1);
// Get original pointer
void* p = (void *)((uint8_t *)ptr - offset);
void* p = (void*)((uint8_t*)ptr - offset);
// Free memory
free(p);

View File

@@ -18,6 +18,8 @@
#include "Android/AndroidWindow.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchWindow.h"
#elif PLATFORM_PS5
#include "Platforms/PS5/Engine/Platform/PS5Window.h"
#else
#error Missing Window implementation!
#endif