[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checks for getcwd(NULL, 0) and get_current_dir_name()

From: Guillem Jover
Subject: Re: Checks for getcwd(NULL, 0) and get_current_dir_name()
Date: Sat, 20 Oct 2012 05:49:25 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, 2012-10-19 at 08:55:57 +0200, Svante Signell wrote:
> On Wed, 2012-10-17 at 17:42 +0200, Svante Signell wrote:
> > > On Wed, 2012-10-17 at 16:15 +0200, Guillem Jover wrote:
> > >     AC_DEFINE([HAVE_GNU_GETCWD], [1],
> > >               [Define to 1 if you have support for 'getcwd(NULL, 0)' GNU 
> > > extension])
> > 
> > BTW, why calling it a GNU extension, not GLIBC or LIBC.
> > >From the man page:  As  an  extension  to  the  POSIX.1-2001 standard,
> > Linux (libc4, libc5, glibc) getcwd() allocates the buffer dynamically
> > using malloc(3) if buf is NULL. 
> > 
> > get_current_dir_name() is a GNU extension though, again according to the
> > man page.
> Can we settle the naming of the HAVE_* for getcwd(NULL, 0) and
> get_current_dir_name() with the corresponding text strings? I would like
> to use these configure.ac snippets whenever appropriate (and having them
> on one of the GNU/Hurd porting web pages). Of course a new test has to
> be written also for get_current_dir_name(), wouldn't be difficult.
> My proposal:
> getcwd(NULL, 0): HAVE_GLIBC_GETCWD (maybe HAVE_GNU_GETCWD as Guillem
> proposed)

Because getcwd(NULL, 0) is also supported by most (if not all) BSD
libc's, using glibc in the name seems just wrong. Now that I've
checked, using GNU might not be correct either, as it's not clear
who added that extension first if the BSDs or GNU (as I had thought).
FreeBSD, NetBSD and OpenBSD appear to support it since around 1994
or so. But it's certainly not specific to a single libc

> get_current_dirname(): HAVE_GNU_GETCWD or HAVE_GET_CURRENT_DIR_NAME (too
> long?)

For this, just use HAVE_FUNCTION as it's customary, and as
AC_CHECK_FUNCS does automatically for you, so that would be


reply via email to

[Prev in Thread] Current Thread [Next in Thread]