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