-db738935c77443840994e5a9f77e619e67a4c43a
+11fd9208f8545e882f945d3ed86fcc33abf1a61b
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
// 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)
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()) == "_")
}
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);
}
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;
// license that can be found in the LICENSE file.
#include "runtime.h"
-#include "go-type.h"
#ifdef USE_LIBFFI
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
#include <stdlib.h>
#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;
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;
}
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
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. */
#include "runtime.h"
#include "go-assert.h"
-#include "go-type.h"
#ifdef USE_LIBFFI
#include "ffi.h"
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:
{
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);
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
{
__builtin_memcpy (&u.buf, call_result, sizeof (ffi_arg));
v = u.v;
- switch (types[0]->__size)
+ switch (types[0]->size)
{
case 1:
{
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;
/* 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
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));
#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)),
+++ /dev/null
-/* 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) */
#include <stddef.h>
#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[]
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
};
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. */
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
};
#include <stdarg.h>
#include "runtime.h"
#include "array.h"
-#include "go-type.h"
extern void runtime_printlock(void)
__asm__(GOSYM_PREFIX "runtime.printlock");
#include "runtime.h"
#include "arch.h"
#include "defs.h"
-#include "go-type.h"
#ifdef USING_SPLIT_STACK
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;
// 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
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)
__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");
/*
* 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)
__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);
__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");