[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: errno --> errno name ?
From: |
Bruno Haible |
Subject: |
Re: errno --> errno name ? |
Date: |
Wed, 3 Aug 2011 00:49:46 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Hi Bruce,
> This isn't a library function, but a program that I needed to polish up a bit.
> Fiddling and tweaking can turn it into a library function without too much
> trouble.
> The last file ("err-names.h") is a derived file that depends on the "mk"
> script
Is the list of errno values meant to be extracted before a tarball is built, or
at build time?
If you want to create a distributable file, IMO Thien-Thi Nguyen's approach [1]
is good. The code would then look similar to lib/strerror-override.c, basically
like this:
#ifdef ENOENT
case ENOENT:
return "ENOENT";
#endif
#ifdef ENOTDIR
case ENOTDIR:
return "ENOTDIR";
#endif
...
If you want to create file at build time, then the mk-err-names.sh script needs
to be a /bin/sh script; you cannot assume that 'bash' is available. Also, what's
the point of using the numeric values of the error numbers? If you generate code
like
case ENOENT:
return "ENOENT";
case ENOTDIR:
return "ENOTDIR";
...
then the code is not only more robust but also requires fewer relocations when
put into a shared library. In
[ 1] = "EPERM",
[ 2] = "ENOENT",
the shared library needs to relocate, during loading, as many pointers as there
are references to strings. See Ulrich Drepper's writeup about how to code for
shared libraries ([2], section 2.4.3).
Bruno
[1] http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00057.html
[2] http://www.akkadia.org/drepper/dsohowto.pdf
--
In memoriam Amatore Sciesa <http://it.wikipedia.org/wiki/Amatore_Sciesa>
- Re: errno --> errno name ?, Bruce Korb, 2011/08/02
- Re: errno --> errno name ?,
Bruno Haible <=
- Re: errno --> errno name ?, Bruce Korb, 2011/08/04
- Re: errno --> errno name ?, Bruno Haible, 2011/08/04
- Re: errno --> errno name ?, Bruce Korb, 2011/08/05
- Re: errno --> errno name ?, Bruce Korb, 2011/08/05
- Re: errno --> errno name ?, Stefano Lattarini, 2011/08/05
- Re: errno --> errno name ?, Bruce Korb, 2011/08/05
- Re: errno --> errno name ?, Bruce Korb, 2011/08/13
- Re: errno --> errno name ?, Bruno Haible, 2011/08/14
- Re: errno --> errno name ?, Bruce Korb, 2011/08/14