diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2011-10-25 00:37:10 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2011-10-25 00:37:10 +0000 |
commit | 4bbe4e2185c5484328182720ff7b3bb4f9593bff (patch) | |
tree | cd67e40a74928c0f58d4f5b79d2e260e4099fee7 /libc/locale | |
parent | 91b4be71461f78cabe1fb5f164cea71b60e9e98a (diff) |
Merge changes between r15223 and r15532 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@15545 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/locale')
-rw-r--r-- | libc/locale/Makefile | 3 | ||||
-rw-r--r-- | libc/locale/global-locale.c | 14 | ||||
-rw-r--r-- | libc/locale/localeinfo.h | 4 | ||||
-rw-r--r-- | libc/locale/programs/locarchive.c | 74 |
4 files changed, 36 insertions, 59 deletions
diff --git a/libc/locale/Makefile b/libc/locale/Makefile index 3f0d0daa7..0186978ba 100644 --- a/libc/locale/Makefile +++ b/libc/locale/Makefile @@ -102,9 +102,6 @@ $(objpfx)localedef $(objpfx)locale: $(lib-modules:%=$(objpfx)%.o) C-translit.h: C-translit.h.in gen-translit.pl $(PERL) gen-translit.pl < $< > $@.tmp mv -f $@.tmp $@ -ifeq ($(with-cvs),yes) - test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@ -endif localepath = "$(localedir):$(i18ndir)" diff --git a/libc/locale/global-locale.c b/libc/locale/global-locale.c index 63d1238fb..c5681a736 100644 --- a/libc/locale/global-locale.c +++ b/libc/locale/global-locale.c @@ -1,5 +1,5 @@ /* Locale object representing the global locale controlled by setlocale. - Copyright (C) 2002, 2006, 2008, 2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2008, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -60,16 +60,6 @@ struct __locale_struct _nl_global_locale attribute_hidden = }; #include <tls.h> -#if HAVE___THREAD + /* The tsd macros don't permit an initializer. */ __thread __locale_t __libc_tsd_LOCALE = &_nl_global_locale; -#else -__libc_tsd_define (, __locale_t, LOCALE) -/* This is a bad kludge presuming the variable name used by the macros. - Using typeof makes sure to barf if we do not match the macro definition. - This ifndef is a further bad kludge for Hurd, where there is an explicit - initialization. */ -# ifndef _HURD_THREADVAR_H -__typeof (__libc_tsd_LOCALE_data) __libc_tsd_LOCALE_data = &_nl_global_locale; -# endif -#endif diff --git a/libc/locale/localeinfo.h b/libc/locale/localeinfo.h index 72e9d3a6e..6cf05b215 100644 --- a/libc/locale/localeinfo.h +++ b/libc/locale/localeinfo.h @@ -1,5 +1,5 @@ /* Declarations for internal libc locale interfaces - Copyright (C) 1995-2003, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright (C) 1995-2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -216,7 +216,7 @@ __libc_tsd_define (extern, __locale_t, LOCALE) unused. We can manage this playing some tricks with weak references. But with thread-local locale settings, it becomes quite ungainly unless we can use __thread variables. So only in that case do we attempt this. */ -#if !defined SHARED && defined HAVE___THREAD && defined HAVE_WEAK_SYMBOLS +#if !defined SHARED && defined HAVE_WEAK_SYMBOLS # include <tls.h> # define NL_CURRENT_INDIRECT 1 #endif diff --git a/libc/locale/programs/locarchive.c b/libc/locale/programs/locarchive.c index bb90e1706..fe74f37d4 100644 --- a/libc/locale/programs/locarchive.c +++ b/libc/locale/programs/locarchive.c @@ -74,6 +74,29 @@ static const char *locnames[] = /* Size of the reserved address space area. */ #define RESERVE_MMAP_SIZE 512 * 1024 * 1024 +/* To prepare for enlargements of the mmaped area reserve some address + space. On some machines, being a file mapping rather than an anonymous + mapping affects the address selection. So do this mapping from the + actual file, even though it's only a dummy to reserve address space. */ +static void * +prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags) +{ + if (total < RESERVE_MMAP_SIZE) + { + void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_SHARED, fd, 0); + if (p != MAP_FAILED) + { + *reserved = RESERVE_MMAP_SIZE; + *xflags = MAP_FIXED; + return p; + } + } + + *reserved = total; + *xflags = 0; + return NULL; +} + static void create_archive (const char *archivefname, struct locarhandle *ah) @@ -81,7 +104,6 @@ create_archive (const char *archivefname, struct locarhandle *ah) int fd; char fname[strlen (archivefname) + sizeof (".XXXXXX")]; struct locarhead head; - void *p; size_t total; strcpy (stpcpy (fname, archivefname), ".XXXXXX"); @@ -129,19 +151,9 @@ create_archive (const char *archivefname, struct locarhandle *ah) error (EXIT_FAILURE, errval, _("cannot resize archive file")); } - /* To prepare for enlargements of the mmaped area reserve some - address space. */ - size_t reserved = RESERVE_MMAP_SIZE; - int xflags = 0; - if (total < reserved - && ((p = mmap64 (NULL, reserved, PROT_NONE, MAP_PRIVATE | MAP_ANON, - -1, 0)) != MAP_FAILED)) - xflags = MAP_FIXED; - else - { - p = NULL; - reserved = total; - } + size_t reserved; + int xflags; + void *p = prepare_address_space (fd, total, &reserved, &xflags); /* Map the header and all the administration data structures. */ p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); @@ -297,7 +309,6 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) int fd; struct locarhead newhead; size_t total; - void *p; unsigned int cnt, loccnt; struct namehashent *oldnamehashtab; struct locarhandle new_ah; @@ -391,19 +402,9 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) error (EXIT_FAILURE, errval, _("cannot resize archive file")); } - /* To prepare for enlargements of the mmaped area reserve some - address space. */ - size_t reserved = RESERVE_MMAP_SIZE; - int xflags = 0; - if (total < reserved - && ((p = mmap64 (NULL, reserved, PROT_NONE, MAP_PRIVATE | MAP_ANON, - -1, 0)) != MAP_FAILED)) - xflags = MAP_FIXED; - else - { - p = NULL; - reserved = total; - } + size_t reserved; + int xflags; + void *p = prepare_address_space (fd, total, &reserved, &xflags); /* Map the header and all the administration data structures. */ p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); @@ -606,20 +607,9 @@ open_archive (struct locarhandle *ah, bool readonly) ah->fd = fd; ah->mmaped = st.st_size; - /* To prepare for enlargements of the mmaped area reserve some - address space. */ - size_t reserved = RESERVE_MMAP_SIZE; - int xflags = 0; - void *p; - if (st.st_size < reserved - && ((p = mmap64 (NULL, reserved, PROT_NONE, MAP_PRIVATE | MAP_ANON, - -1, 0)) != MAP_FAILED)) - xflags = MAP_FIXED; - else - { - p = NULL; - reserved = st.st_size; - } + size_t reserved; + int xflags; + void *p = prepare_address_space (fd, st.st_size, &reserved, &xflags); /* Map the entire file. We might need to compare the category data in the file with the newly added data. */ |