少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
 
// Stopgap measure to allow using some code from the Unity's own platform layer without having to adapt it exclusively
// for il2cpp.
 
#include "il2cpp-config.h"
 
#if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include <new>
 
#define UNITY_PLATFORM_BEGIN_NAMESPACE namespace il2cpp { namespace os {
#define UNITY_PLATFORM_END_NAMESPACE }}
 
#define UNITY_PLATFORM_NEW(type, label) new type
#define UNITY_PLATFORM_NEW_ALIGNED(type, label, alignment) new (alignment) type
#define UNITY_PLATFORM_DELETE(ptr, label) delete ptr
 
inline void* operator new(size_t size, int alignment)
{
    void* result = NULL;
    #if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE
    result = _aligned_malloc(size, alignment);
    #elif IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_PSP2
    result = memalign(alignment, size);
    #else
    if (posix_memalign(&result, size, alignment))
        result = NULL;
    #endif
    if (!result)
        throw std::bad_alloc();
    return result;
}
 
#if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE // Visual C++ warns if new is overridden but delete is not.
inline void operator delete(void* ptr, int alignment) throw ()
{
    free(ptr);
}
 
#endif