@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "musl-compat.h"
#include "uapi/gpio.h"
/* For internal library use only. */
new file mode 100644
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/* SPDX-FileCopyrightText: 2021 Bartosz Golaszewski <bgolaszewski@baylibre.com> */
+
+#ifndef __LIBGPIOD_MUSL_COMPAT_H__
+#define __LIBGPIOD_MUSL_COMPAT_H__
+
+/*
+ * Musl's <sys/ioctl.h> (<bits/ioctl.h>) also defines below macros, un-define
+ * them before adding the ones via <linux/gpio.h> to avoid build failures.
+ */
+
+#undef _IOWR
+#undef _IOR
+#undef _IOW
+#undef _IOC
+#undef _IO
+
+#endif /* __LIBGPIOD_MUSL_COMPAT_H__ */
Musl defines the _IO*() macros in the files included via <sys/ioctl.h> and hence we get redefinition errors during build as <linux/ioctl.h>, included via <uapi/gpio.h>, defines them again. Fix this by undefining the macros between both the includes, document it all in musl-compat.h as well. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- lib/internal.h | 1 + lib/musl-compat.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 lib/musl-compat.h