[flashrom] [PATCH] Add (implicit) support for musl libc.
Stefan Tauner
stefan.tauner at alumni.tuwien.ac.at
Fri Oct 30 02:42:51 CET 2015
From: Gwenhael Goavec-Merou <gwenhael.goavec-merou at trabucayre.com>
This is mostly achieved by fixing or refining the inclusion of header
files and replacing glibc-specific ifdefs with more generic ones.
- <sys/io.h>: Linux-specific and not only available in glibc. Include it
if we are running Linux and not only if glibc is active.
- <sys/fcntl.h>: should be (and is) replaced by <fcntl.h> (without the
"sys" prefix).
- <linux/spi/spidev.h>: Does not include all necessary headers, namely
_IOC_SIZEBITS that is used in the definition of
SPI_MSGSIZE is not brought in via <linux/ioctl.h>
but instead we relied so far on glibc's including
it via <sys/ioctl.h>. Change that to explicitly
including <linux/ioctl.h>.
- <endian.h>: Would also be available in musl but there is no easy way
to detect it so we do not try yet.
The bug report and initial patches were
Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou at trabucayre.com>
Signed-off-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
---
No regressions detected on the buildbot... flashrom can be built completely
(with libpci, libusb and libftdi programmers) with musl after applying this.
hwaccess.h | 3 ++-
linux_spi.c | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/hwaccess.h b/hwaccess.h
index 3e46192..25b1456 100644
--- a/hwaccess.h
+++ b/hwaccess.h
@@ -27,7 +27,7 @@
#include "platform.h"
#if IS_X86
-#if defined(__GLIBC__)
+#if defined(__linux__)
#include <sys/io.h>
#endif
#endif
@@ -115,6 +115,7 @@
#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__)
/* Nonstandard libc-specific macros for determining endianness. */
+/* musl provides an endian.h as well... but it can not be detected from within C. */
#if defined(__GLIBC__)
#include <endian.h>
#if BYTE_ORDER == LITTLE_ENDIAN
diff --git a/linux_spi.c b/linux_spi.c
index 26725e1..19b4965 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -22,13 +22,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
+#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
-#include <sys/ioctl.h>
+#include <linux/ioctl.h>
#include "flash.h"
#include "chipdrivers.h"
#include "programmer.h"
--
Kind regards, Stefan Tauner
More information about the flashrom
mailing list