/* * Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary * source code may only be used and distributed under the Widevine Master * License Agreement. */ #ifndef ODK_OVERFLOW_H_ #define ODK_OVERFLOW_H_ #ifdef __cplusplus extern "C" { #endif #ifndef __has_builtin # define __has_builtin(x) 0 #endif #if (defined(__GNUC__) && __GNUC__ >= 5) || \ __has_builtin(__builtin_add_overflow) # define odk_sub_overflow_u64 __builtin_sub_overflow # define odk_add_overflow_u64 __builtin_add_overflow # define odk_add_overflow_ux __builtin_add_overflow #else int odk_sub_overflow_u64(uint64_t a, uint64_t b, uint64_t* c); int odk_add_overflow_u64(uint64_t a, uint64_t b, uint64_t* c); int odk_add_overflow_ux(size_t a, size_t b, size_t* c); #endif #ifdef __cplusplus } #endif #endif /* ODK_OVERFLOW_H_ */