[gdb/build] Fix build on postmarketos
commit97e9c24c38513a69db81fe4c8206785c3a7050af
authorTom de Vries <tdevries@suse.de>
Thu, 14 Mar 2024 20:28:44 +0000 (14 21:28 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 14 Mar 2024 20:28:44 +0000 (14 21:28 +0100)
treeb1986749a3c67350a8208ae9e39fbfe028f953ba
parentda48217f315084097ef25226c0acab3bbd55ebd3
[gdb/build] Fix build on postmarketos

I tried building gdbserver on postmarketos (which is based on alpine linux,
which uses musl libc), and ran into:
...
gdbserver/linux-low.cc: In lambda function:
gdbserver/linux-low.cc:1907:41: error: \
  'W_EXITCODE' was not declared in this scope
 1907 |               mark_lwp_dead (leader_lp, W_EXITCODE (0, 0), true);
      |                                         ^~~~~~~~~~
...

The macro W_EXITCODE is not defined in gdbsupport/gdb_wait.h.

OTOH, WSETEXIT is defined there, but unused:
...
 /* These are not defined in POSIX, but are used by our programs.  */

 #ifndef WSETEXIT
 # ifdef W_EXITCODE
 #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
 # else
 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
 # endif
 #endif
...

Fix this by dropping the WSETEXIT definition, and instead defining W_EXITCODE.

Tested on x86_64-linux, in combination with an "#undef W_EXITCODE" to make
sure the definition is exercised.

Approved-By: Tom Tromey <tom@tromey.com>
PR build/31483
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31483
gdbsupport/gdb_wait.h