UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UnixPlatform.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*================================================================================
4 UnixPlatform.h: Setup for the linux platform
5==================================================================================*/
6
7#pragma once
8
9// HEADER_UNIT_SKIP - Not included directly
10
11#include <linux/version.h>
12#include <signal.h>
13#include "Clang/ClangPlatform.h"
14
16
17#define PLATFORM_UNIX_USE_CHAR16 1 UE_DEPRECATED_MACRO(5.7, "PLATFORM_UNIX_USE_CHAR16 has been deprecated and should be replaced with 1.")
18
23{
24 typedef unsigned int DWORD;
26 typedef decltype(__null) TYPE_OF_NULL;
27 typedef char16_t WIDECHAR;
28 typedef WIDECHAR TCHAR;
29};
30
32
33#define UNIX_MAX_PATH PATH_MAX
34
35#define PLATFORM_64BITS 1
36#define PLATFORM_CAN_SUPPORT_EDITORONLY_DATA 1
37
38// Base defines, defaults are commented out
39
40#define PLATFORM_SEH_EXCEPTIONS_DISABLED 1
41#define PLATFORM_LITTLE_ENDIAN 1
42#define PLATFORM_SUPPORTS_UNALIGNED_LOADS ((!PLATFORM_CPU_ARM_FAMILY) || PLATFORM_64BITS) // 32-bit ARM doesn't support unaligned loads, other arch's do
43#define PLATFORM_COMPILER_DISTINGUISHES_INT_AND_LONG 1
44#define PLATFORM_SUPPORTS_PRAGMA_PACK 1
45#define PLATFORM_USE_LS_SPEC_FOR_WIDECHAR 1
46#define PLATFORM_WCHAR_IS_4_BYTES 1
47#define PLATFORM_TCHAR_IS_CHAR16 1
48#define PLATFORM_HAS_BSD_TIME 1
49#define PLATFORM_HAS_BSD_THREAD_CPUTIME 1
50#define PLATFORM_USE_PTHREADS 1
51#define PLATFORM_MAX_FILEPATH_LENGTH_DEPRECATED UNIX_MAX_PATH /* @todo linux: avoid using PATH_MAX as it is known to be broken */
52#define PLATFORM_HAS_NO_EPROCLIM 1
53#define PLATFORM_HAS_BSD_IPV6_SOCKETS 1
54#define PLATFORM_HAS_BSD_SOCKET_FEATURE_IOCTL 1
55#define PLATFORM_HAS_BSD_SOCKET_FEATURE_POLL 1
56#define PLATFORM_HAS_BSD_SOCKET_FEATURE_MSG_DONTWAIT 1
57#define PLATFORM_HAS_BSD_SOCKET_FEATURE_RECVMMSG 1
58#define PLATFORM_HAS_BSD_SOCKET_FEATURE_TIMESTAMP 1
59#define PLATFORM_SUPPORTS_MIMALLOC PLATFORM_64BITS
60#define PLATFORM_SUPPORTS_STACK_SYMBOLS 1
61#define PLATFORM_IS_ANSI_MALLOC_THREADSAFE 1
62#define PLATFORM_ALLOW_ALLOCATIONS_IN_FASYNCWRITER_SERIALIZEBUFFERTOARCHIVE 0
63#define PLATFORM_USE_ANSI_POSIX_MALLOC 1
64#define PLATFORM_SUPPORTS_BINDLESS_RENDERING 1
65#define PLATFORM_SUPPORTS_MESH_SHADERS 1
66
67
68#define PLATFORM_RETURN_ADDRESS_FOR_CALLSTACKTRACING PLATFORM_RETURN_ADDRESS
69
70#if WITH_EDITOR
71#define PLATFORM_FILE_READER_BUFFER_SIZE (256*1024)
72#endif
73
74#if PLATFORM_CPU_X86_FAMILY
75 #define PLATFORM_BREAK() { PRAGMA_DISABLE_CPP20_EXTENSION_WARNINGS __asm__ volatile("int $0x03"); PRAGMA_ENABLE_CPP20_EXTENSION_WARNINGS }
76#else
77 #define PLATFORM_BREAK() raise(SIGTRAP)
78#endif // PLATFORM_CPU_X86_FAMILY
79
80#define PLATFORM_CODE_SECTION(Name) __attribute__((section(Name)))
81
82#define PLATFORM_ENABLE_POPCNT_INTRINSIC 1
83
84// SOCK_CLOEXEC is available on Unix since 2.6.27
85#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
86 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_CLOSE_ON_EXEC 1
87#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
88
89#if defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__) || defined (__amd64__)
90 #define PLATFORM_ENABLE_VECTORINTRINSICS 1
91#endif // defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__) || defined (__amd64__)
92
93#if PLATFORM_LINUXARM64
94 // Enable NEON intrinsics for ARM64 builds
95 #define PLATFORM_ENABLE_VECTORINTRINSICS_NEON 1
96 #define PLATFORM_ENABLE_VECTORINTRINSICS 1
97#endif
98
99#ifndef PLATFORM_ALWAYS_HAS_FMA3
100 #define PLATFORM_ALWAYS_HAS_FMA3 0
101#endif
102
103
104// Function type macros.
105#define VARARGS /* Functions with variable arguments */
106#define CDECL /* Standard C function */
107#define STDCALL /* Standard calling convention */
108#if UE_BUILD_DEBUG
109 #define FORCEINLINE inline /* Don't force code to be inline, or you'll run into -Wignored-attributes */
110#else
111 #define FORCEINLINE inline __attribute__ ((always_inline)) /* Force code to be inline */
112#endif // UE_BUILD_DEBUG
113#define FORCENOINLINE __attribute__((noinline)) /* Force code to NOT be inline */
114#define FUNCTION_CHECK_RETURN_END __attribute__ ((warn_unused_result)) /* Wrap a function signature in this to warn that callers should not ignore the return value. */
115#define FUNCTION_NO_RETURN_END __attribute__ ((noreturn)) /* Wrap a function signature in this to indicate that the function never returns. */
116
117// Optimization macros (uses _Pragma to enable inside a #define).
118#if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6))
119 #define PRAGMA_DISABLE_OPTIMIZATION_ACTUAL _Pragma("clang optimize off")
120 #define PRAGMA_ENABLE_OPTIMIZATION_ACTUAL _Pragma("clang optimize on")
121#endif
122
123#define ABSTRACT abstract
124
125// DLL export and import definitions
126#define DLLEXPORT __attribute__((visibility("default")))
127#define DLLIMPORT __attribute__((visibility("default")))
128
129// Alignment.
130#define GCC_PACK(n) __attribute__((packed,aligned(n)))
131#define GCC_ALIGN(n) __attribute__((aligned(n)))
132#if defined(__arm__)
133#define REQUIRES_ALIGNED_ACCESS 1
134#endif
135
136// operator new/delete operators
137// As of 10.9 we need to use _NOEXCEPT & cxx_noexcept compatible definitions
138#if __has_feature(cxx_noexcept)
139#define OPERATOR_NEW_THROW_SPEC
140#else
141#define OPERATOR_NEW_THROW_SPEC throw (std::bad_alloc)
142#endif
143#define OPERATOR_DELETE_THROW_SPEC noexcept
144#define OPERATOR_NEW_NOTHROW_SPEC noexcept
145#define OPERATOR_DELETE_NOTHROW_SPEC noexcept
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FUnixPlatformTypes FPlatformTypes
Definition UnixPlatform.h:31
Definition GenericPlatform.h:33
Definition UnixPlatform.h:23
__SIZE_TYPE__ SIZE_T
Definition UnixPlatform.h:25
unsigned int DWORD
Definition UnixPlatform.h:24
decltype(__null) TYPE_OF_NULL
Definition UnixPlatform.h:26
char16_t WIDECHAR
Definition UnixPlatform.h:27
WIDECHAR TCHAR
Definition UnixPlatform.h:28