From 4a140826453da37a134d792e0224f4e37343e68a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 30 Aug 2019 21:49:49 +0000 Subject: [PATCH] compile, runtime: permit anonymous and empty fields in C header Permit putting structs with anonymous and empty fields in the C header file runtime.inc that is used to build the C runtime code. This is required for upcoming 1.13 support, as the m struct has picked up an anonymous field. Doing this lets the C header contain all the type descriptor structs, so start using those in the C code. This cuts the number of copies of type descriptor definitions from 3 to 2. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192343 From-SVN: r275227 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/gogo.cc | 4 +- gcc/go/gofrontend/types.cc | 11 +- libgo/go/reflect/makefunc_ffi_c.c | 1 - libgo/mkruntimeinc.sh | 8 +- libgo/runtime/go-construct-map.c | 15 +- libgo/runtime/go-fieldtrack.c | 4 +- libgo/runtime/go-reflect-call.c | 80 +++++------ libgo/runtime/go-type.h | 229 ------------------------------ libgo/runtime/go-unsafe-pointer.c | 69 ++++----- libgo/runtime/print.c | 1 - libgo/runtime/proc.c | 1 - libgo/runtime/runtime.h | 20 ++- 13 files changed, 109 insertions(+), 336 deletions(-) delete mode 100644 libgo/runtime/go-type.h diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3ae07c4f6df..e2459733b3d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -db738935c77443840994e5a9f77e619e67a4c43a +11fd9208f8545e882f945d3ed86fcc33abf1a61b The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 7aec0cf1be5..f8114eceac3 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -5238,11 +5238,11 @@ Gogo::write_c_header() // package they are mostly types defined by mkrsysinfo.sh based // on the C system header files. We don't need to translate // types to C and back to Go. But do accept the special cases - // _defer and _panic. + // _defer, _panic, and _type. std::string name = Gogo::unpack_hidden_name(no->name()); if (name[0] == '_' && (name[1] < 'A' || name[1] > 'Z') - && (name != "_defer" && name != "_panic")) + && (name != "_defer" && name != "_panic" && name != "_type")) continue; if (no->is_type() && no->type_value()->struct_type() != NULL) diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 20f8f2747f2..0ada84106f9 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -6777,8 +6777,6 @@ Struct_type::can_write_to_c_header( p != fields->end(); ++p) { - if (p->is_anonymous()) - return false; if (!this->can_write_type_to_c_header(p->type(), requires, declare)) return false; if (Gogo::message_name(p->field_name()) == "_") @@ -6847,6 +6845,9 @@ Struct_type::can_write_type_to_c_header( } if (t->struct_type() != NULL) { + // We will accept empty struct fields, but not print them. + if (t->struct_type()->total_field_count() == 0) + return true; requires->push_back(no); return t->struct_type()->can_write_to_c_header(requires, declare); } @@ -6871,6 +6872,12 @@ Struct_type::write_to_c_header(std::ostream& os) const p != fields->end(); ++p) { + // Skip fields that are empty struct types. The C code can't + // refer to them anyhow. + if (p->type()->struct_type() != NULL + && p->type()->struct_type()->total_field_count() == 0) + continue; + os << '\t'; this->write_field_to_c_header(os, p->field_name(), p->type()); os << ';' << std::endl; diff --git a/libgo/go/reflect/makefunc_ffi_c.c b/libgo/go/reflect/makefunc_ffi_c.c index ef5fb9f083f..a0cfb38890e 100644 --- a/libgo/go/reflect/makefunc_ffi_c.c +++ b/libgo/go/reflect/makefunc_ffi_c.c @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. #include "runtime.h" -#include "go-type.h" #ifdef USE_LIBFFI diff --git a/libgo/mkruntimeinc.sh b/libgo/mkruntimeinc.sh index d29da9b6846..24837389f4f 100755 --- a/libgo/mkruntimeinc.sh +++ b/libgo/mkruntimeinc.sh @@ -29,6 +29,12 @@ do sed -e '/struct '${TYPE}' {/,/^}/s/^.*$//' runtime.inc.tmp2 > runtime.inc.tmp3; mv runtime.inc.tmp3 runtime.inc.tmp2 done -sed -e 's/sigset/sigset_go/' runtime.inc.tmp2 > ${OUT} +sed -e 's/sigset/sigset_go/' runtime.inc.tmp2 > runtime.inc.tmp3 +mv runtime.inc.tmp3 runtime.inc.tmp2 + +# Make all the fields of type structs const. +sed -e '/struct .*type {/,/^}/ s/ \(.*;\)/ const \1/' < runtime.inc.tmp2 > runtime.inc.tmp3 +mv -f runtime.inc.tmp3 ${OUT} + rm -f runtime.inc.tmp2 runtime.inc.tmp3 exit 0 diff --git a/libgo/runtime/go-construct-map.c b/libgo/runtime/go-construct-map.c index 0e71ba93aa2..a72105833d8 100644 --- a/libgo/runtime/go-construct-map.c +++ b/libgo/runtime/go-construct-map.c @@ -9,20 +9,17 @@ #include #include "runtime.h" -#include "go-type.h" -extern void *makemap (const struct __go_map_type *, intgo hint, - void *) +extern void *makemap (const struct maptype *, intgo hint, void *) __asm__ (GOSYM_PREFIX "runtime.makemap"); -extern void *mapassign (const struct __go_map_type *, void *hmap, - const void *key) +extern void *mapassign (const struct maptype *, void *hmap, const void *key) __asm__ (GOSYM_PREFIX "runtime.mapassign"); void * -__go_construct_map (const struct __go_map_type *type, - uintptr_t count, uintptr_t entry_size, - uintptr_t val_offset, const void *ventries) +__go_construct_map (const struct maptype *type, uintptr_t count, + uintptr_t entry_size, uintptr_t val_offset, + const void *ventries) { void *ret; const unsigned char *entries; @@ -35,7 +32,7 @@ __go_construct_map (const struct __go_map_type *type, for (i = 0; i < count; ++i) { p = mapassign (type, ret, entries); - typedmemmove (type->__val_type, p, entries + val_offset); + typedmemmove (type->elem, p, entries + val_offset); entries += entry_size; } diff --git a/libgo/runtime/go-fieldtrack.c b/libgo/runtime/go-fieldtrack.c index 4ac0a34ea24..1d850504723 100644 --- a/libgo/runtime/go-fieldtrack.c +++ b/libgo/runtime/go-fieldtrack.c @@ -5,7 +5,6 @@ license that can be found in the LICENSE file. */ #include "runtime.h" -#include "go-type.h" /* The compiler will track fields that have the tag go:"track". Any function that refers to such a field will call this function with a @@ -41,8 +40,7 @@ extern const char __edata[] __attribute__ ((weak)); extern const char __bss_start[] __attribute__ ((weak)); #endif -extern void *mapassign (const struct __go_map_type *, void *hmap, - const void *key) +extern void *mapassign (const struct maptype *, void *hmap, const void *key) __asm__ (GOSYM_PREFIX "runtime.mapassign"); // The type descriptor for map[string] bool. */ diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c index abd598b46c4..ffae9030420 100644 --- a/libgo/runtime/go-reflect-call.c +++ b/libgo/runtime/go-reflect-call.c @@ -10,7 +10,6 @@ #include "runtime.h" #include "go-assert.h" -#include "go-type.h" #ifdef USE_LIBFFI #include "ffi.h" @@ -22,45 +21,44 @@ reflect_call calls a libffi function, which will be compiled without -fsplit-stack, it will always run with a large stack. */ -static size_t go_results_size (const struct __go_func_type *) +static size_t go_results_size (const struct functype *) __attribute__ ((no_split_stack)); -static void go_set_results (const struct __go_func_type *, unsigned char *, - void **) +static void go_set_results (const struct functype *, unsigned char *, void **) __attribute__ ((no_split_stack)); /* Get the total size required for the result parameters of a function. */ static size_t -go_results_size (const struct __go_func_type *func) +go_results_size (const struct functype *func) { int count; - const struct __go_type_descriptor **types; + const struct _type **types; size_t off; size_t maxalign; int i; - count = func->__out.__count; + count = func->out.__count; if (count == 0) return 0; - types = (const struct __go_type_descriptor **) func->__out.__values; + types = (const struct _type **) func->out.__values; /* A single integer return value is always promoted to a full word. */ if (count == 1) { - switch (types[0]->__code & GO_CODE_MASK) + switch (types[0]->kind & kindMask) { - case GO_BOOL: - case GO_INT8: - case GO_INT16: - case GO_INT32: - case GO_UINT8: - case GO_UINT16: - case GO_UINT32: - case GO_INT: - case GO_UINT: + case kindBool: + case kindInt8: + case kindInt16: + case kindInt32: + case kindUint8: + case kindUint16: + case kindUint32: + case kindInt: + case kindUint: return sizeof (ffi_arg); default: @@ -74,11 +72,11 @@ go_results_size (const struct __go_func_type *func) { size_t align; - align = types[i]->__field_align; + align = types[i]->fieldAlign; if (align > maxalign) maxalign = align; off = (off + align - 1) & ~ (align - 1); - off += types[i]->__size; + off += types[i]->size; } off = (off + maxalign - 1) & ~ (maxalign - 1); @@ -96,35 +94,35 @@ go_results_size (const struct __go_func_type *func) into the addresses in RESULTS. */ static void -go_set_results (const struct __go_func_type *func, unsigned char *call_result, +go_set_results (const struct functype *func, unsigned char *call_result, void **results) { int count; - const struct __go_type_descriptor **types; + const struct _type **types; size_t off; int i; - count = func->__out.__count; + count = func->out.__count; if (count == 0) return; - types = (const struct __go_type_descriptor **) func->__out.__values; + types = (const struct _type **) func->out.__values; /* A single integer return value is always promoted to a full word. */ if (count == 1) { - switch (types[0]->__code & GO_CODE_MASK) + switch (types[0]->kind & kindMask) { - case GO_BOOL: - case GO_INT8: - case GO_INT16: - case GO_INT32: - case GO_UINT8: - case GO_UINT16: - case GO_UINT32: - case GO_INT: - case GO_UINT: + case kindBool: + case kindInt8: + case kindInt16: + case kindInt32: + case kindUint8: + case kindUint16: + case kindUint32: + case kindInt: + case kindUint: { union { @@ -136,7 +134,7 @@ go_set_results (const struct __go_func_type *func, unsigned char *call_result, __builtin_memcpy (&u.buf, call_result, sizeof (ffi_arg)); v = u.v; - switch (types[0]->__size) + switch (types[0]->size) { case 1: { @@ -191,8 +189,8 @@ go_set_results (const struct __go_func_type *func, unsigned char *call_result, size_t align; size_t size; - align = types[i]->__field_align; - size = types[i]->__size; + align = types[i]->fieldAlign; + size = types[i]->size; off = (off + align - 1) & ~ (align - 1); __builtin_memcpy (results[i], call_result + off, size); off += size; @@ -201,7 +199,7 @@ go_set_results (const struct __go_func_type *func, unsigned char *call_result, /* The code that converts the Go type to an FFI type is written in Go, so that it can allocate Go heap memory. */ -extern void ffiFuncToCIF(const struct __go_func_type*, _Bool, _Bool, ffi_cif*) +extern void ffiFuncToCIF(const struct functype*, _Bool, _Bool, ffi_cif*) __asm__ ("runtime.ffiFuncToCIF"); /* Call a function. The type of the function is FUNC_TYPE, and the @@ -217,14 +215,14 @@ extern void ffiFuncToCIF(const struct __go_func_type*, _Bool, _Bool, ffi_cif*) regardless of FUNC_TYPE, it is passed as a pointer. */ void -reflect_call (const struct __go_func_type *func_type, FuncVal *func_val, +reflect_call (const struct functype *func_type, FuncVal *func_val, _Bool is_interface, _Bool is_method, void **params, void **results) { ffi_cif cif; unsigned char *call_result; - __go_assert ((func_type->__common.__code & GO_CODE_MASK) == GO_FUNC); + __go_assert ((func_type->typ.kind & kindMask) == kindFunc); ffiFuncToCIF (func_type, is_interface, is_method, &cif); call_result = (unsigned char *) malloc (go_results_size (func_type)); @@ -243,7 +241,7 @@ reflect_call (const struct __go_func_type *func_type, FuncVal *func_val, #else /* !defined(USE_LIBFFI) */ void -reflect_call (const struct __go_func_type *func_type __attribute__ ((unused)), +reflect_call (const struct functype *func_type __attribute__ ((unused)), FuncVal *func_val __attribute__ ((unused)), _Bool is_interface __attribute__ ((unused)), _Bool is_method __attribute__ ((unused)), diff --git a/libgo/runtime/go-type.h b/libgo/runtime/go-type.h deleted file mode 100644 index 1935703acc6..00000000000 --- a/libgo/runtime/go-type.h +++ /dev/null @@ -1,229 +0,0 @@ -/* go-type.h -- basic information for a Go type. - - Copyright 2009 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. */ - -#ifndef LIBGO_GO_TYPE_H -#define LIBGO_GO_TYPE_H - -#include -#include - -#include "array.h" - -struct String; - -/* Many of the types in this file must match the data structures - generated by the compiler, and must also match the Go types which - appear in go/runtime/type.go and go/reflect/type.go. */ - -/* Type kinds. These are used to get the type descriptor to use for - the type itself, when using unsafe.Typeof or unsafe.Reflect. The - values here must match the values generated by the compiler (the - RUNTIME_TYPE_KIND_xxx values in gcc/go/types.h). These are macros - rather than an enum to make it easy to change values in the future - and hard to get confused about it. - - These correspond to the kind values used by the gc compiler. */ - -#define GO_BOOL 1 -#define GO_INT 2 -#define GO_INT8 3 -#define GO_INT16 4 -#define GO_INT32 5 -#define GO_INT64 6 -#define GO_UINT 7 -#define GO_UINT8 8 -#define GO_UINT16 9 -#define GO_UINT32 10 -#define GO_UINT64 11 -#define GO_UINTPTR 12 -#define GO_FLOAT32 13 -#define GO_FLOAT64 14 -#define GO_COMPLEX64 15 -#define GO_COMPLEX128 16 -#define GO_ARRAY 17 -#define GO_CHAN 18 -#define GO_FUNC 19 -#define GO_INTERFACE 20 -#define GO_MAP 21 -#define GO_PTR 22 -#define GO_SLICE 23 -#define GO_STRING 24 -#define GO_STRUCT 25 -#define GO_UNSAFE_POINTER 26 - -#define GO_DIRECT_IFACE (1 << 5) -#define GO_GC_PROG (1 << 6) -#define GO_NO_POINTERS (1 << 7) - -#define GO_CODE_MASK 0x1f - -/* For each Go type the compiler constructs one of these structures. - This is used for type reflection, interfaces, maps, and reference - counting. */ - -struct __go_type_descriptor -{ - /* The size in bytes of a value of this type. Note that all types - in Go have a fixed size. */ - uintptr_t __size; - - /* The size of the memory prefix of a value of this type that holds - all pointers. */ - uintptr_t __ptrdata; - - /* The type's hash code. */ - uint32_t __hash; - - /* The type code for this type, one of the type kind values above. - This is used by unsafe.Reflect and unsafe.Typeof to determine the - type descriptor to return for this type itself. It is also used - by reflect.toType when mapping to a reflect Type structure. */ - unsigned char __code; - - /* The alignment in bytes of a variable with this type. */ - unsigned char __align; - - /* The alignment in bytes of a struct field with this type. */ - unsigned char __field_align; - - /* This function takes a pointer to a value of this type, and the - size of this type, and returns a hash code. We pass the size - explicitly becaues it means that we can share a single instance - of this function for various different types. */ - const FuncVal *__hashfn; - - /* This function takes two pointers to values of this type, and the - size of this type, and returns whether the values are equal. */ - const FuncVal *__equalfn; - - /* The garbage collection data. */ - const byte *__gcdata; - - /* A string describing this type. This is only used for - debugging. */ - const struct String *__reflection; - - /* A pointer to fields which are only used for some types. */ - const struct __go_uncommon_type *__uncommon; - - /* The descriptor for the type which is a pointer to this type. - This may be NULL. */ - const struct __go_type_descriptor *__pointer_to_this; -}; - -/* The information we store for each method of a type. */ - -struct __go_method -{ - /* The name of the method. */ - const struct String *__name; - - /* This is NULL for an exported method, or the name of the package - where it lives. */ - const struct String *__pkg_path; - - /* The type of the method, without the receiver. This will be a - function type. */ - const struct __go_type_descriptor *__mtype; - - /* The type of the method, with the receiver. This will be a - function type. */ - const struct __go_type_descriptor *__type; - - /* A pointer to the code which implements the method. This is - really a function pointer. */ - const void *__function; -}; - -/* Additional information that we keep for named types and for types - with methods. */ - -struct __go_uncommon_type -{ - /* The name of the type. */ - const struct String *__name; - - /* The type's package. This is NULL for builtin types. */ - const struct String *__pkg_path; - - /* The type's methods. This is an array of struct __go_method. */ - struct __go_open_array __methods; -}; - -/* The type descriptor for a function. */ - -struct __go_func_type -{ - /* Starts like all other type descriptors. */ - struct __go_type_descriptor __common; - - /* Whether this is a varargs function. If this is true, there will - be at least one parameter. For "..." the last parameter type is - "interface{}". For "... T" the last parameter type is "[]T". */ - _Bool __dotdotdot; - - /* The input parameter types. This is an array of pointers to - struct __go_type_descriptor. */ - struct __go_open_array __in; - - /* The output parameter types. This is an array of pointers to - struct __go_type_descriptor. */ - struct __go_open_array __out; -}; - -/* A map type. */ - -struct __go_map_type -{ - /* Starts like all other type descriptors. */ - struct __go_type_descriptor __common; - - /* The map key type. */ - const struct __go_type_descriptor *__key_type; - - /* The map value type. */ - const struct __go_type_descriptor *__val_type; - - /* The map bucket type. */ - const struct __go_type_descriptor *__bucket_type; - - /* The map header type. */ - const struct __go_type_descriptor *__hmap_type; - - /* The size of the key slot. */ - uint8_t __key_size; - - /* Whether to store a pointer to key rather than the key itself. */ - uint8_t __indirect_key; - - /* The size of the value slot. */ - uint8_t __value_size; - - /* Whether to store a pointer to value rather than the value itself. */ - uint8_t __indirect_value; - - /* The size of a bucket. */ - uint16_t __bucket_size; - - /* Whether the key type is reflexive--whether k==k for all keys. */ - _Bool __reflexive_key; - - /* Whether we should update the key when overwriting an entry. */ - _Bool __need_key_update; -}; - -/* A pointer type. */ - -struct __go_ptr_type -{ - /* Starts like all other type descriptors. */ - struct __go_type_descriptor __common; - - /* The type to which this points. */ - const struct __go_type_descriptor *__element_type; -}; - -#endif /* !defined(LIBGO_GO_TYPE_H) */ diff --git a/libgo/runtime/go-unsafe-pointer.c b/libgo/runtime/go-unsafe-pointer.c index 5afd0112fe2..d987acab637 100644 --- a/libgo/runtime/go-unsafe-pointer.c +++ b/libgo/runtime/go-unsafe-pointer.c @@ -7,14 +7,13 @@ #include #include "runtime.h" -#include "go-type.h" /* This file provides the type descriptor for the unsafe.Pointer type. The unsafe package is defined by the compiler itself, which means that there is no package to compile to define the type descriptor. */ -extern const struct __go_type_descriptor unsafe_Pointer +extern const struct _type unsafe_Pointer __asm__ (GOSYM_PREFIX "unsafe.Pointer..d"); extern const byte unsafe_Pointer_gc[] @@ -42,31 +41,33 @@ extern const FuncVal runtime_pointerhash_descriptor extern const FuncVal runtime_pointerequal_descriptor __asm__ (GOSYM_PREFIX "runtime.pointerequal..f"); -const struct __go_type_descriptor unsafe_Pointer = +const struct _type unsafe_Pointer = { - /* __size */ + /* size */ sizeof (void *), - /* __ptrdata */ + /* ptrdata */ sizeof (void *), - /* __hash */ + /* hash */ 78501163U, - /* __code */ - GO_UNSAFE_POINTER | GO_DIRECT_IFACE, - /* __align */ + /* kind */ + kindUnsafePointer | kindDirectIface, + /* align */ __alignof (void *), - /* __field_align */ + /* fieldAlign */ offsetof (struct field_align, p) - 1, - /* __hashfn */ + /* _ */ + 0, + /* hashfn */ &runtime_pointerhash_descriptor, - /* __equalfn */ + /* equalfn */ &runtime_pointerequal_descriptor, - /* __gcdata */ + /* gcdata */ unsafe_Pointer_gc, - /* __reflection */ + /* _string */ &reflection_string, - /* __uncommon */ + /* uncommontype */ NULL, - /* __pointer_to_this */ + /* ptrToThis */ NULL }; @@ -74,7 +75,7 @@ const struct __go_type_descriptor unsafe_Pointer = since any package which refers to that type descriptor will expect it to be defined elsewhere. */ -extern const struct __go_ptr_type pointer_unsafe_Pointer +extern const struct ptrtype pointer_unsafe_Pointer __asm__ (GOSYM_PREFIX "type...1unsafe.Pointer"); /* The reflection string. */ @@ -90,35 +91,37 @@ extern const byte pointer_unsafe_Pointer_gc[] const byte pointer_unsafe_Pointer_gc[] = { 1 }; -const struct __go_ptr_type pointer_unsafe_Pointer = +const struct ptrtype pointer_unsafe_Pointer = { - /* __common */ + /* type */ { - /* __size */ + /* size */ sizeof (void *), - /* __ptrdata */ + /* ptrdata */ sizeof (void *), - /* __hash */ + /* hash */ 1256018616U, - /* __code */ - GO_PTR | GO_DIRECT_IFACE, - /* __align */ + /* kind */ + kindPtr | kindDirectIface, + /* align */ __alignof (void *), - /* __field_align */ + /* fieldAlign */ offsetof (struct field_align, p) - 1, - /* __hashfn */ + /* _ */ + 0, + /*_hashfn */ &runtime_pointerhash_descriptor, - /* __equalfn */ + /* equalfn */ &runtime_pointerequal_descriptor, - /* __gcdata */ + /* gcdata */ pointer_unsafe_Pointer_gc, - /* __reflection */ + /* _string */ &preflection_string, - /* __uncommon */ + /* uncommontype */ NULL, - /* __pointer_to_this */ + /* ptrToThis */ NULL }, - /* __element_type */ + /* elem */ &unsafe_Pointer }; diff --git a/libgo/runtime/print.c b/libgo/runtime/print.c index 4da879620c7..f0269e8d20b 100644 --- a/libgo/runtime/print.c +++ b/libgo/runtime/print.c @@ -7,7 +7,6 @@ #include #include "runtime.h" #include "array.h" -#include "go-type.h" extern void runtime_printlock(void) __asm__(GOSYM_PREFIX "runtime.printlock"); diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 523dfd9ff14..274ce01c0bf 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -18,7 +18,6 @@ #include "runtime.h" #include "arch.h" #include "defs.h" -#include "go-type.h" #ifdef USING_SPLIT_STACK diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 4102f5da0a0..8ff578ecf82 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -72,14 +72,9 @@ typedef struct schedt Sched; typedef struct __go_open_array Slice; typedef struct iface Iface; typedef struct eface Eface; -typedef struct __go_type_descriptor Type; typedef struct _defer Defer; typedef struct _panic Panic; -typedef struct __go_ptr_type PtrType; -typedef struct __go_func_type FuncType; -typedef struct __go_map_type MapType; - typedef struct tracebackg Traceback; typedef struct location Location; @@ -96,6 +91,10 @@ struct FuncVal // variable-size, fn-specific data here }; +// Type structs will be defined by runtime.inc. +struct _type; +struct functype; + #include "array.h" // Rename Go types generated by mkrsysinfo.sh from C types, to avoid @@ -208,7 +207,6 @@ intgo runtime_findnull(const byte*) void runtime_gogo(G*) __asm__ (GOSYM_PREFIX "runtime.gogo"); -struct __go_func_type; void runtime_args(int32, byte**) __asm__ (GOSYM_PREFIX "runtime.args"); void runtime_osinit(void) @@ -249,7 +247,7 @@ void runtime_signalstack(byte*, uintptr) __asm__ (GOSYM_PREFIX "runtime.signalstack"); void runtime_mallocinit(void) __asm__ (GOSYM_PREFIX "runtime.mallocinit"); -void* runtime_mallocgc(uintptr, const Type*, bool) +void* runtime_mallocgc(uintptr, const struct _type*, bool) __asm__ (GOSYM_PREFIX "runtime.mallocgc"); void* runtime_sysAlloc(uintptr, uint64*) __asm__ (GOSYM_PREFIX "runtime.sysAlloc"); @@ -366,7 +364,7 @@ void __wrap_rtems_task_variable_add(void **); /* * runtime go-called */ -void reflect_call(const struct __go_func_type *, FuncVal *, _Bool, _Bool, +void reflect_call(const struct functype *, FuncVal *, _Bool, _Bool, void **, void **) __asm__ (GOSYM_PREFIX "runtime.reflectcall"); void runtime_panic(Eface) @@ -442,9 +440,7 @@ extern void _cgo_notify_runtime_init_done (void) __asm__ (GOSYM_PREFIX "runtime._cgo_notify_runtime_init_done"); extern _Bool runtime_iscgo; extern uintptr __go_end __attribute__ ((weak)); -extern void *getitab(const struct __go_type_descriptor *, - const struct __go_type_descriptor *, - _Bool) +extern void *getitab(const struct _type *, const struct _type *, _Bool) __asm__ (GOSYM_PREFIX "runtime.getitab"); extern void runtime_cpuinit(void); @@ -454,7 +450,7 @@ extern void setIsCgo(void) __asm__ (GOSYM_PREFIX "runtime.setIsCgo"); extern void setSupportAES(bool) __asm__ (GOSYM_PREFIX "runtime.setSupportAES"); -extern void typedmemmove(const Type *, void *, const void *) +extern void typedmemmove(const struct _type *, void *, const void *) __asm__ (GOSYM_PREFIX "runtime.typedmemmove"); extern Sched* runtime_getsched(void) __asm__ (GOSYM_PREFIX "runtime.getsched"); -- 2.30.2