blob: 884eec884a6171bec08912ec205a88a6c6e40495 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __CROS_EC_OVERFLOW_H
#define __CROS_EC_OVERFLOW_H
#include "compiler.h"
/*
* __builtin_add_overflow, __builtin_sub_overflow and __builtin_mul_overflow
* were added in gcc 5.1: https://gcc.gnu.org/gcc-5/changes.html
*/
#if GCC_VERSION > 50100
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
#endif
/*
* __has_builtin available in
* clang 10 and newer: https://clang.llvm.org/docs/LanguageExtensions.html
*/
#ifdef __clang__
#if __has_builtin(__builtin_add_overflow) && \
__has_builtin(__builtin_sub_overflow) && \
__has_builtin(__builtin_mul_overflow)
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
#endif
#endif /* __clang__ */
#include "third_party/linux/overflow.h"
#endif /* __CROS_EC_OVERFLOW_H */
|