xlocale patch

David Chisnall theraven at theravensnest.org
Mon Sep 19 14:29:24 UTC 2011


Hello Roman et al.,

Here is a big patch that provides everything needed to get libc++ building on FreeBSD (head), which I think means that the linker is now the only bit of the C++ stack that is not permissively licensed.  The patch contains the following:

- The POSIX2008 locale functions.  The specifications of these are evidence that the Austin Group has been indulging in the other product that UCB is famous for.  Where the specification is ambiguous (i.e. everywhere), I have used the Darwin implementation as a guide.  This was done because libc++ is developed on Darwin, so will likely expect this behaviour.

- The xlocale (Darwin extension) APIs.  These provide _l suffixed versions of a load of libc functions, which take a locale_t as a special argument.  The standard libc functions are now modified to call the _l version with the current locale.  

- Some stub definitions in libm for the long double versions of the functions (<cmath> needs them to be in <math.h>).  These versions just call the double versions, so they lose precision and are therefore hidden if you define __NO_IMPRECISE_LIBM_FUNCTIONS.  

I've also attached some tests.  The check_functions tool can be used as $(CC) when building libc.  It scans each of the _l functions and ensures that they don't refer to any global state or call any of the non-_l versions.  There are also tests for the new locale functions (these expect a checkout of head in /root/head - modify the Makefile in the tests if it is elsewhere).  As well as running these tests, I've also built world with this diff installed.

This work was sponsored by The FreeBSD Foundation.  Comments / bug reports / test cases welcome!

David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xlocale.diff
Type: application/octet-stream
Size: 388562 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110919/4a8f67a7/xlocale-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tbz
Type: application/octet-stream
Size: 26706 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110919/4a8f67a7/test-0001.obj


More information about the freebsd-hackers mailing list