* locale/locale.h [__USE_GNU] (locale_t): New type alias of __locale_t.
[__USE_GNU] (newlocale, duplocale, freelocale, uselocale): New decls.
[__USE_GNU] (LC_GLOBAL_LOCALE): New macro.
* locale/newlocale.c: Add alias to __ name.
* locale/duplocale.c: Likewise.
* locale/freelocale.c: Likewise.
* locale/uselocale.c: New file.
* locale/Makefile (routines): Add it.
* locale/Versions (libc: GLIBC_2.3): New set.
Add newlocale, duplocale, freelocale, uselocale.
(libc: GLIBC_PRIVATE): Add __uselocale.
# missing function from the experimental locale implementation
__nl_langinfo_l;
}
+ GLIBC_2.3 {
+ # the new "experimental" interface is now public
+ newlocale; duplocale; freelocale; uselocale;
+ }
GLIBC_PRIVATE {
# global variables
__collate_element_hash; __collate_element_strings;
__collate_symbol_classes; __collate_symbol_hash; __collate_symbol_strings;
+
+ # this internal name is used by libpthread
+ __uselocale;
}
}
return result;
}
+weak_alias (__duplocale, duplocale)
/* It's done. */
__libc_lock_unlock (__libc_setlocale_lock);
}
+weak_alias (__freelocale, freelocale)
-/* Copyright (C) 1991,92,1995-1999,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,95-99,2000,01,02 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
/* Get locale datatype definition. */
# include <xlocale.h>
+typedef __locale_t locale_t;
+
/* Return a reference to a data structure representing a set of locale
datasets. Unlike for the CATEGORY parameter for `setlocale' the
CATEGORY_MASK parameter here uses a single bit for each category.
record is replaced. */
extern __locale_t __newlocale (int __category_mask, __const char *__locale,
__locale_t __base) __THROW;
+extern __locale_t newlocale (int __category_mask, __const char *__locale,
+ __locale_t __base) __THROW;
/* Return a duplicate of the set of locale in DATASET. All usage
counters are increased if necessary. */
extern __locale_t __duplocale (__locale_t __dataset) __THROW;
+extern __locale_t duplocale (__locale_t __dataset) __THROW;
/* Free the data associated with a locale dataset previously returned
by a call to `setlocale_r'. */
extern void __freelocale (__locale_t __dataset) __THROW;
+extern void freelocale (__locale_t __dataset) __THROW;
+
+/* Switch the current thread's locale to DATASET.
+ If DATASET is null, instead just return the current setting.
+ The special value LC_GLOBAL_LOCALE is the initial setting
+ for all threads and can also be installed any time, meaning
+ the thread uses the global settings controlled by `setlocale'. */
+extern __locale_t __uselocale (__locale_t __dataset) __THROW;
+extern __locale_t uselocale (__locale_t __dataset) __THROW;
+
+/* This value can be passed to `uselocale' and may be returned by it.
+ Passing this value to any other function has undefined behavior. */
+# define LC_GLOBAL_LOCALE ((__locale_t) -1L)
+
#endif
__END_DECLS
--- /dev/null
+/* uselocale -- fetch and set the current per-thread locale
+ Copyright (C) 2002 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <locale.h>
+#include "localeinfo.h"
+
+#ifdef SHARED
+
+/* Switch the current thread's locale to DATASET.
+ If DATASET is null, instead just return the current setting.
+ The special value LC_GLOBAL_LOCALE is the initial setting
+ for all threads, and means the thread uses the global
+ setting controlled by `setlocale'. */
+locale_t
+__uselocale (locale_t newloc)
+{
+ if (newloc == NULL)
+ {
+ locale_t loc = __libc_tsd_get (LOCALE);
+ return loc == &_nl_global_locale ? LC_GLOBAL_LOCALE : loc;
+ }
+ if (newloc == LC_GLOBAL_LOCALE)
+ {
+ __libc_tsd_set (LOCALE, &_nl_global_locale);
+ return LC_GLOBAL_LOCALE;
+ }
+ __libc_tsd_set (LOCALE, newloc);
+ return newloc;
+}
+weak_alias (__uselocale, uselocale)
+
+#else
+
+# warning uselocale not implemented for static linking yet
+
+#endif