]> git.ipfire.org Git - thirdparty/glibc.git/blame - locale/global-locale.c
.
[thirdparty/glibc.git] / locale / global-locale.c
CommitLineData
1a0d874e 1/* Locale object representing the global locale controlled by setlocale.
32c075e1 2 Copyright (C) 2002 Free Software Foundation, Inc.
1a0d874e
RM
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20#include <locale.h>
21#include "localeinfo.h"
22
23#define DEFINE_CATEGORY(category, category_name, items, a) \
24extern struct locale_data _nl_C_##category; weak_extern (_nl_C_##category)
25#include "categories.def"
26#undef DEFINE_CATEGORY
27
28/* Defined in locale/C-ctype.c. */
29extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
30extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
31extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden;
32weak_extern (_nl_C_LC_CTYPE_class)
33weak_extern (_nl_C_LC_CTYPE_toupper)
34weak_extern (_nl_C_LC_CTYPE_tolower)
35
36/* Here we define the locale object maintained by setlocale.
37 The references in the initializer are weak, so the parts of
38 the structure that are never referred to will be zero. */
39
40struct __locale_struct _nl_global_locale attribute_hidden =
41 {
42 .__locales =
43 {
44#define DEFINE_CATEGORY(category, category_name, items, a) \
45 [category] = &_nl_C_##category,
46#include "categories.def"
1ce8aaae
RM
47#undef DEFINE_CATEGORY
48 },
49 .__names =
50 {
51 [LC_ALL] = _nl_C_name,
52#define DEFINE_CATEGORY(category, category_name, items, a) \
53 [category] = _nl_C_name,
54#include "categories.def"
1a0d874e
RM
55#undef DEFINE_CATEGORY
56 },
57 .__ctype_b = (const unsigned short int *) _nl_C_LC_CTYPE_class + 128,
58 .__ctype_tolower = (const int *) _nl_C_LC_CTYPE_tolower + 128,
59 .__ctype_toupper = (const int *) _nl_C_LC_CTYPE_toupper + 128
60 };
61
62#include <tls.h>
32c075e1 63#if USE_TLS && HAVE___THREAD
1a0d874e
RM
64/* The tsd macros don't permit an initializer. */
65__thread void *__libc_tsd_LOCALE = &_nl_global_locale;
66#else
67__libc_tsd_define (, LOCALE)
68/* This is a bad kludge presuming the variable name used by the macros.
cc13edc8
RM
69 Using typeof makes sure to barf if we do not match the macro definition.
70 This ifndef is a further bad kludge for Hurd, where there is an explicit
71 initialization. */
72# ifndef _HURD_THREADVAR_H
1a0d874e 73__typeof (__libc_tsd_LOCALE_data) __libc_tsd_LOCALE_data = &_nl_global_locale;
cc13edc8 74# endif
1a0d874e 75#endif