diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-02-15 01:57:51 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-02-15 01:57:51 +0000 |
commit | 8a9f2a6bbd6bdf164ca987edac34ac72447881a5 (patch) | |
tree | 0722c462bd08d8478a0d1861b10b9f966193505e /libgo/runtime | |
parent | c8530c410972f09b88bb143e5e5a4910bd72b2ee (diff) | |
download | gcc-8a9f2a6bbd6bdf164ca987edac34ac72447881a5.zip gcc-8a9f2a6bbd6bdf164ca987edac34ac72447881a5.tar.gz gcc-8a9f2a6bbd6bdf164ca987edac34ac72447881a5.tar.bz2 |
compiler, runtime: harmonize types referenced by both C and Go
Compiling with LTO revealed a number of cases in the runtime and
standard library where C and Go disagreed about the type of an object or
function (or where Go and code generated by the compiler disagreed). In
all cases the underlying representation was the same (e.g., uintptr vs.
void*), so this wasn't causing actual problems, but it did result in a
number of annoying warnings when compiling with LTO.
Reviewed-on: https://go-review.googlesource.com/c/160700
From-SVN: r268923
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/go-caller.c | 4 | ||||
-rw-r--r-- | libgo/runtime/go-callers.c | 6 | ||||
-rw-r--r-- | libgo/runtime/go-libmain.c | 2 | ||||
-rw-r--r-- | libgo/runtime/go-main.c | 2 | ||||
-rw-r--r-- | libgo/runtime/go-reflect-call.c | 3 | ||||
-rw-r--r-- | libgo/runtime/go-varargs.c | 11 | ||||
-rw-r--r-- | libgo/runtime/panic.c | 2 | ||||
-rw-r--r-- | libgo/runtime/runtime.h | 6 | ||||
-rw-r--r-- | libgo/runtime/stack.c | 6 |
9 files changed, 27 insertions, 15 deletions
diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c index 6fe4340..2143446 100644 --- a/libgo/runtime/go-caller.c +++ b/libgo/runtime/go-caller.c @@ -192,12 +192,12 @@ struct caller_ret _Bool ok; }; -struct caller_ret Caller (int n) __asm__ (GOSYM_PREFIX "runtime.Caller"); +struct caller_ret Caller (intgo n) __asm__ (GOSYM_PREFIX "runtime.Caller"); /* Implement runtime.Caller. */ struct caller_ret -Caller (int skip) +Caller (intgo skip) { struct caller_ret ret; Location loc; diff --git a/libgo/runtime/go-callers.c b/libgo/runtime/go-callers.c index 7ea70851..a72b4e8 100644 --- a/libgo/runtime/go-callers.c +++ b/libgo/runtime/go-callers.c @@ -236,11 +236,11 @@ runtime_callers (int32 skip, Location *locbuf, int32 m, bool keep_thunks) return data.index; } -int Callers (int, struct __go_open_array) +intgo Callers (intgo, struct __go_open_array) __asm__ (GOSYM_PREFIX "runtime.Callers"); -int -Callers (int skip, struct __go_open_array pc) +intgo +Callers (intgo skip, struct __go_open_array pc) { Location *locbuf; int ret; diff --git a/libgo/runtime/go-libmain.c b/libgo/runtime/go-libmain.c index 4f47639..00a8e6b 100644 --- a/libgo/runtime/go-libmain.c +++ b/libgo/runtime/go-libmain.c @@ -231,7 +231,7 @@ gostart (void *arg) setpagesize (getpagesize ()); runtime_sched = runtime_getsched(); runtime_schedinit (); - __go_go (runtime_main, NULL); + __go_go ((uintptr)(runtime_main), NULL); runtime_mstart (runtime_m ()); abort (); } diff --git a/libgo/runtime/go-main.c b/libgo/runtime/go-main.c index 1048161..301ac4e 100644 --- a/libgo/runtime/go-main.c +++ b/libgo/runtime/go-main.c @@ -55,7 +55,7 @@ main (int argc, char **argv) setpagesize (getpagesize ()); runtime_sched = runtime_getsched(); runtime_schedinit (); - __go_go (runtime_main, NULL); + __go_go ((uintptr)(runtime_main), NULL); runtime_mstart (runtime_m ()); abort (); } diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c index 6a9a7f3..abd598b 100644 --- a/libgo/runtime/go-reflect-call.c +++ b/libgo/runtime/go-reflect-call.c @@ -229,7 +229,8 @@ reflect_call (const struct __go_func_type *func_type, FuncVal *func_val, call_result = (unsigned char *) malloc (go_results_size (func_type)); - ffi_call_go (&cif, func_val->fn, call_result, params, func_val); + ffi_call_go (&cif, (void (*)(void)) func_val->fn, call_result, params, + func_val); /* Some day we may need to free result values if RESULTS is NULL. */ diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c index 691ee56..dda9959 100644 --- a/libgo/runtime/go-varargs.c +++ b/libgo/runtime/go-varargs.c @@ -89,3 +89,14 @@ __go_openat (int fd, char *path, int flags, mode_t mode) } #endif + +// __go_syscall6 is called by both the runtime and syscall packages. +// We use uintptr_t to make sure that the types match, since the Go +// and C "int" types are not the same. + +uintptr_t +__go_syscall6(uintptr_t flag, uintptr_t a1, uintptr_t a2, uintptr_t a3, + uintptr_t a4, uintptr_t a5, uintptr_t a6) +{ + return syscall (flag, a1, a2, a3, a4, a5, a6); +} diff --git a/libgo/runtime/panic.c b/libgo/runtime/panic.c index 9cd69ee..9025505 100644 --- a/libgo/runtime/panic.c +++ b/libgo/runtime/panic.c @@ -34,7 +34,7 @@ runtime_panicstring(const char *s) runtime_throw("panic holding locks"); } } - runtime_newErrorCString(s, &err); + runtime_newErrorCString((uintptr) s, &err); runtime_panic(err); } diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 5da34fb..a6135b0 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -94,7 +94,7 @@ struct String struct FuncVal { - void (*fn)(void); + uintptr_t fn; // variable-size, fn-specific data here }; @@ -295,7 +295,7 @@ void runtime_entersyscall() __asm__ (GOSYM_PREFIX "runtime.entersyscall"); void runtime_entersyscallblock() __asm__ (GOSYM_PREFIX "runtime.entersyscallblock"); -G* __go_go(void (*pfn)(void*), void*); +G* __go_go(uintptr, void*); int32 runtime_callers(int32, Location*, int32, bool keep_callers); int64 runtime_nanotime(void) // monotonic time __asm__(GOSYM_PREFIX "runtime.nanotime"); @@ -389,7 +389,7 @@ void runtime_panic(Eface) /* * runtime c-called (but written in Go) */ -void runtime_newErrorCString(const char*, Eface*) +void runtime_newErrorCString(uintptr, Eface*) __asm__ (GOSYM_PREFIX "runtime.NewErrorCString"); /* diff --git a/libgo/runtime/stack.c b/libgo/runtime/stack.c index 2d5d1e0..be5e523 100644 --- a/libgo/runtime/stack.c +++ b/libgo/runtime/stack.c @@ -20,7 +20,7 @@ extern void * __splitstack_find_context (void *context[10], size_t *, void **, // tail call to doscanstack1. #pragma GCC optimize ("-fno-optimize-sibling-calls") -extern void scanstackblock(void *addr, uintptr size, void *gcw) +extern void scanstackblock(uintptr addr, uintptr size, void *gcw) __asm__("runtime.scanstackblock"); static bool doscanstack1(G*, void*) @@ -84,11 +84,11 @@ static bool doscanstack1(G *gp, void *gcw) { } } if(sp != nil) { - scanstackblock(sp, (uintptr)(spsize), gcw); + scanstackblock((uintptr)(sp), (uintptr)(spsize), gcw); while((sp = __splitstack_find(next_segment, next_sp, &spsize, &next_segment, &next_sp, &initial_sp)) != nil) - scanstackblock(sp, (uintptr)(spsize), gcw); + scanstackblock((uintptr)(sp), (uintptr)(spsize), gcw); } #else byte* bottom; |