1 // -*- C++ -*- 2 //===------------------- support/ibm/locale_mgmt_aix.h --------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 #ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H 12 #define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H 13 14 #if defined(_AIX) 15 #include "cstdlib" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #if !defined(_AIX71) 22 // AIX 7.1 and higher has these definitions. Definitions and stubs 23 // are provied here as a temporary workaround on AIX 6.1. 24 25 #define LC_COLLATE_MASK 1 26 #define LC_CTYPE_MASK 2 27 #define LC_MESSAGES_MASK 4 28 #define LC_MONETARY_MASK 8 29 #define LC_NUMERIC_MASK 16 30 #define LC_TIME_MASK 32 31 #define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ 32 LC_MESSAGES_MASK | LC_MONETARY_MASK |\ 33 LC_NUMERIC_MASK | LC_TIME_MASK) 34 35 typedef void* locale_t; 36 37 // The following are stubs. They are not supported on AIX 6.1. 38 static inline newlocale(int category_mask,const char * locale,locale_t base)39locale_t newlocale(int category_mask, const char *locale, locale_t base) 40 { 41 _LC_locale_t *newloc, *loc; 42 if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) 43 { 44 errno = EINVAL; 45 return (locale_t)0; 46 } 47 if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) 48 { 49 errno = ENOMEM; 50 return (locale_t)0; 51 } 52 if (!base) 53 base = (_LC_locale_t *)__xopen_locale("C"); 54 memcpy(newloc, base, sizeof (_LC_locale_t)); 55 if (category_mask & LC_COLLATE_MASK) 56 newloc->lc_collate = loc->lc_collate; 57 if (category_mask & LC_CTYPE_MASK) 58 newloc->lc_ctype = loc->lc_ctype; 59 //if (category_mask & LC_MESSAGES_MASK) 60 // newloc->lc_messages = loc->lc_messages; 61 if (category_mask & LC_MONETARY_MASK) 62 newloc->lc_monetary = loc->lc_monetary; 63 if (category_mask & LC_TIME_MASK) 64 newloc->lc_time = loc->lc_time; 65 if (category_mask & LC_NUMERIC_MASK) 66 newloc->lc_numeric = loc->lc_numeric; 67 return (locale_t)newloc; 68 } 69 static inline freelocale(locale_t locobj)70void freelocale(locale_t locobj) 71 { 72 free(locobj); 73 } 74 static inline uselocale(locale_t newloc)75locale_t uselocale(locale_t newloc) 76 { 77 return (locale_t)0; 78 } 79 #endif // !defined(_AIX71) 80 81 #ifdef __cplusplus 82 } 83 #endif 84 #endif // defined(_AIX) 85 #endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H 86