5#ifndef RUNTIME_PLATFORM_GLOBALS_H_
6#define RUNTIME_PLATFORM_GLOBALS_H_
8#if __cplusplus >= 201703L
9#define FALL_THROUGH [[fallthrough]]
10#elif defined(__GNUC__) && __GNUC__ >= 7
11#define FALL_THROUGH __attribute__((fallthrough));
12#elif defined(__clang__)
13#define FALL_THROUGH [[clang::fallthrough]]
15#define FALL_THROUGH ((void)0)
18#if !defined(NDEBUG) && !defined(DEBUG)
32#ifndef __STDC_FORMAT_MACROS
33#define __STDC_FORMAT_MACROS
38#if !defined(WIN32_LEAN_AND_MEAN)
39#define WIN32_LEAN_AND_MEAN
50#if !defined(NOSERVICE)
68#define RPC_USE_NATIVE_WCHAR
71#include <versionhelpers.h>
107#if defined(__ANDROID__)
110#define DART_HOST_OS_ANDROID 1
112#elif defined(__linux__) || defined(__FreeBSD__)
115#define DART_HOST_OS_LINUX 1
117#elif defined(__APPLE__)
120#include <TargetConditionals.h>
121#define DART_HOST_OS_MACOS 1
123#define DART_HOST_OS_IOS 1
129#define DART_HOST_OS_WINDOWS 1
131#elif defined(__Fuchsia__)
132#define DART_HOST_OS_FUCHSIA
134#elif !defined(DART_HOST_OS_FUCHSIA)
135#error Automatic target os detection failed.
139#define DEBUG_ONLY(code) code
141#define DEBUG_ONLY(code)
199#if defined(_M_X64) || defined(__x86_64__)
200#define HOST_ARCH_X64 1
201#define ARCH_IS_64_BIT 1
202#elif defined(_M_IX86) || defined(__i386__)
203#define HOST_ARCH_IA32 1
204#define ARCH_IS_32_BIT 1
205#elif defined(_M_ARM) || defined(__ARMEL__)
206#define HOST_ARCH_ARM 1
207#define ARCH_IS_32_BIT 1
208#elif defined(_M_ARM64) || defined(__aarch64__)
209#define HOST_ARCH_ARM64 1
210#define ARCH_IS_64_BIT 1
211#elif defined(__riscv)
212#if __SIZEOF_POINTER__ == 4
213#define HOST_ARCH_RISCV32 1
214#define ARCH_IS_32_BIT 1
215#elif __SIZEOF_POINTER__ == 8
216#define HOST_ARCH_RISCV64 1
217#define ARCH_IS_64_BIT 1
222#error Architecture was not detected as supported by Dart.
231#define DART_FORCE_INLINE __forceinline
233#define DART_FORCE_INLINE inline __attribute__((always_inline))
235#error Automatic compiler detection failed.
240#define DART_NOINLINE __declspec(noinline)
242#define DART_NOINLINE __attribute__((noinline))
244#error Automatic compiler detection failed.
249#define DART_HAS_COMPUTED_GOTO 1
251#error Automatic compiler detection failed.
257#define LIKELY(cond) __builtin_expect((cond), 1)
258#define UNLIKELY(cond) __builtin_expect((cond), 0)
260#define LIKELY(cond) cond
261#define UNLIKELY(cond) cond
267#define DART_UNUSED __attribute__((unused))
275#define DART_USED __attribute__((used))
285#define DART_NORETURN __declspec(noreturn)
287#define DART_NORETURN __attribute__((noreturn))
289#error Automatic compiler detection failed.
293#define DART_PRETTY_FUNCTION __FUNCSIG__
295#define DART_PRETTY_FUNCTION __PRETTY_FUNCTION__
297#error Automatic compiler detection failed.
300#if !defined(TARGET_ARCH_ARM) && !defined(TARGET_ARCH_X64) && \
301 !defined(TARGET_ARCH_IA32) && !defined(TARGET_ARCH_ARM64) && \
302 !defined(TARGET_ARCH_RISCV32) && !defined(TARGET_ARCH_RISCV64)
304#if defined(HOST_ARCH_ARM)
305#define TARGET_ARCH_ARM 1
306#elif defined(HOST_ARCH_X64)
307#define TARGET_ARCH_X64 1
308#elif defined(HOST_ARCH_IA32)
309#define TARGET_ARCH_IA32 1
310#elif defined(HOST_ARCH_ARM64)
311#define TARGET_ARCH_ARM64 1
312#elif defined(HOST_ARCH_RISCV32)
313#define TARGET_ARCH_RISCV32 1
314#elif defined(HOST_ARCH_RISCV64)
315#define TARGET_ARCH_RISCV64 1
317#error Automatic target architecture detection failed.
321#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) || \
322 defined(TARGET_ARCH_RISCV32)
323#define TARGET_ARCH_IS_32_BIT 1
324#elif defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) || \
325 defined(TARGET_ARCH_RISCV64)
326#define TARGET_ARCH_IS_64_BIT 1
328#error Automatic target architecture detection failed.
331#if defined(TARGET_ARCH_IS_64_BIT) && !defined(DART_COMPRESSED_POINTERS)
332#define HAS_SMI_63_BITS 1
337#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) || \
338 defined(TARGET_ARCH_RISCV64)
339#if !defined(ARCH_IS_64_BIT) && !defined(FFI_UNIT_TESTS)
340#error Mismatched Host/Target architectures.
342#elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) || \
343 defined(TARGET_ARCH_RISCV32)
344#if defined(ARCH_IS_64_BIT) && defined(TARGET_ARCH_ARM)
347#define IS_SIMARM_HOST64 1
348#elif !defined(ARCH_IS_32_BIT) && !defined(FFI_UNIT_TESTS)
349#error Mismatched Host/Target architectures.
354#if defined(TARGET_ARCH_IA32)
355#if !defined(HOST_ARCH_IA32)
356#define USING_SIMULATOR 1
358#elif defined(TARGET_ARCH_X64)
359#if !defined(HOST_ARCH_X64)
360#define USING_SIMULATOR 1
362#elif defined(TARGET_ARCH_ARM)
363#if !defined(HOST_ARCH_ARM)
364#define TARGET_HOST_MISMATCH 1
365#if !defined(IS_SIMARM_HOST64)
366#define USING_SIMULATOR 1
369#elif defined(TARGET_ARCH_ARM64)
370#if !defined(HOST_ARCH_ARM64)
371#define USING_SIMULATOR 1
373#elif defined(TARGET_ARCH_RISCV32)
374#if !defined(HOST_ARCH_RISCV32)
375#define USING_SIMULATOR 1
377#elif defined(TARGET_ARCH_RISCV64)
378#if !defined(HOST_ARCH_RISCV64)
379#define USING_SIMULATOR 1
382#error Unknown architecture.
385#if !defined(DART_TARGET_OS_ANDROID) && !defined(DART_TARGET_OS_FUCHSIA) && \
386 !defined(DART_TARGET_OS_MACOS_IOS) && !defined(DART_TARGET_OS_LINUX) && \
387 !defined(DART_TARGET_OS_MACOS) && !defined(DART_TARGET_OS_WINDOWS)
389#if defined(DART_HOST_OS_ANDROID)
390#define DART_TARGET_OS_ANDROID 1
391#elif defined(DART_HOST_OS_FUCHSIA)
392#define DART_TARGET_OS_FUCHSIA 1
393#elif defined(DART_HOST_OS_IOS)
394#define DART_TARGET_OS_MACOS 1
395#define DART_TARGET_OS_MACOS_IOS 1
396#elif defined(DART_HOST_OS_LINUX)
397#define DART_TARGET_OS_LINUX 1
398#elif defined(DART_HOST_OS_MACOS)
399#define DART_TARGET_OS_MACOS 1
400#elif defined(DART_HOST_OS_WINDOWS)
401#define DART_TARGET_OS_WINDOWS 1
403#error Automatic target OS detection failed.
422#if defined(ARCH_IS_32_BIT)
423#define Pp "08" PRIxPTR
425#define Pp "016" PRIxPTR
430#define DART_INT64_C(x) x##I64
431#define DART_UINT64_C(x) x##UI64
433#define DART_INT64_C(x) x##LL
434#define DART_UINT64_C(x) x##ULL
439#define strtoll _strtoi64
445static_assert(
kInt8Size ==
sizeof(int8_t),
"Mismatched int8 size constant");
448static_assert(
kInt16Size ==
sizeof(int16_t),
"Mismatched int16 size constant");
451static_assert(
kInt32Size ==
sizeof(int32_t),
"Mismatched int32 size constant");
454static_assert(
kInt64Size ==
sizeof(int64_t),
"Mismatched int64 size constant");
472#define DART_2PART_UINT64_C(a, b) \
473 (((static_cast<uint64_t>(a) << kBitsPerInt32) + 0x##b##u))
510static_assert(
kWordSize ==
sizeof(
word),
"Mismatched word size constant");
552 return static_cast<double>(size_in_words) /
MBInWords;
580#if !defined(DISALLOW_COPY_AND_ASSIGN)
581#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
583 TypeName(const TypeName&) = delete; \
584 void operator=(const TypeName&) = delete
592#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
593#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
595 TypeName() = delete; \
596 DISALLOW_COPY_AND_ASSIGN(TypeName)
603#if !defined(DISALLOW_ALLOCATION)
604#define DISALLOW_ALLOCATION() \
606 void operator delete(void* pointer) { \
607 fprintf(stderr, "unreachable code\n"); \
612 void* operator new(size_t size);
645template <
class D,
class S>
647 static_assert(
sizeof(
D) ==
sizeof(
S),
648 "Source and destination must have the same size");
652 memcpy(&destination, &
source,
sizeof(destination));
661template <
class D,
class S>
665 memcpy(&destination,
reinterpret_cast<const void*
>(&
source),
666 sizeof(destination));
672#if defined(DART_HOST_OS_WINDOWS)
673#define snprintf _sprintf_p
674#define strtok_r strtok_s
677#if !defined(DART_HOST_OS_WINDOWS)
678#if defined(TEMP_FAILURE_RETRY)
682#undef TEMP_FAILURE_RETRY
694#define PRINTF_ATTRIBUTE(string_index, first_to_check) \
695 __attribute__((__format__(__printf__, string_index, first_to_check)))
697#define PRINTF_ATTRIBUTE(string_index, first_to_check)
701#define STDIN_FILENO 0
702#define STDOUT_FILENO 1
703#define STDERR_FILENO 2
708#define PATH_MAX MAX_PATH
716#if !defined(PRODUCT) || defined(DART_PRECOMPILER) || \
717 defined(FORCE_INCLUDE_DISASSEMBLER)
718#if defined(DART_PRECOMPILED_RUNTIME) && defined(PRODUCT)
719#error Requested to include IL printer into PRODUCT AOT runtime
721#define INCLUDE_IL_PRINTER 1
722#if !defined(FORCE_INCLUDE_DISASSEMBLER)
723#define FORCE_INCLUDE_DISASSEMBLER 1
728#if !defined(DART_ENABLE_HEAP_SNAPSHOT_WRITER) && !defined(PRODUCT)
729#define DART_ENABLE_HEAP_SNAPSHOT_WRITER 1
732#if defined(DART_HOST_OS_ANDROID)
733#define kHostOperatingSystemName "android"
734#elif defined(DART_HOST_OS_FUCHSIA)
735#define kHostOperatingSystemName "fuchsia"
736#elif defined(DART_HOST_OS_IOS)
737#define kHostOperatingSystemName "ios"
738#elif defined(DART_HOST_OS_LINUX)
739#define kHostOperatingSystemName "linux"
740#elif defined(DART_HOST_OS_MACOS)
741#define kHostOperatingSystemName "macos"
742#elif defined(DART_HOST_OS_WINDOWS)
743#define kHostOperatingSystemName "windows"
745#error Host operating system detection failed.
748#if defined(HOST_ARCH_ARM)
749#define kHostArchitectureName "arm"
750#elif defined(HOST_ARCH_ARM64)
751#define kHostArchitectureName "arm64"
752#elif defined(HOST_ARCH_IA32)
753#define kHostArchitectureName "ia32"
754#elif defined(HOST_ARCH_RISCV32)
755#define kHostArchitectureName "riscv32"
756#elif defined(HOST_ARCH_RISCV64)
757#define kHostArchitectureName "riscv64"
758#elif defined(HOST_ARCH_X64)
759#define kHostArchitectureName "x64"
761#error Host architecture detection failed.
764#if defined(TARGET_ARCH_ARM)
765#define kTargetArchitectureName "arm"
766#elif defined(TARGET_ARCH_ARM64)
767#define kTargetArchitectureName "arm64"
768#elif defined(TARGET_ARCH_IA32)
769#define kTargetArchitectureName "ia32"
770#elif defined(TARGET_ARCH_RISCV32)
771#define kTargetArchitectureName "riscv32"
772#elif defined(TARGET_ARCH_RISCV64)
773#define kTargetArchitectureName "riscv64"
774#elif defined(TARGET_ARCH_X64)
775#define kTargetArchitectureName "x64"
777#error Target architecture detection failed.
784#if defined(DART_TARGET_OS_ANDROID)
785#define kTargetOperatingSystemName "android"
786#elif defined(DART_TARGET_OS_FUCHSIA)
787#define kTargetOperatingSystemName "fuchsia"
788#elif defined(DART_TARGET_OS_LINUX)
789#define kTargetOperatingSystemName "linux"
790#elif defined(DART_TARGET_OS_MACOS_IOS)
791#define kTargetOperatingSystemName "ios"
792#elif defined(DART_TARGET_OS_MACOS)
793#define kTargetOperatingSystemName "macos"
794#elif defined(DART_TARGET_OS_WINDOWS)
795#define kTargetOperatingSystemName "windows"
797#error Target operating system detection failed.
constexpr int16_t kMaxInt16
constexpr int64_t kMaxInt64
constexpr int64_t kMinInt64
constexpr intptr_t kBitsPerWordLog2
constexpr intptr_t kBitsPerByteLog2
constexpr uint8_t kMaxUint8
constexpr intptr_t kMicrosecondsPerMillisecond
constexpr intptr_t MBInWordsLog2
constexpr intptr_t GBInWords
constexpr double MicrosecondsToSeconds(int64_t micros)
DART_FORCE_INLINE D bit_cast(const S &source)
constexpr intptr_t kBitsPerWord
constexpr intptr_t kNanosecondsPerMillisecond
constexpr intptr_t kMicrosecondsPerSecond
constexpr intptr_t RoundWordsToGB(intptr_t size_in_words)
constexpr intptr_t RoundWordsToMB(intptr_t size_in_words)
constexpr int32_t kMinInt32
constexpr intptr_t kNanosecondsPerMicrosecond
constexpr intptr_t kInt8Size
constexpr intptr_t kIntptrMin
constexpr intptr_t MBLog2
constexpr intptr_t kInt64Size
constexpr uint64_t kMaxUint64
constexpr intptr_t kInt32SizeLog2
constexpr uint32_t kMaxUint32
constexpr intptr_t kBitsPerByte
constexpr intptr_t kIntptrOne
constexpr intptr_t kSimd128Size
constexpr intptr_t kWordSizeLog2
constexpr uword kUwordMax
constexpr intptr_t kNanosecondsPerSecond
constexpr intptr_t kBitsPerInt16
constexpr intptr_t MBInWords
constexpr double WordsToMB(intptr_t size_in_words)
constexpr intptr_t kMillisecondsPerSecond
constexpr intptr_t kInt16SizeLog2
constexpr intptr_t GBLog2
constexpr intptr_t kInt8SizeLog2
constexpr intptr_t kInt32Size
constexpr intptr_t KBInWordsLog2
constexpr intptr_t kBitsPerInt32
constexpr int8_t kMaxInt8
constexpr intptr_t kQuadSize
constexpr intptr_t GBInWordsLog2
constexpr int32_t kMaxInt32
constexpr intptr_t kInt64SizeLog2
constexpr intptr_t kWordSize
constexpr intptr_t kFloatSize
constexpr int16_t kMinInt16
constexpr double MicrosecondsToMilliseconds(int64_t micros)
DART_FORCE_INLINE D bit_copy(const S &source)
constexpr int64_t kMinInt64RepresentableAsDouble
constexpr intptr_t KBInWords
constexpr int64_t kMaxInt64RepresentableAsDouble
constexpr intptr_t kDoubleSize
constexpr intptr_t kInt16Size
constexpr intptr_t KBLog2
constexpr int8_t kMinInt8
constexpr intptr_t kBitsPerInt64
constexpr int64_t kSignBitDouble
constexpr intptr_t RoundWordsToKB(intptr_t size_in_words)
constexpr uint16_t kMaxUint16
constexpr intptr_t kIntptrMax
constexpr intptr_t kBitsPerInt8
void writeTo(simd128_value_t *v)
simd128_value_t & readFrom(const float *v)
simd128_value_t & readFrom(const int32_t *v)
simd128_value_t & readFrom(const double *v)
simd128_value_t & readFrom(const simd128_value_t *v)