1 /* go-print.c -- support for the go print statement.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
12 #include "go-string.h"
13 #include "interface.h"
15 /* This implements the various little functions which are called by
16 the predeclared functions print/println/panic/panicln. */
31 __go_print_string (struct __go_string val
)
33 printf ("%.*s", (int) val
.__length
, (const char *) val
.__data
);
37 __go_print_uint64 (uint64_t val
)
39 printf ("%llu", (unsigned long long) val
);
43 __go_print_int64 (int64_t val
)
45 printf ("%lld", (long long) val
);
49 __go_print_double (double val
)
51 printf ("%.24g", val
);
55 __go_print_complex (__complex
double val
)
57 printf ("(%.24g%s%.24gi)",
58 __builtin_creal (val
),
59 (__builtin_cimag (val
) >= 0 || __builtin_isnan (__builtin_cimag(val
))
62 __builtin_cimag (val
));
66 __go_print_bool (_Bool val
)
68 fputs (val
? "true" : "false", stdout
);
72 __go_print_pointer (void *val
)
78 __go_print_empty_interface (struct __go_empty_interface e
)
80 printf ("(%p,%p)", e
.__type_descriptor
, e
.__object
);
84 __go_print_interface (struct __go_interface i
)
86 printf ("(%p,%p)", i
.__methods
, i
.__object
);
90 __go_print_slice (struct __go_open_array val
)
92 printf ("[%d/%d]%p", val
.__count
, val
.__capacity
, val
.__values
);