All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/mbuffer: fix build with powerpc
@ 2020-04-21 12:38 Fabrice Fontaine
  2020-04-21 14:51 ` Thomas Petazzoni
  0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Fontaine @ 2020-04-21 12:38 UTC (permalink / raw)
  To: buildroot

Fixes:
 - http://autobuild.buildroot.org/results/5f4e9079b3377a869ec7002a8138b80eb6194bbb

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 .../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

diff --git a/package/mbuffer/0002-log.c-fix-build-with-powerpc.patch b/package/mbuffer/0002-log.c-fix-build-with-powerpc.patch
new file mode 100644
index 0000000000..9873a72d01
--- /dev/null
+++ b/package/mbuffer/0002-log.c-fix-build-with-powerpc.patch
@@ -0,0 +1,38 @@
+From 9fbda0adbf59a44f5f0d725f5c31f88ccec7ca56 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+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 <fontaine.fabrice@gmail.com>
+[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
+
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Buildroot] [PATCH 1/1] package/mbuffer: fix build with powerpc
  2020-04-21 12:38 [Buildroot] [PATCH 1/1] package/mbuffer: fix build with powerpc Fabrice Fontaine
@ 2020-04-21 14:51 ` Thomas Petazzoni
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni @ 2020-04-21 14:51 UTC (permalink / raw)
  To: buildroot

Hello Fabrice,

On Tue, 21 Apr 2020 14:38:52 +0200
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> ++#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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-21 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 12:38 [Buildroot] [PATCH 1/1] package/mbuffer: fix build with powerpc Fabrice Fontaine
2020-04-21 14:51 ` Thomas Petazzoni

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.