All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-gpio@vger.kernel.org, Kent Gibson <warthog618@gmail.com>,
	Arnd Bergmann <arnd@kernel.org>
Subject: [PATCH] libgpiod: Fix build failure with musl
Date: Thu,  9 Dec 2021 16:28:53 +0530	[thread overview]
Message-ID: <4a8c598db0a78421b074f19eb2157d89f3198440.1639047500.git.viresh.kumar@linaro.org> (raw)

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

diff --git a/lib/internal.h b/lib/internal.h
index 32f36b5cd4cf..89c94cdd8ef6 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -8,6 +8,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "musl-compat.h"
 #include "uapi/gpio.h"
 
 /* For internal library use only. */
diff --git a/lib/musl-compat.h b/lib/musl-compat.h
new file mode 100644
index 000000000000..69787de86f7c
--- /dev/null
+++ b/lib/musl-compat.h
@@ -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__ */
-- 
2.31.1.272.g89b43f80a514


             reply	other threads:[~2021-12-09 10:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 10:58 Viresh Kumar [this message]
2021-12-09 11:59 ` [PATCH] libgpiod: Fix build failure with musl Viresh Kumar
2021-12-09 15:16 ` Andy Shevchenko
2021-12-09 18:32   ` Bartosz Golaszewski
2021-12-10  3:38     ` Viresh Kumar
2021-12-10 10:58       ` Viresh Kumar
2021-12-10 13:34         ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a8c598db0a78421b074f19eb2157d89f3198440.1639047500.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=arnd@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.