Golang on Genode: a follow-up

Taru Karttunen taruti at ...102...
Wed May 31 15:22:40 CEST 2017


On 31.05 14:33, Josef Söntgen wrote:
> Hello Rolf,
> 
> * Rolf Sommerhalder <rolf.sommerhalder at ...278...> [2017-05-25 19:59:34 +0200]:
> > After following the threads about Golang on Genode and reviewing
> > AtmanOS, I suspect that AtmanOS could facilitate bringing Go to
> > Genode, for example by making AtmanOS target Virtualbox in addition to
> > Xen (maybe not so elegant), or by adapting/replacing AtmanOS'
> > microkernel with Genode, and porting the Go runtime, standard library
> > and system packages that AtmanOS wrote in Go for Xen or its own
> > microkernel, respectively (maybe preferable over Virtualbox).
> > 
> > Am I reading too much into it? Would it be worth diving deeper into
> > AtmanOS' sources? Any thoughts, comments?
> 
> It definitely looks interesting wrt to investigating how much
> infrastructure the current Go runtime needs or rather on what
> functionality from the underlying system it depends. So diving
> into the source code would be worthwhile indeed. It still stands
> to reason how to properly wrap the Genode's C++ API, though.

Typically C++ APIs are wrapped in Go with a thin wrapper of C++ 
extern "C" functions that also translate such exceptions into
errors. SWIG can do this in theory for Go, but in practice 
doing it by hand or quick scripting tends to be easier unless 
deep class hierarchies are involved. The wrapper functions
are then called from Go with cgo.

They tend to look like:

extern "C" myerror_t libfoo_baz(baz* ptr, int arg, foo* ret) {
  try {
     *ret = ptr->bazbaz(arg);
     return noerror;
   } catch(...) {
    return errorcode;
  }
}

If lots of templates are involved then things become somewhat harder.

- Taru Karttunen




More information about the users mailing list