cpu_model.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===-- cpu_model_common.c - Utilities for cpu model detection ----*- C -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements common utilities for runtime cpu model detection.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef COMPILER_RT_LIB_BUILTINS_CPU_MODEL_COMMON_H
  13. #define COMPILER_RT_LIB_BUILTINS_CPU_MODEL_COMMON_H
  14. #define bool int
  15. #define true 1
  16. #define false 0
  17. #ifndef __has_attribute
  18. #define __has_attribute(attr) 0
  19. #endif
  20. #if __has_attribute(constructor)
  21. #if __GNUC__ >= 9
  22. // Ordinarily init priorities below 101 are disallowed as they are reserved for
  23. // the implementation. However, we are the implementation, so silence the
  24. // diagnostic, since it doesn't apply to us.
  25. #pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
  26. #endif
  27. // We're choosing init priority 90 to force our constructors to run before any
  28. // constructors in the end user application (starting at priority 101). This
  29. // value matches the libgcc choice for the same functions.
  30. #define CONSTRUCTOR_ATTRIBUTE __attribute__((constructor(90)))
  31. #else
  32. // FIXME: For MSVC, we should make a function pointer global in .CRT$X?? so that
  33. // this runs during initialization.
  34. #define CONSTRUCTOR_ATTRIBUTE
  35. #endif
  36. #endif