nvramtool: Fix building on Linux systems with musl libc

Current implementation only supports glibc (by looking for __GLIBC__)
and fails to build on systems with alternative libc implementations,
such as musl; sys/io.h is never included, there are no outb/inb
functions which results in undefined references at linking stage.

Using __linux__ instead of __GLIBC__ to test whether the system is Linux
seems to be a more proper way to detect Linux and it also fixes
nvramtool compilation on musl systems.

Tested on Gentoo Linux with musl 1.2.2 (builds and works fine) and Void
Linux with glibc (still builds and works fine).

Change-Id: Idcdc3a033b40f16a6053209813f1e06209ee459a
Signed-off-by: Evgeny Zinoviev <me@ch1p.io>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/48757
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Evgeny Zinoviev 2020-12-20 00:40:01 +03:00 committed by Felix Held
parent 58c063ebd0
commit c3566b67f6
1 changed files with 1 additions and 1 deletions

View File

@ -11,7 +11,7 @@
#define INW(x) __extension__ ({ u_int tmp = (x); inw(tmp); })
#define INL(x) __extension__ ({ u_int tmp = (x); inl(tmp); })
#else
#if defined(__GLIBC__) && (defined(__i386__) || defined(__x86_64__))
#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
#include <sys/io.h>
#endif
#if (defined(__MACH__) && defined(__APPLE__))