* [Buildroot] [PATCH 1/1] package/upmpdcli: Add patch to fix OPEN_MAX build error
@ 2015-07-16 20:53 Jörg Krause
2015-07-18 12:36 ` Thomas Petazzoni
0 siblings, 1 reply; 3+ messages in thread
From: Jörg Krause @ 2015-07-16 20:53 UTC (permalink / raw)
To: buildroot
Not all systems define POSIX.1 value OPEN_MAX. In this case just close
all descriptors up to some arbitrary limit - say 256 [1].
Fixes:
http://autobuild.buildroot.net/results/d66/d660a9409552b3e1ad9e3ed716386fd0a67fd8db
http://autobuild.buildroot.net/results/f19/f19e843cdcc968a72919ca3792a90dd40552bd59
http://autobuild.buildroot.net/results/a77/a776001dae51c4dae1f25b3a9bf9a9fe2ca69003
http://autobuild.buildroot.net/results/3e7/3e7590566ed3cc7a1dd412fb66b7b987e847aa25
and many more.
Pull request is opened on github [2].
[1]
Advanced Programming in the UNIX Environment, Richard Stevens, p. 52.
[2]
https://github.com/medoc92/upmpdcli/pull/13
Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
---
.../0001-Fix-undefined-OPEN_MAX-error.patch | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 package/upmpdcli/0001-Fix-undefined-OPEN_MAX-error.patch
diff --git a/package/upmpdcli/0001-Fix-undefined-OPEN_MAX-error.patch b/package/upmpdcli/0001-Fix-undefined-OPEN_MAX-error.patch
new file mode 100644
index 0000000..d74eb99
--- /dev/null
+++ b/package/upmpdcli/0001-Fix-undefined-OPEN_MAX-error.patch
@@ -0,0 +1,37 @@
+From eb2fb0b2ce8987c5288c571cfb0586710c4486bb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
+Date: Thu, 16 Jul 2015 22:24:13 +0200
+Subject: [PATCH 1/1] Fix undefined OPEN_MAX error
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Not all systems define POSIX.1 value OPEN_MAX. In this case just close
+all descriptors up to some arbitrary limit - say 256 [1].
+
+[1]
+Advanced Programming in the UNIX Environment, Richard Stevens, p. 52.
+
+Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
+---
+ src/closefrom.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/closefrom.cpp b/src/closefrom.cpp
+index a713875..4429b20 100644
+--- a/src/closefrom.cpp
++++ b/src/closefrom.cpp
+@@ -154,6 +154,10 @@ int libclf_closefrom(int fd0)
+
+ static int closefrom_maxfd = -1;
+
++#ifndef OPEN_MAX
++#define OPEN_MAX 256 /* Guess */
++#endif
++
+ void libclf_setmaxfd(int max)
+ {
+ closefrom_maxfd = max;
+--
+2.4.6
+
--
2.4.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH 1/1] package/upmpdcli: Add patch to fix OPEN_MAX build error
2015-07-16 20:53 [Buildroot] [PATCH 1/1] package/upmpdcli: Add patch to fix OPEN_MAX build error Jörg Krause
@ 2015-07-18 12:36 ` Thomas Petazzoni
2015-07-19 6:44 ` Jörg Krause
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2015-07-18 12:36 UTC (permalink / raw)
To: buildroot
Dear J?rg Krause,
On Thu, 16 Jul 2015 22:53:12 +0200, J?rg Krause wrote:
> ++#ifndef OPEN_MAX
> ++#define OPEN_MAX 256 /* Guess */
> ++#endif
> ++
This is not the right fix. There is some Linux-specific code in
closefrom.cpp, but it doesn't get used since when you build C++ code
with -std=c++0x, the compiler doesn't define "linux" or "__linux", but
"__linux__", so the following test doesn't work anymore:
#elif (defined(linux) || defined(__linux))
See what the compiler does, without -std=c++0x:
$ ./output/host/usr/bin/powerpc-linux-g++ -dM -E - < /dev/null | grep -i linux#define __linux 1
#define __linux__ 1
#define __gnu_linux__ 1
#define linux 1
And now, with -std=c++0x:
$ ./output/host/usr/bin/powerpc-linux-g++ -std=c++0x -dM -E - < /dev/null | grep -i linux
#define __linux__ 1
#define __gnu_linux__ 1
So, just change the closefrom.cpp Linux test to:
#elif (defined(linux) || defined(__linux) || defined(__linux__))
and it will build fine, and be a lot better than a guessed 256 value.
Can you submit a new patch that does this, and report the proper
solution upstream?
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH 1/1] package/upmpdcli: Add patch to fix OPEN_MAX build error
2015-07-18 12:36 ` Thomas Petazzoni
@ 2015-07-19 6:44 ` Jörg Krause
0 siblings, 0 replies; 3+ messages in thread
From: Jörg Krause @ 2015-07-19 6:44 UTC (permalink / raw)
To: buildroot
Dear Thomas Petazzoni,
On Sa, 2015-07-18 at 14:36 +0200, Thomas Petazzoni wrote:
> Dear J?rg Krause,
>
> On Thu, 16 Jul 2015 22:53:12 +0200, J?rg Krause wrote:
>
> > ++#ifndef OPEN_MAX
> > ++#define OPEN_MAX 256 /* Guess */
> > ++#endif
> > ++
>
> This is not the right fix. There is some Linux-specific code in
> closefrom.cpp, but it doesn't get used since when you build C++ code
> with -std=c++0x, the compiler doesn't define "linux" or "__linux",
> but
> "__linux__", so the following test doesn't work anymore:
>
> #elif (defined(linux) || defined(__linux))
>
> See what the compiler does, without -std=c++0x:
>
> $ ./output/host/usr/bin/powerpc-linux-g++ -dM -E - < /dev/null | grep
> -i linux#define __linux 1
> #define __linux__ 1
> #define __gnu_linux__ 1
> #define linux 1
>
> And now, with -std=c++0x:
>
> $ ./output/host/usr/bin/powerpc-linux-g++ -std=c++0x -dM -E - <
> /dev/null | grep -i linux
> #define __linux__ 1
> #define __gnu_linux__ 1
>
> So, just change the closefrom.cpp Linux test to:
>
> #elif (defined(linux) || defined(__linux) || defined(__linux__))
>
> and it will build fine, and be a lot better than a guessed 256 value.
> Can you submit a new patch that does this, and report the proper
> solution upstream?
I see! You're right, it works. I'll submit a new patch.
Best regards
J?rg Krause
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-19 6:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16 20:53 [Buildroot] [PATCH 1/1] package/upmpdcli: Add patch to fix OPEN_MAX build error Jörg Krause
2015-07-18 12:36 ` Thomas Petazzoni
2015-07-19 6:44 ` Jörg Krause
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox