39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
/* Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
|
source code may only be used and distributed under the Widevine License
|
|
Agreement. */
|
|
|
|
#ifndef OEMCRYPTO_COMPILER_DETECTION_H_
|
|
#define OEMCRYPTO_COMPILER_DETECTION_H_
|
|
|
|
/* These polyfills allow us to use __has_attribute() and __has_builtin() even
|
|
on compilers that did not have them, simplifying preprocessor logic
|
|
elsewhere.
|
|
|
|
Note that __has_attribute() and __has_builtin() were often not available on
|
|
older compilers. Universal support in GCC & Clang didn't come until 2020.
|
|
Checks for attributes or builtins that are older than that should also
|
|
perform a manual compiler version check to detect older compilers. */
|
|
|
|
#if !defined(__has_attribute)
|
|
# define __has_attribute(x) 0
|
|
#endif
|
|
|
|
#if !defined(__has_builtin)
|
|
# define __has_builtin(x) 0
|
|
#endif
|
|
|
|
#if defined(__GNUC__)
|
|
# define COMPATIBLE_WITH_GCC(major_version) (__GNUC__ >= (major_version))
|
|
#else
|
|
# define COMPATIBLE_WITH_GCC(x) 0
|
|
#endif
|
|
|
|
#if defined(__clang__) && defined(__clang_major__)
|
|
# define COMPATIBLE_WITH_CLANG(major_version) \
|
|
(__clang_major__ >= (major_version))
|
|
#else
|
|
# define COMPATIBLE_WITH_CLANG(x) 0
|
|
#endif
|
|
|
|
#endif /* OEMCRYPTO_COMPILER_DETECTION_H_ */
|