Commit graph

13 commits

Author SHA1 Message Date
Yabin Cui
f7e3b3e48a Use pthread_once for g_uselocale_key creation.
Bug: 19625804
Change-Id: I57ec4c965067dc0c157c795c1f7217a3ca403286
2015-03-05 20:39:10 -08:00
Yabin Cui
4a2891d8c8 Better control of pthread keys used in bionic.
Change-Id: I1e1bc77c0e7879baead6c3417282ce549a1153b5
2015-03-04 16:53:23 -08:00
Dan Albert
75ef63d6cf Move some pthread functions to signal.h.
POSIX specifies that pthread_kill(3) and pthread_sigmask(3) are
supposed to live in signal.h rather than pthread.h.

Since signal.h now needs pthread_t and pthread_attr_t, I've moved
those defintions into include/machine/pthread_types.h to keep the
namespace clean. I also sorted some includes. The combination of these
two things seems to have exploded into a cascade of missing includes,
so this patch also cleans up all those.

Change-Id: Icfa92a39432fe83f542a797e5a113289d7e4ad0c
2014-11-21 10:26:09 -08:00
Elliott Hughes
b20c24456e Implement all the POSIX _l functions.
Strictly speaking, this only implements the _l variants of the functions
we actually have. We're still missing nl_langinfo_l, for example, but we
don't have nl_langinfo either.

Change-Id: Ie711c7b04e7b9100932a13f5a5d5b28847eb4c12
2014-11-06 15:52:22 -08:00
Elliott Hughes
7e0d0f8572 Fix newlocale with a NULL locale name.
Bug: https://code.google.com/p/android/issues/detail?id=78567
Change-Id: I272dabc12ab186b44a525c7e8ac1846e62334e85
2014-11-04 18:03:44 -08:00
Dan Albert
224ff048ef Change name of MB_CUR_MAX implementation function.
Glibc calls theirs __ctype_get_mb_cur_max. Make ours match to cut down
on differences between bionic and glibc.

Bug: 11156955
Change-Id: Ib7231f01aa9676dff30aea0af25d597bfe07bc73
2014-08-14 13:56:51 -07:00
Dan Albert
1aec7c1a35 Proper MB_CUR_MAX.
Previously this was hard coded to 4. This is only the case for UTF-8
locales.

As a side effect, this properly reports C.UTF-8 as the default locale
instead of C.

Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
2014-07-30 17:09:46 -07:00
Dan Albert
1abb8bd21d en_US.UTF-8 is also supported.
Change-Id: Ic35fad3596dc5e24ee8ae35543a274a471f27bb2
2014-07-25 11:24:03 -07:00
Elliott Hughes
1728b23965 Switch to g_ for globals.
That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
2014-05-14 10:02:03 -07:00
Elliott Hughes
5a0aa3dee2 Switch to a working UTF-8 mb/wc implementation.
Although glibc gets by with an 8-byte mbstate_t, OpenBSD uses 12 bytes (of
the 128 bytes it reserves!).

We can actually implement UTF-8 encoding/decoding with a 0-byte mbstate_t
which means we can make things work on LP32 too, as long as we accept the
limitation that the caller needs to present us with a complete sequence
before we'll process it.

Our behavior is fine when going from characters to bytes; we just
update the source wchar_t** to say how far through the input we got.

I'll come back and use the 4 bytes we do have to cope with byte sequences
split across multiple input buffers. The fact that we don't support
UTF-8 sequences longer than 4 bytes plus the fact that the first byte of
a UTF-8 sequence encodes the length means we shouldn't need the other
fields OpenBSD used (at the cost of some recomputation in cases where a
sequence is split across buffers).

This patch also makes the minimal changes necessary to setlocale(3) to
make us behave like glibc when an app requests UTF-8. (The difference
being that our "C" locale is the same as our "C.UTF-8" locale.)

Change-Id: Ied327a8c4643744b3611bf6bb005a9b389ba4c2f
2014-05-01 14:46:54 -07:00
Elliott Hughes
2f68866f37 Make uselocale(3) claim its pthread key in an ELF constructor.
pthread_once is nice for decoupling, but it makes resource availability less
predictable, which is a bad thing.

This fixes a test failure if uselocale(3) is called before
pthread.pthread_key_create_lots runs.

Change-Id: Ie2634f986a50e7965582d4bd6e5aaf48cf0d55c8
2014-04-18 13:34:26 -07:00
Elliott Hughes
c4936e20a3 Flesh out <locale.h>.
This is a trivial implementation that only supports the C/POSIX locale.

Change-Id: Ib11cea4249e1862aca96a8b94d58ea9a418cbe75
2014-04-08 19:37:38 -07:00
Elliott Hughes
5363a45f2b Clean up localeconv(3).
The OpenBSD doesn't support C99, and the extent to which we support
locales is trivial, so just do it ourselves.

Change-Id: If0a06e627ecc593f7b8ea3e9389365782e49b00e
2014-04-08 14:34:12 -07:00
Renamed from libc/bionic/setlocale.cpp (Browse further)