541 {
543}
546}
549}
550constexpr double WordsToMB(intptr_t size_in_words) {
551 return static_cast<double>(size_in_words) / MBInWords;
552}
553
557
558
568
569
572}
575}
576
577
578
579#if !defined(DISALLOW_COPY_AND_ASSIGN)
580#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
581 private: \
582 TypeName(const TypeName&) = delete; \
583 void operator=(const TypeName&) = delete
584#endif
585
586
587
588
589
590
591#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
592#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
593 private: \
594 TypeName() = delete; \
595 DISALLOW_COPY_AND_ASSIGN(TypeName)
596#endif
597
598
599
600
601
602#if !defined(DISALLOW_ALLOCATION)
603#define DISALLOW_ALLOCATION() \
604 public: \
605 void operator delete(void* pointer) { \
606 fprintf(stderr, "unreachable code\n"); \
607 abort(); \
608 } \
609 \
610 private: \
611 void* operator new(size_t size);
612#endif
613
614
615
616template <typename T>
617static inline void USE(
T&&) {}
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644template <class D, class S>
646 static_assert(
sizeof(
D) ==
sizeof(S),
647 "Source and destination must have the same size");
648
650
651 memcpy(&destination, &
source,
sizeof(destination));
652 return destination;
653}
654
655
656
657
658
659
660template <class D, class S>
663
664 memcpy(&destination,
reinterpret_cast<const void*
>(&
source),
665 sizeof(destination));
666 return destination;
667}
668
669
670
671#if defined(DART_HOST_OS_WINDOWS)
672#define snprintf _sprintf_p
673#define strtok_r strtok_s
674#endif
675
676#if !defined(DART_HOST_OS_WINDOWS)
677#if defined(TEMP_FAILURE_RETRY)
678
679
680
681#undef TEMP_FAILURE_RETRY
682#endif
683#endif
684
685#if __GNUC__
686
687
688
689
690
691
692
693#define PRINTF_ATTRIBUTE(string_index, first_to_check) \
694 __attribute__((__format__(__printf__, string_index, first_to_check)))
695#else
696#define PRINTF_ATTRIBUTE(string_index, first_to_check)
697#endif
698
699#if defined(_WIN32)
700#define STDIN_FILENO 0
701#define STDOUT_FILENO 1
702#define STDERR_FILENO 2
703#endif
704
705#ifndef PATH_MAX
706
707#define PATH_MAX MAX_PATH
708#endif
709
710
711#undef OVERFLOW
712
713
714
715#if !defined(PRODUCT) || defined(DART_PRECOMPILER) || \
716 defined(FORCE_INCLUDE_DISASSEMBLER)
717#if defined(DART_PRECOMPILED_RUNTIME) && defined(PRODUCT)
718#error Requested to include IL printer into PRODUCT AOT runtime
719#endif
720#define INCLUDE_IL_PRINTER 1
721#if !defined(FORCE_INCLUDE_DISASSEMBLER)
722#define FORCE_INCLUDE_DISASSEMBLER 1
723#endif
724#endif
725
726
727#if !defined(DART_ENABLE_HEAP_SNAPSHOT_WRITER) && !defined(PRODUCT)
728#define DART_ENABLE_HEAP_SNAPSHOT_WRITER 1
729#endif
730
731#if defined(DART_HOST_OS_ANDROID)
732#define kHostOperatingSystemName "android"
733#elif defined(DART_HOST_OS_FUCHSIA)
734#define kHostOperatingSystemName "fuchsia"
735#elif defined(DART_HOST_OS_IOS)
736#define kHostOperatingSystemName "ios"
737#elif defined(DART_HOST_OS_LINUX)
738#define kHostOperatingSystemName "linux"
739#elif defined(DART_HOST_OS_MACOS)
740#define kHostOperatingSystemName "macos"
741#elif defined(DART_HOST_OS_WINDOWS)
742#define kHostOperatingSystemName "windows"
743#else
744#error Host operating system detection failed.
745#endif
746
747#if defined(HOST_ARCH_ARM)
748#define kHostArchitectureName "arm"
749#elif defined(HOST_ARCH_ARM64)
750#define kHostArchitectureName "arm64"
751#elif defined(HOST_ARCH_IA32)
752#define kHostArchitectureName "ia32"
753#elif defined(HOST_ARCH_RISCV32)
754#define kHostArchitectureName "riscv32"
755#elif defined(HOST_ARCH_RISCV64)
756#define kHostArchitectureName "riscv64"
757#elif defined(HOST_ARCH_X64)
758#define kHostArchitectureName "x64"
759#else
760#error Host architecture detection failed.
761#endif
762
763#if defined(TARGET_ARCH_ARM)
764#define kTargetArchitectureName "arm"
765#elif defined(TARGET_ARCH_ARM64)
766#define kTargetArchitectureName "arm64"
767#elif defined(TARGET_ARCH_IA32)
768#define kTargetArchitectureName "ia32"
769#elif defined(TARGET_ARCH_RISCV32)
770#define kTargetArchitectureName "riscv32"
771#elif defined(TARGET_ARCH_RISCV64)
772#define kTargetArchitectureName "riscv64"
773#elif defined(TARGET_ARCH_X64)
774#define kTargetArchitectureName "x64"
775#else
776#error Target architecture detection failed.
777#endif
778
779
780
781
782
783#if defined(DART_TARGET_OS_ANDROID)
784#define kTargetOperatingSystemName "android"
785#elif defined(DART_TARGET_OS_FUCHSIA)
786#define kTargetOperatingSystemName "fuchsia"
787#elif defined(DART_TARGET_OS_LINUX)
788#define kTargetOperatingSystemName "linux"
789#elif defined(DART_TARGET_OS_MACOS_IOS)
790#define kTargetOperatingSystemName "ios"
791#elif defined(DART_TARGET_OS_MACOS)
792#define kTargetOperatingSystemName "macos"
793#elif defined(DART_TARGET_OS_WINDOWS)
794#define kTargetOperatingSystemName "windows"
795#else
796#error Target operating system detection failed.
797#endif
798
799}
800
801#endif
constexpr uint64_t kMicrosecondsPerMillisecond
static constexpr int kMicrosecondsPerSecond
constexpr intptr_t MBInWordsLog2
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 RoundWordsToGB(intptr_t size_in_words)
constexpr intptr_t RoundWordsToMB(intptr_t size_in_words)
constexpr intptr_t kNanosecondsPerMicrosecond
constexpr intptr_t kIntptrMin
constexpr intptr_t kIntptrOne
constexpr intptr_t kNanosecondsPerSecond
constexpr double WordsToMB(intptr_t size_in_words)
constexpr intptr_t kMillisecondsPerSecond
constexpr intptr_t KBInWordsLog2
constexpr intptr_t GBInWordsLog2
constexpr double MicrosecondsToMilliseconds(int64_t micros)
DART_FORCE_INLINE D bit_copy(const S &source)
constexpr intptr_t kIntptrMax