Message ID | 1437079992-31679-1-git-send-email-joerg.krause@embedded.rocks |
---|---|
State | Rejected |
Headers | show |
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
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
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 +
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