(__getlogin_r_loginuid): Also fail if tpwd after pwuid call is NULL.
[glibc.git] / locale / global-locale.c
blob63d1238fb0d05f88ef18669a1d022cc92e55b335
1 /* Locale object representing the global locale controlled by setlocale.
2 Copyright (C) 2002, 2006, 2008, 2010 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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. */
20 #include <locale.h>
21 #include "localeinfo.h"
23 #define DEFINE_CATEGORY(category, category_name, items, a) \
24 extern struct __locale_data _nl_C_##category; weak_extern (_nl_C_##category)
25 #include "categories.def"
26 #undef DEFINE_CATEGORY
28 /* Defined in locale/C-ctype.c. */
29 extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
30 extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
31 extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden;
32 weak_extern (_nl_C_LC_CTYPE_class)
33 weak_extern (_nl_C_LC_CTYPE_toupper)
34 weak_extern (_nl_C_LC_CTYPE_tolower)
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. */
40 struct __locale_struct _nl_global_locale attribute_hidden =
42 .__locales =
44 #define DEFINE_CATEGORY(category, category_name, items, a) \
45 [category] = &_nl_C_##category,
46 #include "categories.def"
47 #undef DEFINE_CATEGORY
49 .__names =
51 [LC_ALL] = _nl_C_name,
52 #define DEFINE_CATEGORY(category, category_name, items, a) \
53 [category] = _nl_C_name,
54 #include "categories.def"
55 #undef DEFINE_CATEGORY
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
62 #include <tls.h>
63 #if HAVE___THREAD
64 /* The tsd macros don't permit an initializer. */
65 __thread __locale_t __libc_tsd_LOCALE = &_nl_global_locale;
66 #else
67 __libc_tsd_define (, __locale_t, LOCALE)
68 /* This is a bad kludge presuming the variable name used by the macros.
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
73 __typeof (__libc_tsd_LOCALE_data) __libc_tsd_LOCALE_data = &_nl_global_locale;
74 # endif
75 #endif