locale_mgmt_aix.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
  11. #define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
  12. #if defined(_AIX)
  13. #include "cstdlib"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if !defined(_AIX71)
  18. // AIX 7.1 and higher has these definitions. Definitions and stubs
  19. // are provied here as a temporary workaround on AIX 6.1.
  20. #define LC_COLLATE_MASK 1
  21. #define LC_CTYPE_MASK 2
  22. #define LC_MESSAGES_MASK 4
  23. #define LC_MONETARY_MASK 8
  24. #define LC_NUMERIC_MASK 16
  25. #define LC_TIME_MASK 32
  26. #define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \
  27. LC_MESSAGES_MASK | LC_MONETARY_MASK |\
  28. LC_NUMERIC_MASK | LC_TIME_MASK)
  29. typedef void* locale_t;
  30. // The following are stubs. They are not supported on AIX 6.1.
  31. static inline
  32. locale_t newlocale(int category_mask, const char *locale, locale_t base)
  33. {
  34. _LC_locale_t *newloc, *loc;
  35. if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL)
  36. {
  37. errno = EINVAL;
  38. return (locale_t)0;
  39. }
  40. if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL)
  41. {
  42. errno = ENOMEM;
  43. return (locale_t)0;
  44. }
  45. if (!base)
  46. base = (_LC_locale_t *)__xopen_locale("C");
  47. memcpy(newloc, base, sizeof (_LC_locale_t));
  48. if (category_mask & LC_COLLATE_MASK)
  49. newloc->lc_collate = loc->lc_collate;
  50. if (category_mask & LC_CTYPE_MASK)
  51. newloc->lc_ctype = loc->lc_ctype;
  52. //if (category_mask & LC_MESSAGES_MASK)
  53. // newloc->lc_messages = loc->lc_messages;
  54. if (category_mask & LC_MONETARY_MASK)
  55. newloc->lc_monetary = loc->lc_monetary;
  56. if (category_mask & LC_TIME_MASK)
  57. newloc->lc_time = loc->lc_time;
  58. if (category_mask & LC_NUMERIC_MASK)
  59. newloc->lc_numeric = loc->lc_numeric;
  60. return (locale_t)newloc;
  61. }
  62. static inline
  63. void freelocale(locale_t locobj)
  64. {
  65. free(locobj);
  66. }
  67. static inline
  68. locale_t uselocale(locale_t newloc)
  69. {
  70. return (locale_t)0;
  71. }
  72. #endif // !defined(_AIX71)
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif // defined(_AIX)
  77. #endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H