blob: c0879d0cea3df3919e3e8653702636b648fbd010 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* Copyright (C) 2003 Manuel Novoa III
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the Free
15 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#include <features.h>
19#include "pthread.h"
20#include "internals.h"
21#include <locale.h>
22#include <assert.h>
23#include <stdlib.h>
24
25extern struct _pthread_descr_struct __pthread_initial_thread;
26
27__locale_t __curlocale(void)
28{
29 pthread_descr self = thread_self();
30
31#ifdef NDEBUG
32 return THREAD_GETMEM (self, locale);
33#else
34 {
35 __locale_t r = THREAD_GETMEM (self, locale);
36
37 assert(r);
38
39 return r;
40 }
41#endif
42}
43
44__locale_t __curlocale_set(__locale_t newloc)
45{
46 __locale_t oldloc;
47 pthread_descr self = thread_self();
48
49 oldloc = THREAD_GETMEM (self, locale);
50
51 assert(newloc != LC_GLOBAL_LOCALE);
52 assert(oldloc);
53
54 THREAD_SETMEM (self, locale, newloc);
55
56 return oldloc;
57}