Include headers for getrlimit() in sha1_file.c
PATCH 1/1 Include headers for getrlimit() in sha1_file.c
Fixes compilation error on OpenBSD:sha1_file.c: In function 'open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known sha1_file.c:721: warning: implicit declaration of function 'getrlimit' sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function) sha1_file.c:718: warning: unused variable 'lim'
--- sha1_file.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
sha1_file.c +4 -0
@@ -18,6 +18,10 @@#include "pack-revindex.h" #include "sha1-lookup.h" +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#ifndef O_NOATIME #if defined(__linux__) && (defined(__i386__) || defined(__PPC__))#define O_NOATIME 01000000
Signature · 1 line
1.7.3.5
(+cc: Shawn, Erik)
Hi Stefan,
Quoted 6 lines · Stefan Sperling
Fixes compilation error on OpenBSD:
sha1_file.c: In function 'open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known sha1_file.c:721: warning: implicit declaration of function 'getrlimit' sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function) sha1_file.c:718: warning: unused variable 'lim'
Good catch.
sha1_file.c line 23
Quoted 9 lines
sha1_file.c +3
-0@@ -18,6 +18,10 @@#include "pack-revindex.h" #include "sha1-lookup.h" +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h>
System headers like this tend to go in git-compat-util.h, so portability fixes having to do with compatibility replacements or order of inclusion only need to happen in one place.
In this case, afaict sys/resource.h is not available on mingw, meaning the #include would probably go in the "#ifndef __MINGW32__" block. Maybe something like this (untested)?
-- 8< --
Subject: compat: add missing #include <sys/resource.h>
Starting with commit c793430 (Limit file descriptors used by packs, 2011-02-28), git uses getrlimit to tell how many file descriptors it can use. Unfortunately it does not include the header declaring that function, resulting in compilation errors on OpenBSD:
sha1_file.c: In function 'open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known sha1_file.c:721: warning: implicit declaration of function 'getrlimit' sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function) sha1_file.c:718: warning: unused variable 'lim'
The standard header to include for this is <sys/resource.h> (which on some systems itself requires declarations from <sys/types.h> or <sys/time.h>). Probably the problem was missed until now because in current glibc sys/resource.h happens to be included by sys/wait.h.
MinGW does not provide sys/resource.h (and compat/mingw takes care of providing getrlimit some other way), so add the missing #include to the "#ifndef __MINGW32__" block in git-compat-util.h.
--- git-compat-util.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
git-compat-util.h +1 -0
@@ -118,6 +118,7 @@#endif #ifndef __MINGW32__#include <sys/wait.h> +#include <sys/resource.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <termios.h>
Signature · 1 line
1.7.4.1
Hi,
Quoted 12 lines · Jonathan Nieder
(+cc: Shawn, Erik)
Hi Stefan,Quoted 6 lines · Stefan Sperling
Fixes compilation error on OpenBSD:
sha1_file.c: In function 'open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known sha1_file.c:721: warning: implicit declaration of function 'getrlimit' sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function) sha1_file.c:718: warning: unused variable 'lim'
This also fix the build on FreeBSD 8 (did not test other version).
- Arnaud
Quoted 69 lines
Good catch.
sha1_file.c line 23
Quoted 9 lines
sha1_file.c +3
-0@@ -18,6 +18,10 @@ #include "pack-revindex.h" #include "sha1-lookup.h" +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> System headers like this tend to go in
git-compat-util.h, so portability fixes having to do with compatibility replacements or order of inclusion only need to happen in one place.In this case, afaict
sys/resource.his not available on mingw, meaning the #include would probably go in the "#ifndef__MINGW32__" block. Maybe something like this (untested)?-- 8< --
Subject: compat: add missing #include <sys/resource.h>Starting with commit c793430 (Limit file descriptors used by packs, 2011-02-28), git uses getrlimit to tell how many file descriptors it can use. Unfortunately it does not include the header declaring that function, resulting in compilation errors on OpenBSD:
sha1_file.c: In function '
open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known sha1_file.c:721: warning: implicit declaration of function 'getrlimit' sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function) sha1_file.c:718: warning: unused variable 'lim'The standard header to include for this is <
sys/resource.h> (which on some systems itself requires declarations from <sys/types.h> or <sys/time.h>). Probably the problem was missed until now because in current glibcsys/resource.hhappens to be included bysys/wait.h.MinGW does not provide
sys/resource.h(and compat/mingw takes care of providing getrlimit some other way), so add the missing #include to the "#ifndef__MINGW32__" block ingit-compat-util.h.Reported-by Stefan Sperling <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>---
git-compat-util.h | 1 +1 files changed, 1 insertions(+), 0 deletions(-)git-compat-util.h +1
-1@@ -118,6 +118,7 @@ #endif #ifndef __MINGW32__ #include <sys/wait.h> +#include <sys/resource.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <termios.h> --1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
git-compat-util.h line 124
Quoted 12 lines · Jonathan Nieder
git-compat-util.h +1
-0@@ -118,6 +118,7 @@#endif #ifndef __MINGW32__#include <sys/wait.h> +#include <sys/resource.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <termios.h>
Works for me. Thanks.
PATCH RESEND 1/1 compat: add missing #include <sys/resource.h>
In reply to Jonathan NiederDate: Fri, 18 Mar 2011 15:23:52 -0500
Starting with commit c793430 (Limit file descriptors used by packs, 2011-02-28), git uses getrlimit to tell how many file descriptors it can use. Unfortunately it does not include the header declaring that function, resulting in compilation errors:
sha1_file.c: In function 'open_packed_git_1':
sha1_file.c:718: error: storage size of 'lim' isn't known sha1_file.c:721: warning: implicit declaration of function 'getrlimit' sha1_file.c:721: error: 'RLIMIT_NOFILE' undeclared (first use in this function) sha1_file.c:718: warning: unused variable 'lim'
The standard header to include for this is <sys/resource.h> (which on some systems itself requires declarations from <sys/types.h> or <sys/time.h>). Probably the problem was missed until now because in current glibc sys/resource.h happens to be included by sys/wait.h.
MinGW does not provide sys/resource.h (and compat/mingw takes care of providing getrlimit some other way), so add the missing #include to the "#ifndef __MINGW32__" block in git-compat-util.h.
---
Oops, should have sent this as its own message before. Thanks to doug on irc for a ping.
git-compat-util.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
git-compat-util.h +1 -0
@@ -118,6 +118,7 @@#endif #ifndef __MINGW32__#include <sys/wait.h> +#include <sys/resource.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <termios.h>
Signature · 1 line
1.7.4.2
Re: [PATCH maint resend] compat: add missing #include <sys/resource.h>
Hi Junio,
Quoted 1 line · Jonathan Nieder
Date: Fri, 18 Mar 2011 15:23:52 -0500
[...]
Quoted 1 line
sha1_file.c:721: error: '
RLIMIT_NOFILE' undeclared (first use in this function)
[...]
Quoted 4 lines
Reported-by Stefan Sperling <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>
Ping? Would you like a shorter commit message, or was this just lost in the noise?
Re: [PATCH maint resend] compat: add missing #include <sys/resource.h>
Quoted 2 lines · Jonathan Nieder
Ping? Would you like a shorter commit message, or was this just lost in the noise?
No, it was sitting in my to-be-applied box. Thanks.