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