package/mbuffer: fix build with powerpc
PATCH 1/1 package/mbuffer: fix build with powerpc
Fixes:
- http://autobuild.buildroot.org/results/5f4e9079b3377a869ec7002a8138b80eb6194bbb
--- .../0002-log.c-fix-build-with-powerpc.patch | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/mbuffer/0002-log.c-fix-build-with-powerpc.patch
package/mbuffer/0002-log.c-fix-build-with-powerpc.patch new file +38 -0
@@ -0,0 +1,38 @@ +From 9fbda0adbf59a44f5f0d725f5c31f88ccec7ca56 Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine <[email protected]> +Date: Tue, 21 Apr 2020 14:30:20 +0200 +Subject: [PATCH] log.c: fix build with powerpc + +Include linux/limits.h if __linux__ is defined to avoid the following +build failure: + +log.c: In function 'infomsg': +log.c:123:12: error: 'PIPE_BUF' undeclared (first use in this function) + if (s <= PIPE_BUF) { + ^~~~~~~~ + +Fixes: + - http://autobuild.buildroot.org/results/5f4e9079b3377a869ec7002a8138b80eb6194bbb + +Signed-off-by: Fabrice Fontaine <[email protected]> +[Upstream status: sent to thomas at maier-komor.de] +--- + log.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/log.c b/log.c +index 6ea6507..738d493 100644 +--- a/log.c ++++ b/log.c +@@ -29,7 +29,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +-#if defined(__linux) ++#if defined(__linux) || defined(__linux__) + #include <linux/limits.h> + #elif defined(__bsd) + #include <sys/syslimits.h> +-- +2.25.1 +
Signature · 1 line
2.25.1
PATCH 1/1 package/mbuffer: fix build with powerpc
Hello Fabrice,
Quoted 2 lines · On Tue, 21 Apr 2020 14:38:52 +0200 Fabrice Fontaine…
++#if
defined(__linux)||defined(__linux__)
+ #include <linux/limits.h>
This shouldn't include <linux/limits.h> directly. Indeed, PIPE_BUF is defined by the POSIX standard as being defined in <limits.h>, see man limits.h(0P):
{PIPE_BUF}
Maximum number of bytes that is guaranteed to be atomic when writing to a pipe.
Minimum Acceptable Value: {_POSIX_PIPE_BUF}However, it is only defined if _POSIX_SOURCE is defined, which may gets done automatically or not depending on which C standard you're building with.
Demo:
$ cat toto.c
#include <limits.h>
#include <stdio.h>
int main(void) { printf("%d\n", PIPE_BUF); return 0; }$ gcc -std=c89 -o toto toto.c
toto.c: In function ?main?:
toto.c:4:33: error: ?PIPE_BUF? undeclared (first use in this function)
4 | int main(void) { printf("%d\n", PIPE_BUF); return 0; }
| ^~~~~~~~
toto.c:4:33: note: each undeclared identifier is reported only once for each function it appears in$ gcc -std=gnu89 -o toto toto.c $ # i.e, builds fine!
$ gcc -std=c89 -D_POSIX_SOURCE -o toto toto.c $ # i.e, builds fine!
That being said, it's not your fault: the upstream code already does the bad thing of including <linux/limits.h>.
And BTW, this issue has nothing to do with PowerPC at all. As you can see, even on my x64-64 platform, if you use PIPE_BUF in c89 or c99 code, it doesn't work unless you define _POSIX_SOURCE.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com