CVSROOT:	/cvsroot
Module name:	pgsql-server
Changes by:	petere@postgresql.org	02/08/29 18:09:23

Modified files:
	src/include/port: hpux.h 

Log message:
	Workaround for broken large file support on HP-UX


Thu, 29 Aug 2002 18:09:23 -0400 (EDT)
petere@postgresql.org (Peter Eisentraut - PostgreSQL)
pgsql-server/src/include/port hpux.h
petere@postgresql.org (Peter Eisentraut - PostgreSQL) writes:
> Modified files:
> 	src/include/port: hpux.h 
> Log message:
> 	Workaround for broken large file support on HP-UX

Good try but it didn't help.  After looking more closely I've realized
that HP's system headers are just hopelessly broken, at least on HPUX
10.20 (which, to be fair, is well behind the curve now).  There is just
no way to compile 64-bit support without drawing warnings in 
-Wmissing-declarations mode, because they've simply not included all
the declarations that should be there.  _LARGEFILE64_SOURCE was a red
herring --- I forgot to count underscores carefully, and I now see that
the declarations that _LARGEFILE64_SOURCE exposes aren't the ones that
gcc is complaining about the lack of.

What I'm currently thinking we should do is default largefile support to
off in HPUX < 11.0; is there a convenient way to accomplish that in
autoconf?

			regards, tom lane

Thu, 29 Aug 2002 22:09:45 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: pgsql-server/src/include/port hpux.h 
Tom Lane writes:

> What I'm currently thinking we should do is default largefile support to
> off in HPUX < 11.0; is there a convenient way to accomplish that in
> autoconf?

Something like this maybe (before AC_SYS_LARGEFILE):

case $host_os in hpuxZYX*)
if test "${enable_largefile+set}" != set; then
enable_largefile=no
fi
esac

I found an HP whitepaper on the large file support and it seems they don't
have the problem of missing declarations.

http://docs.hp.com/hpux/onlinedocs/os/lgfiles4.pdf

Note the example in section 6.4.1.  On page 37 they grep the preprocessed
source and somehow manage to get a declaration of __lseek64() in there.
Maybe it's a later OS release.

-- 
Peter Eisentraut   peter_e@gmx.net


Mon, 2 Sep 2002 20:02:23 +0200 (CEST)
Peter Eisentraut <peter_e@gmx.net>
Re: [COMMITTERS] pgsql-server/src/include/port hpux.h 
Peter Eisentraut <peter_e@gmx.net> writes:
> I found an HP whitepaper on the large file support and it seems they don't
> have the problem of missing declarations.
> http://docs.hp.com/hpux/onlinedocs/os/lgfiles4.pdf
> Note the example in section 6.4.1.  On page 37 they grep the preprocessed
> source and somehow manage to get a declaration of __lseek64() in there.

Yeah, but you'll notice they *have to* declare __lseek64(), 'cause the
compiler will otherwise assume it returns int.  I've been through these
files now and it seems that they've very carefully included only the
minimal declarations they absolutely had to.  What's really annoying
is that the prototypes are there --- but #ifdef'd out of sight:

# if defined(_FILE64)
#  ifndef __cplusplus
    extern off_t __lseek64();
#   ifdef __STDC_EXT__
     static truncate(a,b) const char *a; off_t b; { return __truncate64(a,b); }
#   else
     static truncate(a,b) off_t b;                { return __truncate64(a,b); }
#   endif /* __STDC_EXT__ */
    static int prealloc(a,b) off_t b;  	          { return __prealloc64(a,b); }
    static int lockf(a,b,c) off_t c;   		  { return __lockf64(a,b,c); }
    static int ftruncate(a,b) off_t b;	  	  { return __ftruncate64(a,b); }
    static off_t lseek(a,b,c) off_t b;		  { return __lseek64(a,b,c); }
#  else /* __cplusplus */
    extern off_t __lseek64(int, off_t, int);
    extern int __truncate64(const char *, off_t);
    extern int __prealloc64(int, off_t);
    extern int __lockf64(int, int, off_t);
    extern int __ftruncate64(int, off_t);
    inline int truncate(const char *a, off_t b)  { return __truncate64(a,b); }
    inline int prealloc(int a, off_t b)          { return __prealloc64(a,b); }
    inline int lockf(int a, int b, off_t c)      { return __lockf64(a,b,c); }
    inline int ftruncate(int a, off_t b)         { return __ftruncate64(a,b); }
    inline off_t lseek(int a, off_t b, int c)    { return __lseek64(a,b,c); }
#  endif /* __cplusplus */
# endif /* _FILE64 */

The bottom line is that large file support does work on HPUX 10.20, but
it will generate a ton of warning messages if you build using gcc and
-Wmissing-declarations.

I'm now thinking that I will just edit my local copies of the system
headers to add the missing declarations so that I don't see these
warnings.  Turning off largefile support is probably too high a price
for users to pay just so Tom Lane doesn't have to see warnings ;-)

			regards, tom lane

Wed, 04 Sep 2002 12:32:40 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [COMMITTERS] pgsql-server/src/include/port hpux.h 