aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/libgo/runtime/go-cdiv.c
diff options
context:
space:
mode:
authorAndrew Hsieh <andrewhsieh@google.com>2014-06-18 13:00:04 -0700
committerPavel Chupin <pavel.v.chupin@intel.com>2014-06-19 22:38:42 +0400
commitf190d6284359da8ae8694b2d2e14b01602a959ed (patch)
treed4e0548e7cec02d60b1082368032e66a1c509a02 /gcc-4.8/libgo/runtime/go-cdiv.c
parent4ff2f42147bc128ce38789071d98e55844cd3a5e (diff)
downloadtoolchain_gcc-f190d6284359da8ae8694b2d2e14b01602a959ed.tar.gz
toolchain_gcc-f190d6284359da8ae8694b2d2e14b01602a959ed.tar.bz2
toolchain_gcc-f190d6284359da8ae8694b2d2e14b01602a959ed.zip
Merge GCC 4.8.3
Change-Id: I0abe59f7705b3eccc6b2f123af75b2e30917696a
Diffstat (limited to 'gcc-4.8/libgo/runtime/go-cdiv.c')
-rw-r--r--gcc-4.8/libgo/runtime/go-cdiv.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc-4.8/libgo/runtime/go-cdiv.c b/gcc-4.8/libgo/runtime/go-cdiv.c
new file mode 100644
index 000000000..0a81e458c
--- /dev/null
+++ b/gcc-4.8/libgo/runtime/go-cdiv.c
@@ -0,0 +1,46 @@
+/* go-cdiv.c -- complex division routines
+
+ Copyright 2013 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+
+/* Calls to these functions are generated by the Go frontend for
+ division of complex64 or complex128. We use these because Go's
+ complex division expects slightly different results from the GCC
+ default. When dividing NaN+1.0i / 0+0i, Go expects NaN+NaNi but
+ GCC generates NaN+Infi. NaN+Infi seems wrong seems the rules of
+ C99 Annex G specify that if either side of a complex number is Inf,
+ the the whole number is Inf, but an operation involving NaN ought
+ to result in NaN, not Inf. */
+
+__complex float
+__go_complex64_div (__complex float a, __complex float b)
+{
+ if (__builtin_expect (b == 0+0i, 0))
+ {
+ if (!__builtin_isinff (__real__ a)
+ && !__builtin_isinff (__imag__ a)
+ && (__builtin_isnanf (__real__ a) || __builtin_isnanf (__imag__ a)))
+ {
+ /* Pass "1" to nanf to match math/bits.go. */
+ return __builtin_nanf("1") + __builtin_nanf("1")*1i;
+ }
+ }
+ return a / b;
+}
+
+__complex double
+__go_complex128_div (__complex double a, __complex double b)
+{
+ if (__builtin_expect (b == 0+0i, 0))
+ {
+ if (!__builtin_isinf (__real__ a)
+ && !__builtin_isinf (__imag__ a)
+ && (__builtin_isnan (__real__ a) || __builtin_isnan (__imag__ a)))
+ {
+ /* Pass "1" to nan to match math/bits.go. */
+ return __builtin_nan("1") + __builtin_nan("1")*1i;
+ }
+ }
+ return a / b;
+}