Commit 8cd0c73f authored by Gwenhael Goavec-Merou's avatar Gwenhael Goavec-Merou Committed by Stefan Tauner
Browse files

Add (implicit) support for musl libc


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>: Contains iopl(2) and x86 I/O port access functions (inb, outb etc).
               Generally Linux-specific but also availble on debian/kFreeBSD.
               Provided by glibc as well as musl and uclibc.
               Include it if we are running Linux or if glibc is detected.
 - <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.

Corresponding to flashrom svn r1898.

The bug report and initial patches were
Signed-off-by: default avatarGwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
Signed-off-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
parent c8305e1d
...@@ -26,12 +26,6 @@ ...@@ -26,12 +26,6 @@
#include "platform.h" #include "platform.h"
#if IS_X86
#if defined(__GLIBC__)
#include <sys/io.h>
#endif
#endif
#if NEED_PCI == 1 #if NEED_PCI == 1
/* /*
* libpci headers use the variable name "index" which triggers shadowing * libpci headers use the variable name "index" which triggers shadowing
...@@ -115,6 +109,7 @@ ...@@ -115,6 +109,7 @@
#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__) #if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__)
/* Nonstandard libc-specific macros for determining endianness. */ /* 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__) #if defined(__GLIBC__)
#include <endian.h> #include <endian.h>
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
...@@ -204,6 +199,13 @@ cpu_to_be(64) ...@@ -204,6 +199,13 @@ cpu_to_be(64)
#if NEED_PCI == 1 #if NEED_PCI == 1
#if IS_X86 #if IS_X86
/* sys/io.h provides iopl(2) and x86 I/O port access functions (inb, outb etc).
* It is included in glibc (thus available also on debian/kFreeBSD) but also in other libcs that mimic glibc,
* e.g. musl and uclibc. */
#if defined(__linux__) || defined(__GLIBC__)
#include <sys/io.h>
#endif
#define __FLASHROM_HAVE_OUTB__ 1 #define __FLASHROM_HAVE_OUTB__ 1
/* for iopl and outb under Solaris */ /* for iopl and outb under Solaris */
......
...@@ -22,13 +22,14 @@ ...@@ -22,13 +22,14 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/spi/spidev.h> #include <linux/spi/spidev.h>
#include <sys/ioctl.h> #include <linux/ioctl.h>
#include "flash.h" #include "flash.h"
#include "chipdrivers.h" #include "chipdrivers.h"
#include "programmer.h" #include "programmer.h"
......
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