PowerPC: Change sched_getcpu to use vDSO getcpu instead of syscall.
[glibc.git] / intl / gettextP.h
blobb48912d2120a3ecdfd6996686011f99201a40c39
1 /* Header describing internals of libintl library.
2 Copyright (C) 1995-1999, 2000, 2001, 2004-2005, 2007, 2011
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _GETTEXTP_H
22 #define _GETTEXTP_H
24 #include <stddef.h> /* Get size_t. */
26 #ifdef _LIBC
27 # include "../iconv/gconv_int.h"
28 #else
29 # if HAVE_ICONV
30 # include <iconv.h>
31 # endif
32 #endif
34 #include "loadinfo.h"
36 #include "gmo.h" /* Get nls_uint32. */
38 /* @@ end of prolog @@ */
40 #ifndef PARAMS
41 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
42 # define PARAMS(args) args
43 # else
44 # define PARAMS(args) ()
45 # endif
46 #endif
48 #ifndef internal_function
49 # define internal_function
50 #endif
52 #ifndef attribute_hidden
53 # define attribute_hidden
54 #endif
56 #ifndef W
57 # define W(flag, data) ((flag) ? SWAP (data) : (data))
58 #endif
61 #ifdef _LIBC
62 # include <byteswap.h>
63 # define SWAP(i) bswap_32 (i)
64 #else
65 static nls_uint32 SWAP PARAMS ((nls_uint32 i));
67 static inline nls_uint32
68 SWAP (i)
69 nls_uint32 i;
71 return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
73 #endif
76 /* In-memory representation of system dependent string. */
77 struct sysdep_string_desc
79 /* Length of addressed string, including the trailing NUL. */
80 size_t length;
81 /* Pointer to addressed string. */
82 const char *pointer;
85 /* Cache of translated strings after charset conversion.
86 Note: The strings are converted to the target encoding only on an as-needed
87 basis. */
88 struct converted_domain
90 /* The target encoding name. */
91 const char *encoding;
92 /* The descriptor for conversion from the message catalog's encoding to
93 this target encoding. */
94 #ifdef _LIBC
95 __gconv_t conv;
96 #else
97 # if HAVE_ICONV
98 iconv_t conv;
99 # endif
100 #endif
101 /* The table of translated strings after charset conversion. */
102 char **conv_tab;
105 /* The representation of an opened message catalog. */
106 struct loaded_domain
108 /* Pointer to memory containing the .mo file. */
109 const char *data;
110 /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
111 int use_mmap;
112 /* Size of mmap()ed memory. */
113 size_t mmap_size;
114 /* 1 if the .mo file uses a different endianness than this machine. */
115 int must_swap;
116 /* Pointer to additional malloc()ed memory. */
117 void *malloced;
119 /* Number of static strings pairs. */
120 nls_uint32 nstrings;
121 /* Pointer to descriptors of original strings in the file. */
122 const struct string_desc *orig_tab;
123 /* Pointer to descriptors of translated strings in the file. */
124 const struct string_desc *trans_tab;
126 /* Number of system dependent strings pairs. */
127 nls_uint32 n_sysdep_strings;
128 /* Pointer to descriptors of original sysdep strings. */
129 const struct sysdep_string_desc *orig_sysdep_tab;
130 /* Pointer to descriptors of translated sysdep strings. */
131 const struct sysdep_string_desc *trans_sysdep_tab;
133 /* Size of hash table. */
134 nls_uint32 hash_size;
135 /* Pointer to hash table. */
136 const nls_uint32 *hash_tab;
137 /* 1 if the hash table uses a different endianness than this machine. */
138 int must_swap_hash_tab;
140 /* Cache of charset conversions of the translated strings. */
141 struct converted_domain *conversions;
142 size_t nconversions;
143 __libc_rwlock_define (, conversions_lock);
145 const struct expression *plural;
146 unsigned long int nplurals;
149 /* We want to allocate a string at the end of the struct. But ISO C
150 doesn't allow zero sized arrays. */
151 #ifdef __GNUC__
152 # define ZERO 0
153 #else
154 # define ZERO 1
155 #endif
157 /* A set of settings bound to a message domain. Used to store settings
158 from bindtextdomain() and bind_textdomain_codeset(). */
159 struct binding
161 struct binding *next;
162 char *dirname;
163 char *codeset;
164 char domainname[ZERO];
167 /* A counter which is incremented each time some previous translations
168 become invalid.
169 This variable is part of the external ABI of the GNU libintl. */
170 extern int _nl_msg_cat_cntr;
172 #ifndef _LIBC
173 const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
174 #endif
176 struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
177 char *__locale,
178 const char *__domainname,
179 struct binding *__domainbinding))
180 internal_function;
181 void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
182 struct binding *__domainbinding))
183 internal_function;
185 char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
186 struct binding *domainbinding, const char *msgid,
187 int convert, size_t *lengthp))
188 internal_function;
190 #ifdef _LIBC
191 extern char *__gettext PARAMS ((const char *__msgid));
192 extern char *__dgettext PARAMS ((const char *__domainname,
193 const char *__msgid));
194 extern char *__dcgettext PARAMS ((const char *__domainname,
195 const char *__msgid, int __category));
196 extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
197 unsigned long int __n));
198 extern char *__dngettext PARAMS ((const char *__domainname,
199 const char *__msgid1, const char *__msgid2,
200 unsigned long int n));
201 extern char *__dcngettext PARAMS ((const char *__domainname,
202 const char *__msgid1, const char *__msgid2,
203 unsigned long int __n, int __category));
204 extern char *__dcigettext PARAMS ((const char *__domainname,
205 const char *__msgid1, const char *__msgid2,
206 int __plural, unsigned long int __n,
207 int __category));
208 extern char *__textdomain PARAMS ((const char *__domainname));
209 extern char *__bindtextdomain PARAMS ((const char *__domainname,
210 const char *__dirname));
211 extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
212 const char *__codeset));
213 extern void _nl_finddomain_subfreeres PARAMS ((void)) attribute_hidden;
214 extern void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
215 internal_function attribute_hidden;
216 #else
217 extern char *libintl_gettext PARAMS ((const char *__msgid));
218 extern char *libintl_dgettext PARAMS ((const char *__domainname,
219 const char *__msgid));
220 extern char *libintl_dcgettext PARAMS ((const char *__domainname,
221 const char *__msgid, int __category));
222 extern char *libintl_ngettext PARAMS ((const char *__msgid1,
223 const char *__msgid2,
224 unsigned long int __n));
225 extern char *libintl_dngettext PARAMS ((const char *__domainname,
226 const char *__msgid1,
227 const char *__msgid2,
228 unsigned long int __n));
229 extern char *libintl_dcngettext PARAMS ((const char *__domainname,
230 const char *__msgid1,
231 const char *__msgid2,
232 unsigned long int __n,
233 int __category));
234 extern char *libintl_dcigettext PARAMS ((const char *__domainname,
235 const char *__msgid1,
236 const char *__msgid2,
237 int __plural, unsigned long int __n,
238 int __category));
239 extern char *libintl_textdomain PARAMS ((const char *__domainname));
240 extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
241 const char *__dirname));
242 extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
243 const char *__codeset));
244 #endif
246 /* @@ begin of epilog @@ */
248 #endif /* gettextP.h */