[RFA/commit] Fix filestuff.c build error if RLIMIT_NOFILE not defined.
Joel Brobecker
brobecker@adacore.com
Tue Nov 26 09:39:00 GMT 2013
Hello,
Not all systems supporting getrlimit also support RLIMIT_NOFILE
(Eg. All LynxOS systems appear to be lacking support for this).
So check its existance before using it.
gdb/ChangeLog:
* common/filestuff.c (fdwalk): Add "defined(RLIMIT_NOFILE)"
preprocessor check.
Tested on x86_64-linux. With the LynxOS gdbservers, we get the same
results back when using the AdaCore testsuite.
Bordering on the obvious, I decided for an RFA, just in case, because
it relies on RLIMIT_NOFILE always being a marcro, POSIX does not seem
to require it. It seems to be true in practice, though, for all systems
I checked (Various flavors of GNU/Linux, including embedded ones,
Solaris, AIX, Lynx, etc).
OK to commit?
Thanks,
--
Joel
---
gdb/common/filestuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
index 2792d59..b884c02 100644
--- a/gdb/common/filestuff.c
+++ b/gdb/common/filestuff.c
@@ -115,7 +115,7 @@ fdwalk (int (*func) (void *, int), void *arg)
{
int max, fd;
-#ifdef HAVE_GETRLIMIT
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
struct rlimit rlim;
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && rlim.rlim_max != RLIM_INFINITY)
--
1.8.1.2
More information about the Gdb-patches
mailing list