1 #ifndef __PDCLIB_LOCALE_H
2 #define __PDCLIB_LOCALE_H __PDCLIB_LOCALE_H
3 #include <_PDCLIB_int.h>
8 #define _PDCLIB_LOCALE_METHOD_TSS 't'
9 #define _PDCLIB_LOCALE_METHOD_THREAD_LOCAL 'T'
11 #if !defined(_PDCLIB_LOCALE_METHOD)
12 #error _PDCLIB_LOCALE_METHOD undefined: don't know where I'm storing the thread locale
13 #elif _PDCLIB_LOCALE_METHOD == _PDCLIB_LOCALE_METHOD_TSS
14 extern tss_t _PDCLIB_locale_tss;
15 static inline locale_t _PDCLIB_threadlocale( void )
17 locale_t l = tss_get(_PDCLIB_locale_tss);
19 l = &_PDCLIB_global_locale;
23 static inline void _PDCLIB_setthreadlocale( locale_t l )
25 if(tss_set(_PDCLIB_locale_tss, l) != thrd_success)
28 #elif _PDCLIB_LOCALE_METHOD == _PDCLIB_LOCALE_METHOD_THREAD_LOCAL
29 extern thread_local locale_t _PDCLIB_locale_tls;
30 #define _PDCLIB_threadlocale() (_PDCLIB_locale_tls || &_PDCLIB_global_locale)
31 static inline locale_t _PDCLIB_threadlocale( void )
33 locale_t l = _PDCLIB_locale_tls;
35 l = &_PDCLIB_global_locale;
39 static inline void _PDCLIB_setthreadlocale( locale_t l )
41 _PDCLIB_locale_tls = l;
44 #error Locale TSS method unspecified
47 /* -------------------------------------------------------------------------- */
48 /* <ctype.h> lookup tables */
49 /* -------------------------------------------------------------------------- */
51 #define _PDCLIB_CTYPE_ALPHA 1
52 #define _PDCLIB_CTYPE_BLANK 2
53 #define _PDCLIB_CTYPE_CNTRL 4
54 #define _PDCLIB_CTYPE_GRAPH 8
55 #define _PDCLIB_CTYPE_PUNCT 16
56 #define _PDCLIB_CTYPE_SPACE 32
57 #define _PDCLIB_CTYPE_LOWER 64
58 #define _PDCLIB_CTYPE_UPPER 128
59 #define _PDCLIB_CTYPE_DIGIT 256
60 #define _PDCLIB_CTYPE_XDIGT 512
62 typedef struct _PDCLIB_ctype
64 _PDCLIB_uint16_t flags;
67 unsigned char collation;
70 typedef struct _PDCLIB_wctype
73 _PDCLIB_uint16_t flags;
74 _PDCLIB_uint32_t lower;
75 _PDCLIB_uint32_t upper;
78 struct _PDCLIB_locale {
79 _PDCLIB_charcodec_t _Codec;
83 _PDCLIB_ctype_t *_CType;
86 char *_ErrnoStr[_PDCLIB_ERRNO_MAX];