mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: "Enrico Jörns" <ejo@pengutronix.de>,
	"Ahmad Fatoum" <a.fatoum@pengutronix.de>
Subject: [PATCH master v2] scripts: include/linux/types.h: define loff_t for musl
Date: Mon, 27 Jan 2025 15:31:46 +0100	[thread overview]
Message-ID: <20250127143146.2965544-1-a.fatoum@pengutronix.de> (raw)

musl doesn't define loff_t, but glibc does and both of them define
__linux__. This leads to build errors with musl when code makes it into
scripts/ that uses loff_t. This was already fixed once e.g. in commit
c0d065fb0aa0 ("scripts: bareboximd: remove usage of loff_t").

Instead of playing whack-a-mole in future, let's just define loff_t
for non-glibc builds of scripts/.

Also, make sure <linux/types.h> is always included for scripts/common.h,
which is the only header currently making use of loff_t.

Fixes: 5171f4d0696f ("scripts: implement read_fd and pread_full for tools")
Reported-by: Enrico Jörns <ejo@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - include <linux/types.h> from scripts/common.h (Enrico)
---
 scripts/common.h              | 2 ++
 scripts/include/linux/types.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/common.h b/scripts/common.h
index a0d16606b5d9..21ec576a5be9 100644
--- a/scripts/common.h
+++ b/scripts/common.h
@@ -1,6 +1,8 @@
 #ifndef __COMMON_H
 #define __COMMON_H
 
+#include <linux/types.h>
+
 int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_size);
 void *read_file(const char *filename, size_t *size);
 void *read_fd(int fd, size_t *out_size);
diff --git a/scripts/include/linux/types.h b/scripts/include/linux/types.h
index e81d7e810126..02a330cd4e79 100644
--- a/scripts/include/linux/types.h
+++ b/scripts/include/linux/types.h
@@ -14,7 +14,7 @@ typedef int16_t __s16;
 typedef uint8_t __u8;
 typedef int8_t __s8;
 
-#ifndef __linux__
+#ifndef __GLIBC__
 typedef long long loff_t;
 #endif
 
-- 
2.39.5




                 reply	other threads:[~2025-01-27 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250127143146.2965544-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=ejo@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox