Wednesday, August 27, 2008

man-pages-3.08 is released

I've uploaded man-pages-3.08 into the release directory (or view the online pages). Notable changes in man-pages-3.08 are:

  • A new numa(7) page gives an overview of the Linux NUMA interfaces.
  • A new getnetent_r(3) page documents getnetent_r(), getnetbyname_r(), and getnetbyaddr_r(), the reentrant equivalents of getnetent(), getnetbyname(), and getnetbyaddr().
  • A new getprotoent_r(3) page documents getprotoent_r(), getprotobyname_r(), and getprotobynumber_r(), the reentrant equivalents of getprotoent(), getprotobyname(), and getprotobynumber().
  • A new getrpcent_r(3) page documents getrpcent_r(), getrpcbyname_r(), and
    getrpcbynumber_r(), the reentrant equivalents of getrpcent(), getrpcbyname(), and getrpcbynumber().
  • A new getservent_r(3) page documents documents getservent_r(), getservbyname_r(), and getservbyport_r(), the reentrant equivalents of getservent(), getservbyname(), and getservbyport().
  • Further updates related to changes in the recently approved POSIX.1-2008 standard.

Friday, August 15, 2008

Speaking at LPC

My paper for Linux Plumbers Conference (16-19 September, Portland, OR) got accepted :-). I'll be considering the question: Who owns the interface?

Tuesday, August 12, 2008

man-pages-3.07 is released

I've uploaded man-pages-3.07 into the release directory (or view the online pages). Notable changes in man-pages-3.07 are:

  • A new move_pages(2) page, written by Christoph Lameter, documents the move_pages() system call. This page was formerly part of the numactl package, but has been revised and moved into man-pages (its natural home, since it is a kernel interface).
  • A new clock_getcpuclockid(3) page describes the clock_getcpuclockid() library function.
  • A new udplite(7) page, written by Gerrit Renker, documents the Linux implementation (since kernel 2.6.20) of the UDP-Lite transport layer protocol.
  • The proc(5) man page adds a description of the /proc/PID/numa_maps file.
  • Various updates and improvements by Lee Schermerhorn for the mbind(2), get_mempolicy(2), and set_mempolicy(2) pages.
  • Following on from last week's big update to the math man pages, there are a few more changes to these pages. Most notably, where error-reporting details have differed (from glibc 2.8) in earlier versions of glibc, the differences have been noted in the man pages. Currently, the details have been extended back until glibc 2.3.2, but I hope to extend them back further, when I can get test results. If you want to help, look here.
  • On 24 July, the Governing Board of The Open Group approved the 2008 revisions of POSIX.1. Among other things, POSIX.1-2008 marks some previously specified functions as obsolete, and drops the specifications of some other functions altogether. The manual pages have been updated to reflect all of these changes. (The standard should be published in final form after approval by the IEEE, but in the meantime you can get access to the draft by joining the Austin group.)
  • VERSIONS sections have been added to the man pages of many library functions to indicate the glibc version where the function first appeared.

Grünegg Fenster

Friday, August 8, 2008

Translating man-pages

Update, 2020-06-20: I've maintained the post below mainly for historical interest. However things have moved along quite a bit in 12 years, rendering various of my suggestions obsolete. If you are thinking about translating manual pages, see the manpages-I10n project, which oversees translations into several languages and employs a range of useful tooling for translation.

Lately, I've gotten a few requests for information about how to translate man-pages into other languages. First off, I should say that I have never translated man-pages. But I have communicated with a few people who do. So these are my current thoughts... Do you really want to do this? Before you answer this, consider the following:
  • man-pages contains the documentation of the Linux and glibc programming APIs (i.e., pages in Sections 2, 3, 4, 5, and 7). Is this the set of man pages that your group of language speakers most need? If, for example, you are more interested in translating pages for end users, then you might want instead to translate pages in the coreutils package. (More generally, if you want to find out which package a particular man page belongs to, take a look here.)
  • How big is the target audience? Your target audience is primarily programmers. What proportion of them aren't able to read English well enough to read man pages, and therefore would benefit from a translation? Is that group big enough to warrant the effort of a translation? Or is there perhaps a better place where you can invest your time in working on Linux?
  • How much time do you have? There are currently around 850 pages in man-pages, amounting to perhaps 2000 pages of printed text. My guess is that this amounts to one to two person years of translation work. In other words, you'll need to have a team of translators, if you intend to complete the translation in any reasonable time.
  • What is your longer term commitment? man-pages is a moving target: starting a couple of months ago, I'm now working full time on man-pages, and I make a release every week or so. The French translator estimates that there is around two days' work for him translating each release. Now, I may not be working full time on man-pages forever, and therefore the required translation effort may decrease some day, but the point remains that there is a significant ongoing effort required to keep a translation up to date and useful.

The size of the translation effort should not be underestimated. It is because it is so large that to date there has been only one complete and up-to-date translation: the French translation. (For a while, there was a fairly full German translation, but it seems to have languished for a few years now.) The state of the French translation has largely been down to the extraordinary work of two people: Christophe Blaess, and more recently, Alain Portal. (In fact, there are nowadays two French translations which cooperate to some extent: the Debian distribution has a team doing a French translation of man-pages.) But nowadays even the French translator(s) have started to feel the strain resulting from the recent increase in my output.

If you decide you really want to do a translation (and think very carefully before you do decide that!), then I have a few thoughts on how you go about it.

Tools: I have no real recommendations here (since I never translated man-pages). But it's worth mentioning that the Debian French translators use po4a, and see it as very beneficial for their work, especially for facilitating the work of a team of translators.

Other than that, I'd say that you need to:

  • Estimate the time required to translate the 850 pages in man-pages, and decide if you have the necessary number translators who have sufficient time to complete the work.
  • Divide the work up so that your translators can work independently on translations. I suggest you divide the pages up into small, related parcels. For example, the POSIX message queue pages (mq_*) could be a parcel translated by a single translator, or the math man pages could be a parcel translated by a single translator, etc.
  • Come up with a review plan, so that each translation by one member of your team is reviewed by at least one other member.
  • Devise a glossary of terminology, so that you all translate English technical terms ("e.g., shared memory segment") into the same terms in the target language.
  • Plan for ongoing maintenance, so that as the English man pages are updated, then the translated pages are also updated. Don't underestimate the amount of this work!

My suggestion is that if you go forward with a translation project, then:

  • Pick a particular man-pages release -- let's say man-pages-3.x -- and translate all of the pages in that version.
  • When that is completed, you can then update your translation with all of the changes that have occurred in the English original since release man-pages-3.x. I keep fairly detailed changelogs which should assist you during this phase of the work.

I suggest doing things this way since I estimate that trying to do a translation while simultaneously trying to keep up with changes in already translated pages would just prove too difficult. You might decide otherwise.

And finally... did I mention that you should think long and hard before embarking on a translation of man-pages?

[12 Aug 08: minor updates, to point out exactly which sections are in man-pages, and to suggest more appropriate pages to translate, if targeting end users.]

Wednesday, August 6, 2008

Help request: testing of math function error reporting

As I mentioned in my previous post, as of man-pages-3.06, the math man pages now describe the error-reporting behavior of the math functions as at glibc 2.8. I'd like to extend those descriptions to cover differences in older glibc versions. In order to do that, I've written some scripts to check the error-reporting behavior of the math functions, and I'd like to run them on as many different versions of glibc as possible.

If you'd like to help, and you have an x86 system with an older glibc (look at the version number in the first line of output produced by the command /lib/libc.so.6), run the script in this tarball (see the README file inside the tarball for details), and send me the resulting log file (email to mtk.manpages AT gmail.com).

Updated, 2012- 03-06: Fix link to tarball

Math functions and error reporting

Math functions are different from most other library functions in the kinds of errors that they report, and in the way that they report errors. Broadly speaking, a math function can fail for one of the following reasons:

  • Domain error: an argument to the function was outside the range for which the function was defined. For example, the call sqrt(-1.0) gives a domain error because a negative number does not have (real) square root. When a domain error occurs, a math function typicall returns a NaN (not-a-number).
  • Pole error: the function result is an exact infinity. For example log(0.0) is negative infinity. When a pole error occurs, most math functions return the floating-point representation of positive or negative infinity, as appropriate (i.e., HUGE_VAL or -HUGE_VAL for functions returning a double).
  • Range error (overflow): an overflow occurs if the function result is too large to be represented as a floating-point number. For example, exp(1e10) produces a number too large to represent in a double. When an overflow occurs, most math functions return the floating-point representation of positive or negative infinity, as appropriate (i.e., HUGE_VAL or -HUGE_VAL for functions returning a double).
  • Range error (underflow): an underflow occurs if the function result is so small that it can't be represented as a (normalized) floating-point number. For example, exp(-1e10) produces a number too large to represent in a double. When an underflow occurs, a math function usually either returns a (signed) zero, or a subnormal value, as appropriate.

(More details can be found in the math_error(7) man page.)

Many library functions report an error by returning a NULL pointer or an integer -1. Neither of these mechanisms would be suitable for math functions: these functions usually return a floating-point value, and -1 is in many cases a valid successful return. For this reasons, the C99 and POSIX.1-2001 standards define two other mechanisms by which math functions can report errors.

The first of the error-reporting mechanisms is to use the traditional errno variable. We set the errno to zero before the call, and if it has a non-zero value after the call, then an error occurred. On error, errno is set as follows:

  • Domain error: EDOM

  • Pole error: ERANGE

  • Overflow: ERANGE

  • Underflow: ERANGE
(These settings do of course make it hard to distinguish the last three types of errors.)

The other error-reporting mechanism is exceptions. For each of the errors described above, the system raises an exception, and the fetestexcept() library function can be used to check whether an exception occurred. In order to use this mechanism we do the following:

  1. Call feclearexcept(FE_ALL_EXCEPT) to clear any existing exceptions.

  2. Call the math library function.

  3. Call fetestexcept(FE_INVALID FE_DIVBYZERO FE_OVERFLOW FE_UNDERFLOW).

If the math function was successful, then fetestexcept() returns 0. If an error occurred while calling the math function, then fetestexcept() returns a bit mask indicating the error. In this bit mask, exactly one of FE_INVALID, FE_DIVBYZERO, FE_OVERFLOW, or FE_UNDERFLOW will be set. The exceptions raised for each error are:

  • Domain error: invalid exception (FE_INVALID)

  • Pole error: divide-by-zero exception (FE_DIVBYZERO)

  • Overflow: overflow exception (FE_OVERFLOW)

  • Underflow: underflow exception (FE_UNDERFLOW)

C99 and POSIX.1-2001 require an implementation to support at least one of the error-reporting mechanisms for all math functions, and allow both to be supported. The standards specify an identifier, math_errhandling, that an implementation should set to indicate which mechanisms are supported. If (math_errhandling & MATH_ERRNO) is non-zero, then errno is set to indicate errors. If (math_errhandling & MATH_EXCEPT) is non-zero ,then exceptions are raised on errors.

The CONFORMANCE file in the glibc sources has long explained that:

Implementing MATH_ERRNO, MATH_ERREXCEPT and math_errhandling in needs compiler support: see
http://sources.redhat.com/ml/libc-hacker/2000-06/msg00008.html
http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html
http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html

But to date this support has not arrived. In any case, this support is a somewhat moot point, since it transpires that neither of the mechanisms is supported by all of the math functions in glibc: most (but not all) support exceptions, many support both exceptions and errno, a few support errno but not exceptions, and one or two functions support neither mechanism. To make things even worse, the man pages didn't fully and correctly describe the details for each math function. Since man-pages-3.06, the details should now be accurate, at least for glibc 2.8.

Ideally, all of the glibc math functions would support both mechanisms, so that programs that depend on either mechanism could be happily ported to Linux. With that idea in mind, I went through and tested the error-reporting behavior for each math function, and filed a series of bug reports that document deviations from that ideal.

In order to get an overview, the table below summarizes the situation for all of the math functions as at glibc 2.8. The third and fourth columns indicate whether errno is correctly set and an exception is raised for each error case.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































FunctionExpected errorerrno set correctly?Exception correctly raised?Notes
acos(+-inf)domainyy-
acosh(x<1)domainyy-
asin(+-inf)domainyy-
asinh()---No errors occur
atan()---No errors occur
atan2()---No errors occur
atanh(+-1)polenyerrno is set to EDOM (should be ERANGE)
atanh(x>1)domainyy-
cbrt()---No errors occur
ceil()---No errors occur
cos(+-inf)domainny-
cosh(+-large)overflowyye.g., cosh(DBL_MAX)
erf(+-small)underflownyFor subnormal x
erfc(x)underflownyResult underflows but produces representable (i.e., subnormal) result; e.g., erfc(27)
exp(+large)overflowyy-
exp(-large)underflowyy-
exp10(+large)overflowyyGNU extension, but inconsistent with exp()
exp10(-large)underflownyGNU extension, but inconsistent with exp()
exp2(+large)overflowyy-
exp2(-large)underflowyy-
expm1(+large)overflowny-
fabs()---No errors occur
fdim()overflownye.g., fdim(DBL_MAX, -DBL_MAX)
floor()---No errors occur
fma()domainnyVarious causes, e.g., one of x or y is an infinity and the other is 0.
fma()overflownye.g., fma(DBL_MAX, DBL_MAX, 0)
fma()underflownye.g., fma(DBL_MIN, DBL_MIN, 0)
fmax()---No errors occur
fmin()---No errors occur
fmod(+-inf,y)domainny-
fmod(x,0)domainyy-
hypot()overflowyye.g., hypot(DBL_MAX, DBL_MAX)
hypot()underflownye.g., if both arguments are small subnormal numbers
ilogb(+-inf)domainnnDoes correctly return INT_MAX
ilogb(0)domainnyDoes correctly return FP_ILOGB0
ilogb(nan)domainnyDoes correctly return FP_ILOGBNAN
j0()underflowyne.g., j0(DBL_MAX)
j1()underflowyn-
jn()underflowyn-
ldexp(x, +large-exp)overflowyy-
ldexp(x, -large-exp)underflowyy-
lgamma()overflowyye.g., lgamma(DBL_MAX)
lgamma()polenyOccurs when x is a non-positive integer; errno is set to EDOM (should be ERANGE)
llrint()domainnyx is NaN, infinity, or too large to store in a long long
llround()domainnyx is NaN, infinity, or too large to store in a long long
log(0)poleyy-
log(x<0)domainyy-
log10(0)poleyy-
log10(x<0)domainyy-
log1p(-1)poleny-
log1p(x<-1)domainny-
log2(0)poleyy-
log2(x<0)domainyy-
logb(0)poleny-
lrint()domainnyx is NaN, infinity, or too large to store in a long
lround()domainnyx is NaN, infinity, or too large to store in a long
nearbyint()---No errors occur
nextafter()overflownye.g., nextafter(DBL_MAX, +inf)
nextafter()underflownye.g., nextafter(DBL_MIN, 0);
nexttoward()overflownye.g., nexttoward(DBL_MAX, +inf)
nexttoward()underflownye.g., nexttoward(DBL_MIN, 0);
pow(0, -y)pole (0, neg)nyerrno is set to EDOM (should be ERANGE)
pow(x,y)overflowyy

Suitable values to cause overflow (e.g., pow(2, 1e100))

pow(x,y)underflowyy

Suitable values to cause underflow (e.g., pow(2, -1e100)

pow(x<0,>

domainyy-
remainder(+-inf,y)domainny-
remainder(x,0)domainyy-
remquo(+-inf,y)domainny-
remquo(x,0)domainny-
rint()---No errors occur
round()---No errors occur
scalb()overflownye.g., scalb(DBL_MAX, 200)
scalb()underflownye.g., scalb(DBL_MAX, -200)
scalb(0,+inf)domainny-
scalbln()overflownye.g., scalbln(DBL_MAX, 200)
scalbln()underflownye.g., scalbln(DBL_MAX, -200)
scalbn()overflownye.g., scalbn(DBL_MAX, 200)
scalbn()underflownye.g., scalbn(DBL_MAX, -200)
sin(+-inf)domainny-
sinh(+-large)overflowy-e.g., sinh(DBL_MAX)
sqrt(x<0)domainyy-
tan(+-inf)domainny-
tan(pi/2)overflow--No test possible, since the best approximation of pi/2 in double precision only yields a tan() value of 1.633e16.
tanh()---No errors occur
tgamma()underflownyOccurs for ranges of x values between negative integers, e.g., tgamma(-10000.5)
tgamma(+-0)poleyy-
tgamma(+large)overflowyy-
tgamma(-inf)domainny

Note the difference from
tgamma(x<0)

tgamma(x<0)domainyyFor finite x
trunc()---No errors occur
y0()overflow--Not possible to overflow with double
y0()underflowyne.g., y0(DBL_MAX)
y0(0)polennerrno is set to EDOM (should be ERANGE)
y0(x<0)domainyy-
y1()overflow--Not possible to overflow with double
y1()underflowyne.g., y1(DBL_MAX)
y1(0)polennerrno is set to EDOM (should be ERANGE)
y1(x<0)domainyy-
yn()overflownye.g., yn(1000, DBL_MIN)
yn()underflowyne.g., yn(10, DBL_MAX)
yn(0)polennerrno is set to EDOM (should be ERANGE)
yn(x<0)domainyy-

Tuesday, August 5, 2008

man-pages-3.06 is released

I've uploaded man-pages-3.06 into the release directory (or view the online pages). The main changes in man-pages-3.06 are updates to around 65 math pages. The changes are broadly as follows:
  • RETURN VALUE: in many cases, the math pages lacked descriptions of the return value when the function arguments are special cases such as +0, -0, NaN (not-a-number), +infinity, -infinity, etc. This has been fixed. I carried out tests on glibc 2.8 to ensure that the behavior of all of these functions matches the RETURN VALUE descriptions (and the POSIX.1-2001 requirements).
  • BUGS: a BUGS sections was added to a few pages to document deviations from from expected behavior.
  • ERRORS: many pages lacked a clear (or indeed any) description of how errno is set on error and what exception is raised for each error. This has been fixed. The ERRORS sections are now generally headed up as per the POSIX.1 way of doing things, describing Pole, Range, and Domain errors, as applicable. I carried out tests on glibc 2.8 to ensure that all of these functions match the ERRORS descriptions. Deviations from POSIX.1-2001 requirements have been filed as glibc bug reports, and noted in the man pages. (The pages now describe the situation for ERRORS as at glibc 2.8. I may eventually try and extend the text with descriptions of changes in older versions of glibc; watch for a post on that subject in the next days, when I'll describe my test scripts.)
  • Fixed feature test macros (FTMs). Often, the FTM requirements for the float and long double versions of a math function are different from the requirements for the double version. Each math page now shows the correct FTM requirements for all three versions of the function(s) it describes. This may have required either a change to the existing FTM text (if the requirements for the double function were already described), or the addition of an FTM description to a SYNOPSIS where one was not previously present (typically because the double version of the function does not require any FTMs to be defined). A few outright errors in the documentation of FTM requirements were also fixed.
  • CONFORMING TO: in many cases, POSIX.1-2001 was not mentioned. Where a function is specified in POSIX.1-2001, this is now noted. Also, statements about what other standards a function conforms to were generally clarified. (The wording about which functions conformed to C99 was previously often done as an add-on sentence; now it is made part of the first sentence of the CONFORMING TO section, along with mention of POSIX.1-2001.)
While making all of the above changes, I split out some logically separate material from existing pages to create three new pages: erfc(3) (formerly part of erf(3)), scalbln(3) (formerly part of scalb(3)), and y0(3) (formerly part of j0(3)).

P.S. One point that is still not covered in any page is the circumstances that generate inexact (FE_INEXACT) floating-point exceptions. (The details for these exceptions are not specified in POSIX.1-2001, and I haven't gone looking for the standards that describe the details.) If anyone has thoughts on what needs to be done about this, I'm open to ideas.

Grünegg