atoll: Assume that the compiler supports 'long long'.
[gnulib.git] / lib / locale.in.h
blobf4eccc230ccf8ac138e79cff9a84054280110350
1 /* A POSIX <locale.h>.
2 Copyright (C) 2007-2019 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #if __GNUC__ >= 3
18 @PRAGMA_SYSTEM_HEADER@
19 #endif
20 @PRAGMA_COLUMNS@
22 #if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
23 || defined _GL_ALREADY_INCLUDING_LOCALE_H
25 /* Special invocation convention:
26 - Inside mingw header files,
27 - To handle Solaris header files (through Solaris 10) when combined
28 with gettext's libintl.h. */
30 #@INCLUDE_NEXT@ @NEXT_LOCALE_H@
32 #else
33 /* Normal invocation convention. */
35 #ifndef _@GUARD_PREFIX@_LOCALE_H
37 #define _GL_ALREADY_INCLUDING_LOCALE_H
39 /* The include_next requires a split double-inclusion guard. */
40 #@INCLUDE_NEXT@ @NEXT_LOCALE_H@
42 #undef _GL_ALREADY_INCLUDING_LOCALE_H
44 #ifndef _@GUARD_PREFIX@_LOCALE_H
45 #define _@GUARD_PREFIX@_LOCALE_H
47 /* NetBSD 5.0 mis-defines NULL. */
48 #include <stddef.h>
50 /* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
51 #if @HAVE_XLOCALE_H@
52 # include <xlocale.h>
53 #endif
55 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
57 /* The definition of _GL_ARG_NONNULL is copied here. */
59 /* The definition of _GL_WARN_ON_USE is copied here. */
61 /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
62 On systems that don't define it, use the same value as GNU libintl. */
63 #if !defined LC_MESSAGES
64 # define LC_MESSAGES 1729
65 #endif
67 /* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
68 int_n_*. Instead of overriding 'struct lconv', merely define these member
69 names as macros. This avoids trouble in C++ mode. */
70 #if defined _MSC_VER
71 # define int_p_cs_precedes p_cs_precedes
72 # define int_p_sign_posn p_sign_posn
73 # define int_p_sep_by_space p_sep_by_space
74 # define int_n_cs_precedes n_cs_precedes
75 # define int_n_sign_posn n_sign_posn
76 # define int_n_sep_by_space n_sep_by_space
77 #endif
79 /* Bionic libc's 'struct lconv' is just a dummy. */
80 #if @REPLACE_STRUCT_LCONV@
81 # define lconv rpl_lconv
82 struct lconv
84 /* All 'char *' are actually 'const char *'. */
86 /* Members that depend on the LC_NUMERIC category of the locale. See
87 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
89 /* Symbol used as decimal point. */
90 char *decimal_point;
91 /* Symbol used to separate groups of digits to the left of the decimal
92 point. */
93 char *thousands_sep;
94 /* Definition of the size of groups of digits to the left of the decimal
95 point. */
96 char *grouping;
98 /* Members that depend on the LC_MONETARY category of the locale. See
99 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
101 /* Symbol used as decimal point. */
102 char *mon_decimal_point;
103 /* Symbol used to separate groups of digits to the left of the decimal
104 point. */
105 char *mon_thousands_sep;
106 /* Definition of the size of groups of digits to the left of the decimal
107 point. */
108 char *mon_grouping;
109 /* Sign used to indicate a value >= 0. */
110 char *positive_sign;
111 /* Sign used to indicate a value < 0. */
112 char *negative_sign;
114 /* For formatting local currency. */
115 /* Currency symbol (3 characters) followed by separator (1 character). */
116 char *currency_symbol;
117 /* Number of digits after the decimal point. */
118 char frac_digits;
119 /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
120 comes after the number. */
121 char p_cs_precedes;
122 /* For values >= 0: Position of the sign. */
123 char p_sign_posn;
124 /* For values >= 0: Placement of spaces between currency symbol, sign, and
125 number. */
126 char p_sep_by_space;
127 /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
128 comes after the number. */
129 char n_cs_precedes;
130 /* For values < 0: Position of the sign. */
131 char n_sign_posn;
132 /* For values < 0: Placement of spaces between currency symbol, sign, and
133 number. */
134 char n_sep_by_space;
136 /* For formatting international currency. */
137 /* Currency symbol (3 characters) followed by separator (1 character). */
138 char *int_curr_symbol;
139 /* Number of digits after the decimal point. */
140 char int_frac_digits;
141 /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
142 comes after the number. */
143 char int_p_cs_precedes;
144 /* For values >= 0: Position of the sign. */
145 char int_p_sign_posn;
146 /* For values >= 0: Placement of spaces between currency symbol, sign, and
147 number. */
148 char int_p_sep_by_space;
149 /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
150 comes after the number. */
151 char int_n_cs_precedes;
152 /* For values < 0: Position of the sign. */
153 char int_n_sign_posn;
154 /* For values < 0: Placement of spaces between currency symbol, sign, and
155 number. */
156 char int_n_sep_by_space;
158 #endif
160 #if @GNULIB_LOCALECONV@
161 # if @REPLACE_LOCALECONV@
162 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 # undef localeconv
164 # define localeconv rpl_localeconv
165 # endif
166 _GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
167 _GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
168 # else
169 _GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
170 # endif
171 # if __GLIBC__ >= 2
172 _GL_CXXALIASWARN (localeconv);
173 # endif
174 #elif @REPLACE_STRUCT_LCONV@
175 # undef localeconv
176 # define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
177 #elif defined GNULIB_POSIXCHECK
178 # undef localeconv
179 # if HAVE_RAW_DECL_LOCALECONV
180 _GL_WARN_ON_USE (localeconv,
181 "localeconv returns too few information on some platforms - "
182 "use gnulib module localeconv for portability");
183 # endif
184 #endif
186 #if @GNULIB_SETLOCALE@
187 # if @REPLACE_SETLOCALE@
188 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
189 # undef setlocale
190 # define setlocale rpl_setlocale
191 # define GNULIB_defined_setlocale 1
192 # endif
193 _GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
194 _GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
195 # else
196 _GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
197 # endif
198 # if __GLIBC__ >= 2
199 _GL_CXXALIASWARN (setlocale);
200 # endif
201 #elif defined GNULIB_POSIXCHECK
202 # undef setlocale
203 # if HAVE_RAW_DECL_SETLOCALE
204 _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
205 "use gnulib module setlocale for portability");
206 # endif
207 #endif
209 #if @GNULIB_SETLOCALE_NULL@
210 /* Recommended size of a buffer for a locale name for a single category.
211 On glibc systems, you can have locale names that are relative file names;
212 assume a maximum length 256.
213 In native Windows, in 2018 the longest locale name was of length 58
214 ("FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251"). */
215 # define SETLOCALE_NULL_MAX (256+1)
216 /* Recommended size of a buffer for a locale name with all categories.
217 On glibc systems, you can have locale names that are relative file names;
218 assume maximum length 256 for each. There are 12 categories; so, the
219 maximum total length is 148+12*256.
220 In native Windows, there are 5 categories, and the maximum total length is
221 55+5*58. */
222 # define SETLOCALE_NULL_ALL_MAX (148+12*256+1)
223 /* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
224 except that
225 - it is guaranteed to be multithread-safe,
226 - it returns the resulting locale category name or locale name in the
227 user-supplied buffer BUF, which must be BUFSIZE bytes long.
228 The recommended minimum buffer size is
229 - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and
230 - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL.
231 The return value is an error code: 0 if the call is successful, EINVAL if
232 CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed
233 size (including the trailing NUL byte). In the latter case, a truncated
234 result is returned in BUF, but still NUL-terminated if BUFSIZE > 0.
235 For this call to be multithread-safe, *all* calls to
236 setlocale (CATEGORY, NULL) in all other threads must have been converted
237 to use setlocale_null_r or setlocale_null as well, and the other threads
238 must not make other setlocale invocations (since changing the global locale
239 has side effects on all threads). */
240 _GL_FUNCDECL_SYS (setlocale_null_r, int,
241 (int category, char *buf, size_t bufsize)
242 _GL_ARG_NONNULL ((2)));
243 _GL_CXXALIAS_SYS (setlocale_null_r, int,
244 (int category, char *buf, size_t bufsize));
245 _GL_CXXALIASWARN (setlocale_null_r);
246 /* setlocale_null (CATEGORY) is like setlocale (CATEGORY, NULL), except that
247 it is guaranteed to be multithread-safe.
248 The return value is NULL if CATEGORY is invalid.
249 For this call to be multithread-safe, *all* calls to
250 setlocale (CATEGORY, NULL) in all other threads must have been converted
251 to use setlocale_null_r or setlocale_null as well, and the other threads
252 must not make other setlocale invocations (since changing the global locale
253 has side effects on all threads). */
254 _GL_FUNCDECL_SYS (setlocale_null, const char *, (int category));
255 _GL_CXXALIAS_SYS (setlocale_null, const char *, (int category));
256 _GL_CXXALIASWARN (setlocale_null);
257 #endif
259 #if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_NEWLOCALE@)
260 # if @REPLACE_NEWLOCALE@
261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
262 # undef newlocale
263 # define newlocale rpl_newlocale
264 # define GNULIB_defined_newlocale 1
265 # endif
266 _GL_FUNCDECL_RPL (newlocale, locale_t,
267 (int category_mask, const char *name, locale_t base)
268 _GL_ARG_NONNULL ((2)));
269 _GL_CXXALIAS_RPL (newlocale, locale_t,
270 (int category_mask, const char *name, locale_t base));
271 # else
272 # if @HAVE_NEWLOCALE@
273 _GL_CXXALIAS_SYS (newlocale, locale_t,
274 (int category_mask, const char *name, locale_t base));
275 # endif
276 # endif
277 # if @HAVE_NEWLOCALE@
278 _GL_CXXALIASWARN (newlocale);
279 # endif
280 # if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
281 # ifndef HAVE_WORKING_NEWLOCALE
282 # define HAVE_WORKING_NEWLOCALE 1
283 # endif
284 # endif
285 #elif defined GNULIB_POSIXCHECK
286 # undef newlocale
287 # if HAVE_RAW_DECL_NEWLOCALE
288 _GL_WARN_ON_USE (newlocale, "newlocale is not portable");
289 # endif
290 #endif
292 #if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @HAVE_DUPLOCALE@)
293 # if @REPLACE_DUPLOCALE@
294 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
295 # undef duplocale
296 # define duplocale rpl_duplocale
297 # define GNULIB_defined_duplocale 1
298 # endif
299 _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
300 _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
301 # else
302 # if @HAVE_DUPLOCALE@
303 _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
304 # endif
305 # endif
306 # if @HAVE_DUPLOCALE@
307 _GL_CXXALIASWARN (duplocale);
308 # endif
309 # if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
310 # ifndef HAVE_WORKING_DUPLOCALE
311 # define HAVE_WORKING_DUPLOCALE 1
312 # endif
313 # endif
314 #elif defined GNULIB_POSIXCHECK
315 # undef duplocale
316 # if HAVE_RAW_DECL_DUPLOCALE
317 _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
318 "use gnulib module duplocale for portability");
319 # endif
320 #endif
322 #if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @HAVE_FREELOCALE@)
323 # if @REPLACE_FREELOCALE@
324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
325 # undef freelocale
326 # define freelocale rpl_freelocale
327 # define GNULIB_defined_freelocale 1
328 # endif
329 _GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
330 _GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
331 # else
332 # if @HAVE_FREELOCALE@
333 /* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
334 int. */
335 _GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
336 # endif
337 # endif
338 # if @HAVE_FREELOCALE@
339 _GL_CXXALIASWARN (freelocale);
340 # endif
341 #elif defined GNULIB_POSIXCHECK
342 # undef freelocale
343 # if HAVE_RAW_DECL_FREELOCALE
344 _GL_WARN_ON_USE (freelocale, "freelocale is not portable");
345 # endif
346 #endif
348 #endif /* _@GUARD_PREFIX@_LOCALE_H */
349 #endif /* _@GUARD_PREFIX@_LOCALE_H */
350 #endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */