From: Arnaud Lacombe Date: Sat, 19 Mar 2011 00:22:24 GMT Subject: Re: [PATCH] Include headers for getrlimit() in sha1_file.c Message-ID: In-Reply-To: <20110318202351.GA22696@elie> Hi, On Fri, Mar 18, 2011 at 4:23 PM, Jonathan Nieder wrote: > (+cc: Shawn, Erik) > Hi Stefan, > > Stefan Sperling wrote: > >> 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 > Good catch. > >> --- a/sha1_file.c >> +++ b/sha1_file.c >> @@ -18,6 +18,10 @@ >>  #include "pack-revindex.h" >>  #include "sha1-lookup.h" >> >> +#include >> +#include >> +#include > > 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 > > 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 (which on > some systems itself requires declarations from or > ).  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. > > Reported-by: Stefan Sperling > Signed-off-by: Jonathan Nieder > --- >  git-compat-util.h |    1 + >  1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/git-compat-util.h b/git-compat-util.h > index 49b50ee..40498b3 100644 > --- a/git-compat-util.h > +++ b/git-compat-util.h > @@ -118,6 +118,7 @@ >  #endif >  #ifndef __MINGW32__ >  #include > +#include >  #include >  #include >  #include > -- > 1.7.4.1 > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at  http://vger.kernel.org/majordomo-info.html >