1#pragma once 2 3#include "libc.h" 4#include "threads_impl.h" 5#include <locale.h> 6#include <stdlib.h> 7 8#define LOCALE_NAME_MAX 15 9 10struct __locale_map { 11 const void* map; 12 size_t map_size; 13 char name[LOCALE_NAME_MAX + 1]; 14 const struct __locale_map* next; 15}; 16 17extern const struct __locale_map __c_dot_utf8; 18extern const struct __locale_struct __c_locale; 19extern const struct __locale_struct __c_dot_utf8_locale; 20 21const struct __locale_map* __get_locale(int, const char*) ATTR_LIBC_VISIBILITY; 22const char* __mo_lookup(const void*, size_t, const char*) ATTR_LIBC_VISIBILITY; 23const char* __lctrans(const char*, const struct __locale_map*) 24 ATTR_LIBC_VISIBILITY; 25const char* __lctrans_cur(const char*) ATTR_LIBC_VISIBILITY; 26int __loc_is_allocated(locale_t) ATTR_LIBC_VISIBILITY; 27 28#define LCTRANS(msg, lc, loc) __lctrans(msg, (loc)->cat[(lc)]) 29#define LCTRANS_CUR(msg) __lctrans_cur(msg) 30 31#define C_LOCALE ((locale_t)&__c_locale) 32#define UTF8_LOCALE ((locale_t)&__c_dot_utf8_locale) 33 34#define CURRENT_LOCALE (__thrd_current()->locale) 35 36#define CURRENT_UTF8 (!!__thrd_current()->locale->cat[LC_CTYPE]) 37 38#undef MB_CUR_MAX 39#define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1) 40