projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix ESRCH error handling for clock_getcpuclockid
[musl]
/
src
/
locale
/
locale_map.c
diff --git
a/src/locale/locale_map.c
b/src/locale/locale_map.c
index
30aa7fc
..
da61f7f
100644
(file)
--- a/
src/locale/locale_map.c
+++ b/
src/locale/locale_map.c
@@
-1,8
+1,16
@@
#include <locale.h>
#include <string.h>
#include <locale.h>
#include <string.h>
+#include <sys/mman.h>
+#include <stdlib.h>
#include "locale_impl.h"
#include "libc.h"
#include "locale_impl.h"
#include "libc.h"
-#include "atomic.h"
+#include "lock.h"
+#include "fork_impl.h"
+
+#define malloc __libc_malloc
+#define calloc undef
+#define realloc undef
+#define free undef
const char *__lctrans_impl(const char *msg, const struct __locale_map *lm)
{
const char *__lctrans_impl(const char *msg, const struct __locale_map *lm)
{
@@
-11,10
+19,6
@@
const char *__lctrans_impl(const char *msg, const struct __locale_map *lm)
return trans ? trans : msg;
}
return trans ? trans : msg;
}
-const unsigned char *__map_file(const char *, size_t *);
-int __munmap(void *, size_t);
-char *__strchrnul(const char *, int);
-
static const char envvars[][12] = {
"LC_CTYPE",
"LC_NUMERIC",
static const char envvars[][12] = {
"LC_CTYPE",
"LC_NUMERIC",
@@
-24,17
+28,11
@@
static const char envvars[][12] = {
"LC_MESSAGES",
};
"LC_MESSAGES",
};
-static const uint32_t empty_mo[] = { 0x950412de, 0, -1, -1, -1 };
-
-static const struct __locale_map c_dot_utf8 = {
- .map = empty_mo,
- .map_size = sizeof empty_mo,
- .name = "C.UTF-8"
-};
+volatile int __locale_lock[1];
+volatile int *const __locale_lockptr = __locale_lock;
const struct __locale_map *__get_locale(int cat, const char *val)
{
const struct __locale_map *__get_locale(int cat, const char *val)
{
- static int lock[2];
static void *volatile loc_head;
const struct __locale_map *p;
struct __locale_map *new = 0;
static void *volatile loc_head;
const struct __locale_map *p;
struct __locale_map *new = 0;
@@
-58,27
+56,19
@@
const struct __locale_map *__get_locale(int cat, const char *val)
if (builtin) {
if (cat == LC_CTYPE && val[1]=='.')
if (builtin) {
if (cat == LC_CTYPE && val[1]=='.')
- return (void *)&c_dot_utf8;
+ return (void *)&
__
c_dot_utf8;
return 0;
}
for (p=loc_head; p; p=p->next)
if (!strcmp(val, p->name)) return p;
return 0;
}
for (p=loc_head; p; p=p->next)
if (!strcmp(val, p->name)) return p;
- LOCK(lock);
-
- for (p=loc_head; p; p=p->next)
- if (!strcmp(val, p->name)) {
- UNLOCK(lock);
- return p;
- }
-
if (!libc.secure) path = getenv("MUSL_LOCPATH");
/* FIXME: add a default path? */
if (path) for (; *path; path=z+!!*z) {
z = __strchrnul(path, ':');
if (!libc.secure) path = getenv("MUSL_LOCPATH");
/* FIXME: add a default path? */
if (path) for (; *path; path=z+!!*z) {
z = __strchrnul(path, ':');
- l = z - path
- !!*z
;
+ l = z - path;
if (l >= sizeof buf - n - 2) continue;
memcpy(buf, path, l);
buf[l] = '/';
if (l >= sizeof buf - n - 2) continue;
memcpy(buf, path, l);
buf[l] = '/';
@@
-107,8
+97,8
@@
const struct __locale_map *__get_locale(int cat, const char *val)
* sake of being able to do message translations at the
* application level. */
if (!new && (new = malloc(sizeof *new))) {
* sake of being able to do message translations at the
* application level. */
if (!new && (new = malloc(sizeof *new))) {
- new->map =
empty_mo
;
- new->map_size =
sizeof empty_mo
;
+ new->map =
__c_dot_utf8.map
;
+ new->map_size =
__c_dot_utf8.map_size
;
memcpy(new->name, val, n);
new->name[n] = 0;
new->next = loc_head;
memcpy(new->name, val, n);
new->name[n] = 0;
new->next = loc_head;
@@
-117,8
+107,7
@@
const struct __locale_map *__get_locale(int cat, const char *val)
/* For LC_CTYPE, never return a null pointer unless the
* requested name was "C" or "POSIX". */
/* For LC_CTYPE, never return a null pointer unless the
* requested name was "C" or "POSIX". */
- if (!new && cat == LC_CTYPE) new = (void *)&c_dot_utf8;
+ if (!new && cat == LC_CTYPE) new = (void *)&
__
c_dot_utf8;
- UNLOCK(lock);
return new;
}
return new;
}