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
This commit is contained in:
parent
aff0632d4f
commit
4a14082645
|
@ -1,4 +1,4 @@
|
||||||
db738935c77443840994e5a9f77e619e67a4c43a
|
11fd9208f8545e882f945d3ed86fcc33abf1a61b
|
||||||
|
|
||||||
The first line of this file holds the git revision number of the last
|
The first line of this file holds the git revision number of the last
|
||||||
merge done from the gofrontend repository.
|
merge done from the gofrontend repository.
|
||||||
|
|
|
@ -5238,11 +5238,11 @@ Gogo::write_c_header()
|
||||||
// package they are mostly types defined by mkrsysinfo.sh based
|
// package they are mostly types defined by mkrsysinfo.sh based
|
||||||
// on the C system header files. We don't need to translate
|
// 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
|
// 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());
|
std::string name = Gogo::unpack_hidden_name(no->name());
|
||||||
if (name[0] == '_'
|
if (name[0] == '_'
|
||||||
&& (name[1] < 'A' || name[1] > 'Z')
|
&& (name[1] < 'A' || name[1] > 'Z')
|
||||||
&& (name != "_defer" && name != "_panic"))
|
&& (name != "_defer" && name != "_panic" && name != "_type"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (no->is_type() && no->type_value()->struct_type() != NULL)
|
if (no->is_type() && no->type_value()->struct_type() != NULL)
|
||||||
|
|
|
@ -6777,8 +6777,6 @@ Struct_type::can_write_to_c_header(
|
||||||
p != fields->end();
|
p != fields->end();
|
||||||
++p)
|
++p)
|
||||||
{
|
{
|
||||||
if (p->is_anonymous())
|
|
||||||
return false;
|
|
||||||
if (!this->can_write_type_to_c_header(p->type(), requires, declare))
|
if (!this->can_write_type_to_c_header(p->type(), requires, declare))
|
||||||
return false;
|
return false;
|
||||||
if (Gogo::message_name(p->field_name()) == "_")
|
if (Gogo::message_name(p->field_name()) == "_")
|
||||||
|
@ -6847,6 +6845,9 @@ Struct_type::can_write_type_to_c_header(
|
||||||
}
|
}
|
||||||
if (t->struct_type() != NULL)
|
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);
|
requires->push_back(no);
|
||||||
return t->struct_type()->can_write_to_c_header(requires, declare);
|
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 != fields->end();
|
||||||
++p)
|
++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';
|
os << '\t';
|
||||||
this->write_field_to_c_header(os, p->field_name(), p->type());
|
this->write_field_to_c_header(os, p->field_name(), p->type());
|
||||||
os << ';' << std::endl;
|
os << ';' << std::endl;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
#ifdef USE_LIBFFI
|
#ifdef USE_LIBFFI
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,12 @@ do
|
||||||
sed -e '/struct '${TYPE}' {/,/^}/s/^.*$//' runtime.inc.tmp2 > runtime.inc.tmp3;
|
sed -e '/struct '${TYPE}' {/,/^}/s/^.*$//' runtime.inc.tmp2 > runtime.inc.tmp3;
|
||||||
mv runtime.inc.tmp3 runtime.inc.tmp2
|
mv runtime.inc.tmp3 runtime.inc.tmp2
|
||||||
done
|
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
|
rm -f runtime.inc.tmp2 runtime.inc.tmp3
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -9,20 +9,17 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
extern void *makemap (const struct __go_map_type *, intgo hint,
|
extern void *makemap (const struct maptype *, intgo hint, void *)
|
||||||
void *)
|
|
||||||
__asm__ (GOSYM_PREFIX "runtime.makemap");
|
__asm__ (GOSYM_PREFIX "runtime.makemap");
|
||||||
|
|
||||||
extern void *mapassign (const struct __go_map_type *, void *hmap,
|
extern void *mapassign (const struct maptype *, void *hmap, const void *key)
|
||||||
const void *key)
|
|
||||||
__asm__ (GOSYM_PREFIX "runtime.mapassign");
|
__asm__ (GOSYM_PREFIX "runtime.mapassign");
|
||||||
|
|
||||||
void *
|
void *
|
||||||
__go_construct_map (const struct __go_map_type *type,
|
__go_construct_map (const struct maptype *type, uintptr_t count,
|
||||||
uintptr_t count, uintptr_t entry_size,
|
uintptr_t entry_size, uintptr_t val_offset,
|
||||||
uintptr_t val_offset, const void *ventries)
|
const void *ventries)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
const unsigned char *entries;
|
const unsigned char *entries;
|
||||||
|
@ -35,7 +32,7 @@ __go_construct_map (const struct __go_map_type *type,
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
p = mapassign (type, ret, entries);
|
p = mapassign (type, ret, entries);
|
||||||
typedmemmove (type->__val_type, p, entries + val_offset);
|
typedmemmove (type->elem, p, entries + val_offset);
|
||||||
entries += entry_size;
|
entries += entry_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
/* The compiler will track fields that have the tag go:"track". Any
|
/* 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
|
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));
|
extern const char __bss_start[] __attribute__ ((weak));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void *mapassign (const struct __go_map_type *, void *hmap,
|
extern void *mapassign (const struct maptype *, void *hmap, const void *key)
|
||||||
const void *key)
|
|
||||||
__asm__ (GOSYM_PREFIX "runtime.mapassign");
|
__asm__ (GOSYM_PREFIX "runtime.mapassign");
|
||||||
|
|
||||||
// The type descriptor for map[string] bool. */
|
// The type descriptor for map[string] bool. */
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "go-assert.h"
|
#include "go-assert.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
#ifdef USE_LIBFFI
|
#ifdef USE_LIBFFI
|
||||||
#include "ffi.h"
|
#include "ffi.h"
|
||||||
|
@ -22,45 +21,44 @@
|
||||||
reflect_call calls a libffi function, which will be compiled
|
reflect_call calls a libffi function, which will be compiled
|
||||||
without -fsplit-stack, it will always run with a large stack. */
|
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));
|
__attribute__ ((no_split_stack));
|
||||||
static void go_set_results (const struct __go_func_type *, unsigned char *,
|
static void go_set_results (const struct functype *, unsigned char *, void **)
|
||||||
void **)
|
|
||||||
__attribute__ ((no_split_stack));
|
__attribute__ ((no_split_stack));
|
||||||
|
|
||||||
/* Get the total size required for the result parameters of a
|
/* Get the total size required for the result parameters of a
|
||||||
function. */
|
function. */
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
go_results_size (const struct __go_func_type *func)
|
go_results_size (const struct functype *func)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
const struct __go_type_descriptor **types;
|
const struct _type **types;
|
||||||
size_t off;
|
size_t off;
|
||||||
size_t maxalign;
|
size_t maxalign;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
count = func->__out.__count;
|
count = func->out.__count;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return 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
|
/* A single integer return value is always promoted to a full
|
||||||
word. */
|
word. */
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
switch (types[0]->__code & GO_CODE_MASK)
|
switch (types[0]->kind & kindMask)
|
||||||
{
|
{
|
||||||
case GO_BOOL:
|
case kindBool:
|
||||||
case GO_INT8:
|
case kindInt8:
|
||||||
case GO_INT16:
|
case kindInt16:
|
||||||
case GO_INT32:
|
case kindInt32:
|
||||||
case GO_UINT8:
|
case kindUint8:
|
||||||
case GO_UINT16:
|
case kindUint16:
|
||||||
case GO_UINT32:
|
case kindUint32:
|
||||||
case GO_INT:
|
case kindInt:
|
||||||
case GO_UINT:
|
case kindUint:
|
||||||
return sizeof (ffi_arg);
|
return sizeof (ffi_arg);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -74,11 +72,11 @@ go_results_size (const struct __go_func_type *func)
|
||||||
{
|
{
|
||||||
size_t align;
|
size_t align;
|
||||||
|
|
||||||
align = types[i]->__field_align;
|
align = types[i]->fieldAlign;
|
||||||
if (align > maxalign)
|
if (align > maxalign)
|
||||||
maxalign = align;
|
maxalign = align;
|
||||||
off = (off + align - 1) & ~ (align - 1);
|
off = (off + align - 1) & ~ (align - 1);
|
||||||
off += types[i]->__size;
|
off += types[i]->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
off = (off + maxalign - 1) & ~ (maxalign - 1);
|
off = (off + maxalign - 1) & ~ (maxalign - 1);
|
||||||
|
@ -96,35 +94,35 @@ go_results_size (const struct __go_func_type *func)
|
||||||
into the addresses in RESULTS. */
|
into the addresses in RESULTS. */
|
||||||
|
|
||||||
static void
|
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)
|
void **results)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
const struct __go_type_descriptor **types;
|
const struct _type **types;
|
||||||
size_t off;
|
size_t off;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
count = func->__out.__count;
|
count = func->out.__count;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
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
|
/* A single integer return value is always promoted to a full
|
||||||
word. */
|
word. */
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
switch (types[0]->__code & GO_CODE_MASK)
|
switch (types[0]->kind & kindMask)
|
||||||
{
|
{
|
||||||
case GO_BOOL:
|
case kindBool:
|
||||||
case GO_INT8:
|
case kindInt8:
|
||||||
case GO_INT16:
|
case kindInt16:
|
||||||
case GO_INT32:
|
case kindInt32:
|
||||||
case GO_UINT8:
|
case kindUint8:
|
||||||
case GO_UINT16:
|
case kindUint16:
|
||||||
case GO_UINT32:
|
case kindUint32:
|
||||||
case GO_INT:
|
case kindInt:
|
||||||
case GO_UINT:
|
case kindUint:
|
||||||
{
|
{
|
||||||
union
|
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));
|
__builtin_memcpy (&u.buf, call_result, sizeof (ffi_arg));
|
||||||
v = u.v;
|
v = u.v;
|
||||||
|
|
||||||
switch (types[0]->__size)
|
switch (types[0]->size)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
|
@ -191,8 +189,8 @@ go_set_results (const struct __go_func_type *func, unsigned char *call_result,
|
||||||
size_t align;
|
size_t align;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
align = types[i]->__field_align;
|
align = types[i]->fieldAlign;
|
||||||
size = types[i]->__size;
|
size = types[i]->size;
|
||||||
off = (off + align - 1) & ~ (align - 1);
|
off = (off + align - 1) & ~ (align - 1);
|
||||||
__builtin_memcpy (results[i], call_result + off, size);
|
__builtin_memcpy (results[i], call_result + off, size);
|
||||||
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,
|
/* The code that converts the Go type to an FFI type is written in Go,
|
||||||
so that it can allocate Go heap memory. */
|
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");
|
__asm__ ("runtime.ffiFuncToCIF");
|
||||||
|
|
||||||
/* Call a function. The type of the function is FUNC_TYPE, and the
|
/* 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. */
|
regardless of FUNC_TYPE, it is passed as a pointer. */
|
||||||
|
|
||||||
void
|
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,
|
_Bool is_interface, _Bool is_method, void **params,
|
||||||
void **results)
|
void **results)
|
||||||
{
|
{
|
||||||
ffi_cif cif;
|
ffi_cif cif;
|
||||||
unsigned char *call_result;
|
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);
|
ffiFuncToCIF (func_type, is_interface, is_method, &cif);
|
||||||
|
|
||||||
call_result = (unsigned char *) malloc (go_results_size (func_type));
|
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) */
|
#else /* !defined(USE_LIBFFI) */
|
||||||
|
|
||||||
void
|
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)),
|
FuncVal *func_val __attribute__ ((unused)),
|
||||||
_Bool is_interface __attribute__ ((unused)),
|
_Bool is_interface __attribute__ ((unused)),
|
||||||
_Bool is_method __attribute__ ((unused)),
|
_Bool is_method __attribute__ ((unused)),
|
||||||
|
|
|
@ -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 <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#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) */
|
|
|
@ -7,14 +7,13 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
/* This file provides the type descriptor for the unsafe.Pointer type.
|
/* This file provides the type descriptor for the unsafe.Pointer type.
|
||||||
The unsafe package is defined by the compiler itself, which means
|
The unsafe package is defined by the compiler itself, which means
|
||||||
that there is no package to compile to define the type
|
that there is no package to compile to define the type
|
||||||
descriptor. */
|
descriptor. */
|
||||||
|
|
||||||
extern const struct __go_type_descriptor unsafe_Pointer
|
extern const struct _type unsafe_Pointer
|
||||||
__asm__ (GOSYM_PREFIX "unsafe.Pointer..d");
|
__asm__ (GOSYM_PREFIX "unsafe.Pointer..d");
|
||||||
|
|
||||||
extern const byte unsafe_Pointer_gc[]
|
extern const byte unsafe_Pointer_gc[]
|
||||||
|
@ -42,31 +41,33 @@ extern const FuncVal runtime_pointerhash_descriptor
|
||||||
extern const FuncVal runtime_pointerequal_descriptor
|
extern const FuncVal runtime_pointerequal_descriptor
|
||||||
__asm__ (GOSYM_PREFIX "runtime.pointerequal..f");
|
__asm__ (GOSYM_PREFIX "runtime.pointerequal..f");
|
||||||
|
|
||||||
const struct __go_type_descriptor unsafe_Pointer =
|
const struct _type unsafe_Pointer =
|
||||||
{
|
{
|
||||||
/* __size */
|
/* size */
|
||||||
sizeof (void *),
|
sizeof (void *),
|
||||||
/* __ptrdata */
|
/* ptrdata */
|
||||||
sizeof (void *),
|
sizeof (void *),
|
||||||
/* __hash */
|
/* hash */
|
||||||
78501163U,
|
78501163U,
|
||||||
/* __code */
|
/* kind */
|
||||||
GO_UNSAFE_POINTER | GO_DIRECT_IFACE,
|
kindUnsafePointer | kindDirectIface,
|
||||||
/* __align */
|
/* align */
|
||||||
__alignof (void *),
|
__alignof (void *),
|
||||||
/* __field_align */
|
/* fieldAlign */
|
||||||
offsetof (struct field_align, p) - 1,
|
offsetof (struct field_align, p) - 1,
|
||||||
/* __hashfn */
|
/* _ */
|
||||||
|
0,
|
||||||
|
/* hashfn */
|
||||||
&runtime_pointerhash_descriptor,
|
&runtime_pointerhash_descriptor,
|
||||||
/* __equalfn */
|
/* equalfn */
|
||||||
&runtime_pointerequal_descriptor,
|
&runtime_pointerequal_descriptor,
|
||||||
/* __gcdata */
|
/* gcdata */
|
||||||
unsafe_Pointer_gc,
|
unsafe_Pointer_gc,
|
||||||
/* __reflection */
|
/* _string */
|
||||||
&reflection_string,
|
&reflection_string,
|
||||||
/* __uncommon */
|
/* uncommontype */
|
||||||
NULL,
|
NULL,
|
||||||
/* __pointer_to_this */
|
/* ptrToThis */
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ const struct __go_type_descriptor unsafe_Pointer =
|
||||||
since any package which refers to that type descriptor will expect
|
since any package which refers to that type descriptor will expect
|
||||||
it to be defined elsewhere. */
|
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");
|
__asm__ (GOSYM_PREFIX "type...1unsafe.Pointer");
|
||||||
|
|
||||||
/* The reflection string. */
|
/* The reflection string. */
|
||||||
|
@ -90,35 +91,37 @@ extern const byte pointer_unsafe_Pointer_gc[]
|
||||||
|
|
||||||
const byte pointer_unsafe_Pointer_gc[] = { 1 };
|
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 *),
|
sizeof (void *),
|
||||||
/* __ptrdata */
|
/* ptrdata */
|
||||||
sizeof (void *),
|
sizeof (void *),
|
||||||
/* __hash */
|
/* hash */
|
||||||
1256018616U,
|
1256018616U,
|
||||||
/* __code */
|
/* kind */
|
||||||
GO_PTR | GO_DIRECT_IFACE,
|
kindPtr | kindDirectIface,
|
||||||
/* __align */
|
/* align */
|
||||||
__alignof (void *),
|
__alignof (void *),
|
||||||
/* __field_align */
|
/* fieldAlign */
|
||||||
offsetof (struct field_align, p) - 1,
|
offsetof (struct field_align, p) - 1,
|
||||||
/* __hashfn */
|
/* _ */
|
||||||
|
0,
|
||||||
|
/*_hashfn */
|
||||||
&runtime_pointerhash_descriptor,
|
&runtime_pointerhash_descriptor,
|
||||||
/* __equalfn */
|
/* equalfn */
|
||||||
&runtime_pointerequal_descriptor,
|
&runtime_pointerequal_descriptor,
|
||||||
/* __gcdata */
|
/* gcdata */
|
||||||
pointer_unsafe_Pointer_gc,
|
pointer_unsafe_Pointer_gc,
|
||||||
/* __reflection */
|
/* _string */
|
||||||
&preflection_string,
|
&preflection_string,
|
||||||
/* __uncommon */
|
/* uncommontype */
|
||||||
NULL,
|
NULL,
|
||||||
/* __pointer_to_this */
|
/* ptrToThis */
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
/* __element_type */
|
/* elem */
|
||||||
&unsafe_Pointer
|
&unsafe_Pointer
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "array.h"
|
#include "array.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
extern void runtime_printlock(void)
|
extern void runtime_printlock(void)
|
||||||
__asm__(GOSYM_PREFIX "runtime.printlock");
|
__asm__(GOSYM_PREFIX "runtime.printlock");
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "go-type.h"
|
|
||||||
|
|
||||||
#ifdef USING_SPLIT_STACK
|
#ifdef USING_SPLIT_STACK
|
||||||
|
|
||||||
|
|
|
@ -72,14 +72,9 @@ typedef struct schedt Sched;
|
||||||
typedef struct __go_open_array Slice;
|
typedef struct __go_open_array Slice;
|
||||||
typedef struct iface Iface;
|
typedef struct iface Iface;
|
||||||
typedef struct eface Eface;
|
typedef struct eface Eface;
|
||||||
typedef struct __go_type_descriptor Type;
|
|
||||||
typedef struct _defer Defer;
|
typedef struct _defer Defer;
|
||||||
typedef struct _panic Panic;
|
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 tracebackg Traceback;
|
||||||
|
|
||||||
typedef struct location Location;
|
typedef struct location Location;
|
||||||
|
@ -96,6 +91,10 @@ struct FuncVal
|
||||||
// variable-size, fn-specific data here
|
// variable-size, fn-specific data here
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Type structs will be defined by runtime.inc.
|
||||||
|
struct _type;
|
||||||
|
struct functype;
|
||||||
|
|
||||||
#include "array.h"
|
#include "array.h"
|
||||||
|
|
||||||
// Rename Go types generated by mkrsysinfo.sh from C types, to avoid
|
// 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*)
|
void runtime_gogo(G*)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.gogo");
|
__asm__ (GOSYM_PREFIX "runtime.gogo");
|
||||||
struct __go_func_type;
|
|
||||||
void runtime_args(int32, byte**)
|
void runtime_args(int32, byte**)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.args");
|
__asm__ (GOSYM_PREFIX "runtime.args");
|
||||||
void runtime_osinit(void)
|
void runtime_osinit(void)
|
||||||
|
@ -249,7 +247,7 @@ void runtime_signalstack(byte*, uintptr)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.signalstack");
|
__asm__ (GOSYM_PREFIX "runtime.signalstack");
|
||||||
void runtime_mallocinit(void)
|
void runtime_mallocinit(void)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.mallocinit");
|
__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");
|
__asm__ (GOSYM_PREFIX "runtime.mallocgc");
|
||||||
void* runtime_sysAlloc(uintptr, uint64*)
|
void* runtime_sysAlloc(uintptr, uint64*)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.sysAlloc");
|
__asm__ (GOSYM_PREFIX "runtime.sysAlloc");
|
||||||
|
@ -366,7 +364,7 @@ void __wrap_rtems_task_variable_add(void **);
|
||||||
/*
|
/*
|
||||||
* runtime go-called
|
* 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 **)
|
void **, void **)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.reflectcall");
|
__asm__ (GOSYM_PREFIX "runtime.reflectcall");
|
||||||
void runtime_panic(Eface)
|
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");
|
__asm__ (GOSYM_PREFIX "runtime._cgo_notify_runtime_init_done");
|
||||||
extern _Bool runtime_iscgo;
|
extern _Bool runtime_iscgo;
|
||||||
extern uintptr __go_end __attribute__ ((weak));
|
extern uintptr __go_end __attribute__ ((weak));
|
||||||
extern void *getitab(const struct __go_type_descriptor *,
|
extern void *getitab(const struct _type *, const struct _type *, _Bool)
|
||||||
const struct __go_type_descriptor *,
|
|
||||||
_Bool)
|
|
||||||
__asm__ (GOSYM_PREFIX "runtime.getitab");
|
__asm__ (GOSYM_PREFIX "runtime.getitab");
|
||||||
|
|
||||||
extern void runtime_cpuinit(void);
|
extern void runtime_cpuinit(void);
|
||||||
|
@ -454,7 +450,7 @@ extern void setIsCgo(void)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.setIsCgo");
|
__asm__ (GOSYM_PREFIX "runtime.setIsCgo");
|
||||||
extern void setSupportAES(bool)
|
extern void setSupportAES(bool)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.setSupportAES");
|
__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");
|
__asm__ (GOSYM_PREFIX "runtime.typedmemmove");
|
||||||
extern Sched* runtime_getsched(void)
|
extern Sched* runtime_getsched(void)
|
||||||
__asm__ (GOSYM_PREFIX "runtime.getsched");
|
__asm__ (GOSYM_PREFIX "runtime.getsched");
|
||||||
|
|
Loading…
Reference in New Issue