Commit 77719d8a authored by Kirill Smelkov's avatar Kirill Smelkov

libgolang: Fix build with old gcc

Gcc 5.4 from Ubuntu 16.04 LTS complains e.g.

    ./golang/libgolang.h: In function ‘golang::_selcase golang::_selrecv_(golang::_chan*, void*, bool*)’:
    ./golang/libgolang.h:227:5: sorry, unimplemented: non-trivial designated initializers not supported
         };
         ^

The problem started to appear after 47111d3e (libgolang: Teach select to accept
inplace tx data) when we moved _selcase.ptxrx inside union.

Let's add workaround for older compilers, even though e.g. gcc 8.3 from Debian
10 accepts existing code just fine.
parent b316e504
...@@ -194,9 +194,9 @@ _selcase _selsend(_chan *ch, const void *ptx) { ...@@ -194,9 +194,9 @@ _selcase _selsend(_chan *ch, const void *ptx) {
.op = _CHANSEND, .op = _CHANSEND,
.flags = (enum _selflags)0, .flags = (enum _selflags)0,
.user = 0xff, .user = 0xff,
.ptxrx = (void *)ptx,
.rxok = NULL,
}; };
_ .ptxrx = (void *)ptx;
_ .rxok = NULL;
return _; return _;
} }
...@@ -208,9 +208,9 @@ _selcase _selrecv(_chan *ch, void *prx) { ...@@ -208,9 +208,9 @@ _selcase _selrecv(_chan *ch, void *prx) {
.op = _CHANRECV, .op = _CHANRECV,
.flags = (enum _selflags)0, .flags = (enum _selflags)0,
.user = 0xff, .user = 0xff,
.ptxrx = prx,
.rxok = NULL,
}; };
_ .ptxrx = prx;
_ .rxok = NULL;
return _; return _;
} }
...@@ -222,9 +222,9 @@ _selcase _selrecv_(_chan *ch, void *prx, bool *pok) { ...@@ -222,9 +222,9 @@ _selcase _selrecv_(_chan *ch, void *prx, bool *pok) {
.op = _CHANRECV, .op = _CHANRECV,
.flags = (enum _selflags)0, .flags = (enum _selflags)0,
.user = 0xff, .user = 0xff,
.ptxrx = prx,
.rxok = pok,
}; };
_ .ptxrx = prx;
_ .rxok = pok;
return _; return _;
} }
......
...@@ -842,14 +842,18 @@ void _chan::_dataq_popleft(void *prx) { ...@@ -842,14 +842,18 @@ void _chan::_dataq_popleft(void *prx) {
// ---- select ---- // ---- select ----
// _default represents default case for _select. // _default represents default case for _select.
const _selcase _default = { static _selcase _mkdefault() {
.ch = NULL, _selcase _ = {
.op = _DEFAULT, .ch = NULL,
.flags = (_selflags)0, .op = _DEFAULT,
.user = 0xff, .flags = (_selflags)0,
.ptxrx = NULL, .user = 0xff,
.rxok = NULL, };
}; _ .ptxrx = NULL;
_ .rxok = NULL;
return _;
}
const _selcase _default = _mkdefault();
const void *_selcase::ptx() const { const void *_selcase::ptx() const {
const _selcase *cas = this; const _selcase *cas = this;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment