#include "go-alloc.h"
#include "interface.h"
#include "go-panic.h"
-#include "go-string.h"
-
-/* Go memory allocated by code not written in Go. We keep a linked
- list of these allocations so that the garbage collector can see
- them. */
-
-struct cgoalloc
-{
- struct cgoalloc *next;
- void *alloc;
-};
/* Prepare to call from code written in Go to code written in C or
C++. This takes the current goroutine out of the Go scheduler, as
*/
/* We let Go code call these via the syscall package. */
-void syscall_cgocall(void) __asm__ ("syscall.Cgocall");
-void syscall_cgocalldone(void) __asm__ ("syscall.CgocallDone");
-void syscall_cgocallback(void) __asm__ ("syscall.CgocallBack");
-void syscall_cgocallbackdone(void) __asm__ ("syscall.CgocallBackDone");
+void syscall_cgocall(void) __asm__ (GOSYM_PREFIX "syscall.Cgocall");
+void syscall_cgocalldone(void) __asm__ (GOSYM_PREFIX "syscall.CgocallDone");
+void syscall_cgocallback(void) __asm__ (GOSYM_PREFIX "syscall.CgocallBack");
+void syscall_cgocallbackdone(void) __asm__ (GOSYM_PREFIX "syscall.CgocallBackDone");
void
syscall_cgocall ()
/* We are going back to Go, and we are not in a recursive call.
Let the garbage collector clean up any unreferenced
memory. */
- g->cgoalloc = NULL;
+ g->cgomal = NULL;
}
/* If we are invoked because the C function called _cgo_panic, then
{
void *ret;
G *g;
- struct cgoalloc *c;
+ CgoMal *c;
ret = __go_alloc (n);
g = runtime_g ();
- c = (struct cgoalloc *) __go_alloc (sizeof (struct cgoalloc));
- c->next = g->cgoalloc;
+ c = (CgoMal *) __go_alloc (sizeof (CgoMal));
+ c->next = g->cgomal;
c->alloc = ret;
- g->cgoalloc = c;
+ g->cgomal = c;
return ret;
}
}
extern const struct __go_type_descriptor string_type_descriptor
- asm ("__go_tdn_string");
+ __asm__ (GOSYM_PREFIX "__go_tdn_string");
void
_cgo_panic (const char *p)
{
- int len;
+ intgo len;
unsigned char *data;
- struct __go_string *ps;
+ String *ps;
struct __go_empty_interface e;
runtime_exitsyscall ();
data = alloc_saved (len);
__builtin_memcpy (data, p, len);
ps = alloc_saved (sizeof *ps);
- ps->__data = data;
- ps->__length = len;
+ ps->str = data;
+ ps->len = len;
e.__type_descriptor = &string_type_descriptor;
e.__object = ps;
/* Return the number of CGO calls. */
-int64 runtime_NumCgoCall (void) __asm__ ("runtime.NumCgoCall");
+int64 runtime_NumCgoCall (void) __asm__ (GOSYM_PREFIX "runtime.NumCgoCall");
int64
runtime_NumCgoCall (void)