aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/print.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2014-05-28 23:10:47 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2014-05-28 23:10:47 +0000
commit93c521ea9cf06574be59d946d160938accc4eb4c (patch)
treedf34b4ed79bf7318bf3a3954769e5b025f585952 /libgo/runtime/print.c
parentbc2eed9a8e6b0f1cf976ffe626471c5755eb2ca4 (diff)
downloadgcc-93c521ea9cf06574be59d946d160938accc4eb4c.zip
gcc-93c521ea9cf06574be59d946d160938accc4eb4c.tar.gz
gcc-93c521ea9cf06574be59d946d160938accc4eb4c.tar.bz2
runtime: fix misc gcc-isms and undefined behavior
This includes the use of __complex and __builtin_ functions where unprefixed entities would suffice, and the use of a union for bit-casting between types. From-SVN: r211036
Diffstat (limited to 'libgo/runtime/print.c')
-rw-r--r--libgo/runtime/print.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libgo/runtime/print.c b/libgo/runtime/print.c
index 766ddbd..1656a99 100644
--- a/libgo/runtime/print.c
+++ b/libgo/runtime/print.c
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include <complex.h>
+#include <math.h>
#include <stdarg.h>
#include "runtime.h"
#include "array.h"
@@ -105,7 +107,7 @@ go_vprintf(const char *s, va_list va)
runtime_printfloat(va_arg(va, float64));
break;
case 'C':
- runtime_printcomplex(va_arg(va, __complex double));
+ runtime_printcomplex(va_arg(va, complex double));
break;
case 'i':
runtime_printiface(va_arg(va, Iface));
@@ -174,13 +176,12 @@ runtime_printfloat(double v)
gwrite("NaN", 3);
return;
}
- i = __builtin_isinf_sign(v);
- if(i > 0) {
- gwrite("+Inf", 4);
- return;
- }
- if(i < 0) {
- gwrite("-Inf", 4);
+ if(isinf(v)) {
+ if(signbit(v)) {
+ gwrite("-Inf", 4);
+ } else {
+ gwrite("+Inf", 4);
+ }
return;
}
@@ -243,11 +244,11 @@ runtime_printfloat(double v)
}
void
-runtime_printcomplex(__complex double v)
+runtime_printcomplex(complex double v)
{
gwrite("(", 1);
- runtime_printfloat(__builtin_creal(v));
- runtime_printfloat(__builtin_cimag(v));
+ runtime_printfloat(creal(v));
+ runtime_printfloat(cimag(v));
gwrite("i)", 2);
}