1 #ifndef _LOCALE_IMPL_H 2 #define _LOCALE_IMPL_H 3 4 #include <locale.h> 5 #include <stdlib.h> 6 #include "libc.h" 7 #include "pthread_impl.h" 8 9 #define LOCALE_NAME_MAX 23 10 #define VALID 2 11 #define INVALID 1 12 13 struct __locale_map { 14 const void *map; 15 size_t map_size; 16 char name[LOCALE_NAME_MAX+1]; 17 const struct __locale_map *next; 18 char flag; 19 }; 20 21 extern hidden volatile int __locale_lock[1]; 22 23 extern hidden const struct __locale_map __c_dot_utf8; 24 extern hidden const struct __locale_struct __c_locale; 25 extern hidden const struct __locale_struct __c_dot_utf8_locale; 26 27 hidden const struct __locale_map *__get_locale(int, const char *); 28 hidden const char *__mo_lookup(const void *, size_t, const char *); 29 hidden const char *__lctrans(const char *, const struct __locale_map *); 30 hidden const char *__lctrans_cur(const char *); 31 hidden const char *__lctrans_impl(const char *, const struct __locale_map *); 32 hidden int __loc_is_allocated(locale_t); 33 hidden char *__gettextdomain(void); 34 35 #define LOC_MAP_FAILED ((const struct __locale_map *)-1) 36 37 #define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)]) 38 #define LCTRANS_CUR(msg) __lctrans_cur(msg) 39 40 #define C_LOCALE ((locale_t)&__c_locale) 41 #define UTF8_LOCALE ((locale_t)&__c_dot_utf8_locale) 42 43 #define CURRENT_LOCALE (__pthread_self()->locale) 44 45 #define CURRENT_UTF8 (!!__pthread_self()->locale->cat[LC_CTYPE]) 46 47 #undef MB_CUR_MAX 48 #define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1) 49 50 #endif 51