locale_mgmt_aix.h 2.4 KB

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