• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_UTIL_TOOLCHAIN_H_
18 #define CHRE_UTIL_TOOLCHAIN_H_
19 
20 /**
21  * @file
22  * Compiler/build toolchain-specific macros used by nanoapps and the CHRE system
23  */
24 
25 #if defined(__GNUC__) || defined(__clang__)
26 
27 // Promoting float to double is a necessary part of vararg-based logging, so
28 // ignore those warnings when logging via chre/util/nanoapp/log.h
29 #define CHRE_LOG_PREAMBLE \
30     _Pragma("GCC diagnostic push") \
31     _Pragma("GCC diagnostic ignored \"-Wdouble-promotion\"")
32 
33 #define CHRE_LOG_EPILOGUE \
34     _Pragma("GCC diagnostic pop")
35 
36 // Enable printf-style compiler warnings for mismatched format string and args
37 #define CHRE_PRINTF_ATTR(formatPos, argStart) \
38     __attribute__((format(printf, formatPos, argStart)))
39 
40 #else  // if !defined(__GNUC__) && !defined(__clang__)
41 
42 #error Need to add support for new compiler
43 
44 #endif
45 
46 #endif  // CHRE_UTIL_TOOLCHAIN_H_
47