summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-12 17:36:48 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-02-13 09:28:09 -0500
commit16942c6fdaddb819b71b72e53aa4aa691e3c0053 (patch)
tree05a719c0753521789eff1ebc4c4c284d80afb696 /src/common.h
parent8aab36a3010372edec71e8c765d4ecfd848c09b6 (diff)
downloadlibgit2-16942c6fdaddb819b71b72e53aa4aa691e3c0053.tar.gz
integer overflow: use compiler intrinsics if supported
gcc and clang support __builtin_add_overflow, use it whenever possible, falling back to our naive routines.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h
index 8d1e89064..98109ae3a 100644
--- a/src/common.h
+++ b/src/common.h
@@ -17,6 +17,11 @@
# define GIT_INLINE(type) static inline type
#endif
+/** Support for gcc/clang __has_builtin intrinsic */
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
#include <assert.h>
#include <errno.h>
#include <limits.h>