Re: [HACKERS] BSD gettext

2001-05-24 Thread Nathan Myers

On Thu, May 24, 2001 at 10:30:01AM -0400, Bruce Momjian wrote:
> > The HPUX man page for mmap documents its failure return value as "-1",
> > so I hacked around this with
> > 
> > #ifndef MAP_FAILED
> > #define MAP_FAILED ((void *) (-1))
> > #endif
> > 
> > whereupon it built and passed the simple self-test you suggested.
> > However, I think it's pretty foolish to depend on mmap for such
> > little reason as this code does.  I suggest ripping out the mmap
> > usage and just reading the file with good old read(2).
> 
> Agreed.  Let read() use mmap() internally if it wants to.

The reason mmap() is faster than read() is that it can avoid copying 
data to the place you specify.  read() can "use mmap() internally" only 
in cases rare enough to hardly be worth checking for.  

Stdio is often able to use mmap() internally for parsing, and in 
glibc-2.x (and, I think, on recent Solarix and BSDs) it does.  Usually, 
therefore, it would be better to use stdio functions (except fread()!) 
in place of read(), where possible, to allow this optimization.

Using mmap() in place of disk read() almost always results in enough
performance improvement to make doing so worth a lot of disruption.
Today mmap() is used heavily enough, in important programs, that 
worries about unreliability are no better founded than worries about
read().

Nathan Myers
[EMAIL PROTECTED]

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [HACKERS] BSD gettext

2001-05-24 Thread Tom Lane

Peter Eisentraut <[EMAIL PROTECTED]> writes:
> This is a compilation of the BSD-licensed gettext tools from NetBSD plus
> some of my own code, put into a (hopefully) portable package, intended to
> be evaluated for possible use in PostgreSQL.  Give it a try if you're
> interested.

On HPUX 10.20:

make[2]: Entering directory `/home/tgl/pgsql/bsd-gettext-0.0/libintl'
/bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -c 
gettext.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -c gettext.c -o gettext.o
gettext.c: In function `mapit':
gettext.c:313: `MAP_FAILED' undeclared (first use in this function)
gettext.c:313: (Each undeclared identifier is reported only once
gettext.c:313: for each function it appears in.)
gettext.c: In function `unmapit':
gettext.c:442: `MAP_FAILED' undeclared (first use in this function)
make[2]: *** [gettext.lo] Error 1

The HPUX man page for mmap documents its failure return value as "-1",
so I hacked around this with

#ifndef MAP_FAILED
#define MAP_FAILED ((void *) (-1))
#endif

whereupon it built and passed the simple self-test you suggested.
However, I think it's pretty foolish to depend on mmap for such
little reason as this code does.  I suggest ripping out the mmap
usage and just reading the file with good old read(2).

regards, tom lane

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



Re: [HACKERS] BSD gettext

2001-05-22 Thread Rick Robino

Peter Eisentraut wrote:
> 
> http://www.postgresql.org/~petere/gettext.html
> 
> This is a compilation of the BSD-licensed gettext tools from NetBSD plus
> some of my own code, put into a (hopefully) portable package, intended to
> be evaluated for possible use in PostgreSQL.  Give it a try if you're
> interested.  I've already tried it on FreeBSD, Linux, and Unixware, so
> don't bother with those.

# uname -a
SunOS mage 5.8 Generic_108528-06 sun4u sparc SUNW,Ultra-5_10
# pwd
/usr/local/src/3/bsd-gettext-0.0
# gmake install >/dev/null 2>&1 
# echo $?   
0
# LANGUAGE=sv /usr/local/bin/gettext
/usr/local/bin/gettext: argument saknas
# 



-- 

Rick Robino v. (503) 891-9283
Wave Division Consulting@. wavedivision.com

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster