mirrored from git://git.sv.gnu.org/smalltalk.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
libgst: Add alternative multiplication overflow check
Apple clang on OSX and the version on FreeBSD optimize the multiplication check away. Clang introduced a family of builtins to do the multiplication and check for the overflow and GCC made the API usable. For clang we would need to know if intptr_t is of type int, long int, long long int and then use the smul, smull smulll. Luckily clang is adopting the better interface and this is what we are starting to use now. This means the new code will be used on GCC5 (and later) and some future versions of clang. 2015-11-07 Holger Hans Peter Freyther <holger@freyther.de> * build-aux/overflow-builtins.m4: Add new macro. * configure.ac: Use GST_C_OVERFLOW_BUILTINS macro. 2015-11-07 Holger Hans Peter Freyther <holger@freyther.de> * interp.inl: Add alternative mul_with_check implementation.
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
dnl Check whether the host supports synchronization builtins. | ||
|
||
AC_DEFUN([GST_C_OVERFLOW_BUILTINS], [ | ||
AC_REQUIRE([AC_CANONICAL_HOST]) | ||
AC_CACHE_CHECK([whether the host supports __builtin_mul_overflow], | ||
gst_cv_have_builtin_mul_overflow, [ | ||
save_CFLAGS="$CFLAGS" | ||
case $host in | ||
i?86-apple-darwin*) ;; | ||
i?86-*-*) CFLAGS="$CFLAGS -march=i486" ;; | ||
esac | ||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foovar = 0;]], [[ | ||
if (__builtin_mul_overflow(44444, 55555, &foovar)) | ||
return 23;]])], | ||
[gst_cv_have_builtin_mul_overflow=yes], | ||
[gst_cv_have_builtin_mul_overflow=no]) | ||
CFLAGS="$save_CFLAGS" | ||
]) | ||
if test $gst_cv_have_builtin_mul_overflow = yes; then | ||
AC_DEFINE(HAVE_OVERFLOW_BUILTINS, 1, | ||
[Define to 1 if the host supports __builtin_*_overflow builtins]) | ||
fi | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters