Beispiel #1
0
void
syscall_cgocallback ()
{
  M *mp;

  mp = runtime_m ();
  if (mp == NULL)
    {
      runtime_needm ();
      mp = runtime_m ();
      mp->dropextram = true;
    }

  runtime_exitsyscall (0);

  if (runtime_m ()->ncgo == 0)
    {
      /* The C call to Go came from a thread not currently running any
	 Go.  In the case of -buildmode=c-archive or c-shared, this
	 call may be coming in before package initialization is
	 complete.  Wait until it is.  */
      chanrecv1 (NULL, runtime_main_init_done, NULL);
    }

  mp = runtime_m ();
  if (mp->needextram)
    {
      mp->needextram = 0;
      runtime_newextram ();
    }
}
Beispiel #2
0
void
_cgo_panic (const char *p)
{
  intgo len;
  unsigned char *data;
  String *ps;
  Eface e;
  const struct __go_type_descriptor *td;

  runtime_exitsyscall (0);
  len = __builtin_strlen (p);
  data = alloc_saved (len);
  __builtin_memcpy (data, p, len);
  ps = alloc_saved (sizeof *ps);
  ps->str = data;
  ps->len = len;
  td = &string_type_descriptor;
  memcpy(&e._type, &td, sizeof td); /* This is a const_cast.  */
  e.data = ps;

  /* We don't call runtime_entersyscall here, because normally what
     will happen is that we will walk up the stack to a Go deferred
     function that calls recover.  However, this will do the wrong
     thing if this panic is recovered and the stack unwinding is
     caught by a C++ exception handler.  It might be possible to
     handle this by calling runtime_entersyscall in the personality
     function in go-unwind.c.  FIXME.  */

  __go_panic (e);
}
Beispiel #3
0
void *
_cgo_allocate (size_t n)
{
  void *ret;

  runtime_exitsyscall (0);
  ret = alloc_saved (n);
  runtime_entersyscall (0);
  return ret;
}
Beispiel #4
0
Datei: go-cgo.c Projekt: axw/llgo
void
syscall_cgocalldone ()
{
  G* g;

  g = runtime_g ();
  __go_assert (g != NULL);
  --g->ncgo;
  if (g->ncgo == 0)
    {
      /* We are going back to Go, and we are not in a recursive call.
	 Let the garbage collector clean up any unreferenced
	 memory.  */
      g->cgomal = NULL;
    }

  /* If we are invoked because the C function called _cgo_panic, then
     _cgo_panic will already have exited syscall mode.  */
  if (g->status == Gsyscall)
    runtime_exitsyscall ();
}
Beispiel #5
0
void
runtime_testing_exitsyscall()
{
	runtime_exitsyscall();
}
Beispiel #6
0
void
syscall_cgocallback ()
{
  runtime_exitsyscall ();
}