· 10 years ago · Feb 25, 2016, 12:00 PM
1# 1 "<built-in>"
2# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
3/*-
4 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
5 * Copyright (c) 1992, 1993, 1994
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Copyright (c) 2011 The FreeBSD Foundation
9 * All rights reserved.
10 * Portions of this software were developed by David Chisnall
11 * under sponsorship from the FreeBSD Foundation.
12 *
13 * This code is derived from software contributed to Berkeley by
14 * Henry Spencer.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * @(#)regcomp.c 8.5 (Berkeley) 3/20/94
41 */
42
43#if defined(LIBC_SCCS) && !defined(lint)
44static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
45#endif /* LIBC_SCCS and not lint */
46# 44 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
47#if 0 /* expanded by -frewrite-includes */
48#include <sys/cdefs.h>
49#endif /* expanded by -frewrite-includes */
50# 44 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
51# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 1 3 4
52/*-
53 * Copyright (c) 1991, 1993
54 * The Regents of the University of California. All rights reserved.
55 *
56 * This code is derived from software contributed to Berkeley by
57 * Berkeley Software Design, Inc.
58 *
59 * Redistribution and use in source and binary forms, with or without
60 * modification, are permitted provided that the following conditions
61 * are met:
62 * 1. Redistributions of source code must retain the above copyright
63 * notice, this list of conditions and the following disclaimer.
64 * 2. Redistributions in binary form must reproduce the above copyright
65 * notice, this list of conditions and the following disclaimer in the
66 * documentation and/or other materials provided with the distribution.
67 * 4. Neither the name of the University nor the names of its contributors
68 * may be used to endorse or promote products derived from this software
69 * without specific prior written permission.
70 *
71 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
72 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
74 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
75 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
76 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
77 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
78 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
79 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
80 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
81 * SUCH DAMAGE.
82 *
83 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
84 * $FreeBSD$
85 */
86
87#ifndef _SYS_CDEFS_H_
88#define _SYS_CDEFS_H_
89
90/*
91 * Testing against Clang-specific extensions.
92 */
93#ifndef __has_attribute
94#define __has_attribute(x) 0
95#endif
96# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
97#ifndef __has_extension
98#define __has_extension __has_feature
99#endif
100# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
101#ifndef __has_feature
102#define __has_feature(x) 0
103#endif
104# 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
105#ifndef __has_include
106#define __has_include(x) 0
107#endif
108# 54 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
109#ifndef __has_builtin
110#define __has_builtin(x) 0
111#endif
112# 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
113
114#if defined(__cplusplus)
115#define __BEGIN_DECLS extern "C" {
116#define __END_DECLS }
117#else
118# 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
119#define __BEGIN_DECLS
120#define __END_DECLS
121#endif
122# 65 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
123
124/*
125 * This code has been put in place to help reduce the addition of
126 * compiler specific defines in FreeBSD code. It helps to aid in
127 * having a compiler-agnostic source tree.
128 */
129
130#if defined(__GNUC__) || defined(__INTEL_COMPILER)
131
132#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
133#define __GNUCLIKE_ASM 3
134#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
135#else
136# 78 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
137#define __GNUCLIKE_ASM 2
138#endif
139# 80 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
140#define __GNUCLIKE___TYPEOF 1
141#define __GNUCLIKE___OFFSETOF 1
142#define __GNUCLIKE___SECTION 1
143
144#ifndef __INTEL_COMPILER
145#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
146#endif
147# 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
148
149#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
150#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
151 __INTEL_COMPILER < 800
152#undef __GNUCLIKE_BUILTIN_CONSTANT_P
153#endif
154# 93 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
155
156#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
157#define __GNUCLIKE_BUILTIN_VARARGS 1
158#define __GNUCLIKE_BUILTIN_STDARG 1
159#define __GNUCLIKE_BUILTIN_VAALIST 1
160#endif
161# 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
162
163#if defined(__GNUC__)
164#define __GNUC_VA_LIST_COMPATIBILITY 1
165#endif
166# 103 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
167
168/*
169 * Compiler memory barriers, specific to gcc and clang.
170 */
171#if defined(__GNUC__)
172#define __compiler_membar() __asm __volatile(" " : : : "memory")
173#endif
174# 110 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
175
176#ifndef __INTEL_COMPILER
177#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
178#define __GNUCLIKE_MATH_BUILTIN_RELOPS
179#endif
180# 115 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
181
182#define __GNUCLIKE_BUILTIN_MEMCPY 1
183
184/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
185#define __CC_SUPPORTS_INLINE 1
186#define __CC_SUPPORTS___INLINE 1
187#define __CC_SUPPORTS___INLINE__ 1
188
189#define __CC_SUPPORTS___FUNC__ 1
190#define __CC_SUPPORTS_WARNING 1
191
192#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
193
194#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
195
196#endif /* __GNUC__ || __INTEL_COMPILER */
197# 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
198
199/*
200 * Macro to test if we're using a specific version of gcc or later.
201 */
202#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
203#define __GNUC_PREREQ__(ma, mi) \
204 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
205#else
206# 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
207#define __GNUC_PREREQ__(ma, mi) 0
208#endif
209# 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
210
211/*
212 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
213 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
214 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
215 * mode -- there must be no spaces between its arguments, and for nested
216 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
217 * concatenate double-quoted strings produced by the __STRING macro, but
218 * this only works with ANSI C.
219 *
220 * __XSTRING is like __STRING, but it expands any macros in its argument
221 * first. It is only available with ANSI C.
222 */
223#if defined(__STDC__) || defined(__cplusplus)
224#define __P(protos) protos /* full-blown ANSI C */
225#define __CONCAT1(x,y) x ## y
226#define __CONCAT(x,y) __CONCAT1(x,y)
227#define __STRING(x) #x /* stringify without expanding x */
228#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
229
230#define __const const /* define reserved names to standard */
231#define __signed signed
232#define __volatile volatile
233#if defined(__cplusplus)
234#define __inline inline /* convert to C++ keyword */
235#else
236# 167 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
237#if !(defined(__CC_SUPPORTS___INLINE))
238#define __inline /* delete GCC keyword */
239#endif /* ! __CC_SUPPORTS___INLINE */
240# 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
241#endif /* !__cplusplus */
242# 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
243
244#else /* !(__STDC__ || __cplusplus) */
245# 173 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
246#define __P(protos) () /* traditional C preprocessor */
247#define __CONCAT(x,y) x/**/y
248#define __STRING(x) "x"
249
250#if !defined(__CC_SUPPORTS___INLINE)
251#define __const /* delete pseudo-ANSI C keywords */
252#define __inline
253#define __signed
254#define __volatile
255/*
256 * In non-ANSI C environments, new programs will want ANSI-only C keywords
257 * deleted from the program and old programs will want them left alone.
258 * When using a compiler other than gcc, programs using the ANSI C keywords
259 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
260 * When using "gcc -traditional", we assume that this is the intent; if
261 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
262 */
263#ifndef NO_ANSI_KEYWORDS
264#define const /* delete ANSI C keywords */
265#define inline
266#define signed
267#define volatile
268#endif /* !NO_ANSI_KEYWORDS */
269# 196 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
270#endif /* !__CC_SUPPORTS___INLINE */
271# 197 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
272#endif /* !(__STDC__ || __cplusplus) */
273# 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
274
275/*
276 * Compiler-dependent macros to help declare dead (non-returning) and
277 * pure (no side effects) functions, and unused variables. They are
278 * null except for versions of gcc that are known to support the features
279 * properly (old versions of gcc-2 supported the dead and pure features
280 * in a different (wrong) way). If we do not provide an implementation
281 * for a given compiler, let the compile fail if it is told to use
282 * a feature that we cannot live without.
283 */
284#ifdef lint
285#define __dead2
286#define __pure2
287#define __unused
288#define __packed
289#define __aligned(x)
290#define __alloc_align(x)
291#define __alloc_size(x)
292#define __section(x)
293#define __weak_symbol
294#else
295# 219 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
296#define __weak_symbol __attribute__((__weak__))
297#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
298#define __dead2
299#define __pure2
300#define __unused
301#endif
302# 225 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
303#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
304#define __dead2 __attribute__((__noreturn__))
305#define __pure2 __attribute__((__const__))
306#define __unused
307/* XXX Find out what to do for __packed, __aligned and __section */
308#endif
309# 231 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
310#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
311#define __dead2 __attribute__((__noreturn__))
312#define __pure2 __attribute__((__const__))
313#define __unused __attribute__((__unused__))
314#define __used __attribute__((__used__))
315#define __packed __attribute__((__packed__))
316#define __aligned(x) __attribute__((__aligned__(x)))
317#define __section(x) __attribute__((__section__(x)))
318#endif
319# 240 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
320#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
321#define __alloc_size(x) __attribute__((__alloc_size__(x)))
322#else
323# 243 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
324#define __alloc_size(x)
325#endif
326# 245 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
327#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
328#define __alloc_align(x) __attribute__((__alloc_align__(x)))
329#else
330# 248 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
331#define __alloc_align(x)
332#endif
333# 250 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
334#endif /* lint */
335# 251 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
336
337#if !__GNUC_PREREQ__(2, 95)
338#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
339#endif
340# 255 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
341
342/*
343 * Keywords added in C11.
344 */
345
346#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
347
348#if !__has_extension(c_alignas)
349#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
350 __has_extension(cxx_alignas)
351#define _Alignas(x) alignas(x)
352#else
353# 267 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
354/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
355#define _Alignas(x) __aligned(x)
356#endif
357# 270 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
358#endif
359# 271 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
360
361#if defined(__cplusplus) && __cplusplus >= 201103L
362#define _Alignof(x) alignof(x)
363#else
364# 275 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
365#define _Alignof(x) __alignof(x)
366#endif
367# 277 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
368
369#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
370/*
371 * No native support for _Atomic(). Place object in structure to prevent
372 * most forms of direct non-atomic access.
373 */
374#define _Atomic(T) struct { T volatile __val; }
375#endif
376# 285 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
377
378#if defined(__cplusplus) && __cplusplus >= 201103L
379#define _Noreturn [[noreturn]]
380#else
381# 289 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
382#define _Noreturn __dead2
383#endif
384# 291 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
385
386#if !__has_extension(c_static_assert)
387#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
388 __has_extension(cxx_static_assert)
389#define _Static_assert(x, y) static_assert(x, y)
390#elif __GNUC_PREREQ__(4,6)
391# 297 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
392/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
393#elif defined(__COUNTER__)
394# 299 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
395#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
396#define __Static_assert(x, y) ___Static_assert(x, y)
397#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \
398 __unused
399#else
400# 304 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
401#define _Static_assert(x, y) struct __hack
402#endif
403# 306 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
404#endif
405# 307 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
406
407#if !__has_extension(c_thread_local)
408/*
409 * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
410 * without actually supporting the thread_local keyword. Don't check for
411 * the presence of C++11 when defining _Thread_local.
412 */
413#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
414 __has_extension(cxx_thread_local)
415#define _Thread_local thread_local
416#else
417# 318 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
418#define _Thread_local __thread
419#endif
420# 320 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
421#endif
422# 321 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
423
424#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
425# 323 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
426
427/*
428 * Emulation of C11 _Generic(). Unlike the previously defined C11
429 * keywords, it is not possible to implement this using exactly the same
430 * syntax. Therefore implement something similar under the name
431 * __generic(). Unlike _Generic(), this macro can only distinguish
432 * between a single type, so it requires nested invocations to
433 * distinguish multiple cases.
434 */
435
436#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
437 __has_extension(c_generic_selections)
438#define __generic(expr, t, yes, no) \
439 _Generic(expr, t: yes, default: no)
440#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
441# 338 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
442#define __generic(expr, t, yes, no) \
443 __builtin_choose_expr( \
444 __builtin_types_compatible_p(__typeof(expr), t), yes, no)
445#endif
446# 342 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
447
448#if __GNUC_PREREQ__(2, 96)
449#define __malloc_like __attribute__((__malloc__))
450#define __pure __attribute__((__pure__))
451#else
452# 347 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
453#define __malloc_like
454#define __pure
455#endif
456# 350 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
457
458#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
459#define __always_inline __attribute__((__always_inline__))
460#else
461# 354 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
462#define __always_inline
463#endif
464# 356 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
465
466#if __GNUC_PREREQ__(3, 1)
467#define __noinline __attribute__ ((__noinline__))
468#else
469# 360 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
470#define __noinline
471#endif
472# 362 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
473
474#if __GNUC_PREREQ__(3, 3)
475#define __nonnull(x) __attribute__((__nonnull__(x)))
476#define __nonnull_all __attribute__((__nonnull__))
477#else
478# 367 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
479#define __nonnull(x)
480#define __nonnull_all
481#endif
482# 370 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
483
484#if __GNUC_PREREQ__(3, 4)
485#define __fastcall __attribute__((__fastcall__))
486#define __result_use_check __attribute__((__warn_unused_result__))
487#else
488# 375 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
489#define __fastcall
490#define __result_use_check
491#endif
492# 378 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
493
494#if __GNUC_PREREQ__(4, 1)
495#define __returns_twice __attribute__((__returns_twice__))
496#else
497# 382 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
498#define __returns_twice
499#endif
500# 384 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
501
502#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
503#define __unreachable() __builtin_unreachable()
504#else
505# 388 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
506#define __unreachable() ((void)0)
507#endif
508# 390 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
509
510/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
511#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
512#define __func__ NULL
513#endif
514# 395 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
515
516#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
517#define __LONG_LONG_SUPPORTED
518#endif
519# 399 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
520
521/* C++11 exposes a load of C99 stuff */
522#if defined(__cplusplus) && __cplusplus >= 201103L
523#define __LONG_LONG_SUPPORTED
524#ifndef __STDC_LIMIT_MACROS
525#define __STDC_LIMIT_MACROS
526#endif
527# 406 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
528#ifndef __STDC_CONSTANT_MACROS
529#define __STDC_CONSTANT_MACROS
530#endif
531# 409 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
532#endif
533# 410 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
534
535/*
536 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
537 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
538 * a way to define the `restrict' type qualifier without disturbing older
539 * software that is unaware of C99 keywords.
540 */
541#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
542#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
543#define __restrict
544#else
545# 421 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
546#define __restrict restrict
547#endif
548# 423 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
549#endif
550# 424 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
551
552/*
553 * GNU C version 2.96 adds explicit branch prediction so that
554 * the CPU back-end can hint the processor and also so that
555 * code blocks can be reordered such that the predicted path
556 * sees a more linear flow, thus improving cache behavior, etc.
557 *
558 * The following two macros provide us with a way to utilize this
559 * compiler feature. Use __predict_true() if you expect the expression
560 * to evaluate to true, and __predict_false() if you expect the
561 * expression to evaluate to false.
562 *
563 * A few notes about usage:
564 *
565 * * Generally, __predict_false() error condition checks (unless
566 * you have some _strong_ reason to do otherwise, in which case
567 * document it), and/or __predict_true() `no-error' condition
568 * checks, assuming you want to optimize for the no-error case.
569 *
570 * * Other than that, if you don't know the likelihood of a test
571 * succeeding from empirical or other `hard' evidence, don't
572 * make predictions.
573 *
574 * * These are meant to be used in places that are run `a lot'.
575 * It is wasteful to make predictions in code that is run
576 * seldomly (e.g. at subsystem initialization time) as the
577 * basic block reordering that this affects can often generate
578 * larger code.
579 */
580#if __GNUC_PREREQ__(2, 96)
581#define __predict_true(exp) __builtin_expect((exp), 1)
582#define __predict_false(exp) __builtin_expect((exp), 0)
583#else
584# 457 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
585#define __predict_true(exp) (exp)
586#define __predict_false(exp) (exp)
587#endif
588# 460 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
589
590#if __GNUC_PREREQ__(4, 0)
591#define __null_sentinel __attribute__((__sentinel__))
592#define __exported __attribute__((__visibility__("default")))
593#define __hidden __attribute__((__visibility__("hidden")))
594#else
595# 466 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
596#define __null_sentinel
597#define __exported
598#define __hidden
599#endif
600# 470 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
601
602/*
603 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
604 * require it.
605 */
606#if __GNUC_PREREQ__(4, 1)
607#define __offsetof(type, field) __builtin_offsetof(type, field)
608#else
609# 478 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
610#ifndef __cplusplus
611#define __offsetof(type, field) \
612 ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
613#else
614# 482 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
615#define __offsetof(type, field) \
616 (__offsetof__ (reinterpret_cast <__size_t> \
617 (&reinterpret_cast <const volatile char &> \
618 (static_cast<type *> (0)->field))))
619#endif
620# 487 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
621#endif
622# 488 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
623#define __rangeof(type, start, end) \
624 (__offsetof(type, end) - __offsetof(type, start))
625
626/*
627 * Given the pointer x to the member m of the struct s, return
628 * a pointer to the containing structure. When using GCC, we first
629 * assign pointer x to a local variable, to check that its type is
630 * compatible with member m.
631 */
632#if __GNUC_PREREQ__(3, 1)
633#define __containerof(x, s, m) ({ \
634 const volatile __typeof(((s *)0)->m) *__x = (x); \
635 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
636})
637#else
638# 503 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
639#define __containerof(x, s, m) \
640 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
641#endif
642# 506 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
643
644/*
645 * Compiler-dependent macros to declare that functions take printf-like
646 * or scanf-like arguments. They are null except for versions of gcc
647 * that are known to support the features properly (old versions of gcc-2
648 * didn't permit keeping the keywords out of the application namespace).
649 */
650#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
651#define __printflike(fmtarg, firstvararg)
652#define __scanflike(fmtarg, firstvararg)
653#define __format_arg(fmtarg)
654#define __strfmonlike(fmtarg, firstvararg)
655#define __strftimelike(fmtarg, firstvararg)
656#else
657# 520 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
658#define __printflike(fmtarg, firstvararg) \
659 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
660#define __scanflike(fmtarg, firstvararg) \
661 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
662#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
663#define __strfmonlike(fmtarg, firstvararg) \
664 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
665#define __strftimelike(fmtarg, firstvararg) \
666 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
667#endif
668# 530 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
669
670/*
671 * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
672 * the use of non-standard inlining. In general we should try to avoid
673 * using these but GCC-compatible compilers tend to support the extensions
674 * well enough to use them in limited cases.
675 */
676#if defined(__GNUC_GNU_INLINE__) || defined(__GNUC_STDC_INLINE__)
677#if __GNUC_PREREQ__(4, 3) || __has_attribute(__artificial__)
678#define __gnu_inline __attribute__((__gnu_inline__, __artificial__))
679#else
680# 541 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
681#define __gnu_inline __attribute__((__gnu_inline__))
682#endif /* artificial */
683# 543 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
684#else
685# 544 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
686#define __gnu_inline
687#endif
688# 546 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
689
690/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
691#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
692 defined(__GNUC__) && !defined(__INTEL_COMPILER)
693#define __printf0like(fmtarg, firstvararg) \
694 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
695#else
696# 553 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
697#define __printf0like(fmtarg, firstvararg)
698#endif
699# 555 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
700
701#if defined(__GNUC__) || defined(__INTEL_COMPILER)
702#ifndef __INTEL_COMPILER
703#define __strong_reference(sym,aliassym) \
704 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
705#endif
706# 561 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
707#ifdef __STDC__
708#define __weak_reference(sym,alias) \
709 __asm__(".weak " #alias); \
710 __asm__(".equ " #alias ", " #sym)
711#define __warn_references(sym,msg) \
712 __asm__(".section .gnu.warning." #sym); \
713 __asm__(".asciz \"" msg "\""); \
714 __asm__(".previous")
715#define __sym_compat(sym,impl,verid) \
716 __asm__(".symver " #impl ", " #sym "@" #verid)
717#define __sym_default(sym,impl,verid) \
718 __asm__(".symver " #impl ", " #sym "@@" #verid)
719#else
720# 574 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
721#define __weak_reference(sym,alias) \
722 __asm__(".weak alias"); \
723 __asm__(".equ alias, sym")
724#define __warn_references(sym,msg) \
725 __asm__(".section .gnu.warning.sym"); \
726 __asm__(".asciz \"msg\""); \
727 __asm__(".previous")
728#define __sym_compat(sym,impl,verid) \
729 __asm__(".symver impl, sym@verid")
730#define __sym_default(impl,sym,verid) \
731 __asm__(".symver impl, sym@@verid")
732#endif /* __STDC__ */
733# 586 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
734#endif /* __GNUC__ || __INTEL_COMPILER */
735# 587 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
736
737#define __GLOBL1(sym) __asm__(".globl " #sym)
738#define __GLOBL(sym) __GLOBL1(sym)
739
740#if defined(__GNUC__) || defined(__INTEL_COMPILER)
741#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
742#else
743# 594 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
744/*
745 * The following definition might not work well if used in header files,
746 * but it should be better than nothing. If you want a "do nothing"
747 * version, then it should generate some harmless declaration, such as:
748 * #define __IDSTRING(name,string) struct __hack
749 */
750#define __IDSTRING(name,string) static const char name[] __unused = string
751#endif
752# 602 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
753
754/*
755 * Embed the rcs id of a source file in the resulting library. Note that in
756 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
757 * Usage:
758 * __FBSDID("$FreeBSD$");
759 */
760#ifndef __FBSDID
761#if !defined(lint) && !defined(STRIP_FBSDID)
762#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
763#else
764# 613 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
765#define __FBSDID(s) struct __hack
766#endif
767# 615 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
768#endif
769# 616 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
770
771#ifndef __RCSID
772#ifndef NO__RCSID
773#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
774#else
775# 621 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
776#define __RCSID(s) struct __hack
777#endif
778# 623 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
779#endif
780# 624 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
781
782#ifndef __RCSID_SOURCE
783#ifndef NO__RCSID_SOURCE
784#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
785#else
786# 629 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
787#define __RCSID_SOURCE(s) struct __hack
788#endif
789# 631 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
790#endif
791# 632 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
792
793#ifndef __SCCSID
794#ifndef NO__SCCSID
795#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
796#else
797# 637 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
798#define __SCCSID(s) struct __hack
799#endif
800# 639 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
801#endif
802# 640 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
803
804#ifndef __COPYRIGHT
805#ifndef NO__COPYRIGHT
806#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
807#else
808# 645 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
809#define __COPYRIGHT(s) struct __hack
810#endif
811# 647 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
812#endif
813# 648 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
814
815#ifndef __DECONST
816#if !__has_feature(capabilities)
817#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
818#else
819# 653 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
820#define __DECONST(type, var) ((type)(__intcap_t)(__capability const void *)(var))
821#endif
822# 655 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
823#endif
824# 656 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
825
826#ifndef __DEVOLATILE
827#if !__has_feature(capabilities)
828#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
829#else
830# 661 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
831#define __DEVOLATILE(type, var) ((type)(__intcap_t)(__capability volatile void *)(var))
832#endif
833# 663 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
834#endif
835# 664 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
836
837#ifndef __DEQUALIFY
838#if !__has_feature(capabilities)
839#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
840#else
841# 669 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
842#define __DEQUALIFY(type, var) ((type)(__intcap_t)(__capability const volatile void *)(var))
843#endif
844# 671 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
845#endif
846# 672 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
847
848/*-
849 * The following definitions are an extension of the behavior originally
850 * implemented in <sys/_posix.h>, but with a different level of granularity.
851 * POSIX.1 requires that the macros we test be defined before any standard
852 * header file is included.
853 *
854 * Here's a quick run-down of the versions:
855 * defined(_POSIX_SOURCE) 1003.1-1988
856 * _POSIX_C_SOURCE == 1 1003.1-1990
857 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
858 * _POSIX_C_SOURCE == 199309 1003.1b-1993
859 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
860 * and the omnibus ISO/IEC 9945-1: 1996
861 * _POSIX_C_SOURCE == 200112 1003.1-2001
862 * _POSIX_C_SOURCE == 200809 1003.1-2008
863 *
864 * In addition, the X/Open Portability Guide, which is now the Single UNIX
865 * Specification, defines a feature-test macro which indicates the version of
866 * that specification, and which subsumes _POSIX_C_SOURCE.
867 *
868 * Our macros begin with two underscores to avoid namespace screwage.
869 */
870
871/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
872#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
873#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
874#define _POSIX_C_SOURCE 199009
875#endif
876# 701 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
877
878/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
879#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
880#undef _POSIX_C_SOURCE
881#define _POSIX_C_SOURCE 199209
882#endif
883# 707 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
884
885/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
886#ifdef _XOPEN_SOURCE
887#if _XOPEN_SOURCE - 0 >= 700
888#define __XSI_VISIBLE 700
889#undef _POSIX_C_SOURCE
890#define _POSIX_C_SOURCE 200809
891#elif _XOPEN_SOURCE - 0 >= 600
892# 715 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
893#define __XSI_VISIBLE 600
894#undef _POSIX_C_SOURCE
895#define _POSIX_C_SOURCE 200112
896#elif _XOPEN_SOURCE - 0 >= 500
897# 719 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
898#define __XSI_VISIBLE 500
899#undef _POSIX_C_SOURCE
900#define _POSIX_C_SOURCE 199506
901#endif
902# 723 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
903#endif
904# 724 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
905
906/*
907 * Deal with all versions of POSIX. The ordering relative to the tests above is
908 * important.
909 */
910#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
911#define _POSIX_C_SOURCE 198808
912#endif
913# 732 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
914#ifdef _POSIX_C_SOURCE
915#if _POSIX_C_SOURCE >= 200809
916#define __POSIX_VISIBLE 200809
917#define __ISO_C_VISIBLE 1999
918#elif _POSIX_C_SOURCE >= 200112
919# 737 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
920#define __POSIX_VISIBLE 200112
921#define __ISO_C_VISIBLE 1999
922#elif _POSIX_C_SOURCE >= 199506
923# 740 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
924#define __POSIX_VISIBLE 199506
925#define __ISO_C_VISIBLE 1990
926#elif _POSIX_C_SOURCE >= 199309
927# 743 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
928#define __POSIX_VISIBLE 199309
929#define __ISO_C_VISIBLE 1990
930#elif _POSIX_C_SOURCE >= 199209
931# 746 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
932#define __POSIX_VISIBLE 199209
933#define __ISO_C_VISIBLE 1990
934#elif _POSIX_C_SOURCE >= 199009
935# 749 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
936#define __POSIX_VISIBLE 199009
937#define __ISO_C_VISIBLE 1990
938#else
939# 752 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
940#define __POSIX_VISIBLE 198808
941#define __ISO_C_VISIBLE 0
942#endif /* _POSIX_C_SOURCE */
943# 755 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
944#else
945# 756 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
946/*-
947 * Deal with _ANSI_SOURCE:
948 * If it is defined, and no other compilation environment is explicitly
949 * requested, then define our internal feature-test macros to zero. This
950 * makes no difference to the preprocessor (undefined symbols in preprocessing
951 * expressions are defined to have value zero), but makes it more convenient for
952 * a test program to print out the values.
953 *
954 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
955 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
956 * environment (and in fact we will never get here).
957 */
958#if defined(_ANSI_SOURCE) /* Hide almost everything. */
959#define __POSIX_VISIBLE 0
960#define __XSI_VISIBLE 0
961#define __BSD_VISIBLE 0
962#define __ISO_C_VISIBLE 1990
963#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
964# 774 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
965#define __POSIX_VISIBLE 0
966#define __XSI_VISIBLE 0
967#define __BSD_VISIBLE 0
968#define __ISO_C_VISIBLE 1999
969#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
970# 779 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
971#define __POSIX_VISIBLE 0
972#define __XSI_VISIBLE 0
973#define __BSD_VISIBLE 0
974#define __ISO_C_VISIBLE 2011
975#else /* Default environment: show everything. */
976# 784 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
977#define __POSIX_VISIBLE 200809
978#define __XSI_VISIBLE 700
979#define __BSD_VISIBLE 1
980#define __ISO_C_VISIBLE 2011
981#endif
982# 789 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
983#endif
984# 790 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
985
986#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__)
987#define __NO_TLS 1
988#endif
989# 794 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
990
991/*
992 * Type Safety Checking
993 *
994 * Clang provides additional attributes to enable checking type safety
995 * properties that cannot be enforced by the C type system.
996 */
997
998#if __has_attribute(__argument_with_type_tag__) && \
999 __has_attribute(__type_tag_for_datatype__) && !defined(lint)
1000#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
1001 __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
1002#define __datatype_type_tag(kind, type) \
1003 __attribute__((__type_tag_for_datatype__(kind, type)))
1004#else
1005# 809 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1006#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
1007#define __datatype_type_tag(kind, type)
1008#endif
1009# 812 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1010
1011/*
1012 * Lock annotations.
1013 *
1014 * Clang provides support for doing basic thread-safety tests at
1015 * compile-time, by marking which locks will/should be held when
1016 * entering/leaving a functions.
1017 *
1018 * Furthermore, it is also possible to annotate variables and structure
1019 * members to enforce that they are only accessed when certain locks are
1020 * held.
1021 */
1022
1023#if __has_extension(c_thread_safety_attributes)
1024#define __lock_annotate(x) __attribute__((x))
1025#else
1026# 828 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1027#define __lock_annotate(x)
1028#endif
1029# 830 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1030
1031/* Structure implements a lock. */
1032#define __lockable __lock_annotate(lockable)
1033
1034/* Function acquires an exclusive or shared lock. */
1035#define __locks_exclusive(...) \
1036 __lock_annotate(exclusive_lock_function(__VA_ARGS__))
1037#define __locks_shared(...) \
1038 __lock_annotate(shared_lock_function(__VA_ARGS__))
1039
1040/* Function attempts to acquire an exclusive or shared lock. */
1041#define __trylocks_exclusive(...) \
1042 __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
1043#define __trylocks_shared(...) \
1044 __lock_annotate(shared_trylock_function(__VA_ARGS__))
1045
1046/* Function releases a lock. */
1047#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
1048
1049/* Function asserts that an exclusive or shared lock is held. */
1050#define __asserts_exclusive(...) \
1051 __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
1052#define __asserts_shared(...) \
1053 __lock_annotate(assert_shared_lock(__VA_ARGS__))
1054
1055/* Function requires that an exclusive or shared lock is or is not held. */
1056#define __requires_exclusive(...) \
1057 __lock_annotate(exclusive_locks_required(__VA_ARGS__))
1058#define __requires_shared(...) \
1059 __lock_annotate(shared_locks_required(__VA_ARGS__))
1060#define __requires_unlocked(...) \
1061 __lock_annotate(locks_excluded(__VA_ARGS__))
1062
1063/* Function should not be analyzed. */
1064#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
1065
1066/* Guard variables and structure members by lock. */
1067#define __guarded_by(x) __lock_annotate(guarded_by(x))
1068#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
1069
1070#endif /* !_SYS_CDEFS_H_ */
1071# 871 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1072# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
1073__FBSDID("$FreeBSD$");
1074
1075#if 0 /* expanded by -frewrite-includes */
1076#include <sys/types.h>
1077#endif /* expanded by -frewrite-includes */
1078# 47 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
1079# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 1 3 4
1080/*-
1081 * Copyright (c) 1982, 1986, 1991, 1993, 1994
1082 * The Regents of the University of California. All rights reserved.
1083 * (c) UNIX System Laboratories, Inc.
1084 * All or some portions of this file are derived from material licensed
1085 * to the University of California by American Telephone and Telegraph
1086 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
1087 * the permission of UNIX System Laboratories, Inc.
1088 *
1089 * Redistribution and use in source and binary forms, with or without
1090 * modification, are permitted provided that the following conditions
1091 * are met:
1092 * 1. Redistributions of source code must retain the above copyright
1093 * notice, this list of conditions and the following disclaimer.
1094 * 2. Redistributions in binary form must reproduce the above copyright
1095 * notice, this list of conditions and the following disclaimer in the
1096 * documentation and/or other materials provided with the distribution.
1097 * 4. Neither the name of the University nor the names of its contributors
1098 * may be used to endorse or promote products derived from this software
1099 * without specific prior written permission.
1100 *
1101 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1102 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1103 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1104 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1105 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1106 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1107 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1108 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1109 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1110 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1111 * SUCH DAMAGE.
1112 *
1113 * @(#)types.h 8.6 (Berkeley) 2/19/95
1114 * $FreeBSD$
1115 */
1116
1117#ifndef _SYS_TYPES_H_
1118#define _SYS_TYPES_H_
1119
1120#if 0 /* expanded by -frewrite-includes */
1121#include <sys/cdefs.h>
1122#endif /* expanded by -frewrite-includes */
1123# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1124# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1125
1126/* Machine type dependent parameters. */
1127#if 0 /* expanded by -frewrite-includes */
1128#include <machine/endian.h>
1129#endif /* expanded by -frewrite-includes */
1130# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1131# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 1 3 4
1132/*-
1133 * Copyright (c) 1987, 1991 Regents of the University of California.
1134 * All rights reserved.
1135 *
1136 * Redistribution and use in source and binary forms, with or without
1137 * modification, are permitted provided that the following conditions
1138 * are met:
1139 * 1. Redistributions of source code must retain the above copyright
1140 * notice, this list of conditions and the following disclaimer.
1141 * 2. Redistributions in binary form must reproduce the above copyright
1142 * notice, this list of conditions and the following disclaimer in the
1143 * documentation and/or other materials provided with the distribution.
1144 * 4. Neither the name of the University nor the names of its contributors
1145 * may be used to endorse or promote products derived from this software
1146 * without specific prior written permission.
1147 *
1148 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1149 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1150 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1151 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1152 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1153 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1154 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1155 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1156 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1157 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1158 * SUCH DAMAGE.
1159 *
1160 * @(#)endian.h 7.8 (Berkeley) 4/3/91
1161 * $FreeBSD$
1162 */
1163
1164#ifndef _MACHINE_ENDIAN_H_
1165#define _MACHINE_ENDIAN_H_
1166
1167#if 0 /* expanded by -frewrite-includes */
1168#include <sys/cdefs.h>
1169#endif /* expanded by -frewrite-includes */
1170# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1171# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1172#ifndef __ASSEMBLER__
1173#if 0 /* expanded by -frewrite-includes */
1174#include <sys/_types.h>
1175#endif /* expanded by -frewrite-includes */
1176# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1177# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 1 3 4
1178/*-
1179 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
1180 * All rights reserved.
1181 *
1182 * Redistribution and use in source and binary forms, with or without
1183 * modification, are permitted provided that the following conditions
1184 * are met:
1185 * 1. Redistributions of source code must retain the above copyright
1186 * notice, this list of conditions and the following disclaimer.
1187 * 2. Redistributions in binary form must reproduce the above copyright
1188 * notice, this list of conditions and the following disclaimer in the
1189 * documentation and/or other materials provided with the distribution.
1190 *
1191 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1192 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1193 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1194 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1195 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1196 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1197 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1198 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1199 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1200 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1201 * SUCH DAMAGE.
1202 *
1203 * $FreeBSD$
1204 */
1205
1206#ifndef _SYS__TYPES_H_
1207#define _SYS__TYPES_H_
1208
1209#if 0 /* expanded by -frewrite-includes */
1210#include <sys/cdefs.h>
1211#endif /* expanded by -frewrite-includes */
1212# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1213# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1214#if 0 /* expanded by -frewrite-includes */
1215#include <machine/_types.h>
1216#endif /* expanded by -frewrite-includes */
1217# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1218# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 1 3 4
1219/*-
1220 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
1221 * Copyright (c) 1990, 1993
1222 * The Regents of the University of California. All rights reserved.
1223 *
1224 * Redistribution and use in source and binary forms, with or without
1225 * modification, are permitted provided that the following conditions
1226 * are met:
1227 * 1. Redistributions of source code must retain the above copyright
1228 * notice, this list of conditions and the following disclaimer.
1229 * 2. Redistributions in binary form must reproduce the above copyright
1230 * notice, this list of conditions and the following disclaimer in the
1231 * documentation and/or other materials provided with the distribution.
1232 * 3. All advertising materials mentioning features or use of this software
1233 * must display the following acknowledgement:
1234 * This product includes software developed by the University of
1235 * California, Berkeley and its contributors.
1236 * 4. Neither the name of the University nor the names of its contributors
1237 * may be used to endorse or promote products derived from this software
1238 * without specific prior written permission.
1239 *
1240 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1241 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1242 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1243 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1244 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1245 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1246 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1247 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1248 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1249 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1250 * SUCH DAMAGE.
1251 *
1252 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
1253 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
1254 * from: src/sys/i386/include/_types.h,v 1.12 2005/07/02 23:13:31 thompsa
1255 * $FreeBSD$
1256 */
1257
1258#ifndef _MACHINE__TYPES_H_
1259#define _MACHINE__TYPES_H_
1260
1261#ifndef _SYS_CDEFS_H_
1262#error this file needs sys/cdefs.h as a prerequisite
1263#endif
1264# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1265
1266/*
1267 * Basic types upon which most other types are built.
1268 */
1269typedef signed char __int8_t;
1270typedef unsigned char __uint8_t;
1271typedef short __int16_t;
1272typedef unsigned short __uint16_t;
1273typedef int __int32_t;
1274typedef unsigned int __uint32_t;
1275#ifdef __mips_n64
1276typedef long __int64_t;
1277typedef unsigned long __uint64_t;
1278#else
1279# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1280#ifndef lint
1281__extension__
1282#endif
1283# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1284/* LONGLONG */
1285typedef long long __int64_t;
1286#ifndef lint
1287__extension__
1288#endif
1289# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1290/* LONGLONG */
1291typedef unsigned long long __uint64_t;
1292#endif
1293# 71 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1294
1295/*
1296 * Standard type definitions.
1297 */
1298typedef __int32_t __clock_t; /* clock()... */
1299typedef double __double_t;
1300typedef float __float_t;
1301#ifdef __mips_n64
1302#ifndef __CHERI_PURE_CAPABILITY__
1303typedef __int64_t __critical_t;
1304typedef __int64_t __intfptr_t;
1305typedef __int64_t __intptr_t;
1306#else
1307# 84 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1308typedef __intcap_t __critical_t;
1309typedef __intcap_t __intfptr_t;
1310typedef __intcap_t __intptr_t;
1311#endif
1312# 88 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1313#else
1314# 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1315typedef __int32_t __critical_t;
1316typedef __int32_t __intfptr_t;
1317typedef __int32_t __intptr_t;
1318#endif
1319# 93 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1320typedef __int64_t __intmax_t;
1321typedef __int32_t __int_fast8_t;
1322typedef __int32_t __int_fast16_t;
1323typedef __int32_t __int_fast32_t;
1324typedef __int64_t __int_fast64_t;
1325typedef __int8_t __int_least8_t;
1326typedef __int16_t __int_least16_t;
1327typedef __int32_t __int_least32_t;
1328typedef __int64_t __int_least64_t;
1329#if defined(__mips_n64) || defined(__mips_n32)
1330typedef __int64_t __register_t;
1331typedef __int64_t f_register_t;
1332#else
1333# 106 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1334typedef __int32_t __register_t;
1335typedef __int32_t f_register_t;
1336#endif
1337# 109 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1338#ifdef __mips_n64
1339typedef __int64_t __ptrdiff_t;
1340typedef __int64_t __segsz_t;
1341typedef __uint64_t __size_t;
1342typedef __int64_t __ssize_t;
1343#ifndef __CHERI_PURE_CAPABILITY__
1344typedef __uint64_t __uintfptr_t;
1345typedef __uint64_t __uintptr_t;
1346#else
1347# 118 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1348typedef __uintcap_t __uintfptr_t;
1349typedef __uintcap_t __uintptr_t;
1350#endif
1351# 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1352#else
1353# 122 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1354typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
1355typedef __int32_t __segsz_t; /* segment size (in pages) */
1356typedef __uint32_t __size_t; /* sizeof() */
1357typedef __int32_t __ssize_t; /* byte count or error */
1358typedef __uint32_t __uintfptr_t;
1359typedef __uint32_t __uintptr_t;
1360#endif
1361# 129 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1362typedef __int64_t __time_t; /* time()... */
1363typedef __uint64_t __uintmax_t;
1364typedef __uint32_t __uint_fast8_t;
1365typedef __uint32_t __uint_fast16_t;
1366typedef __uint32_t __uint_fast32_t;
1367typedef __uint64_t __uint_fast64_t;
1368typedef __uint8_t __uint_least8_t;
1369typedef __uint16_t __uint_least16_t;
1370typedef __uint32_t __uint_least32_t;
1371typedef __uint64_t __uint_least64_t;
1372#if defined(__mips_n64) || defined(__mips_n32)
1373typedef __uint64_t __u_register_t;
1374#else
1375# 142 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1376typedef __uint32_t __u_register_t;
1377#endif
1378# 144 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1379#ifdef __mips_n64
1380typedef __uint64_t __vm_offset_t;
1381typedef __uint64_t __vm_size_t;
1382#else
1383# 148 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1384typedef __uint32_t __vm_offset_t;
1385typedef __uint32_t __vm_size_t;
1386#endif
1387# 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1388#if defined(__mips_n64) || defined(__mips_n32) /* PHYSADDR_64_BIT */
1389typedef __uint64_t __vm_paddr_t;
1390#else
1391# 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1392typedef __uint32_t __vm_paddr_t;
1393#endif
1394# 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1395
1396typedef __int64_t __vm_ooffset_t;
1397typedef __uint64_t __vm_pindex_t;
1398typedef int ___wchar_t;
1399
1400#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
1401#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */
1402
1403/*
1404 * Unusual type definitions.
1405 */
1406#ifdef __GNUCLIKE_BUILTIN_VARARGS
1407typedef __builtin_va_list __va_list; /* internally known to gcc */
1408#else
1409# 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1410typedef char * __va_list;
1411#endif /* __GNUCLIKE_BUILTIN_VARARGS */
1412# 172 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1413#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
1414 && !defined(__NO_GNUC_VA_LIST)
1415#define __GNUC_VA_LIST
1416typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
1417#endif
1418# 177 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1419
1420#endif /* !_MACHINE__TYPES_H_ */
1421# 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1422# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 2 3 4
1423
1424/*
1425 * Standard type definitions.
1426 */
1427typedef __int32_t __blksize_t; /* file block size */
1428typedef __int64_t __blkcnt_t; /* file block count */
1429typedef __int32_t __clockid_t; /* clock_gettime()... */
1430typedef __uint32_t __fflags_t; /* file flags */
1431typedef __uint64_t __fsblkcnt_t;
1432typedef __uint64_t __fsfilcnt_t;
1433typedef __uint32_t __gid_t;
1434typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
1435typedef __uint32_t __ino_t; /* inode number */
1436typedef long __key_t; /* IPC key (for Sys V IPC) */
1437typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
1438typedef __uint16_t __mode_t; /* permissions */
1439typedef int __accmode_t; /* access permissions */
1440typedef int __nl_item;
1441typedef __uint16_t __nlink_t; /* link count */
1442typedef __int64_t __off_t; /* file offset */
1443typedef __int32_t __pid_t; /* process [group] */
1444typedef __int64_t __rlim_t; /* resource limit - intentionally */
1445 /* signed, because of legacy code */
1446 /* that uses -1 for RLIM_INFINITY */
1447typedef __uint8_t __sa_family_t;
1448typedef __uint32_t __socklen_t;
1449typedef long __suseconds_t; /* microseconds (signed) */
1450typedef struct __timer *__timer_t; /* timer_gettime()... */
1451typedef struct __mq *__mqd_t; /* mq_open()... */
1452typedef __uint32_t __uid_t;
1453typedef unsigned int __useconds_t; /* microseconds (unsigned) */
1454typedef int __cpuwhich_t; /* which parameter for cpuset. */
1455typedef int __cpulevel_t; /* level parameter for cpuset. */
1456typedef int __cpusetid_t; /* cpuset identifier. */
1457
1458/*
1459 * Unusual type definitions.
1460 */
1461/*
1462 * rune_t is declared to be an ``int'' instead of the more natural
1463 * ``unsigned long'' or ``long''. Two things are happening here. It is not
1464 * unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
1465 * it looks like 10646 will be a 31 bit standard. This means that if your
1466 * ints cannot hold 32 bits, you will be in trouble. The reason an int was
1467 * chosen over a long is that the is*() and to*() routines take ints (says
1468 * ANSI C), but they use __ct_rune_t instead of int.
1469 *
1470 * NOTE: rune_t is not covered by ANSI nor other standards, and should not
1471 * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and
1472 * rune_t must be the same type. Also, wint_t should be able to hold all
1473 * members of the largest character set plus one extra value (WEOF), and
1474 * must be at least 16 bits.
1475 */
1476typedef int __ct_rune_t; /* arg type for ctype funcs */
1477typedef __ct_rune_t __rune_t; /* rune_t (see above) */
1478typedef __ct_rune_t __wint_t; /* wint_t (see above) */
1479
1480/* Clang already provides these types as built-ins, but only in C++ mode. */
1481#if !defined(__clang__) || !defined(__cplusplus)
1482typedef __uint_least16_t __char16_t;
1483typedef __uint_least32_t __char32_t;
1484#endif
1485# 96 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1486/* In C++11, char16_t and char32_t are built-in types. */
1487#if defined(__cplusplus) && __cplusplus >= 201103L
1488#define _CHAR16_T_DECLARED
1489#define _CHAR32_T_DECLARED
1490#endif
1491# 101 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1492
1493typedef __uint32_t __dev_t; /* device number */
1494
1495typedef __uint32_t __fixpt_t; /* fixed point number */
1496
1497/*
1498 * mbstate_t is an opaque object to keep conversion state during multibyte
1499 * stream conversions.
1500 */
1501typedef union {
1502 char __mbstate8[128];
1503 __int64_t _mbstateL; /* for alignment */
1504} __mbstate_t;
1505
1506typedef unsigned long __rman_res_t;
1507
1508#endif /* !_SYS__TYPES_H_ */
1509# 118 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1510# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 2 3 4
1511#endif
1512# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1513
1514#ifdef __cplusplus
1515extern "C" {
1516#endif
1517# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1518
1519/*
1520 * Definitions for byte order, according to byte significance from low
1521 * address to high.
1522 */
1523#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
1524#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
1525#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
1526
1527#ifdef __MIPSEB__
1528#define _BYTE_ORDER _BIG_ENDIAN
1529#else
1530# 56 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1531#define _BYTE_ORDER _LITTLE_ENDIAN
1532#endif /* __MIBSEB__ */
1533# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1534
1535/*
1536 * Deprecated variants that don't have enough underscores to be useful in more
1537 * strict namespaces.
1538 */
1539#if __BSD_VISIBLE
1540#define LITTLE_ENDIAN _LITTLE_ENDIAN
1541#define BIG_ENDIAN _BIG_ENDIAN
1542#define PDP_ENDIAN _PDP_ENDIAN
1543#define BYTE_ORDER _BYTE_ORDER
1544#endif
1545# 69 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1546
1547#ifndef __ASSEMBLER__
1548#if defined(__GNUCLIKE_BUILTIN_CONSTANT_P) && defined(__OPTIMIZE__)
1549#define __is_constant(x) __builtin_constant_p(x)
1550#else
1551# 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1552#define __is_constant(x) 0
1553#endif
1554# 76 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1555
1556#define __bswap16_const(x) (((x) >> 8) | (((x) << 8) & 0xff00))
1557#define __bswap32_const(x) (((x) >> 24) | (((x) >> 8) & 0xff00) | \
1558 (((x) << 8) & 0xff0000) | (((x) << 24) & 0xff000000))
1559#define __bswap64_const(x) (((x) >> 56) | (((x) >> 40) & 0xff00) | \
1560 (((x) >> 24) & 0xff0000) | (((x) >> 8) & 0xff000000) | \
1561 (((x) << 8) & ((__uint64_t)0xff << 32)) | \
1562 (((x) << 24) & ((__uint64_t)0xff << 40)) | \
1563 (((x) << 40) & ((__uint64_t)0xff << 48)) | (((x) << 56)))
1564
1565static __inline __uint16_t
1566__bswap16_var(__uint16_t _x)
1567{
1568
1569 return ((_x >> 8) | ((_x << 8) & 0xff00));
1570}
1571
1572static __inline __uint32_t
1573__bswap32_var(__uint32_t _x)
1574{
1575
1576 return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff0000) |
1577 ((_x << 24) & 0xff000000));
1578}
1579
1580static __inline __uint64_t
1581__bswap64_var(__uint64_t _x)
1582{
1583
1584 return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
1585 ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
1586 ((_x << 24) & ((__uint64_t)0xff << 40)) |
1587 ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
1588}
1589
1590#define __bswap16(x) ((__uint16_t)(__is_constant((x)) ? \
1591 __bswap16_const((__uint16_t)(x)) : __bswap16_var((__uint16_t)(x))))
1592#define __bswap32(x) ((__uint32_t)(__is_constant((x)) ? \
1593 __bswap32_const((__uint32_t)(x)) : __bswap32_var((__uint32_t)(x))))
1594#define __bswap64(x) ((__uint64_t)(__is_constant((x)) ? \
1595 __bswap64_const((__uint64_t)(x)) : __bswap64_var((__uint64_t)(x))))
1596
1597#ifdef __MIPSEB__
1598#define __htonl(x) ((__uint32_t)(x))
1599#define __htons(x) ((__uint16_t)(x))
1600#define __ntohl(x) ((__uint32_t)(x))
1601#define __ntohs(x) ((__uint16_t)(x))
1602/*
1603 * Define the order of 32-bit words in 64-bit words.
1604 */
1605/*
1606 * XXXMIPS: Additional parentheses to make gcc more happy.
1607 */
1608#define _QUAD_HIGHWORD 0
1609#define _QUAD_LOWWORD 1
1610#else
1611# 132 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1612#define _QUAD_HIGHWORD 1
1613#define _QUAD_LOWWORD 0
1614#define __ntohl(x) (__bswap32((x)))
1615#define __ntohs(x) (__bswap16((x)))
1616#define __htonl(x) (__bswap32((x)))
1617#define __htons(x) (__bswap16((x)))
1618#endif /* _MIPSEB */
1619# 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1620
1621#endif /* _ASSEMBLER_ */
1622# 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1623
1624#ifdef __cplusplus
1625}
1626#endif
1627# 145 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1628
1629#endif /* !_MACHINE_ENDIAN_H_ */
1630# 147 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1631# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
1632#if 0 /* expanded by -frewrite-includes */
1633#include <sys/_types.h>
1634#endif /* expanded by -frewrite-includes */
1635# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1636# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1637
1638#if 0 /* expanded by -frewrite-includes */
1639#include <sys/_pthreadtypes.h>
1640#endif /* expanded by -frewrite-includes */
1641# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1642# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 1 3 4
1643/*
1644 * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
1645 * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au>
1646 * All rights reserved.
1647 *
1648 * Redistribution and use in source and binary forms, with or without
1649 * modification, are permitted provided that the following conditions
1650 * are met:
1651 * 1. Redistributions of source code must retain the above copyright
1652 * notice, this list of conditions and the following disclaimer.
1653 * 2. Redistributions in binary form must reproduce the above copyright
1654 * notice, this list of conditions and the following disclaimer in the
1655 * documentation and/or other materials provided with the distribution.
1656 * 3. All advertising materials mentioning features or use of this software
1657 * must display the following acknowledgement:
1658 * This product includes software developed by Chris Provenzano.
1659 * 4. The name of Chris Provenzano may not be used to endorse or promote
1660 * products derived from this software without specific prior written
1661 * permission.
1662 *
1663 * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
1664 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1665 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1666 * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
1667 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1668 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1669 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1670 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1671 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1672 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1673 * SUCH DAMAGE.
1674 *
1675 * $FreeBSD$
1676 */
1677
1678#ifndef _SYS__PTHREADTYPES_H_
1679#define _SYS__PTHREADTYPES_H_
1680
1681/*
1682 * Forward structure definitions.
1683 *
1684 * These are mostly opaque to the user.
1685 */
1686struct pthread;
1687struct pthread_attr;
1688struct pthread_cond;
1689struct pthread_cond_attr;
1690struct pthread_mutex;
1691struct pthread_mutex_attr;
1692struct pthread_once;
1693struct pthread_rwlock;
1694struct pthread_rwlockattr;
1695struct pthread_barrier;
1696struct pthread_barrier_attr;
1697struct pthread_spinlock;
1698
1699/*
1700 * Primitive system data type definitions required by P1003.1c.
1701 *
1702 * Note that P1003.1c specifies that there are no defined comparison
1703 * or assignment operators for the types pthread_attr_t, pthread_cond_t,
1704 * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
1705 */
1706#ifndef _PTHREAD_T_DECLARED
1707typedef struct pthread *pthread_t;
1708#define _PTHREAD_T_DECLARED
1709#endif
1710# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 3 4
1711typedef struct pthread_attr *pthread_attr_t;
1712typedef struct pthread_mutex *pthread_mutex_t;
1713typedef struct pthread_mutex_attr *pthread_mutexattr_t;
1714typedef struct pthread_cond *pthread_cond_t;
1715typedef struct pthread_cond_attr *pthread_condattr_t;
1716typedef int pthread_key_t;
1717typedef struct pthread_once pthread_once_t;
1718typedef struct pthread_rwlock *pthread_rwlock_t;
1719typedef struct pthread_rwlockattr *pthread_rwlockattr_t;
1720typedef struct pthread_barrier *pthread_barrier_t;
1721typedef struct pthread_barrierattr *pthread_barrierattr_t;
1722typedef struct pthread_spinlock *pthread_spinlock_t;
1723
1724/*
1725 * Additional type definitions:
1726 *
1727 * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for
1728 * use in header symbols.
1729 */
1730typedef void *pthread_addr_t;
1731typedef void *(*pthread_startroutine_t)(void *);
1732
1733/*
1734 * Once definitions.
1735 */
1736struct pthread_once {
1737 int state;
1738 pthread_mutex_t mutex;
1739};
1740
1741#endif /* ! _SYS__PTHREADTYPES_H_ */
1742# 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 3 4
1743# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
1744
1745#if __BSD_VISIBLE
1746typedef unsigned char u_char;
1747typedef unsigned short u_short;
1748typedef unsigned int u_int;
1749typedef unsigned long u_long;
1750#ifndef _KERNEL
1751typedef unsigned short ushort; /* Sys V compatibility */
1752typedef unsigned int uint; /* Sys V compatibility */
1753#endif
1754# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1755#endif
1756# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1757
1758/*
1759 * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
1760 */
1761#if 0 /* expanded by -frewrite-includes */
1762#include <sys/_stdint.h>
1763#endif /* expanded by -frewrite-includes */
1764# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1765# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 1 3 4
1766/*-
1767 * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org>
1768 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
1769 * All rights reserved.
1770 *
1771 * Redistribution and use in source and binary forms, with or without
1772 * modification, are permitted provided that the following conditions
1773 * are met:
1774 * 1. Redistributions of source code must retain the above copyright
1775 * notice, this list of conditions and the following disclaimer.
1776 * 2. Redistributions in binary form must reproduce the above copyright
1777 * notice, this list of conditions and the following disclaimer in the
1778 * documentation and/or other materials provided with the distribution.
1779 *
1780 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1781 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1782 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1783 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1784 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1785 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1786 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1787 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1788 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1789 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1790 * SUCH DAMAGE.
1791 *
1792 * $FreeBSD$
1793 */
1794
1795#ifndef _SYS__STDINT_H_
1796#define _SYS__STDINT_H_
1797
1798#ifndef _INT8_T_DECLARED
1799typedef __int8_t int8_t;
1800#define _INT8_T_DECLARED
1801#endif
1802# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1803
1804#ifndef _INT16_T_DECLARED
1805typedef __int16_t int16_t;
1806#define _INT16_T_DECLARED
1807#endif
1808# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1809
1810#ifndef _INT32_T_DECLARED
1811typedef __int32_t int32_t;
1812#define _INT32_T_DECLARED
1813#endif
1814# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1815
1816#ifndef _INT64_T_DECLARED
1817typedef __int64_t int64_t;
1818#define _INT64_T_DECLARED
1819#endif
1820# 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1821
1822#ifndef _UINT8_T_DECLARED
1823typedef __uint8_t uint8_t;
1824#define _UINT8_T_DECLARED
1825#endif
1826# 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1827
1828#ifndef _UINT16_T_DECLARED
1829typedef __uint16_t uint16_t;
1830#define _UINT16_T_DECLARED
1831#endif
1832# 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1833
1834#ifndef _UINT32_T_DECLARED
1835typedef __uint32_t uint32_t;
1836#define _UINT32_T_DECLARED
1837#endif
1838# 67 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1839
1840#ifndef _UINT64_T_DECLARED
1841typedef __uint64_t uint64_t;
1842#define _UINT64_T_DECLARED
1843#endif
1844# 72 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1845
1846#ifndef _INTPTR_T_DECLARED
1847typedef __intptr_t intptr_t;
1848#define _INTPTR_T_DECLARED
1849#endif
1850# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1851#ifndef _UINTPTR_T_DECLARED
1852typedef __uintptr_t uintptr_t;
1853#define _UINTPTR_T_DECLARED
1854#endif
1855# 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1856#ifndef _INTMAX_T_DECLARED
1857typedef __intmax_t intmax_t;
1858#define _INTMAX_T_DECLARED
1859#endif
1860# 85 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1861#ifndef _UINTMAX_T_DECLARED
1862typedef __uintmax_t uintmax_t;
1863#define _UINTMAX_T_DECLARED
1864#endif
1865# 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1866
1867#endif /* !_SYS__STDINT_H_ */
1868# 91 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1869# 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
1870
1871typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */
1872typedef __uint16_t u_int16_t;
1873typedef __uint32_t u_int32_t;
1874typedef __uint64_t u_int64_t;
1875
1876typedef __uint64_t u_quad_t; /* quads (deprecated) */
1877typedef __int64_t quad_t;
1878typedef quad_t * qaddr_t;
1879
1880typedef char * caddr_t; /* core address */
1881typedef const char * c_caddr_t; /* core address, pointer to const */
1882
1883#ifndef _BLKSIZE_T_DECLARED
1884typedef __blksize_t blksize_t;
1885#define _BLKSIZE_T_DECLARED
1886#endif
1887# 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1888
1889typedef __cpuwhich_t cpuwhich_t;
1890typedef __cpulevel_t cpulevel_t;
1891typedef __cpusetid_t cpusetid_t;
1892
1893#ifndef _BLKCNT_T_DECLARED
1894typedef __blkcnt_t blkcnt_t;
1895#define _BLKCNT_T_DECLARED
1896#endif
1897# 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1898
1899#ifndef _CLOCK_T_DECLARED
1900typedef __clock_t clock_t;
1901#define _CLOCK_T_DECLARED
1902#endif
1903# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1904
1905#ifndef _CLOCKID_T_DECLARED
1906typedef __clockid_t clockid_t;
1907#define _CLOCKID_T_DECLARED
1908#endif
1909# 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1910
1911typedef __critical_t critical_t; /* Critical section value */
1912typedef __int64_t daddr_t; /* disk address */
1913
1914#ifndef _DEV_T_DECLARED
1915typedef __dev_t dev_t; /* device number or struct cdev */
1916#define _DEV_T_DECLARED
1917#endif
1918# 108 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1919
1920#ifndef _FFLAGS_T_DECLARED
1921typedef __fflags_t fflags_t; /* file flags */
1922#define _FFLAGS_T_DECLARED
1923#endif
1924# 113 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1925
1926typedef __fixpt_t fixpt_t; /* fixed point number */
1927
1928#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
1929typedef __fsblkcnt_t fsblkcnt_t;
1930typedef __fsfilcnt_t fsfilcnt_t;
1931#define _FSBLKCNT_T_DECLARED
1932#endif
1933# 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1934
1935#ifndef _GID_T_DECLARED
1936typedef __gid_t gid_t; /* group id */
1937#define _GID_T_DECLARED
1938#endif
1939# 126 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1940
1941#ifndef _IN_ADDR_T_DECLARED
1942typedef __uint32_t in_addr_t; /* base type for internet address */
1943#define _IN_ADDR_T_DECLARED
1944#endif
1945# 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1946
1947#ifndef _IN_PORT_T_DECLARED
1948typedef __uint16_t in_port_t;
1949#define _IN_PORT_T_DECLARED
1950#endif
1951# 136 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1952
1953#ifndef _ID_T_DECLARED
1954typedef __id_t id_t; /* can hold a uid_t or pid_t */
1955#define _ID_T_DECLARED
1956#endif
1957# 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1958
1959#ifndef _INO_T_DECLARED
1960typedef __ino_t ino_t; /* inode number */
1961#define _INO_T_DECLARED
1962#endif
1963# 146 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1964
1965#ifndef _KEY_T_DECLARED
1966typedef __key_t key_t; /* IPC key (for Sys V IPC) */
1967#define _KEY_T_DECLARED
1968#endif
1969# 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1970
1971#ifndef _LWPID_T_DECLARED
1972typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */
1973#define _LWPID_T_DECLARED
1974#endif
1975# 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1976
1977#ifndef _MODE_T_DECLARED
1978typedef __mode_t mode_t; /* permissions */
1979#define _MODE_T_DECLARED
1980#endif
1981# 161 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1982
1983#ifndef _ACCMODE_T_DECLARED
1984typedef __accmode_t accmode_t; /* access permissions */
1985#define _ACCMODE_T_DECLARED
1986#endif
1987# 166 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1988
1989#ifndef _NLINK_T_DECLARED
1990typedef __nlink_t nlink_t; /* link count */
1991#define _NLINK_T_DECLARED
1992#endif
1993# 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1994
1995#ifndef _OFF_T_DECLARED
1996typedef __off_t off_t; /* file offset */
1997#define _OFF_T_DECLARED
1998#endif
1999# 176 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2000
2001#ifndef _PID_T_DECLARED
2002typedef __pid_t pid_t; /* process id */
2003#define _PID_T_DECLARED
2004#endif
2005# 181 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2006
2007typedef __register_t register_t;
2008
2009#ifndef _RLIM_T_DECLARED
2010typedef __rlim_t rlim_t; /* resource limit */
2011#define _RLIM_T_DECLARED
2012#endif
2013# 188 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2014
2015typedef __int64_t sbintime_t;
2016
2017typedef __segsz_t segsz_t; /* segment size (in pages) */
2018
2019#ifndef _SIZE_T_DECLARED
2020typedef __size_t size_t;
2021#define _SIZE_T_DECLARED
2022#endif
2023# 197 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2024
2025#ifndef _SSIZE_T_DECLARED
2026typedef __ssize_t ssize_t;
2027#define _SSIZE_T_DECLARED
2028#endif
2029# 202 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2030
2031#ifndef _SUSECONDS_T_DECLARED
2032typedef __suseconds_t suseconds_t; /* microseconds (signed) */
2033#define _SUSECONDS_T_DECLARED
2034#endif
2035# 207 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2036
2037#ifndef _TIME_T_DECLARED
2038typedef __time_t time_t;
2039#define _TIME_T_DECLARED
2040#endif
2041# 212 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2042
2043#ifndef _TIMER_T_DECLARED
2044typedef __timer_t timer_t;
2045#define _TIMER_T_DECLARED
2046#endif
2047# 217 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2048
2049#ifndef _MQD_T_DECLARED
2050typedef __mqd_t mqd_t;
2051#define _MQD_T_DECLARED
2052#endif
2053# 222 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2054
2055typedef __u_register_t u_register_t;
2056
2057#ifndef _UID_T_DECLARED
2058typedef __uid_t uid_t; /* user id */
2059#define _UID_T_DECLARED
2060#endif
2061# 229 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2062
2063#ifndef _USECONDS_T_DECLARED
2064typedef __useconds_t useconds_t; /* microseconds (unsigned) */
2065#define _USECONDS_T_DECLARED
2066#endif
2067# 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2068
2069#ifndef _CAP_IOCTL_T_DECLARED
2070#define _CAP_IOCTL_T_DECLARED
2071typedef unsigned long cap_ioctl_t;
2072#endif
2073# 239 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2074
2075#ifndef _CAP_RIGHTS_T_DECLARED
2076#define _CAP_RIGHTS_T_DECLARED
2077struct cap_rights;
2078
2079typedef struct cap_rights cap_rights_t;
2080#endif
2081# 246 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2082
2083typedef __vm_offset_t vm_offset_t;
2084typedef __vm_ooffset_t vm_ooffset_t;
2085typedef __vm_paddr_t vm_paddr_t;
2086typedef __vm_pindex_t vm_pindex_t;
2087typedef __vm_size_t vm_size_t;
2088
2089typedef __rman_res_t rman_res_t;
2090
2091#ifdef _KERNEL
2092typedef int boolean_t;
2093typedef struct device *device_t;
2094typedef __intfptr_t intfptr_t;
2095
2096/*
2097 * XXX this is fixed width for historical reasons. It should have had type
2098 * __int_fast32_t. Fixed-width types should not be used unless binary
2099 * compatibility is essential. Least-width types should be used even less
2100 * since they provide smaller benefits.
2101 *
2102 * XXX should be MD.
2103 *
2104 * XXX this is bogus in -current, but still used for spl*().
2105 */
2106typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */
2107
2108typedef __uintfptr_t uintfptr_t;
2109typedef __uint64_t uoff_t;
2110typedef char vm_memattr_t; /* memory attribute codes */
2111typedef struct vm_page *vm_page_t;
2112
2113#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
2114#define __bool_true_false_are_defined 1
2115#define false 0
2116#define true 1
2117#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
2118typedef int _Bool;
2119#endif
2120# 284 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2121typedef _Bool bool;
2122#endif /* !__bool_true_false_are_defined && !__cplusplus */
2123# 286 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2124
2125#define offsetof(type, field) __offsetof(type, field)
2126
2127#endif /* !_KERNEL */
2128# 290 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2129
2130/*
2131 * The following are all things that really shouldn't exist in this header,
2132 * since its purpose is to provide typedefs, not miscellaneous doodads.
2133 */
2134
2135#ifdef __POPCNT__
2136#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x))
2137#define __bitcount32(x) __builtin_popcount((__uint32_t)(x))
2138#define __bitcount16(x) __builtin_popcount((__uint16_t)(x))
2139#define __bitcountl(x) __builtin_popcountl((unsigned long)(x))
2140#define __bitcount(x) __builtin_popcount((unsigned int)(x))
2141#else
2142# 303 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2143/*
2144 * Population count algorithm using SWAR approach
2145 * - "SIMD Within A Register".
2146 */
2147static __inline __uint16_t
2148__bitcount16(__uint16_t _x)
2149{
2150
2151 _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1);
2152 _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2);
2153 _x = (_x + (_x >> 4)) & 0x0f0f;
2154 _x = (_x + (_x >> 8)) & 0x00ff;
2155 return (_x);
2156}
2157
2158static __inline __uint32_t
2159__bitcount32(__uint32_t _x)
2160{
2161
2162 _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1);
2163 _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2);
2164 _x = (_x + (_x >> 4)) & 0x0f0f0f0f;
2165 _x = (_x + (_x >> 8));
2166 _x = (_x + (_x >> 16)) & 0x000000ff;
2167 return (_x);
2168}
2169
2170#ifdef __LP64__
2171static __inline __uint64_t
2172__bitcount64(__uint64_t _x)
2173{
2174
2175 _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1);
2176 _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2);
2177 _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f;
2178 _x = (_x + (_x >> 8));
2179 _x = (_x + (_x >> 16));
2180 _x = (_x + (_x >> 32)) & 0x000000ff;
2181 return (_x);
2182}
2183
2184#define __bitcountl(x) __bitcount64((unsigned long)(x))
2185#else
2186# 346 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2187static __inline __uint64_t
2188__bitcount64(__uint64_t _x)
2189{
2190
2191 return (__bitcount32(_x >> 32) + __bitcount32(_x));
2192}
2193
2194#define __bitcountl(x) __bitcount32((unsigned long)(x))
2195#endif
2196# 355 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2197#define __bitcount(x) __bitcount32((unsigned int)(x))
2198#endif
2199# 357 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2200
2201#if __BSD_VISIBLE
2202
2203#if 0 /* expanded by -frewrite-includes */
2204#include <sys/select.h>
2205#endif /* expanded by -frewrite-includes */
2206# 360 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2207# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 1 3 4
2208/*-
2209 * Copyright (c) 1992, 1993
2210 * The Regents of the University of California. All rights reserved.
2211 *
2212 * Redistribution and use in source and binary forms, with or without
2213 * modification, are permitted provided that the following conditions
2214 * are met:
2215 * 1. Redistributions of source code must retain the above copyright
2216 * notice, this list of conditions and the following disclaimer.
2217 * 2. Redistributions in binary form must reproduce the above copyright
2218 * notice, this list of conditions and the following disclaimer in the
2219 * documentation and/or other materials provided with the distribution.
2220 * 4. Neither the name of the University nor the names of its contributors
2221 * may be used to endorse or promote products derived from this software
2222 * without specific prior written permission.
2223 *
2224 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2225 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2226 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2227 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2228 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2229 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2230 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2231 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2233 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2234 * SUCH DAMAGE.
2235 *
2236 * $FreeBSD$
2237 */
2238
2239#ifndef _SYS_SELECT_H_
2240#define _SYS_SELECT_H_
2241
2242#if 0 /* expanded by -frewrite-includes */
2243#include <sys/cdefs.h>
2244#endif /* expanded by -frewrite-includes */
2245# 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2246# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2247#if 0 /* expanded by -frewrite-includes */
2248#include <sys/_types.h>
2249#endif /* expanded by -frewrite-includes */
2250# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2251# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2252
2253#if 0 /* expanded by -frewrite-includes */
2254#include <sys/_sigset.h>
2255#endif /* expanded by -frewrite-includes */
2256# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2257# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 1 3 4
2258/*-
2259 * Copyright (c) 1982, 1986, 1989, 1991, 1993
2260 * The Regents of the University of California. All rights reserved.
2261 * (c) UNIX System Laboratories, Inc.
2262 * All or some portions of this file are derived from material licensed
2263 * to the University of California by American Telephone and Telegraph
2264 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
2265 * the permission of UNIX System Laboratories, Inc.
2266 *
2267 * Redistribution and use in source and binary forms, with or without
2268 * modification, are permitted provided that the following conditions
2269 * are met:
2270 * 1. Redistributions of source code must retain the above copyright
2271 * notice, this list of conditions and the following disclaimer.
2272 * 2. Redistributions in binary form must reproduce the above copyright
2273 * notice, this list of conditions and the following disclaimer in the
2274 * documentation and/or other materials provided with the distribution.
2275 * 4. Neither the name of the University nor the names of its contributors
2276 * may be used to endorse or promote products derived from this software
2277 * without specific prior written permission.
2278 *
2279 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2280 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2281 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2282 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2283 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2284 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2285 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2286 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2287 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2288 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2289 * SUCH DAMAGE.
2290 *
2291 * @(#)signal.h 8.4 (Berkeley) 5/4/95
2292 * $FreeBSD$
2293 */
2294
2295#ifndef _SYS__SIGSET_H_
2296#define _SYS__SIGSET_H_
2297
2298/*
2299 * sigset_t macros.
2300 */
2301#define _SIG_WORDS 4
2302#define _SIG_MAXSIG 128
2303#define _SIG_IDX(sig) ((sig) - 1)
2304#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
2305#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
2306#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0)
2307
2308typedef struct __sigset {
2309 __uint32_t __bits[_SIG_WORDS];
2310} __sigset_t;
2311
2312#if defined(_KERNEL) && defined(COMPAT_43)
2313typedef unsigned int osigset_t;
2314#endif
2315# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 3 4
2316
2317#endif /* !_SYS__SIGSET_H_ */
2318# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 3 4
2319# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
2320#if 0 /* expanded by -frewrite-includes */
2321#include <sys/_timeval.h>
2322#endif /* expanded by -frewrite-includes */
2323# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2324# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 1 3 4
2325/*-
2326 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
2327 * All rights reserved.
2328 *
2329 * Redistribution and use in source and binary forms, with or without
2330 * modification, are permitted provided that the following conditions
2331 * are met:
2332 * 1. Redistributions of source code must retain the above copyright
2333 * notice, this list of conditions and the following disclaimer.
2334 * 2. Redistributions in binary form must reproduce the above copyright
2335 * notice, this list of conditions and the following disclaimer in the
2336 * documentation and/or other materials provided with the distribution.
2337 *
2338 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2339 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2340 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2341 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2342 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2343 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2344 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2345 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2346 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2347 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2348 * SUCH DAMAGE.
2349 *
2350 * $FreeBSD$
2351 */
2352
2353#ifndef _SYS__TIMEVAL_H_
2354#define _SYS__TIMEVAL_H_
2355
2356#if 0 /* expanded by -frewrite-includes */
2357#include <sys/_types.h>
2358#endif /* expanded by -frewrite-includes */
2359# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2360# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2361
2362#ifndef _SUSECONDS_T_DECLARED
2363typedef __suseconds_t suseconds_t;
2364#define _SUSECONDS_T_DECLARED
2365#endif
2366# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2367
2368#ifndef _TIME_T_DECLARED
2369typedef __time_t time_t;
2370#define _TIME_T_DECLARED
2371#endif
2372# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2373
2374/*
2375 * Structure returned by gettimeofday(2) system call, and used in other calls.
2376 */
2377struct timeval {
2378 time_t tv_sec; /* seconds */
2379 suseconds_t tv_usec; /* and microseconds */
2380};
2381
2382#endif /* !_SYS__TIMEVAL_H_ */
2383# 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2384# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
2385#if 0 /* expanded by -frewrite-includes */
2386#include <sys/timespec.h>
2387#endif /* expanded by -frewrite-includes */
2388# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2389# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 1 3 4
2390/*-
2391 * Copyright (c) 1982, 1986, 1993
2392 * The Regents of the University of California. All rights reserved.
2393 *
2394 * Redistribution and use in source and binary forms, with or without
2395 * modification, are permitted provided that the following conditions
2396 * are met:
2397 * 1. Redistributions of source code must retain the above copyright
2398 * notice, this list of conditions and the following disclaimer.
2399 * 2. Redistributions in binary form must reproduce the above copyright
2400 * notice, this list of conditions and the following disclaimer in the
2401 * documentation and/or other materials provided with the distribution.
2402 * 4. Neither the name of the University nor the names of its contributors
2403 * may be used to endorse or promote products derived from this software
2404 * without specific prior written permission.
2405 *
2406 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2407 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2408 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2409 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2410 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2411 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2412 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2413 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2414 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2415 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2416 * SUCH DAMAGE.
2417 *
2418 * @(#)time.h 8.5 (Berkeley) 5/4/95
2419 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
2420 * $FreeBSD$
2421 */
2422
2423#ifndef _SYS_TIMESPEC_H_
2424#define _SYS_TIMESPEC_H_
2425
2426#if 0 /* expanded by -frewrite-includes */
2427#include <sys/cdefs.h>
2428#endif /* expanded by -frewrite-includes */
2429# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2430# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2431#if 0 /* expanded by -frewrite-includes */
2432#include <sys/_timespec.h>
2433#endif /* expanded by -frewrite-includes */
2434# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2435# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 1 3 4
2436/*-
2437 * Copyright (c) 1982, 1986, 1993
2438 * The Regents of the University of California. All rights reserved.
2439 *
2440 * Redistribution and use in source and binary forms, with or without
2441 * modification, are permitted provided that the following conditions
2442 * are met:
2443 * 1. Redistributions of source code must retain the above copyright
2444 * notice, this list of conditions and the following disclaimer.
2445 * 2. Redistributions in binary form must reproduce the above copyright
2446 * notice, this list of conditions and the following disclaimer in the
2447 * documentation and/or other materials provided with the distribution.
2448 * 4. Neither the name of the University nor the names of its contributors
2449 * may be used to endorse or promote products derived from this software
2450 * without specific prior written permission.
2451 *
2452 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2453 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2454 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2455 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2456 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2457 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2458 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2459 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2460 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2461 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2462 * SUCH DAMAGE.
2463 *
2464 * @(#)time.h 8.5 (Berkeley) 5/4/95
2465 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
2466 * $FreeBSD$
2467 */
2468
2469#ifndef _SYS__TIMESPEC_H_
2470#define _SYS__TIMESPEC_H_
2471
2472#if 0 /* expanded by -frewrite-includes */
2473#include <sys/_types.h>
2474#endif /* expanded by -frewrite-includes */
2475# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2476# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2477
2478#ifndef _TIME_T_DECLARED
2479typedef __time_t time_t;
2480#define _TIME_T_DECLARED
2481#endif
2482# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2483
2484struct timespec {
2485 time_t tv_sec; /* seconds */
2486 long tv_nsec; /* and nanoseconds */
2487};
2488
2489#endif /* !_SYS__TIMESPEC_H_ */
2490# 50 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2491# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 2 3 4
2492
2493#if __BSD_VISIBLE
2494#define TIMEVAL_TO_TIMESPEC(tv, ts) \
2495 do { \
2496 (ts)->tv_sec = (tv)->tv_sec; \
2497 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
2498 } while (0)
2499#define TIMESPEC_TO_TIMEVAL(tv, ts) \
2500 do { \
2501 (tv)->tv_sec = (ts)->tv_sec; \
2502 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
2503 } while (0)
2504
2505#endif /* __BSD_VISIBLE */
2506# 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2507
2508/*
2509 * Structure defined by POSIX.1b to be like a itimerval, but with
2510 * timespecs. Used in the timer_*() system calls.
2511 */
2512struct itimerspec {
2513 struct timespec it_interval;
2514 struct timespec it_value;
2515};
2516
2517#endif /* _SYS_TIMESPEC_H_ */
2518# 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2519# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
2520
2521typedef unsigned long __fd_mask;
2522#if __BSD_VISIBLE
2523typedef __fd_mask fd_mask;
2524#endif
2525# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2526
2527#ifndef _SIGSET_T_DECLARED
2528#define _SIGSET_T_DECLARED
2529typedef __sigset_t sigset_t;
2530#endif
2531# 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2532
2533/*
2534 * Select uses bit masks of file descriptors in longs. These macros
2535 * manipulate such bit fields (the filesystem macros use chars).
2536 * FD_SETSIZE may be defined by the user, but the default here should
2537 * be enough for most uses.
2538 */
2539#ifndef FD_SETSIZE
2540#define FD_SETSIZE 1024
2541#endif
2542# 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2543
2544#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
2545#if __BSD_VISIBLE
2546#define NFDBITS _NFDBITS
2547#endif
2548# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2549
2550#ifndef _howmany
2551#define _howmany(x, y) (((x) + ((y) - 1)) / (y))
2552#endif
2553# 70 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2554
2555typedef struct fd_set {
2556 __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
2557} fd_set;
2558#if __BSD_VISIBLE
2559#define fds_bits __fds_bits
2560#endif
2561# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2562
2563#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
2564#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
2565#if __BSD_VISIBLE
2566#define FD_COPY(f, t) (void)(*(t) = *(f))
2567#endif
2568# 83 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2569#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)
2570#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
2571#define FD_ZERO(p) do { \
2572 fd_set *_p; \
2573 __size_t _n; \
2574 \
2575 _p = (p); \
2576 _n = _howmany(FD_SETSIZE, _NFDBITS); \
2577 while (_n > 0) \
2578 _p->__fds_bits[--_n] = 0; \
2579} while (0)
2580
2581#ifndef _KERNEL
2582
2583__BEGIN_DECLS
2584int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict,
2585 const struct timespec *__restrict, const sigset_t *__restrict);
2586#ifndef _SELECT_DECLARED
2587#define _SELECT_DECLARED
2588/* XXX missing restrict type-qualifier */
2589int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
2590#endif
2591# 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2592__END_DECLS
2593#endif /* !_KERNEL */
2594# 107 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2595
2596#endif /* _SYS_SELECT_H_ */
2597# 109 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2598# 361 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
2599
2600/*
2601 * minor() gives a cookie instead of an index since we don't want to
2602 * change the meanings of bits 0-15 or waste time and space shifting
2603 * bits 16-31 for devices that don't use them.
2604 */
2605#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
2606#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
2607#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
2608
2609/*
2610 * These declarations belong elsewhere, but are repeated here and in
2611 * <stdio.h> to give broken programs a better chance of working with
2612 * 64-bit off_t's.
2613 */
2614#ifndef _KERNEL
2615__BEGIN_DECLS
2616#ifndef _FTRUNCATE_DECLARED
2617#define _FTRUNCATE_DECLARED
2618int ftruncate(int, off_t);
2619#endif
2620# 382 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2621#ifndef _LSEEK_DECLARED
2622#define _LSEEK_DECLARED
2623off_t lseek(int, off_t, int);
2624#endif
2625# 386 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2626#ifndef _MMAP_DECLARED
2627#define _MMAP_DECLARED
2628void * mmap(void *, size_t, int, int, int, off_t);
2629#endif
2630# 390 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2631#ifndef _TRUNCATE_DECLARED
2632#define _TRUNCATE_DECLARED
2633int truncate(const char *, off_t);
2634#endif
2635# 394 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2636__END_DECLS
2637#endif /* !_KERNEL */
2638# 396 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2639
2640#endif /* __BSD_VISIBLE */
2641# 398 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2642
2643#endif /* !_SYS_TYPES_H_ */
2644# 400 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2645# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
2646#if 0 /* expanded by -frewrite-includes */
2647#include <stdio.h>
2648#endif /* expanded by -frewrite-includes */
2649# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
2650# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h" 1
2651/*-
2652 * Copyright (c) 1990, 1993
2653 * The Regents of the University of California. All rights reserved.
2654 *
2655 * This code is derived from software contributed to Berkeley by
2656 * Chris Torek.
2657 *
2658 * Redistribution and use in source and binary forms, with or without
2659 * modification, are permitted provided that the following conditions
2660 * are met:
2661 * 1. Redistributions of source code must retain the above copyright
2662 * notice, this list of conditions and the following disclaimer.
2663 * 2. Redistributions in binary form must reproduce the above copyright
2664 * notice, this list of conditions and the following disclaimer in the
2665 * documentation and/or other materials provided with the distribution.
2666 * 3. Neither the name of the University nor the names of its contributors
2667 * may be used to endorse or promote products derived from this software
2668 * without specific prior written permission.
2669 *
2670 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2671 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2672 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2673 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2674 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2675 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2676 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2677 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2678 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2679 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2680 * SUCH DAMAGE.
2681 *
2682 * @(#)stdio.h 8.5 (Berkeley) 4/29/95
2683 * $FreeBSD$
2684 */
2685
2686#ifndef _STDIO_H_
2687#define _STDIO_H_
2688
2689#if 0 /* expanded by -frewrite-includes */
2690#include <sys/cdefs.h>
2691#endif /* expanded by -frewrite-includes */
2692# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2693# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2694#if 0 /* expanded by -frewrite-includes */
2695#include <sys/_null.h>
2696#endif /* expanded by -frewrite-includes */
2697# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2698# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 1 3 4
2699/*-
2700 * Copyright (c) 2003 Marcel Moolenaar
2701 * All rights reserved.
2702 *
2703 * Redistribution and use in source and binary forms, with or without
2704 * modification, are permitted provided that the following conditions
2705 * are met:
2706 *
2707 * 1. Redistributions of source code must retain the above copyright
2708 * notice, this list of conditions and the following disclaimer.
2709 * 2. Redistributions in binary form must reproduce the above copyright
2710 * notice, this list of conditions and the following disclaimer in the
2711 * documentation and/or other materials provided with the distribution.
2712 *
2713 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2714 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2715 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2716 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2717 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2718 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2719 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2720 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2721 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2722 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2723 *
2724 * $FreeBSD$
2725 */
2726
2727#ifndef NULL
2728
2729#if !defined(__cplusplus)
2730#define NULL ((void *)0)
2731#else
2732# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2733#if __cplusplus >= 201103L
2734#define NULL nullptr
2735#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
2736# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2737#define NULL __null
2738#else
2739# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2740#if defined(__LP64__)
2741#define NULL (0L)
2742#else
2743# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2744#define NULL 0
2745#endif /* __LP64__ */
2746# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2747#endif /* __GNUG__ */
2748# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2749#endif /* !__cplusplus */
2750# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2751
2752#endif
2753# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
2754# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h" 2
2755#if 0 /* expanded by -frewrite-includes */
2756#include <sys/_types.h>
2757#endif /* expanded by -frewrite-includes */
2758# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2759# 42 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2760
2761typedef __off_t fpos_t;
2762
2763#ifndef _SIZE_T_DECLARED
2764typedef __size_t size_t;
2765#define _SIZE_T_DECLARED
2766#endif
2767# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2768
2769#if __POSIX_VISIBLE >= 200809
2770#ifndef _OFF_T_DECLARED
2771#define _OFF_T_DECLARED
2772typedef __off_t off_t;
2773#endif
2774# 55 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2775#ifndef _SSIZE_T_DECLARED
2776#define _SSIZE_T_DECLARED
2777typedef __ssize_t ssize_t;
2778#endif
2779# 59 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2780#endif
2781# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2782
2783#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
2784#ifndef _VA_LIST_DECLARED
2785typedef __va_list va_list;
2786#define _VA_LIST_DECLARED
2787#endif
2788# 66 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2789#endif
2790# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2791
2792#define _FSTDIO /* Define for new stdio with functions. */
2793
2794/*
2795 * NB: to fit things in six character monocase externals, the stdio
2796 * code uses the prefix `__s' for stdio objects, typically followed
2797 * by a three-character attempt at a mnemonic.
2798 */
2799
2800/* stdio buffers */
2801struct __sbuf {
2802 unsigned char *_base;
2803 int _size;
2804};
2805
2806/*
2807 * stdio state variables.
2808 *
2809 * The following always hold:
2810 *
2811 * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
2812 * _lbfsize is -_bf._size, else _lbfsize is 0
2813 * if _flags&__SRD, _w is 0
2814 * if _flags&__SWR, _r is 0
2815 *
2816 * This ensures that the getc and putc macros (or inline functions) never
2817 * try to write or read from a file that is in `read' or `write' mode.
2818 * (Moreover, they can, and do, automatically switch from read mode to
2819 * write mode, and back, on "r+" and "w+" files.)
2820 *
2821 * _lbfsize is used only to make the inline line-buffered output stream
2822 * code as compact as possible.
2823 *
2824 * _ub, _up, and _ur are used when ungetc() pushes back more characters
2825 * than fit in the current _bf, or when ungetc() pushes back a character
2826 * that does not match the previous one in _bf. When this happens,
2827 * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
2828 * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
2829 *
2830 * Certain members of __sFILE are accessed directly via macros or
2831 * inline functions. To preserve ABI compat, these members must not
2832 * be disturbed. These members are marked below with (*).
2833 */
2834struct __sFILE {
2835 unsigned char *_p; /* (*) current position in (some) buffer */
2836 int _r; /* (*) read space left for getc() */
2837 int _w; /* (*) write space left for putc() */
2838 short _flags; /* (*) flags, below; this FILE is free if 0 */
2839 short _file; /* (*) fileno, if Unix descriptor, else -1 */
2840 struct __sbuf _bf; /* (*) the buffer (at least 1 byte, if !NULL) */
2841 int _lbfsize; /* (*) 0 or -_bf._size, for inline putc */
2842
2843 /* operations */
2844 void *_cookie; /* (*) cookie passed to io functions */
2845 int (*_close)(void *);
2846 int (*_read)(void *, char *, int);
2847 fpos_t (*_seek)(void *, fpos_t, int);
2848 int (*_write)(void *, const char *, int);
2849
2850 /* separate buffer for long sequences of ungetc() */
2851 struct __sbuf _ub; /* ungetc buffer */
2852 unsigned char *_up; /* saved _p when _p is doing ungetc data */
2853 int _ur; /* saved _r when _r is counting ungetc data */
2854
2855 /* tricks to meet minimum requirements even when malloc() fails */
2856 unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
2857 unsigned char _nbuf[1]; /* guarantee a getc() buffer */
2858
2859 /* separate buffer for fgetln() when line crosses buffer boundary */
2860 struct __sbuf _lb; /* buffer for fgetln() */
2861
2862 /* Unix stdio files get aligned to block boundaries on fseek() */
2863 int _blksize; /* stat.st_blksize (may be != _bf._size) */
2864 fpos_t _offset; /* current lseek offset */
2865
2866 struct pthread_mutex *_fl_mutex; /* used for MT-safety */
2867 struct pthread *_fl_owner; /* current owner */
2868 int _fl_count; /* recursive lock count */
2869 int _orientation; /* orientation for fwide() */
2870 __mbstate_t _mbstate; /* multibyte conversion state */
2871 int _flags2; /* additional flags */
2872};
2873#ifndef _STDFILE_DECLARED
2874#define _STDFILE_DECLARED
2875typedef struct __sFILE FILE;
2876#endif
2877# 153 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2878#ifndef _STDSTREAM_DECLARED
2879__BEGIN_DECLS
2880extern FILE *__stdinp;
2881extern FILE *__stdoutp;
2882extern FILE *__stderrp;
2883__END_DECLS
2884#define _STDSTREAM_DECLARED
2885#endif
2886# 161 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2887
2888#define __SLBF 0x0001 /* line buffered */
2889#define __SNBF 0x0002 /* unbuffered */
2890#define __SRD 0x0004 /* OK to read */
2891#define __SWR 0x0008 /* OK to write */
2892 /* RD and WR are never simultaneously asserted */
2893#define __SRW 0x0010 /* open for reading & writing */
2894#define __SEOF 0x0020 /* found EOF */
2895#define __SERR 0x0040 /* found error */
2896#define __SMBF 0x0080 /* _bf._base is from malloc */
2897#define __SAPP 0x0100 /* fdopen()ed in append mode */
2898#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
2899#define __SOPT 0x0400 /* do fseek() optimization */
2900#define __SNPT 0x0800 /* do not do fseek() optimization */
2901#define __SOFF 0x1000 /* set iff _offset is in fact correct */
2902#define __SMOD 0x2000 /* true => fgetln modified _p text */
2903#define __SALC 0x4000 /* allocate string space dynamically */
2904#define __SIGN 0x8000 /* ignore this file in _fwalk */
2905
2906#define __S2OAP 0x0001 /* O_APPEND mode is set */
2907
2908/*
2909 * The following three definitions are for ANSI C, which took them
2910 * from System V, which brilliantly took internal interface macros and
2911 * made them official arguments to setvbuf(), without renaming them.
2912 * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
2913 *
2914 * Although numbered as their counterparts above, the implementation
2915 * does not rely on this.
2916 */
2917#define _IOFBF 0 /* setvbuf should set fully buffered */
2918#define _IOLBF 1 /* setvbuf should set line buffered */
2919#define _IONBF 2 /* setvbuf should set unbuffered */
2920
2921#define BUFSIZ 1024 /* size of buffer used by setbuf */
2922#define EOF (-1)
2923
2924/*
2925 * FOPEN_MAX is a minimum maximum, and is the number of streams that
2926 * stdio can provide without attempting to allocate further resources
2927 * (which could fail). Do not use this for anything.
2928 */
2929 /* must be == _POSIX_STREAM_MAX <limits.h> */
2930#ifndef FOPEN_MAX
2931#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
2932#endif
2933# 207 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2934#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
2935
2936/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
2937#if __XSI_VISIBLE
2938#define P_tmpdir "/tmp/"
2939#endif
2940# 213 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2941#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
2942#define TMP_MAX 308915776
2943
2944#ifndef SEEK_SET
2945#define SEEK_SET 0 /* set file offset to offset */
2946#endif
2947# 219 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2948#ifndef SEEK_CUR
2949#define SEEK_CUR 1 /* set file offset to current plus offset */
2950#endif
2951# 222 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2952#ifndef SEEK_END
2953#define SEEK_END 2 /* set file offset to EOF plus offset */
2954#endif
2955# 225 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2956
2957#define stdin __stdinp
2958#define stdout __stdoutp
2959#define stderr __stderrp
2960
2961__BEGIN_DECLS
2962#ifdef _XLOCALE_H_
2963#if 0 /* expanded by -frewrite-includes */
2964#include <xlocale/_stdio.h>
2965#endif /* expanded by -frewrite-includes */
2966# 232 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2967# 233 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2968#endif
2969# 234 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
2970/*
2971 * Functions defined in ANSI C standard.
2972 */
2973void clearerr(FILE *);
2974int fclose(FILE *);
2975int feof(FILE *);
2976int ferror(FILE *);
2977int fflush(FILE *);
2978int fgetc(FILE *);
2979int fgetpos(FILE * __restrict, fpos_t * __restrict);
2980char *fgets(char * __restrict, int, FILE * __restrict);
2981FILE *fopen(const char * __restrict, const char * __restrict);
2982int fprintf(FILE * __restrict, const char * __restrict, ...);
2983int fputc(int, FILE *);
2984int fputs(const char * __restrict, FILE * __restrict);
2985size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
2986FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict);
2987int fscanf(FILE * __restrict, const char * __restrict, ...);
2988int fseek(FILE *, long, int);
2989int fsetpos(FILE *, const fpos_t *);
2990long ftell(FILE *);
2991size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
2992int getc(FILE *);
2993int getchar(void);
2994char *gets(char *);
2995void perror(const char *);
2996int printf(const char * __restrict, ...);
2997int putc(int, FILE *);
2998int putchar(int);
2999int puts(const char *);
3000int remove(const char *);
3001int rename(const char *, const char *);
3002void rewind(FILE *);
3003int scanf(const char * __restrict, ...);
3004void setbuf(FILE * __restrict, char * __restrict);
3005int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
3006int sprintf(char * __restrict, const char * __restrict, ...);
3007int sscanf(const char * __restrict, const char * __restrict, ...);
3008FILE *tmpfile(void);
3009char *tmpnam(char *);
3010int ungetc(int, FILE *);
3011int vfprintf(FILE * __restrict, const char * __restrict,
3012 __va_list);
3013int vprintf(const char * __restrict, __va_list);
3014int vsprintf(char * __restrict, const char * __restrict,
3015 __va_list);
3016
3017#if __ISO_C_VISIBLE >= 1999
3018int snprintf(char * __restrict, size_t, const char * __restrict,
3019 ...) __printflike(3, 4);
3020int vfscanf(FILE * __restrict, const char * __restrict, __va_list)
3021 __scanflike(2, 0);
3022int vscanf(const char * __restrict, __va_list) __scanflike(1, 0);
3023int vsnprintf(char * __restrict, size_t, const char * __restrict,
3024 __va_list) __printflike(3, 0);
3025int vsscanf(const char * __restrict, const char * __restrict, __va_list)
3026 __scanflike(2, 0);
3027#endif
3028# 292 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3029
3030/*
3031 * Functions defined in all versions of POSIX 1003.1.
3032 */
3033#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506)
3034#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */
3035#endif
3036# 299 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3037
3038#if __POSIX_VISIBLE
3039#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
3040
3041char *ctermid(char *);
3042FILE *fdopen(int, const char *);
3043int fileno(FILE *);
3044#endif /* __POSIX_VISIBLE */
3045# 307 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3046
3047#if __POSIX_VISIBLE >= 199209
3048int pclose(FILE *);
3049FILE *popen(const char *, const char *);
3050#endif
3051# 312 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3052
3053#if __POSIX_VISIBLE >= 199506
3054int ftrylockfile(FILE *);
3055void flockfile(FILE *);
3056void funlockfile(FILE *);
3057
3058/*
3059 * These are normally used through macros as defined below, but POSIX
3060 * requires functions as well.
3061 */
3062int getc_unlocked(FILE *);
3063int getchar_unlocked(void);
3064int putc_unlocked(int, FILE *);
3065int putchar_unlocked(int);
3066#endif
3067# 327 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3068#if __BSD_VISIBLE
3069void clearerr_unlocked(FILE *);
3070int feof_unlocked(FILE *);
3071int ferror_unlocked(FILE *);
3072int fileno_unlocked(FILE *);
3073#endif
3074# 333 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3075
3076#if __POSIX_VISIBLE >= 200112
3077int fseeko(FILE *, __off_t, int);
3078__off_t ftello(FILE *);
3079#endif
3080# 338 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3081
3082#if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600
3083int getw(FILE *);
3084int putw(int, FILE *);
3085#endif /* BSD or X/Open before issue 6 */
3086# 343 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3087
3088#if __XSI_VISIBLE
3089char *tempnam(const char *, const char *);
3090#endif
3091# 347 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3092
3093#if __POSIX_VISIBLE >= 200809
3094FILE *fmemopen(void * __restrict, size_t, const char * __restrict);
3095ssize_t getdelim(char ** __restrict, size_t * __restrict, int,
3096 FILE * __restrict);
3097FILE *open_memstream(char **, size_t *);
3098int renameat(int, const char *, int, const char *);
3099int vdprintf(int, const char * __restrict, __va_list);
3100
3101/*
3102 * Every programmer and his dog wrote functions called getline() and dprintf()
3103 * before POSIX.1-2008 came along and decided to usurp the names, so we
3104 * don't prototype them by default unless one of the following is true:
3105 * a) the app has requested them specifically by defining _WITH_GETLINE or
3106 * _WITH_DPRINTF, respectively
3107 * b) the app has requested a POSIX.1-2008 environment via _POSIX_C_SOURCE
3108 * c) the app defines a GNUism such as _BSD_SOURCE or _GNU_SOURCE
3109 */
3110#ifndef _WITH_GETLINE
3111#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
3112#define _WITH_GETLINE
3113#elif defined(_POSIX_C_SOURCE)
3114# 369 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3115#if _POSIX_C_SOURCE >= 200809
3116#define _WITH_GETLINE
3117#endif
3118# 372 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3119#endif
3120# 373 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3121#endif
3122# 374 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3123
3124#ifdef _WITH_GETLINE
3125ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
3126#endif
3127# 378 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3128
3129#ifndef _WITH_DPRINTF
3130#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
3131#define _WITH_DPRINTF
3132#elif defined(_POSIX_C_SOURCE)
3133# 383 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3134#if _POSIX_C_SOURCE >= 200809
3135#define _WITH_DPRINTF
3136#endif
3137# 386 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3138#endif
3139# 387 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3140#endif
3141# 388 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3142
3143#ifdef _WITH_DPRINTF
3144int (dprintf)(int, const char * __restrict, ...);
3145#endif
3146# 392 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3147
3148#endif /* __POSIX_VISIBLE >= 200809 */
3149# 394 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3150
3151/*
3152 * Routines that are purely local.
3153 */
3154#if __BSD_VISIBLE
3155int asprintf(char **, const char *, ...) __printflike(2, 3);
3156char *ctermid_r(char *);
3157void fcloseall(void);
3158int fdclose(FILE *, int *);
3159char *fgetln(FILE *, size_t *);
3160const char *fmtcheck(const char *, const char *) __format_arg(2);
3161int fpurge(FILE *);
3162void setbuffer(FILE *, char *, int);
3163int setlinebuf(FILE *);
3164int vasprintf(char **, const char *, __va_list)
3165 __printflike(2, 0);
3166
3167/*
3168 * The system error table contains messages for the first sys_nerr
3169 * positive errno values. Use strerror() or strerror_r() from <string.h>
3170 * instead.
3171 */
3172extern const int sys_nerr;
3173extern const char * const sys_errlist[];
3174
3175/*
3176 * Stdio function-access interface.
3177 */
3178FILE *funopen(const void *,
3179 int (*)(void *, char *, int),
3180 int (*)(void *, const char *, int),
3181 fpos_t (*)(void *, fpos_t, int),
3182 int (*)(void *));
3183#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
3184#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
3185
3186/*
3187 * Portability hacks. See <sys/types.h>.
3188 */
3189#ifndef _FTRUNCATE_DECLARED
3190#define _FTRUNCATE_DECLARED
3191int ftruncate(int, __off_t);
3192#endif
3193# 437 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3194#ifndef _LSEEK_DECLARED
3195#define _LSEEK_DECLARED
3196__off_t lseek(int, __off_t, int);
3197#endif
3198# 441 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3199#ifndef _MMAP_DECLARED
3200#define _MMAP_DECLARED
3201void *mmap(void *, size_t, int, int, int, __off_t);
3202#endif
3203# 445 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3204#ifndef _TRUNCATE_DECLARED
3205#define _TRUNCATE_DECLARED
3206int truncate(const char *, __off_t);
3207#endif
3208# 449 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3209#endif /* __BSD_VISIBLE */
3210# 450 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3211
3212/*
3213 * Functions internal to the implementation.
3214 */
3215int __srget(FILE *);
3216int __swbuf(int, FILE *);
3217
3218/*
3219 * The __sfoo macros are here so that we can
3220 * define function versions in the C library.
3221 */
3222#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
3223#if defined(__GNUC__) && defined(__STDC__)
3224static __inline int __sputc(int _c, FILE *_p) {
3225 if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
3226 return (*_p->_p++ = _c);
3227 else
3228 return (__swbuf(_c, _p));
3229}
3230#else
3231# 470 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3232/*
3233 * This has been tuned to generate reasonable code on the vax using pcc.
3234 */
3235#define __sputc(c, p) \
3236 (--(p)->_w < 0 ? \
3237 (p)->_w >= (p)->_lbfsize ? \
3238 (*(p)->_p = (c)), *(p)->_p != '\n' ? \
3239 (int)*(p)->_p++ : \
3240 __swbuf('\n', p) : \
3241 __swbuf((int)(c), p) : \
3242 (*(p)->_p = (c), (int)*(p)->_p++))
3243#endif
3244# 482 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3245
3246extern int __isthreaded;
3247
3248#ifndef __cplusplus
3249
3250#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
3251#define __sferror(p) (((p)->_flags & __SERR) != 0)
3252#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
3253#define __sfileno(p) ((p)->_file)
3254
3255
3256#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
3257#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
3258#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
3259
3260#if __POSIX_VISIBLE
3261#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
3262#endif
3263# 500 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3264
3265#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
3266#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
3267
3268#define getchar() getc(stdin)
3269#define putchar(x) putc(x, stdout)
3270
3271#if __BSD_VISIBLE
3272/*
3273 * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
3274 * B.8.2.7 for the rationale behind the *_unlocked() macros.
3275 */
3276#define feof_unlocked(p) __sfeof(p)
3277#define ferror_unlocked(p) __sferror(p)
3278#define clearerr_unlocked(p) __sclearerr(p)
3279#define fileno_unlocked(p) __sfileno(p)
3280#endif
3281# 517 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3282#if __POSIX_VISIBLE >= 199506
3283#define getc_unlocked(fp) __sgetc(fp)
3284#define putc_unlocked(x, fp) __sputc(x, fp)
3285
3286#define getchar_unlocked() getc_unlocked(stdin)
3287#define putchar_unlocked(x) putc_unlocked(x, stdout)
3288#endif
3289# 524 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3290#endif /* __cplusplus */
3291# 525 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3292
3293__END_DECLS
3294#endif /* !_STDIO_H_ */
3295# 528 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdio.h"
3296# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
3297#if 0 /* expanded by -frewrite-includes */
3298#include <string.h>
3299#endif /* expanded by -frewrite-includes */
3300# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
3301# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h" 1
3302/*-
3303 * Copyright (c) 1990, 1993
3304 * The Regents of the University of California. All rights reserved.
3305 *
3306 * Redistribution and use in source and binary forms, with or without
3307 * modification, are permitted provided that the following conditions
3308 * are met:
3309 * 1. Redistributions of source code must retain the above copyright
3310 * notice, this list of conditions and the following disclaimer.
3311 * 2. Redistributions in binary form must reproduce the above copyright
3312 * notice, this list of conditions and the following disclaimer in the
3313 * documentation and/or other materials provided with the distribution.
3314 * 3. Neither the name of the University nor the names of its contributors
3315 * may be used to endorse or promote products derived from this software
3316 * without specific prior written permission.
3317 *
3318 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3319 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3320 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3321 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3322 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3323 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3324 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3325 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3326 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3327 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3328 * SUCH DAMAGE.
3329 *
3330 * @(#)string.h 8.1 (Berkeley) 6/2/93
3331 * $FreeBSD$
3332 */
3333
3334#ifndef _STRING_H_
3335#define _STRING_H_
3336
3337#if 0 /* expanded by -frewrite-includes */
3338#include <sys/cdefs.h>
3339#endif /* expanded by -frewrite-includes */
3340# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3341# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3342#if 0 /* expanded by -frewrite-includes */
3343#include <sys/_null.h>
3344#endif /* expanded by -frewrite-includes */
3345# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3346# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3347#if 0 /* expanded by -frewrite-includes */
3348#include <sys/_types.h>
3349#endif /* expanded by -frewrite-includes */
3350# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3351# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3352
3353/*
3354 * Prototype functions which were historically defined in <string.h>, but
3355 * are required by POSIX to be prototyped in <strings.h>.
3356 */
3357#if __BSD_VISIBLE
3358#if 0 /* expanded by -frewrite-includes */
3359#include <strings.h>
3360#endif /* expanded by -frewrite-includes */
3361# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3362# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h" 1
3363/*-
3364 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
3365 * All rights reserved.
3366 *
3367 * Redistribution and use in source and binary forms, with or without
3368 * modification, are permitted provided that the following conditions
3369 * are met:
3370 * 1. Redistributions of source code must retain the above copyright
3371 * notice, this list of conditions and the following disclaimer.
3372 * 2. Redistributions in binary form must reproduce the above copyright
3373 * notice, this list of conditions and the following disclaimer in the
3374 * documentation and/or other materials provided with the distribution.
3375 *
3376 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
3377 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3378 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3379 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3380 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3381 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3382 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3383 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3384 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3385 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3386 * SUCH DAMAGE.
3387 *
3388 * $FreeBSD$
3389 */
3390
3391#ifndef _STRINGS_H_
3392#define _STRINGS_H_
3393
3394#if 0 /* expanded by -frewrite-includes */
3395#include <sys/cdefs.h>
3396#endif /* expanded by -frewrite-includes */
3397# 32 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3398# 33 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3399#if 0 /* expanded by -frewrite-includes */
3400#include <sys/_types.h>
3401#endif /* expanded by -frewrite-includes */
3402# 33 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3403# 34 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3404
3405#ifndef _SIZE_T_DECLARED
3406typedef __size_t size_t;
3407#define _SIZE_T_DECLARED
3408#endif
3409# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3410
3411__BEGIN_DECLS
3412#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
3413int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
3414void bcopy(const void *, void *, size_t); /* LEGACY */
3415void bzero(void *, size_t); /* LEGACY */
3416#endif
3417# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3418#if __BSD_VISIBLE
3419void explicit_bzero(void *, size_t);
3420#endif
3421# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3422#if __XSI_VISIBLE
3423int ffs(int) __pure2;
3424#endif
3425# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3426#if __BSD_VISIBLE
3427int ffsl(long) __pure2;
3428int ffsll(long long) __pure2;
3429int fls(int) __pure2;
3430int flsl(long) __pure2;
3431int flsll(long long) __pure2;
3432#endif
3433# 59 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3434#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
3435char *index(const char *, int) __pure; /* LEGACY */
3436char *rindex(const char *, int) __pure; /* LEGACY */
3437#endif
3438# 63 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3439int strcasecmp(const char *, const char *) __pure;
3440int strncasecmp(const char *, const char *, size_t) __pure;
3441
3442#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
3443#if 0 /* expanded by -frewrite-includes */
3444#include <xlocale/_strings.h>
3445#endif /* expanded by -frewrite-includes */
3446# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3447# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_strings.h" 1
3448/*-
3449 * Copyright (c) 2011, 2012 The FreeBSD Foundation
3450 * All rights reserved.
3451 *
3452 * Redistribution and use in source and binary forms, with or without
3453 * modification, are permitted provided that the following conditions
3454 * are met:
3455 * 1. Redistributions of source code must retain the above copyright
3456 * notice, this list of conditions and the following disclaimer.
3457 * 2. Redistributions in binary form must reproduce the above copyright
3458 * notice, this list of conditions and the following disclaimer in the
3459 * documentation and/or other materials provided with the distribution.
3460 *
3461 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
3462 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3463 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3464 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3465 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3466 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3467 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3468 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3469 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3470 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3471 * SUCH DAMAGE.
3472 *
3473 * $FreeBSD$
3474 */
3475
3476#ifndef _LOCALE_T_DEFINED
3477#define _LOCALE_T_DEFINED
3478typedef struct _xlocale *locale_t;
3479#endif
3480# 33 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_strings.h"
3481
3482/*
3483 * This file is included from both strings.h and xlocale.h. We need to expose
3484 * the declarations unconditionally if we are included from xlocale.h, but only
3485 * if we are in POSIX2008 mode if included from string.h.
3486 */
3487
3488#ifndef _XLOCALE_STRINGS1_H
3489#define _XLOCALE_STRINGS1_H
3490
3491/*
3492 * POSIX2008 functions
3493 */
3494int strcasecmp_l(const char *, const char *, locale_t);
3495int strncasecmp_l(const char *, const char *, size_t, locale_t);
3496#endif /* _XLOCALE_STRINGS1_H */
3497# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_strings.h"
3498# 68 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h" 2
3499#endif
3500# 69 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3501__END_DECLS
3502
3503#endif /* _STRINGS_H_ */
3504# 72 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/strings.h"
3505# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h" 2
3506#endif
3507# 47 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3508
3509#ifndef _SIZE_T_DECLARED
3510typedef __size_t size_t;
3511#define _SIZE_T_DECLARED
3512#endif
3513# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3514
3515__BEGIN_DECLS
3516#if __XSI_VISIBLE >= 600
3517void *memccpy(void * __restrict, const void * __restrict, int, size_t);
3518#endif
3519# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3520void *memchr(const void *, int, size_t) __pure;
3521#if __BSD_VISIBLE
3522void *memrchr(const void *, int, size_t) __pure;
3523#endif
3524# 61 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3525int memcmp(const void *, const void *, size_t) __pure;
3526void *memcpy(void * __restrict, const void * __restrict, size_t);
3527#if __BSD_VISIBLE
3528void *memmem(const void *, size_t, const void *, size_t) __pure;
3529#endif
3530# 66 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3531void *memmove(void *, const void *, size_t);
3532void *memset(void *, int, size_t);
3533#if __POSIX_VISIBLE >= 200809
3534char *stpcpy(char * __restrict, const char * __restrict);
3535char *stpncpy(char * __restrict, const char * __restrict, size_t);
3536#endif
3537# 72 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3538#if __BSD_VISIBLE
3539char *strcasestr(const char *, const char *) __pure;
3540#endif
3541# 75 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3542char *strcat(char * __restrict, const char * __restrict);
3543char *strchr(const char *, int) __pure;
3544#if __BSD_VISIBLE
3545char *strchrnul(const char*, int) __pure;
3546#endif
3547# 80 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3548int strcmp(const char *, const char *) __pure;
3549int strcoll(const char *, const char *);
3550char *strcpy(char * __restrict, const char * __restrict);
3551size_t strcspn(const char *, const char *) __pure;
3552#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
3553char *strdup(const char *) __malloc_like;
3554#endif
3555# 87 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3556char *strerror(int);
3557#if __POSIX_VISIBLE >= 200112
3558int strerror_r(int, char *, size_t);
3559#endif
3560# 91 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3561#if __BSD_VISIBLE
3562size_t strlcat(char * __restrict, const char * __restrict, size_t);
3563size_t strlcpy(char * __restrict, const char * __restrict, size_t);
3564#endif
3565# 95 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3566size_t strlen(const char *) __pure;
3567#if __BSD_VISIBLE
3568void strmode(int, char *);
3569#endif
3570# 99 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3571char *strncat(char * __restrict, const char * __restrict, size_t);
3572int strncmp(const char *, const char *, size_t) __pure;
3573char *strncpy(char * __restrict, const char * __restrict, size_t);
3574#if __POSIX_VISIBLE >= 200809
3575char *strndup(const char *, size_t) __malloc_like;
3576size_t strnlen(const char *, size_t) __pure;
3577#endif
3578# 106 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3579#if __BSD_VISIBLE
3580char *strnstr(const char *, const char *, size_t) __pure;
3581#endif
3582# 109 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3583char *strpbrk(const char *, const char *) __pure;
3584char *strrchr(const char *, int) __pure;
3585#if __BSD_VISIBLE
3586char *strsep(char **, const char *);
3587#endif
3588# 114 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3589#if __POSIX_VISIBLE >= 200809
3590char *strsignal(int);
3591#endif
3592# 117 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3593size_t strspn(const char *, const char *) __pure;
3594char *strstr(const char *, const char *) __pure;
3595char *strtok(char * __restrict, const char * __restrict);
3596#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
3597char *strtok_r(char *, const char *, char **);
3598#endif
3599# 123 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3600size_t strxfrm(char * __restrict, const char * __restrict, size_t);
3601#if __BSD_VISIBLE
3602
3603#ifndef _SWAB_DECLARED
3604#define _SWAB_DECLARED
3605
3606#ifndef _SSIZE_T_DECLARED
3607typedef __ssize_t ssize_t;
3608#define _SSIZE_T_DECLARED
3609#endif /* _SIZE_T_DECLARED */
3610# 133 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3611
3612void swab(const void * __restrict, void * __restrict, ssize_t);
3613#endif /* _SWAB_DECLARED */
3614# 136 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3615
3616#if __has_feature(capabilities)
3617__capability const void *
3618 memchr_c_const(__capability const void *, int, size_t) __pure;
3619__capability void
3620 *memchr_c(__capability const void *, int, size_t) __pure;
3621int memcmp_c(__capability const void *, __capability const void *, size_t)
3622 __pure;
3623__capability void
3624 *memcpy_c(__capability void * __restrict,
3625 __capability const void * __restrict, size_t);
3626void *memcpy_c_fromcap(void * __restrict,
3627 __capability const void * __restrict, size_t);
3628__capability void
3629 *memcpy_c_tocap(__capability void * __restrict,
3630 const void * __restrict, size_t);
3631__capability void
3632 *memmove_c(__capability void * __restrict,
3633 __capability const void * __restrict, size_t);
3634__capability void
3635 *memset_c(__capability void *, int, size_t);
3636
3637__capability char
3638 *strchr_c(__capability const char *, int) __pure;
3639int strcmp_c(__capability const char *,
3640 __capability const char *s2) __pure;
3641__capability char
3642 *strcpy_c(__capability char * __restrict,
3643 __capability const char * __restrict);
3644int strncmp_c(__capability const char *, __capability const char *,
3645 size_t) __pure;
3646__capability char
3647*strncpy_c(__capability char * __restrict, __capability const char * __restrict,
3648 size_t);
3649char *strncpy_c_fromcap(char * __restrict,
3650 __capability const char * __restrict, size_t);
3651__capability char
3652 *strncpy_c_tocap(__capability char * __restrict,
3653 const char * __restrict, size_t);
3654size_t strnlen_c(__capability const char *, size_t) __pure;
3655#endif
3656# 177 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3657
3658#endif /* __BSD_VISIBLE */
3659# 179 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3660
3661#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
3662#if 0 /* expanded by -frewrite-includes */
3663#include <xlocale/_string.h>
3664#endif /* expanded by -frewrite-includes */
3665# 181 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3666# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h" 1
3667/*-
3668 * Copyright (c) 2011, 2012 The FreeBSD Foundation
3669 * All rights reserved.
3670 *
3671 * Redistribution and use in source and binary forms, with or without
3672 * modification, are permitted provided that the following conditions
3673 * are met:
3674 * 1. Redistributions of source code must retain the above copyright
3675 * notice, this list of conditions and the following disclaimer.
3676 * 2. Redistributions in binary form must reproduce the above copyright
3677 * notice, this list of conditions and the following disclaimer in the
3678 * documentation and/or other materials provided with the distribution.
3679 *
3680 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
3681 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3682 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3683 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3684 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3685 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3686 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3687 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3688 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3689 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3690 * SUCH DAMAGE.
3691 *
3692 * $FreeBSD$
3693 */
3694
3695#ifndef _LOCALE_T_DEFINED
3696#define _LOCALE_T_DEFINED
3697typedef struct _xlocale *locale_t;
3698#endif
3699# 33 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
3700
3701/*
3702 * This file is included from both string.h and xlocale.h. We need to expose
3703 * the declarations unconditionally if we are included from xlocale.h, but only
3704 * if we are in POSIX2008 mode if included from string.h.
3705 */
3706
3707#ifndef _XLOCALE_STRING1_H
3708#define _XLOCALE_STRING1_H
3709
3710/*
3711 * POSIX2008 functions
3712 */
3713int strcoll_l(const char *, const char *, locale_t);
3714size_t strxfrm_l(char *, const char *, size_t, locale_t);
3715#endif /* _XLOCALE_STRING1_H */
3716# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
3717
3718/*
3719 * xlocale extensions
3720 */
3721#ifdef _XLOCALE_H_
3722#ifndef _XLOCALE_STRING2_H
3723#define _XLOCALE_STRING2_H
3724char *strcasestr_l(const char *, const char *, locale_t);
3725
3726#endif /* _XLOCALE_STRING2_H */
3727# 59 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
3728#endif /* _XLOCALE_H_ */
3729# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
3730# 182 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h" 2
3731#endif
3732# 183 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3733__END_DECLS
3734
3735#endif /* _STRING_H_ */
3736# 186 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/string.h"
3737# 50 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
3738#if 0 /* expanded by -frewrite-includes */
3739#include <ctype.h>
3740#endif /* expanded by -frewrite-includes */
3741# 50 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
3742# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h" 1
3743/*
3744 * Copyright (c) 1989, 1993
3745 * The Regents of the University of California. All rights reserved.
3746 * (c) UNIX System Laboratories, Inc.
3747 * All or some portions of this file are derived from material licensed
3748 * to the University of California by American Telephone and Telegraph
3749 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
3750 * the permission of UNIX System Laboratories, Inc.
3751 *
3752 * This code is derived from software contributed to Berkeley by
3753 * Paul Borman at Krystal Technologies.
3754 *
3755 * Redistribution and use in source and binary forms, with or without
3756 * modification, are permitted provided that the following conditions
3757 * are met:
3758 * 1. Redistributions of source code must retain the above copyright
3759 * notice, this list of conditions and the following disclaimer.
3760 * 2. Redistributions in binary form must reproduce the above copyright
3761 * notice, this list of conditions and the following disclaimer in the
3762 * documentation and/or other materials provided with the distribution.
3763 * 3. Neither the name of the University nor the names of its contributors
3764 * may be used to endorse or promote products derived from this software
3765 * without specific prior written permission.
3766 *
3767 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3768 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3769 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3770 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3771 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3772 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3773 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3774 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3775 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3776 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3777 * SUCH DAMAGE.
3778 *
3779 * @(#)ctype.h 8.4 (Berkeley) 1/21/94
3780 * $FreeBSD$
3781 */
3782
3783#ifndef _CTYPE_H_
3784#define _CTYPE_H_
3785
3786#if 0 /* expanded by -frewrite-includes */
3787#include <sys/cdefs.h>
3788#endif /* expanded by -frewrite-includes */
3789# 44 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
3790# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
3791#if 0 /* expanded by -frewrite-includes */
3792#include <sys/_types.h>
3793#endif /* expanded by -frewrite-includes */
3794# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
3795# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
3796#if 0 /* expanded by -frewrite-includes */
3797#include <_ctype.h>
3798#endif /* expanded by -frewrite-includes */
3799# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
3800# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h" 1
3801/*
3802 * Copyright (c) 1989, 1993
3803 * The Regents of the University of California. All rights reserved.
3804 * (c) UNIX System Laboratories, Inc.
3805 * All or some portions of this file are derived from material licensed
3806 * to the University of California by American Telephone and Telegraph
3807 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
3808 * the permission of UNIX System Laboratories, Inc.
3809 *
3810 * This code is derived from software contributed to Berkeley by
3811 * Paul Borman at Krystal Technologies.
3812 *
3813 * Redistribution and use in source and binary forms, with or without
3814 * modification, are permitted provided that the following conditions
3815 * are met:
3816 * 1. Redistributions of source code must retain the above copyright
3817 * notice, this list of conditions and the following disclaimer.
3818 * 2. Redistributions in binary form must reproduce the above copyright
3819 * notice, this list of conditions and the following disclaimer in the
3820 * documentation and/or other materials provided with the distribution.
3821 * 3. Neither the name of the University nor the names of its contributors
3822 * may be used to endorse or promote products derived from this software
3823 * without specific prior written permission.
3824 *
3825 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3826 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3827 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3828 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3829 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3830 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3831 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3832 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3833 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3834 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3835 * SUCH DAMAGE.
3836 *
3837 * From @(#)ctype.h 8.4 (Berkeley) 1/21/94
3838 * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp
3839 * $FreeBSD$
3840 */
3841
3842#ifndef __CTYPE_H_
3843#define __CTYPE_H_
3844
3845#if 0 /* expanded by -frewrite-includes */
3846#include <sys/cdefs.h>
3847#endif /* expanded by -frewrite-includes */
3848# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
3849# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
3850#if 0 /* expanded by -frewrite-includes */
3851#include <sys/_types.h>
3852#endif /* expanded by -frewrite-includes */
3853# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
3854# 47 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
3855
3856#define _CTYPE_A 0x00000100L /* Alpha */
3857#define _CTYPE_C 0x00000200L /* Control */
3858#define _CTYPE_D 0x00000400L /* Digit */
3859#define _CTYPE_G 0x00000800L /* Graph */
3860#define _CTYPE_L 0x00001000L /* Lower */
3861#define _CTYPE_P 0x00002000L /* Punct */
3862#define _CTYPE_S 0x00004000L /* Space */
3863#define _CTYPE_U 0x00008000L /* Upper */
3864#define _CTYPE_X 0x00010000L /* X digit */
3865#define _CTYPE_B 0x00020000L /* Blank */
3866#define _CTYPE_R 0x00040000L /* Print */
3867#define _CTYPE_I 0x00080000L /* Ideogram */
3868#define _CTYPE_T 0x00100000L /* Special */
3869#define _CTYPE_Q 0x00200000L /* Phonogram */
3870#define _CTYPE_N 0x00400000L /* Number (superset of digit) */
3871#define _CTYPE_SW0 0x20000000L /* 0 width character */
3872#define _CTYPE_SW1 0x40000000L /* 1 width character */
3873#define _CTYPE_SW2 0x80000000L /* 2 width character */
3874#define _CTYPE_SW3 0xc0000000L /* 3 width character */
3875#define _CTYPE_SWM 0xe0000000L /* Mask for screen width data */
3876#define _CTYPE_SWS 30 /* Bits to shift to get width */
3877
3878/* See comments in <sys/_types.h> about __ct_rune_t. */
3879__BEGIN_DECLS
3880unsigned long ___runetype(__ct_rune_t) __pure;
3881__ct_rune_t ___tolower(__ct_rune_t) __pure;
3882__ct_rune_t ___toupper(__ct_rune_t) __pure;
3883__END_DECLS
3884
3885/*
3886 * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
3887 * to generate code for extern versions of all our inline functions.
3888 */
3889#ifdef _EXTERNALIZE_CTYPE_INLINES_
3890#define _USE_CTYPE_INLINE_
3891#define static
3892#define __inline
3893#endif
3894# 86 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
3895
3896extern int __mb_sb_limit;
3897
3898/*
3899 * Use inline functions if we are allowed to and the compiler supports them.
3900 */
3901#if !defined(_DONT_USE_CTYPE_INLINE_) && \
3902 (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
3903
3904#if 0 /* expanded by -frewrite-includes */
3905#include <runetype.h>
3906#endif /* expanded by -frewrite-includes */
3907# 95 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
3908# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h" 1
3909/*-
3910 * Copyright (c) 1993
3911 * The Regents of the University of California. All rights reserved.
3912 *
3913 * This code is derived from software contributed to Berkeley by
3914 * Paul Borman at Krystal Technologies.
3915 *
3916 * Redistribution and use in source and binary forms, with or without
3917 * modification, are permitted provided that the following conditions
3918 * are met:
3919 * 1. Redistributions of source code must retain the above copyright
3920 * notice, this list of conditions and the following disclaimer.
3921 * 2. Redistributions in binary form must reproduce the above copyright
3922 * notice, this list of conditions and the following disclaimer in the
3923 * documentation and/or other materials provided with the distribution.
3924 * 3. Neither the name of the University nor the names of its contributors
3925 * may be used to endorse or promote products derived from this software
3926 * without specific prior written permission.
3927 *
3928 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3929 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3930 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3931 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3932 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3933 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3934 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3935 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3936 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3937 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3938 * SUCH DAMAGE.
3939 *
3940 * @(#)runetype.h 8.1 (Berkeley) 6/2/93
3941 * $FreeBSD$
3942 */
3943
3944#ifndef _RUNETYPE_H_
3945#define _RUNETYPE_H_
3946
3947#if 0 /* expanded by -frewrite-includes */
3948#include <sys/cdefs.h>
3949#endif /* expanded by -frewrite-includes */
3950# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
3951# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
3952#if 0 /* expanded by -frewrite-includes */
3953#include <sys/_types.h>
3954#endif /* expanded by -frewrite-includes */
3955# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
3956# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
3957
3958#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */
3959#define _CRMASK (~(_CACHED_RUNES - 1))
3960
3961/*
3962 * The lower 8 bits of runetype[] contain the digit value of the rune.
3963 */
3964typedef struct {
3965 __rune_t __min; /* First rune of the range */
3966 __rune_t __max; /* Last rune (inclusive) of the range */
3967 __rune_t __map; /* What first maps to in maps */
3968 unsigned long *__types; /* Array of types in range */
3969} _RuneEntry;
3970
3971typedef struct {
3972 int __nranges; /* Number of ranges stored */
3973 _RuneEntry *__ranges; /* Pointer to the ranges */
3974} _RuneRange;
3975
3976typedef struct {
3977 char __magic[8]; /* Magic saying what version we are */
3978 char __encoding[32]; /* ASCII name of this encoding */
3979
3980 __rune_t (*__sgetrune)(const char *, __size_t, char const **);
3981 int (*__sputrune)(__rune_t, char *, __size_t, char **);
3982 __rune_t __invalid_rune;
3983
3984 unsigned long __runetype[_CACHED_RUNES];
3985 __rune_t __maplower[_CACHED_RUNES];
3986 __rune_t __mapupper[_CACHED_RUNES];
3987
3988 /*
3989 * The following are to deal with Runes larger than _CACHED_RUNES - 1.
3990 * Their data is actually contiguous with this structure so as to make
3991 * it easier to read/write from/to disk.
3992 */
3993 _RuneRange __runetype_ext;
3994 _RuneRange __maplower_ext;
3995 _RuneRange __mapupper_ext;
3996
3997 void *__variable; /* Data which depends on the encoding */
3998 int __variable_len; /* how long that data is */
3999} _RuneLocale;
4000
4001#define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */
4002__BEGIN_DECLS
4003extern const _RuneLocale _DefaultRuneLocale;
4004extern const _RuneLocale *_CurrentRuneLocale;
4005#if defined(__NO_TLS) || defined(__RUNETYPE_INTERNAL)
4006extern const _RuneLocale *__getCurrentRuneLocale(void);
4007#else
4008# 92 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
4009extern _Thread_local const _RuneLocale *_ThreadRuneLocale;
4010static __inline const _RuneLocale *__getCurrentRuneLocale(void)
4011{
4012
4013 if (_ThreadRuneLocale)
4014 return _ThreadRuneLocale;
4015 if (_CurrentRuneLocale)
4016 return _CurrentRuneLocale;
4017 return &_DefaultRuneLocale;
4018}
4019#endif /* __NO_TLS || __RUNETYPE_INTERNAL */
4020# 103 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
4021#define _CurrentRuneLocale (__getCurrentRuneLocale())
4022__END_DECLS
4023
4024#endif /* !_RUNETYPE_H_ */
4025# 107 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/runetype.h"
4026# 96 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h" 2
4027
4028static __inline int
4029__maskrune(__ct_rune_t _c, unsigned long _f)
4030{
4031 return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) :
4032 _CurrentRuneLocale->__runetype[_c]) & _f;
4033}
4034
4035static __inline int
4036__sbmaskrune(__ct_rune_t _c, unsigned long _f)
4037{
4038 return (_c < 0 || _c >= __mb_sb_limit) ? 0 :
4039 _CurrentRuneLocale->__runetype[_c] & _f;
4040}
4041
4042static __inline int
4043__istype(__ct_rune_t _c, unsigned long _f)
4044{
4045 return (!!__maskrune(_c, _f));
4046}
4047
4048static __inline int
4049__sbistype(__ct_rune_t _c, unsigned long _f)
4050{
4051 return (!!__sbmaskrune(_c, _f));
4052}
4053
4054static __inline int
4055__isctype(__ct_rune_t _c, unsigned long _f)
4056{
4057 return (_c < 0 || _c >= 128) ? 0 :
4058 !!(_DefaultRuneLocale.__runetype[_c] & _f);
4059}
4060
4061static __inline __ct_rune_t
4062__toupper(__ct_rune_t _c)
4063{
4064 return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
4065 _CurrentRuneLocale->__mapupper[_c];
4066}
4067
4068static __inline __ct_rune_t
4069__sbtoupper(__ct_rune_t _c)
4070{
4071 return (_c < 0 || _c >= __mb_sb_limit) ? _c :
4072 _CurrentRuneLocale->__mapupper[_c];
4073}
4074
4075static __inline __ct_rune_t
4076__tolower(__ct_rune_t _c)
4077{
4078 return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
4079 _CurrentRuneLocale->__maplower[_c];
4080}
4081
4082static __inline __ct_rune_t
4083__sbtolower(__ct_rune_t _c)
4084{
4085 return (_c < 0 || _c >= __mb_sb_limit) ? _c :
4086 _CurrentRuneLocale->__maplower[_c];
4087}
4088
4089static __inline int
4090__wcwidth(__ct_rune_t _c)
4091{
4092 unsigned int _x;
4093
4094 if (_c == 0)
4095 return (0);
4096 _x = (unsigned int)__maskrune(_c, _CTYPE_SWM|_CTYPE_R);
4097 if ((_x & _CTYPE_SWM) != 0)
4098 return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
4099 return ((_x & _CTYPE_R) != 0 ? 1 : -1);
4100}
4101
4102#else /* not using inlines */
4103# 172 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
4104
4105__BEGIN_DECLS
4106int __maskrune(__ct_rune_t, unsigned long);
4107int __sbmaskrune(__ct_rune_t, unsigned long);
4108int __istype(__ct_rune_t, unsigned long);
4109int __sbistype(__ct_rune_t, unsigned long);
4110int __isctype(__ct_rune_t, unsigned long);
4111__ct_rune_t __toupper(__ct_rune_t);
4112__ct_rune_t __sbtoupper(__ct_rune_t);
4113__ct_rune_t __tolower(__ct_rune_t);
4114__ct_rune_t __sbtolower(__ct_rune_t);
4115int __wcwidth(__ct_rune_t);
4116__END_DECLS
4117#endif /* using inlines */
4118# 186 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
4119
4120#endif /* !__CTYPE_H_ */
4121# 188 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/_ctype.h"
4122# 47 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h" 2
4123
4124__BEGIN_DECLS
4125int isalnum(int);
4126int isalpha(int);
4127int iscntrl(int);
4128int isdigit(int);
4129int isgraph(int);
4130int islower(int);
4131int isprint(int);
4132int ispunct(int);
4133int isspace(int);
4134int isupper(int);
4135int isxdigit(int);
4136int tolower(int);
4137int toupper(int);
4138
4139#if __XSI_VISIBLE
4140int isascii(int);
4141int toascii(int);
4142#endif
4143# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4144
4145#if __ISO_C_VISIBLE >= 1999
4146int isblank(int);
4147#endif
4148# 71 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4149
4150#if __BSD_VISIBLE
4151int digittoint(int);
4152int ishexnumber(int);
4153int isideogram(int);
4154int isnumber(int);
4155int isphonogram(int);
4156int isrune(int);
4157int isspecial(int);
4158#endif
4159# 81 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4160
4161#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
4162#if 0 /* expanded by -frewrite-includes */
4163#include <xlocale/_ctype.h>
4164#endif /* expanded by -frewrite-includes */
4165# 83 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4166# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h" 1
4167/*-
4168 * Copyright (c) 2011 The FreeBSD Foundation
4169 * All rights reserved.
4170 *
4171 * This software was developed by David Chisnall under sponsorship from
4172 * the FreeBSD Foundation.
4173 *
4174 * Redistribution and use in source and binary forms, with or without
4175 * modification, are permitted provided that the following conditions
4176 * are met:
4177 * 1. Redistributions of source code must retain the above copyright
4178 * notice, this list of conditions and the following disclaimer.
4179 * 2. Redistributions in binary form must reproduce the above copyright
4180 * notice, this list of conditions and the following disclaimer in the
4181 * documentation and/or other materials provided with the distribution.
4182 *
4183 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
4184 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4185 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4186 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4187 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4188 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4189 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4190 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4191 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4192 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4193 * SUCH DAMAGE.
4194 *
4195 * $FreeBSD$
4196 */
4197
4198
4199#if (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
4200 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H))
4201
4202#ifdef _XLOCALE_WCTYPES
4203#define _XLOCALE_WCTYPE_H
4204#else
4205# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4206#define _XLOCALE_CTYPE_H
4207#endif
4208# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4209
4210#ifndef _LOCALE_T_DEFINED
4211#define _LOCALE_T_DEFINED
4212typedef struct _xlocale *locale_t;
4213#endif
4214# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4215
4216#ifndef _XLOCALE_RUN_FUNCTIONS_DEFINED
4217#define _XLOCALE_RUN_FUNCTIONS_DEFINED 1
4218unsigned long ___runetype_l(__ct_rune_t, locale_t) __pure;
4219__ct_rune_t ___tolower_l(__ct_rune_t, locale_t) __pure;
4220__ct_rune_t ___toupper_l(__ct_rune_t, locale_t) __pure;
4221_RuneLocale *__runes_for_locale(locale_t, int*);
4222#endif
4223# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4224
4225#ifndef _XLOCALE_INLINE
4226#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
4227/* GNU89 inline has nonstandard semantics. */
4228#define _XLOCALE_INLINE extern __inline
4229#else
4230# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4231/* Hack to work around people who define inline away */
4232#ifdef inline
4233#define _XLOCALE_INLINE static __inline
4234#else
4235# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4236/* Define with C++ / C99 compatible semantics */
4237#define _XLOCALE_INLINE inline
4238#endif
4239# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4240#endif
4241# 68 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4242#endif /* _XLOCALE_INLINE */
4243# 69 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4244
4245#ifdef _XLOCALE_WCTYPES
4246_XLOCALE_INLINE int
4247__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
4248_XLOCALE_INLINE int
4249__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
4250
4251_XLOCALE_INLINE int
4252__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
4253{
4254 int __limit;
4255 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
4256 return ((__c < 0 || __c >= _CACHED_RUNES) ? ___runetype_l(__c, __loc) :
4257 runes->__runetype[__c]) & __f;
4258}
4259
4260_XLOCALE_INLINE int
4261__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
4262{
4263 return (!!__maskrune_l(__c, __f, __loc));
4264}
4265
4266#define XLOCALE_ISCTYPE(fname, cat) \
4267 _XLOCALE_INLINE int isw##fname##_l(int, locale_t);\
4268 _XLOCALE_INLINE int isw##fname##_l(int __c, locale_t __l)\
4269 { return __istype_l(__c, cat, __l); }
4270#else
4271# 96 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4272_XLOCALE_INLINE int
4273__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
4274_XLOCALE_INLINE int
4275__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
4276
4277_XLOCALE_INLINE int
4278__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
4279{
4280 int __limit;
4281 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
4282 return (__c < 0 || __c >= __limit) ? 0 :
4283 runes->__runetype[__c] & __f;
4284}
4285
4286_XLOCALE_INLINE int
4287__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
4288{
4289 return (!!__sbmaskrune_l(__c, __f, __loc));
4290}
4291
4292#define XLOCALE_ISCTYPE(__fname, __cat) \
4293 _XLOCALE_INLINE int is##__fname##_l(int, locale_t); \
4294 _XLOCALE_INLINE int is##__fname##_l(int __c, locale_t __l)\
4295 { return __sbistype_l(__c, __cat, __l); }
4296#endif
4297# 121 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4298
4299XLOCALE_ISCTYPE(alnum, _CTYPE_A|_CTYPE_D|_CTYPE_N)
4300XLOCALE_ISCTYPE(alpha, _CTYPE_A)
4301XLOCALE_ISCTYPE(blank, _CTYPE_B)
4302XLOCALE_ISCTYPE(cntrl, _CTYPE_C)
4303XLOCALE_ISCTYPE(digit, _CTYPE_D)
4304XLOCALE_ISCTYPE(graph, _CTYPE_G)
4305XLOCALE_ISCTYPE(hexnumber, _CTYPE_X)
4306XLOCALE_ISCTYPE(ideogram, _CTYPE_I)
4307XLOCALE_ISCTYPE(lower, _CTYPE_L)
4308XLOCALE_ISCTYPE(number, _CTYPE_D|_CTYPE_N)
4309XLOCALE_ISCTYPE(phonogram, _CTYPE_Q)
4310XLOCALE_ISCTYPE(print, _CTYPE_R)
4311XLOCALE_ISCTYPE(punct, _CTYPE_P)
4312XLOCALE_ISCTYPE(rune, 0xFFFFFF00L)
4313XLOCALE_ISCTYPE(space, _CTYPE_S)
4314XLOCALE_ISCTYPE(special, _CTYPE_T)
4315XLOCALE_ISCTYPE(upper, _CTYPE_U)
4316XLOCALE_ISCTYPE(xdigit, _CTYPE_X)
4317#undef XLOCALE_ISCTYPE
4318
4319#ifdef _XLOCALE_WCTYPES
4320_XLOCALE_INLINE int towlower_l(int, locale_t);
4321_XLOCALE_INLINE int __wcwidth_l(__ct_rune_t, locale_t);
4322_XLOCALE_INLINE int towupper_l(int, locale_t);
4323
4324_XLOCALE_INLINE int towlower_l(int __c, locale_t __l)
4325{
4326 int __limit;
4327 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
4328 return (__c < 0 || __c >= _CACHED_RUNES) ? ___tolower_l(__c, __l) :
4329 __runes->__maplower[__c];
4330}
4331_XLOCALE_INLINE int towupper_l(int __c, locale_t __l)
4332{
4333 int __limit;
4334 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
4335 return (__c < 0 || __c >= _CACHED_RUNES) ? ___toupper_l(__c, __l) :
4336 __runes->__mapupper[__c];
4337}
4338_XLOCALE_INLINE int
4339__wcwidth_l(__ct_rune_t _c, locale_t __l)
4340{
4341 unsigned int _x;
4342
4343 if (_c == 0)
4344 return (0);
4345 _x = (unsigned int)__maskrune_l(_c, _CTYPE_SWM|_CTYPE_R, __l);
4346 if ((_x & _CTYPE_SWM) != 0)
4347 return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
4348 return ((_x & _CTYPE_R) != 0 ? 1 : -1);
4349}
4350int iswctype_l(wint_t __wc, wctype_t __charclass, locale_t __l);
4351wctype_t wctype_l(const char *property, locale_t __l);
4352wint_t towctrans_l(wint_t __wc, wctrans_t desc, locale_t __l);
4353wint_t nextwctype_l(wint_t __wc, wctype_t wct, locale_t __l);
4354wctrans_t wctrans_l(const char *__charclass, locale_t __l);
4355#undef _XLOCALE_WCTYPES
4356#else
4357# 180 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4358_XLOCALE_INLINE int digittoint_l(int, locale_t);
4359_XLOCALE_INLINE int tolower_l(int, locale_t);
4360_XLOCALE_INLINE int toupper_l(int, locale_t);
4361
4362_XLOCALE_INLINE int digittoint_l(int __c, locale_t __l)
4363{ return __sbmaskrune_l((__c), 0xFF, __l); }
4364
4365_XLOCALE_INLINE int tolower_l(int __c, locale_t __l)
4366{
4367 int __limit;
4368 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
4369 return (__c < 0 || __c >= __limit) ? __c :
4370 __runes->__maplower[__c];
4371}
4372_XLOCALE_INLINE int toupper_l(int __c, locale_t __l)
4373{
4374 int __limit;
4375 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
4376 return (__c < 0 || __c >= __limit) ? __c :
4377 __runes->__mapupper[__c];
4378}
4379#endif
4380# 202 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4381#endif /* (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
4382 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H)) */
4383# 204 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
4384# 84 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h" 2
4385#endif
4386# 85 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4387__END_DECLS
4388
4389#ifndef __cplusplus
4390#define isalnum(c) __sbistype((c), _CTYPE_A|_CTYPE_D|_CTYPE_N)
4391#define isalpha(c) __sbistype((c), _CTYPE_A)
4392#define iscntrl(c) __sbistype((c), _CTYPE_C)
4393#define isdigit(c) __sbistype((c), _CTYPE_D)
4394#define isgraph(c) __sbistype((c), _CTYPE_G)
4395#define islower(c) __sbistype((c), _CTYPE_L)
4396#define isprint(c) __sbistype((c), _CTYPE_R)
4397#define ispunct(c) __sbistype((c), _CTYPE_P)
4398#define isspace(c) __sbistype((c), _CTYPE_S)
4399#define isupper(c) __sbistype((c), _CTYPE_U)
4400#define isxdigit(c) __sbistype((c), _CTYPE_X)
4401#define tolower(c) __sbtolower(c)
4402#define toupper(c) __sbtoupper(c)
4403#endif /* !__cplusplus */
4404# 102 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4405
4406#if __XSI_VISIBLE
4407/*
4408 * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to
4409 * tolower() and toupper() respectively, minus extra checking to ensure that
4410 * the argument is a lower or uppercase letter respectively. We've chosen to
4411 * implement these macros with the same error checking as tolower() and
4412 * toupper() since this doesn't violate the specification itself, only its
4413 * intent. We purposely leave _tolower() and _toupper() undocumented to
4414 * discourage their use.
4415 *
4416 * XXX isascii() and toascii() should similarly be undocumented.
4417 */
4418#define _tolower(c) __sbtolower(c)
4419#define _toupper(c) __sbtoupper(c)
4420#define isascii(c) (((c) & ~0x7F) == 0)
4421#define toascii(c) ((c) & 0x7F)
4422#endif
4423# 120 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4424
4425#if __ISO_C_VISIBLE >= 1999 && !defined(__cplusplus)
4426#define isblank(c) __sbistype((c), _CTYPE_B)
4427#endif
4428# 124 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4429
4430#if __BSD_VISIBLE
4431#define digittoint(c) __sbmaskrune((c), 0xFF)
4432#define ishexnumber(c) __sbistype((c), _CTYPE_X)
4433#define isideogram(c) __sbistype((c), _CTYPE_I)
4434#define isnumber(c) __sbistype((c), _CTYPE_D|_CTYPE_N)
4435#define isphonogram(c) __sbistype((c), _CTYPE_Q)
4436#define isrune(c) __sbistype((c), 0xFFFFFF00L)
4437#define isspecial(c) __sbistype((c), _CTYPE_T)
4438#endif
4439# 134 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4440
4441#endif /* !_CTYPE_H_ */
4442# 136 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/ctype.h"
4443# 51 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
4444#if 0 /* expanded by -frewrite-includes */
4445#include <limits.h>
4446#endif /* expanded by -frewrite-includes */
4447# 51 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
4448# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h" 1
4449/*-
4450 * Copyright (c) 1988, 1993
4451 * The Regents of the University of California. All rights reserved.
4452 *
4453 * Redistribution and use in source and binary forms, with or without
4454 * modification, are permitted provided that the following conditions
4455 * are met:
4456 * 1. Redistributions of source code must retain the above copyright
4457 * notice, this list of conditions and the following disclaimer.
4458 * 2. Redistributions in binary form must reproduce the above copyright
4459 * notice, this list of conditions and the following disclaimer in the
4460 * documentation and/or other materials provided with the distribution.
4461 * 3. Neither the name of the University nor the names of its contributors
4462 * may be used to endorse or promote products derived from this software
4463 * without specific prior written permission.
4464 *
4465 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4466 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4467 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4468 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4469 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4470 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4471 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4472 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4473 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4474 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4475 * SUCH DAMAGE.
4476 *
4477 * @(#)limits.h 8.2 (Berkeley) 1/4/94
4478 * $FreeBSD$
4479 */
4480
4481#ifndef _LIMITS_H_
4482#define _LIMITS_H_
4483
4484#if 0 /* expanded by -frewrite-includes */
4485#include <sys/cdefs.h>
4486#endif /* expanded by -frewrite-includes */
4487# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4488# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4489
4490#if __POSIX_VISIBLE
4491#define _POSIX_ARG_MAX 4096
4492#define _POSIX_LINK_MAX 8
4493#define _POSIX_MAX_CANON 255
4494#define _POSIX_MAX_INPUT 255
4495#define _POSIX_NAME_MAX 14
4496#define _POSIX_PIPE_BUF 512
4497#define _POSIX_SSIZE_MAX 32767
4498#define _POSIX_STREAM_MAX 8
4499
4500#if __POSIX_VISIBLE >= 200112
4501#define _POSIX_CHILD_MAX 25
4502#define _POSIX_NGROUPS_MAX 8
4503#define _POSIX_OPEN_MAX 20
4504#define _POSIX_PATH_MAX 256
4505#define _POSIX_TZNAME_MAX 6
4506#else
4507# 55 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4508#define _POSIX_CHILD_MAX 6
4509#define _POSIX_NGROUPS_MAX 0
4510#define _POSIX_OPEN_MAX 16
4511#define _POSIX_PATH_MAX 255
4512#define _POSIX_TZNAME_MAX 3
4513#endif
4514# 61 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4515
4516#if __POSIX_VISIBLE >= 200112
4517#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */
4518#define BC_DIM_MAX 2048 /* max array elements in bc(1) */
4519#define BC_SCALE_MAX 99 /* max scale value in bc(1) */
4520#define BC_STRING_MAX 1000 /* max const string length in bc(1) */
4521#define CHARCLASS_NAME_MAX 14 /* max character class name size */
4522#define COLL_WEIGHTS_MAX 10 /* max weights for order keyword */
4523#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */
4524#define LINE_MAX 2048 /* max bytes in an input line */
4525#define RE_DUP_MAX 255 /* max RE's in interval notation */
4526
4527#define _POSIX2_BC_BASE_MAX 99
4528#define _POSIX2_BC_DIM_MAX 2048
4529#define _POSIX2_BC_SCALE_MAX 99
4530#define _POSIX2_BC_STRING_MAX 1000
4531#define _POSIX2_CHARCLASS_NAME_MAX 14
4532#define _POSIX2_COLL_WEIGHTS_MAX 2
4533#define _POSIX2_EQUIV_CLASS_MAX 2
4534#define _POSIX2_EXPR_NEST_MAX 32
4535#define _POSIX2_LINE_MAX 2048
4536#define _POSIX2_RE_DUP_MAX 255
4537#endif
4538# 84 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4539#endif
4540# 85 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4541
4542#if __POSIX_VISIBLE >= 199309
4543#define _POSIX_AIO_LISTIO_MAX 2
4544#define _POSIX_AIO_MAX 1
4545#define _POSIX_DELAYTIMER_MAX 32
4546#define _POSIX_MQ_OPEN_MAX 8
4547#define _POSIX_MQ_PRIO_MAX 32
4548#define _POSIX_RTSIG_MAX 8
4549#define _POSIX_SEM_NSEMS_MAX 256
4550#define _POSIX_SEM_VALUE_MAX 32767
4551#define _POSIX_SIGQUEUE_MAX 32
4552#define _POSIX_TIMER_MAX 32
4553
4554#define _POSIX_CLOCKRES_MIN 20000000
4555#endif
4556# 100 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4557
4558#if __POSIX_VISIBLE >= 199506
4559#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
4560#define _POSIX_THREAD_KEYS_MAX 128
4561#define _POSIX_THREAD_THREADS_MAX 64
4562#endif
4563# 106 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4564
4565#if __POSIX_VISIBLE >= 200112
4566#define _POSIX_HOST_NAME_MAX 255
4567#define _POSIX_LOGIN_NAME_MAX 9
4568#define _POSIX_SS_REPL_MAX 4
4569#define _POSIX_SYMLINK_MAX 255
4570#define _POSIX_SYMLOOP_MAX 8
4571#define _POSIX_TRACE_EVENT_NAME_MAX 30
4572#define _POSIX_TRACE_NAME_MAX 8
4573#define _POSIX_TRACE_SYS_MAX 8
4574#define _POSIX_TRACE_USER_EVENT_MAX 32
4575#define _POSIX_TTY_NAME_MAX 9
4576
4577#define _POSIX_RE_DUP_MAX _POSIX2_RE_DUP_MAX
4578#endif
4579# 121 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4580
4581#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
4582#define NL_ARGMAX 99 /* max # of position args for printf */
4583#define NL_MSGMAX 32767
4584#define NL_SETMAX 255
4585#define NL_TEXTMAX 2048
4586#endif
4587# 128 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4588
4589#if __XSI_VISIBLE
4590#define _XOPEN_IOV_MAX 16
4591#define _XOPEN_NAME_MAX 255
4592#define _XOPEN_PATH_MAX 1024
4593#define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */
4594
4595#define NL_LANGMAX 31 /* max LANG name length */
4596#define NL_NMAX 1
4597#endif
4598# 138 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4599
4600#define MB_LEN_MAX 6 /* 31-bit UTF-8 */
4601
4602#if 0 /* expanded by -frewrite-includes */
4603#include <sys/limits.h>
4604#endif /* expanded by -frewrite-includes */
4605# 141 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4606# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 1 3 4
4607/*-
4608 * Copyright (c) 1988, 1993
4609 * The Regents of the University of California. All rights reserved.
4610 *
4611 * Redistribution and use in source and binary forms, with or without
4612 * modification, are permitted provided that the following conditions
4613 * are met:
4614 * 1. Redistributions of source code must retain the above copyright
4615 * notice, this list of conditions and the following disclaimer.
4616 * 2. Redistributions in binary form must reproduce the above copyright
4617 * notice, this list of conditions and the following disclaimer in the
4618 * documentation and/or other materials provided with the distribution.
4619 * 4. Neither the name of the University nor the names of its contributors
4620 * may be used to endorse or promote products derived from this software
4621 * without specific prior written permission.
4622 *
4623 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4624 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4625 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4626 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4627 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4628 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4629 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4630 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4631 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4632 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4633 * SUCH DAMAGE.
4634 *
4635 * $FreeBSD$
4636 */
4637
4638#ifndef _SYS_LIMITS_H_
4639#define _SYS_LIMITS_H_
4640
4641#if 0 /* expanded by -frewrite-includes */
4642#include <sys/cdefs.h>
4643#endif /* expanded by -frewrite-includes */
4644# 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4645# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4646#if 0 /* expanded by -frewrite-includes */
4647#include <machine/_limits.h>
4648#endif /* expanded by -frewrite-includes */
4649# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4650# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_limits.h" 1 3 4
4651/*-
4652 * Copyright (c) 1988, 1993
4653 * The Regents of the University of California. All rights reserved.
4654 *
4655 * Redistribution and use in source and binary forms, with or without
4656 * modification, are permitted provided that the following conditions
4657 * are met:
4658 * 1. Redistributions of source code must retain the above copyright
4659 * notice, this list of conditions and the following disclaimer.
4660 * 2. Redistributions in binary form must reproduce the above copyright
4661 * notice, this list of conditions and the following disclaimer in the
4662 * documentation and/or other materials provided with the distribution.
4663 * 4. Neither the name of the University nor the names of its contributors
4664 * may be used to endorse or promote products derived from this software
4665 * without specific prior written permission.
4666 *
4667 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4668 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4669 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4670 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4671 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4672 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4673 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4674 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4675 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4676 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4677 * SUCH DAMAGE.
4678 *
4679 * @(#)limits.h 8.3 (Berkeley) 1/4/94
4680 * from: src/sys/i386/include/_limits.h,v 1.27 2005/01/06 22:18:15 imp
4681 * $FreeBSD$
4682 */
4683
4684#ifndef _MACHINE__LIMITS_H_
4685#define _MACHINE__LIMITS_H_
4686
4687/*
4688 * According to ANSI (section 2.2.4.2), the values below must be usable by
4689 * #if preprocessing directives. Additionally, the expression must have the
4690 * same type as would an expression that is an object of the corresponding
4691 * type converted according to the integral promotions. The subtraction for
4692 * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
4693 * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
4694 */
4695
4696#define __CHAR_BIT 8 /* number of bits in a char */
4697
4698#define __SCHAR_MAX 0x7f /* max value for a signed char */
4699#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
4700
4701#define __UCHAR_MAX 0xff /* max value for an unsigned char */
4702
4703#define __USHRT_MAX 0xffff /* max value for an unsigned short */
4704#define __SHRT_MAX 0x7fff /* max value for a short */
4705#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
4706
4707#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
4708#define __INT_MAX 0x7fffffff /* max value for an int */
4709#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
4710
4711#ifdef __mips_n64
4712#define __ULONG_MAX 0xffffffffffffffff
4713#define __LONG_MAX 0x7fffffffffffffff
4714#define __LONG_MIN (-0x7fffffffffffffff - 1)
4715#define __LONG_BIT 64
4716#else
4717# 67 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_limits.h" 3 4
4718#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
4719#define __LONG_MAX 0x7fffffffL /* max value for a long */
4720#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
4721#define __LONG_BIT 32
4722#endif
4723# 72 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_limits.h" 3 4
4724
4725 /* max value for an unsigned long long */
4726#define __ULLONG_MAX 0xffffffffffffffffULL
4727#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
4728#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
4729
4730#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */
4731
4732#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */
4733
4734#define __OFF_MAX __LLONG_MAX /* max value for an off_t */
4735#define __OFF_MIN __LLONG_MIN /* min value for an off_t */
4736
4737/* Quads and long longs are the same size. Ensure they stay in sync. */
4738#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
4739#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
4740#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
4741
4742#define __WORD_BIT 32
4743
4744#define __MINSIGSTKSZ (512 * 4)
4745
4746#endif /* !_MACHINE__LIMITS_H_ */
4747# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_limits.h" 3 4
4748# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 2 3 4
4749
4750#define CHAR_BIT __CHAR_BIT /* number of bits in a char */
4751
4752#define SCHAR_MAX __SCHAR_MAX /* max value for a signed char */
4753#define SCHAR_MIN __SCHAR_MIN /* min value for a signed char */
4754
4755#define UCHAR_MAX __UCHAR_MAX /* max value for an unsigned char */
4756
4757#ifdef __CHAR_UNSIGNED__
4758#define CHAR_MAX UCHAR_MAX /* max value for a char */
4759#define CHAR_MIN 0 /* min value for a char */
4760#else
4761# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4762#define CHAR_MAX SCHAR_MAX
4763#define CHAR_MIN SCHAR_MIN
4764#endif
4765# 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4766
4767#define USHRT_MAX __USHRT_MAX /* max value for an unsigned short */
4768#define SHRT_MAX __SHRT_MAX /* max value for a short */
4769#define SHRT_MIN __SHRT_MIN /* min value for a short */
4770
4771#define UINT_MAX __UINT_MAX /* max value for an unsigned int */
4772#define INT_MAX __INT_MAX /* max value for an int */
4773#define INT_MIN __INT_MIN /* min value for an int */
4774
4775#define ULONG_MAX __ULONG_MAX /* max for an unsigned long */
4776#define LONG_MAX __LONG_MAX /* max for a long */
4777#define LONG_MIN __LONG_MIN /* min for a long */
4778
4779#ifdef __LONG_LONG_SUPPORTED
4780#define ULLONG_MAX __ULLONG_MAX /* max for an unsigned long long */
4781#define LLONG_MAX __LLONG_MAX /* max for a long long */
4782#define LLONG_MIN __LLONG_MIN /* min for a long long */
4783#endif
4784# 70 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4785
4786#if __POSIX_VISIBLE || __XSI_VISIBLE
4787#define SSIZE_MAX __SSIZE_MAX /* max value for an ssize_t */
4788#endif
4789# 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4790
4791#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
4792#define SIZE_T_MAX __SIZE_T_MAX /* max value for a size_t */
4793
4794#define OFF_MAX __OFF_MAX /* max value for an off_t */
4795#define OFF_MIN __OFF_MIN /* min value for an off_t */
4796#endif
4797# 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4798
4799#if __BSD_VISIBLE
4800#define GID_MAX UINT_MAX /* max value for a gid_t */
4801#define UID_MAX UINT_MAX /* max value for a uid_t */
4802
4803#define UQUAD_MAX (__UQUAD_MAX) /* max value for a uquad_t */
4804#define QUAD_MAX (__QUAD_MAX) /* max value for a quad_t */
4805#define QUAD_MIN (__QUAD_MIN) /* min value for a quad_t */
4806#endif
4807# 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4808
4809#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
4810#define LONG_BIT __LONG_BIT
4811#define WORD_BIT __WORD_BIT
4812#endif
4813# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4814
4815#if __POSIX_VISIBLE
4816#define MQ_PRIO_MAX 64
4817#endif
4818# 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4819
4820#endif /* !_SYS_LIMITS_H_ */
4821# 101 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/limits.h" 3 4
4822# 142 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h" 2
4823
4824#if __POSIX_VISIBLE
4825#if 0 /* expanded by -frewrite-includes */
4826#include <sys/syslimits.h>
4827#endif /* expanded by -frewrite-includes */
4828# 144 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4829# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 1 3 4
4830/*-
4831 * Copyright (c) 1988, 1993
4832 * The Regents of the University of California. All rights reserved.
4833 *
4834 * Redistribution and use in source and binary forms, with or without
4835 * modification, are permitted provided that the following conditions
4836 * are met:
4837 * 1. Redistributions of source code must retain the above copyright
4838 * notice, this list of conditions and the following disclaimer.
4839 * 2. Redistributions in binary form must reproduce the above copyright
4840 * notice, this list of conditions and the following disclaimer in the
4841 * documentation and/or other materials provided with the distribution.
4842 * 4. Neither the name of the University nor the names of its contributors
4843 * may be used to endorse or promote products derived from this software
4844 * without specific prior written permission.
4845 *
4846 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4847 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4848 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4849 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4850 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4851 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4852 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4853 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4854 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4855 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4856 * SUCH DAMAGE.
4857 *
4858 * @(#)syslimits.h 8.1 (Berkeley) 6/2/93
4859 * $FreeBSD$
4860 */
4861
4862#ifndef _SYS_SYSLIMITS_H_
4863#define _SYS_SYSLIMITS_H_
4864
4865#if !defined(_KERNEL) && !defined(_LIMITS_H_) && !defined(_SYS_PARAM_H_)
4866#ifndef _SYS_CDEFS_H_
4867#error this file needs sys/cdefs.h as a prerequisite
4868#endif
4869# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4870#ifdef __CC_SUPPORTS_WARNING
4871#warning "No user-serviceable parts inside."
4872#endif
4873# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4874#endif
4875# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4876
4877/*
4878 * Do not add any new variables here. (See the comment at the end of
4879 * the file for why.)
4880 */
4881#define ARG_MAX 262144 /* max bytes for an exec function */
4882#ifndef CHILD_MAX
4883#define CHILD_MAX 40 /* max simultaneous processes */
4884#endif
4885# 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4886#define LINK_MAX 32767 /* max file link count */
4887#define MAX_CANON 255 /* max bytes in term canon input line */
4888#define MAX_INPUT 255 /* max bytes in terminal input */
4889#define NAME_MAX 255 /* max bytes in a file name */
4890#ifndef NGROUPS_MAX
4891#define NGROUPS_MAX 1023 /* max supplemental group id's */
4892#endif
4893# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4894#ifndef OPEN_MAX
4895#define OPEN_MAX 64 /* max open files per process */
4896#endif
4897# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4898#define PATH_MAX 1024 /* max bytes in pathname */
4899#define PIPE_BUF 512 /* max bytes for atomic pipe writes */
4900#define IOV_MAX 1024 /* max elements in i/o vector */
4901
4902/*
4903 * We leave the following values undefined to force applications to either
4904 * assume conservative values or call sysconf() to get the current value.
4905 *
4906 * HOST_NAME_MAX
4907 *
4908 * (We should do this for most of the values currently defined here,
4909 * but many programs are not prepared to deal with this yet.)
4910 */
4911#endif
4912# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/syslimits.h" 3 4
4913# 145 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h" 2
4914#endif
4915# 146 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4916
4917#endif /* !_LIMITS_H_ */
4918# 148 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/limits.h"
4919# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
4920#if 0 /* expanded by -frewrite-includes */
4921#include <stdlib.h>
4922#endif /* expanded by -frewrite-includes */
4923# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
4924# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h" 1
4925/*-
4926 * Copyright (c) 1990, 1993
4927 * The Regents of the University of California. All rights reserved.
4928 *
4929 * Redistribution and use in source and binary forms, with or without
4930 * modification, are permitted provided that the following conditions
4931 * are met:
4932 * 1. Redistributions of source code must retain the above copyright
4933 * notice, this list of conditions and the following disclaimer.
4934 * 2. Redistributions in binary form must reproduce the above copyright
4935 * notice, this list of conditions and the following disclaimer in the
4936 * documentation and/or other materials provided with the distribution.
4937 * 3. Neither the name of the University nor the names of its contributors
4938 * may be used to endorse or promote products derived from this software
4939 * without specific prior written permission.
4940 *
4941 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4942 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4943 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4944 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4945 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4946 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4947 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4948 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4949 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4950 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4951 * SUCH DAMAGE.
4952 *
4953 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
4954 * $FreeBSD$
4955 */
4956
4957#ifndef _STDLIB_H_
4958#define _STDLIB_H_
4959
4960#if 0 /* expanded by -frewrite-includes */
4961#include <sys/cdefs.h>
4962#endif /* expanded by -frewrite-includes */
4963# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4964# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4965#if 0 /* expanded by -frewrite-includes */
4966#include <sys/_null.h>
4967#endif /* expanded by -frewrite-includes */
4968# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4969# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4970#if 0 /* expanded by -frewrite-includes */
4971#include <sys/_types.h>
4972#endif /* expanded by -frewrite-includes */
4973# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4974# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4975
4976#if __BSD_VISIBLE
4977#ifndef _RUNE_T_DECLARED
4978typedef __rune_t rune_t;
4979#define _RUNE_T_DECLARED
4980#endif
4981# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4982#endif
4983# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4984
4985#ifndef _SIZE_T_DECLARED
4986typedef __size_t size_t;
4987#define _SIZE_T_DECLARED
4988#endif
4989# 51 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4990
4991#ifndef __cplusplus
4992#ifndef _WCHAR_T_DECLARED
4993typedef ___wchar_t wchar_t;
4994#define _WCHAR_T_DECLARED
4995#endif
4996# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4997#endif
4998# 58 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
4999
5000typedef struct {
5001 int quot; /* quotient */
5002 int rem; /* remainder */
5003} div_t;
5004
5005typedef struct {
5006 long quot;
5007 long rem;
5008} ldiv_t;
5009
5010#define EXIT_FAILURE 1
5011#define EXIT_SUCCESS 0
5012
5013#define RAND_MAX 0x7ffffffd
5014
5015__BEGIN_DECLS
5016#ifdef _XLOCALE_H_
5017#if 0 /* expanded by -frewrite-includes */
5018#include <xlocale/_stdlib.h>
5019#endif /* expanded by -frewrite-includes */
5020# 76 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5021# 77 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5022#endif
5023# 78 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5024extern int __mb_cur_max;
5025extern int ___mb_cur_max(void);
5026#define MB_CUR_MAX (___mb_cur_max())
5027
5028_Noreturn void abort(void);
5029int abs(int) __pure2;
5030int atexit(void (*)(void));
5031double atof(const char *);
5032int atoi(const char *);
5033long atol(const char *);
5034void *bsearch(const void *, const void *, size_t,
5035 size_t, int (*)(const void *, const void *));
5036void *calloc(size_t, size_t) __malloc_like __result_use_check
5037 __alloc_size(1) __alloc_size(2);
5038div_t div(int, int) __pure2;
5039_Noreturn void exit(int);
5040void free(void *);
5041char *getenv(const char *);
5042long labs(long) __pure2;
5043ldiv_t ldiv(long, long) __pure2;
5044void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
5045int mblen(const char *, size_t);
5046size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
5047int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
5048void qsort(void *, size_t, size_t,
5049 int (*)(const void *, const void *));
5050int rand(void);
5051void *realloc(void *, size_t) __result_use_check __alloc_size(2);
5052void srand(unsigned);
5053double strtod(const char * __restrict, char ** __restrict);
5054float strtof(const char * __restrict, char ** __restrict);
5055long strtol(const char * __restrict, char ** __restrict, int);
5056long double
5057 strtold(const char * __restrict, char ** __restrict);
5058unsigned long
5059 strtoul(const char * __restrict, char ** __restrict, int);
5060int system(const char *);
5061int wctomb(char *, wchar_t);
5062size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
5063
5064/*
5065 * Functions added in C99 which we make conditionally available in the
5066 * BSD^C89 namespace if the compiler supports `long long'.
5067 * The #if test is more complicated than it ought to be because
5068 * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
5069 * is not supported in the compilation environment (which therefore means
5070 * that it can't really be ISO C99).
5071 *
5072 * (The only other extension made by C99 in thie header is _Exit().)
5073 */
5074#if __ISO_C_VISIBLE >= 1999
5075#ifdef __LONG_LONG_SUPPORTED
5076/* LONGLONG */
5077typedef struct {
5078 long long quot;
5079 long long rem;
5080} lldiv_t;
5081
5082/* LONGLONG */
5083long long
5084 atoll(const char *);
5085/* LONGLONG */
5086long long
5087 llabs(long long) __pure2;
5088/* LONGLONG */
5089lldiv_t lldiv(long long, long long) __pure2;
5090/* LONGLONG */
5091long long
5092 strtoll(const char * __restrict, char ** __restrict, int);
5093/* LONGLONG */
5094unsigned long long
5095 strtoull(const char * __restrict, char ** __restrict, int);
5096#endif /* __LONG_LONG_SUPPORTED */
5097# 151 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5098
5099_Noreturn void _Exit(int);
5100#endif /* __ISO_C_VISIBLE >= 1999 */
5101# 154 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5102
5103/*
5104 * If we're in a mode greater than C99, expose C11 functions.
5105 */
5106#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
5107void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
5108 __alloc_size(2);
5109int at_quick_exit(void (*)(void));
5110_Noreturn void
5111 quick_exit(int);
5112#endif /* __ISO_C_VISIBLE >= 2011 */
5113# 165 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5114/*
5115 * Extensions made by POSIX relative to C.
5116 */
5117#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
5118char *realpath(const char * __restrict, char * __restrict);
5119#endif
5120# 171 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5121#if __POSIX_VISIBLE >= 199506
5122int rand_r(unsigned *); /* (TSF) */
5123#endif
5124# 174 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5125#if __POSIX_VISIBLE >= 200112
5126int posix_memalign(void **, size_t, size_t) __nonnull(1) __alloc_align(2)
5127 __alloc_size(3); /* (ADV) */
5128int setenv(const char *, const char *, int);
5129int unsetenv(const char *);
5130#endif
5131# 180 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5132
5133#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
5134int getsubopt(char **, char *const *, char **);
5135#ifndef _MKDTEMP_DECLARED
5136char *mkdtemp(char *);
5137#define _MKDTEMP_DECLARED
5138#endif
5139# 187 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5140#ifndef _MKSTEMP_DECLARED
5141int mkstemp(char *);
5142#define _MKSTEMP_DECLARED
5143#endif
5144# 191 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5145#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
5146# 192 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5147
5148/*
5149 * The only changes to the XSI namespace in revision 6 were the deletion
5150 * of the ttyslot() and valloc() functions, which FreeBSD never declared
5151 * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
5152 * FreeBSD also does not have, and mktemp(), are to be deleted.
5153 */
5154#if __XSI_VISIBLE
5155/* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
5156long a64l(const char *);
5157double drand48(void);
5158/* char *ecvt(double, int, int * __restrict, int * __restrict); */
5159double erand48(unsigned short[3]);
5160/* char *fcvt(double, int, int * __restrict, int * __restrict); */
5161/* char *gcvt(double, int, int * __restrict, int * __restrict); */
5162int grantpt(int);
5163char *initstate(unsigned long /* XSI requires u_int */, char *, long);
5164long jrand48(unsigned short[3]);
5165char *l64a(long);
5166void lcong48(unsigned short[7]);
5167long lrand48(void);
5168#if !defined(_MKTEMP_DECLARED) && (__BSD_VISIBLE || __XSI_VISIBLE <= 600)
5169char *mktemp(char *);
5170#define _MKTEMP_DECLARED
5171#endif
5172# 217 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5173long mrand48(void);
5174long nrand48(unsigned short[3]);
5175int posix_openpt(int);
5176char *ptsname(int);
5177int putenv(char *);
5178long random(void);
5179unsigned short
5180 *seed48(unsigned short[3]);
5181#ifndef _SETKEY_DECLARED
5182int setkey(const char *);
5183#define _SETKEY_DECLARED
5184#endif
5185# 229 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5186char *setstate(/* const */ char *);
5187void srand48(long);
5188void srandom(unsigned long);
5189int unlockpt(int);
5190#endif /* __XSI_VISIBLE */
5191# 234 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5192
5193#if __BSD_VISIBLE
5194extern const char *malloc_conf;
5195extern void (*malloc_message)(void *, const char *);
5196
5197/*
5198 * The alloca() function can't be implemented in C, and on some
5199 * platforms it can't be implemented at all as a callable function.
5200 * The GNU C compiler provides a built-in alloca() which we can use;
5201 * in all other cases, provide a prototype, mainly to pacify various
5202 * incarnations of lint. On platforms where alloca() is not in libc,
5203 * programs which use it will fail to link when compiled with non-GNU
5204 * compilers.
5205 */
5206#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
5207#undef alloca /* some GNU bits try to get cute and define this on their own */
5208#define alloca(sz) __builtin_alloca(sz)
5209#elif defined(lint)
5210# 252 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5211void *alloca(size_t);
5212#endif
5213# 254 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5214
5215void abort2(const char *, int, void **) __dead2;
5216__uint32_t
5217 arc4random(void);
5218void arc4random_addrandom(unsigned char *, int);
5219void arc4random_buf(void *, size_t);
5220void arc4random_stir(void);
5221__uint32_t
5222 arc4random_uniform(__uint32_t);
5223#ifdef __BLOCKS__
5224int atexit_b(void (^)(void));
5225void *bsearch_b(const void *, const void *, size_t,
5226 size_t, int (^)(const void *, const void *));
5227#endif
5228# 268 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5229char *getbsize(int *, long *);
5230 /* getcap(3) functions */
5231char *cgetcap(char *, const char *, int);
5232int cgetclose(void);
5233int cgetent(char **, char **, const char *);
5234int cgetfirst(char **, char **);
5235int cgetmatch(const char *, const char *);
5236int cgetnext(char **, char **);
5237int cgetnum(char *, const char *, long *);
5238int cgetset(const char *);
5239int cgetstr(char *, const char *, char **);
5240int cgetustr(char *, const char *, char **);
5241
5242int daemon(int, int);
5243char *devname(__dev_t, __mode_t);
5244char *devname_r(__dev_t, __mode_t, char *, int);
5245char *fdevname(int);
5246char *fdevname_r(int, char *, int);
5247int getloadavg(double [], int);
5248const char *
5249 getprogname(void);
5250
5251int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
5252#ifdef __BLOCKS__
5253int heapsort_b(void *, size_t, size_t, int (^)(const void *, const void *));
5254void qsort_b(void *, size_t, size_t,
5255 int (^)(const void *, const void *));
5256#endif
5257# 296 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5258int l64a_r(long, char *, int);
5259int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
5260#ifdef __BLOCKS__
5261int mergesort_b(void *, size_t, size_t, int (^)(const void *, const void *));
5262#endif
5263# 301 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5264int mkostemp(char *, int);
5265int mkostemps(char *, int, int);
5266void qsort_r(void *, size_t, size_t, void *,
5267 int (*)(void *, const void *, const void *));
5268int radixsort(const unsigned char **, int, const unsigned char *,
5269 unsigned);
5270void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
5271 __alloc_size(3);
5272void *reallocf(void *, size_t) __alloc_size(2);
5273int rpmatch(const char *);
5274void setprogname(const char *);
5275int sradixsort(const unsigned char **, int, const unsigned char *,
5276 unsigned);
5277void sranddev(void);
5278void srandomdev(void);
5279long long
5280 strtonum(const char *, long long, long long, const char **);
5281
5282/* Deprecated interfaces, to be removed in FreeBSD 6.0. */
5283__int64_t
5284 strtoq(const char *, char **, int);
5285__uint64_t
5286 strtouq(const char *, char **, int);
5287
5288#if __has_feature(capabilities)
5289long strtol_c(__capability const char * __restrict,
5290 __capability char ** __restrict, int);
5291long double
5292 strtold_c(__capability const char * __restrict,
5293 __capability char ** __restrict);
5294#endif
5295# 332 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5296
5297extern char *suboptarg; /* getsubopt(3) external variable */
5298#endif /* __BSD_VISIBLE */
5299# 335 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5300__END_DECLS
5301
5302#endif /* !_STDLIB_H_ */
5303# 338 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/stdlib.h"
5304# 53 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
5305#if 0 /* expanded by -frewrite-includes */
5306#include <regex.h>
5307#endif /* expanded by -frewrite-includes */
5308# 53 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
5309# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h" 1
5310/*-
5311 * Copyright (c) 1992 Henry Spencer.
5312 * Copyright (c) 1992, 1993
5313 * The Regents of the University of California. All rights reserved.
5314 *
5315 * This code is derived from software contributed to Berkeley by
5316 * Henry Spencer of the University of Toronto.
5317 *
5318 * Redistribution and use in source and binary forms, with or without
5319 * modification, are permitted provided that the following conditions
5320 * are met:
5321 * 1. Redistributions of source code must retain the above copyright
5322 * notice, this list of conditions and the following disclaimer.
5323 * 2. Redistributions in binary form must reproduce the above copyright
5324 * notice, this list of conditions and the following disclaimer in the
5325 * documentation and/or other materials provided with the distribution.
5326 * 3. Neither the name of the University nor the names of its contributors
5327 * may be used to endorse or promote products derived from this software
5328 * without specific prior written permission.
5329 *
5330 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5331 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5332 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5333 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5334 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5335 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5336 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5337 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5338 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5339 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5340 * SUCH DAMAGE.
5341 *
5342 * @(#)regex.h 8.2 (Berkeley) 1/3/94
5343 * $FreeBSD$
5344 */
5345
5346#ifndef _REGEX_H_
5347#define _REGEX_H_
5348
5349#if 0 /* expanded by -frewrite-includes */
5350#include <sys/cdefs.h>
5351#endif /* expanded by -frewrite-includes */
5352# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h"
5353# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h"
5354#if 0 /* expanded by -frewrite-includes */
5355#include <sys/_types.h>
5356#endif /* expanded by -frewrite-includes */
5357# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h"
5358# 42 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h"
5359
5360/* types */
5361typedef __off_t regoff_t;
5362
5363#ifndef _SIZE_T_DECLARED
5364typedef __size_t size_t;
5365#define _SIZE_T_DECLARED
5366#endif
5367# 50 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h"
5368
5369typedef struct {
5370 int re_magic;
5371 size_t re_nsub; /* number of parenthesized subexpressions */
5372 const char *re_endp; /* end pointer for REG_PEND */
5373 struct re_guts *re_g; /* none of your business :-) */
5374} regex_t;
5375
5376typedef struct {
5377 regoff_t rm_so; /* start of match */
5378 regoff_t rm_eo; /* end of match */
5379} regmatch_t;
5380
5381/* regcomp() flags */
5382#define REG_BASIC 0000
5383#define REG_EXTENDED 0001
5384#define REG_ICASE 0002
5385#define REG_NOSUB 0004
5386#define REG_NEWLINE 0010
5387#define REG_NOSPEC 0020
5388#define REG_PEND 0040
5389#define REG_DUMP 0200
5390
5391/* regerror() flags */
5392#define REG_ENOSYS (-1)
5393#define REG_NOMATCH 1
5394#define REG_BADPAT 2
5395#define REG_ECOLLATE 3
5396#define REG_ECTYPE 4
5397#define REG_EESCAPE 5
5398#define REG_ESUBREG 6
5399#define REG_EBRACK 7
5400#define REG_EPAREN 8
5401#define REG_EBRACE 9
5402#define REG_BADBR 10
5403#define REG_ERANGE 11
5404#define REG_ESPACE 12
5405#define REG_BADRPT 13
5406#define REG_EMPTY 14
5407#define REG_ASSERT 15
5408#define REG_INVARG 16
5409#define REG_ILLSEQ 17
5410#define REG_ATOI 255 /* convert name to number (!) */
5411#define REG_ITOA 0400 /* convert number to name (!) */
5412
5413/* regexec() flags */
5414#define REG_NOTBOL 00001
5415#define REG_NOTEOL 00002
5416#define REG_STARTEND 00004
5417#define REG_TRACE 00400 /* tracing of execution */
5418#define REG_LARGE 01000 /* force large representation */
5419#define REG_BACKR 02000 /* force use of backref code */
5420
5421__BEGIN_DECLS
5422int regcomp(regex_t * __restrict, const char * __restrict, int);
5423size_t regerror(int, const regex_t * __restrict, char * __restrict, size_t);
5424/*
5425 * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because
5426 * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a
5427 * syntax error.
5428 */
5429int regexec(const regex_t * __restrict, const char * __restrict, size_t,
5430 regmatch_t * __restrict, int);
5431void regfree(regex_t *);
5432__END_DECLS
5433
5434#endif /* !_REGEX_H_ */
5435# 117 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/regex.h"
5436# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
5437#if 0 /* expanded by -frewrite-includes */
5438#include <runetype.h>
5439#endif /* expanded by -frewrite-includes */
5440# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
5441# 55 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
5442#if 0 /* expanded by -frewrite-includes */
5443#include <wchar.h>
5444#endif /* expanded by -frewrite-includes */
5445# 55 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
5446# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h" 1
5447/*-
5448 * Copyright (c)1999 Citrus Project,
5449 * All rights reserved.
5450 *
5451 * Redistribution and use in source and binary forms, with or without
5452 * modification, are permitted provided that the following conditions
5453 * are met:
5454 * 1. Redistributions of source code must retain the above copyright
5455 * notice, this list of conditions and the following disclaimer.
5456 * 2. Redistributions in binary form must reproduce the above copyright
5457 * notice, this list of conditions and the following disclaimer in the
5458 * documentation and/or other materials provided with the distribution.
5459 *
5460 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5461 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5462 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5463 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5464 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5465 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5466 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5467 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5468 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5469 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5470 * SUCH DAMAGE.
5471 *
5472 * $FreeBSD$
5473 */
5474
5475/*-
5476 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5477 * All rights reserved.
5478 *
5479 * This code is derived from software contributed to The NetBSD Foundation
5480 * by Julian Coleman.
5481 *
5482 * Redistribution and use in source and binary forms, with or without
5483 * modification, are permitted provided that the following conditions
5484 * are met:
5485 * 1. Redistributions of source code must retain the above copyright
5486 * notice, this list of conditions and the following disclaimer.
5487 * 2. Redistributions in binary form must reproduce the above copyright
5488 * notice, this list of conditions and the following disclaimer in the
5489 * documentation and/or other materials provided with the distribution.
5490 *
5491 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
5492 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
5493 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
5494 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
5495 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5496 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5497 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5498 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5499 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5500 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5501 * POSSIBILITY OF SUCH DAMAGE.
5502 *
5503 * $NetBSD: wchar.h,v 1.8 2000/12/22 05:31:42 itojun Exp $
5504 */
5505
5506#ifndef _WCHAR_H_
5507#define _WCHAR_H_
5508
5509#if 0 /* expanded by -frewrite-includes */
5510#include <sys/cdefs.h>
5511#endif /* expanded by -frewrite-includes */
5512# 63 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5513# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5514#if 0 /* expanded by -frewrite-includes */
5515#include <sys/_null.h>
5516#endif /* expanded by -frewrite-includes */
5517# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5518# 65 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5519#if 0 /* expanded by -frewrite-includes */
5520#include <sys/_types.h>
5521#endif /* expanded by -frewrite-includes */
5522# 65 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5523# 66 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5524#if 0 /* expanded by -frewrite-includes */
5525#include <machine/_limits.h>
5526#endif /* expanded by -frewrite-includes */
5527# 66 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5528# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5529#if 0 /* expanded by -frewrite-includes */
5530#include <_ctype.h>
5531#endif /* expanded by -frewrite-includes */
5532# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5533# 68 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5534
5535#ifndef _MBSTATE_T_DECLARED
5536typedef __mbstate_t mbstate_t;
5537#define _MBSTATE_T_DECLARED
5538#endif
5539# 73 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5540
5541#ifndef _SIZE_T_DECLARED
5542typedef __size_t size_t;
5543#define _SIZE_T_DECLARED
5544#endif
5545# 78 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5546
5547#ifndef __cplusplus
5548#ifndef _WCHAR_T_DECLARED
5549typedef ___wchar_t wchar_t;
5550#define _WCHAR_T_DECLARED
5551#endif
5552# 84 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5553#endif
5554# 85 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5555
5556#ifndef _WINT_T_DECLARED
5557typedef __wint_t wint_t;
5558#define _WINT_T_DECLARED
5559#endif
5560# 90 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5561
5562#define WCHAR_MIN __WCHAR_MIN
5563#define WCHAR_MAX __WCHAR_MAX
5564
5565#ifndef WEOF
5566#define WEOF ((wint_t)-1)
5567#endif
5568# 97 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5569
5570#ifndef _STDFILE_DECLARED
5571#define _STDFILE_DECLARED
5572typedef struct __sFILE FILE;
5573#endif
5574# 102 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5575struct tm;
5576
5577__BEGIN_DECLS
5578wint_t btowc(int);
5579wint_t fgetwc(FILE *);
5580wchar_t *
5581 fgetws(wchar_t * __restrict, int, FILE * __restrict);
5582wint_t fputwc(wchar_t, FILE *);
5583int fputws(const wchar_t * __restrict, FILE * __restrict);
5584int fwide(FILE *, int);
5585int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
5586int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
5587wint_t getwc(FILE *);
5588wint_t getwchar(void);
5589size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
5590size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
5591 mbstate_t * __restrict);
5592int mbsinit(const mbstate_t *);
5593size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
5594 mbstate_t * __restrict);
5595wint_t putwc(wchar_t, FILE *);
5596wint_t putwchar(wchar_t);
5597int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
5598 ...);
5599int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
5600wint_t ungetwc(wint_t, FILE *);
5601int vfwprintf(FILE * __restrict, const wchar_t * __restrict,
5602 __va_list);
5603int vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
5604 __va_list);
5605int vwprintf(const wchar_t * __restrict, __va_list);
5606size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
5607wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict);
5608wchar_t *wcschr(const wchar_t *, wchar_t) __pure;
5609int wcscmp(const wchar_t *, const wchar_t *) __pure;
5610int wcscoll(const wchar_t *, const wchar_t *);
5611wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict);
5612size_t wcscspn(const wchar_t *, const wchar_t *) __pure;
5613size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict,
5614 const struct tm * __restrict);
5615size_t wcslen(const wchar_t *) __pure;
5616wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict,
5617 size_t);
5618int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure;
5619wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t);
5620wchar_t *wcspbrk(const wchar_t *, const wchar_t *) __pure;
5621wchar_t *wcsrchr(const wchar_t *, wchar_t) __pure;
5622size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
5623 mbstate_t * __restrict);
5624size_t wcsspn(const wchar_t *, const wchar_t *) __pure;
5625wchar_t *wcsstr(const wchar_t * __restrict, const wchar_t * __restrict)
5626 __pure;
5627size_t wcsxfrm(wchar_t * __restrict, const wchar_t * __restrict, size_t);
5628int wctob(wint_t);
5629double wcstod(const wchar_t * __restrict, wchar_t ** __restrict);
5630wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict,
5631 wchar_t ** __restrict);
5632long wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int);
5633unsigned long
5634 wcstoul(const wchar_t * __restrict, wchar_t ** __restrict, int);
5635wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) __pure;
5636int wmemcmp(const wchar_t *, const wchar_t *, size_t) __pure;
5637wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
5638wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
5639wchar_t *wmemset(wchar_t *, wchar_t, size_t);
5640int wprintf(const wchar_t * __restrict, ...);
5641int wscanf(const wchar_t * __restrict, ...);
5642
5643#ifndef _STDSTREAM_DECLARED
5644extern FILE *__stdinp;
5645extern FILE *__stdoutp;
5646extern FILE *__stderrp;
5647#define _STDSTREAM_DECLARED
5648#endif
5649# 176 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5650
5651#define getwc(fp) fgetwc(fp)
5652#define getwchar() fgetwc(__stdinp)
5653#define putwc(wc, fp) fputwc(wc, fp)
5654#define putwchar(wc) fputwc(wc, __stdoutp)
5655
5656#if __ISO_C_VISIBLE >= 1999
5657int vfwscanf(FILE * __restrict, const wchar_t * __restrict,
5658 __va_list);
5659int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
5660 __va_list);
5661int vwscanf(const wchar_t * __restrict, __va_list);
5662float wcstof(const wchar_t * __restrict, wchar_t ** __restrict);
5663long double
5664 wcstold(const wchar_t * __restrict, wchar_t ** __restrict);
5665#ifdef __LONG_LONG_SUPPORTED
5666/* LONGLONG */
5667long long
5668 wcstoll(const wchar_t * __restrict, wchar_t ** __restrict, int);
5669/* LONGLONG */
5670unsigned long long
5671 wcstoull(const wchar_t * __restrict, wchar_t ** __restrict, int);
5672#endif
5673# 199 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5674#endif /* __ISO_C_VISIBLE >= 1999 */
5675# 200 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5676
5677#if __XSI_VISIBLE
5678int wcswidth(const wchar_t *, size_t);
5679int wcwidth(wchar_t);
5680#define wcwidth(_c) __wcwidth(_c)
5681#endif
5682# 206 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5683
5684#if __POSIX_VISIBLE >= 200809
5685size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
5686 size_t, mbstate_t * __restrict);
5687FILE *open_wmemstream(wchar_t **, size_t *);
5688wchar_t *wcpcpy(wchar_t * __restrict, const wchar_t * __restrict);
5689wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
5690wchar_t *wcsdup(const wchar_t *) __malloc_like;
5691int wcscasecmp(const wchar_t *, const wchar_t *);
5692int wcsncasecmp(const wchar_t *, const wchar_t *, size_t n);
5693size_t wcsnlen(const wchar_t *, size_t) __pure;
5694size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
5695 size_t, mbstate_t * __restrict);
5696#endif
5697# 220 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5698
5699#if __BSD_VISIBLE
5700wchar_t *fgetwln(FILE * __restrict, size_t * __restrict);
5701size_t wcslcat(wchar_t *, const wchar_t *, size_t);
5702size_t wcslcpy(wchar_t *, const wchar_t *, size_t);
5703#endif
5704# 226 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5705
5706#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
5707#if 0 /* expanded by -frewrite-includes */
5708#include <xlocale/_wchar.h>
5709#endif /* expanded by -frewrite-includes */
5710# 228 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5711# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h" 1
5712/*-
5713 * Copyright (c) 2011, 2012 The FreeBSD Foundation
5714 * All rights reserved.
5715 *
5716 * This software was developed by David Chisnall under sponsorship from
5717 * the FreeBSD Foundation.
5718 *
5719 * Redistribution and use in source and binary forms, with or without
5720 * modification, are permitted provided that the following conditions
5721 * are met:
5722 * 1. Redistributions of source code must retain the above copyright
5723 * notice, this list of conditions and the following disclaimer.
5724 * 2. Redistributions in binary form must reproduce the above copyright
5725 * notice, this list of conditions and the following disclaimer in the
5726 * documentation and/or other materials provided with the distribution.
5727 *
5728 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5729 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5730 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5731 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5732 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5733 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5734 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5735 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5736 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5737 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5738 * SUCH DAMAGE.
5739 *
5740 * $FreeBSD$
5741 */
5742
5743#ifndef _LOCALE_T_DEFINED
5744#define _LOCALE_T_DEFINED
5745typedef struct _xlocale *locale_t;
5746#endif
5747# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
5748
5749#ifndef _XLOCALE_WCHAR1_H
5750#define _XLOCALE_WCHAR1_H
5751int wcscasecmp_l(const wchar_t *, const wchar_t *,
5752 locale_t);
5753int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t,
5754 locale_t);
5755int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
5756size_t wcsxfrm_l(wchar_t * __restrict,
5757 const wchar_t * __restrict, size_t, locale_t);
5758
5759#endif /* _XLOCALE_WCHAR1_H */
5760# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
5761
5762/*
5763 * Only declare the non-POSIX functions if we're included from xlocale.h.
5764 */
5765
5766#ifdef _XLOCALE_H_
5767#ifndef _XLOCALE_WCHAR2_H
5768#define _XLOCALE_WCHAR2_H
5769
5770wint_t btowc_l(int, locale_t);
5771wint_t fgetwc_l(FILE *, locale_t);
5772wchar_t *fgetws_l(wchar_t * __restrict, int, FILE * __restrict,
5773 locale_t);
5774wint_t fputwc_l(wchar_t, FILE *, locale_t);
5775int fputws_l(const wchar_t * __restrict, FILE * __restrict,
5776 locale_t);
5777int fwprintf_l(FILE * __restrict, locale_t,
5778 const wchar_t * __restrict, ...);
5779int fwscanf_l(FILE * __restrict, locale_t,
5780 const wchar_t * __restrict, ...);
5781wint_t getwc_l(FILE *, locale_t);
5782wint_t getwchar_l(locale_t);
5783size_t mbrlen_l(const char * __restrict, size_t,
5784 mbstate_t * __restrict, locale_t);
5785size_t mbrtowc_l(wchar_t * __restrict,
5786 const char * __restrict, size_t,
5787 mbstate_t * __restrict, locale_t);
5788int mbsinit_l(const mbstate_t *, locale_t);
5789size_t mbsrtowcs_l(wchar_t * __restrict,
5790 const char ** __restrict, size_t,
5791 mbstate_t * __restrict, locale_t);
5792wint_t putwc_l(wchar_t, FILE *, locale_t);
5793wint_t putwchar_l(wchar_t, locale_t);
5794int swprintf_l(wchar_t * __restrict, size_t n, locale_t,
5795 const wchar_t * __restrict, ...);
5796int swscanf_l(const wchar_t * __restrict, locale_t,
5797 const wchar_t * __restrict, ...);
5798wint_t ungetwc_l(wint_t, FILE *, locale_t);
5799int vfwprintf_l(FILE * __restrict, locale_t,
5800 const wchar_t * __restrict, __va_list);
5801int vswprintf_l(wchar_t * __restrict, size_t n, locale_t,
5802 const wchar_t * __restrict, __va_list);
5803int vwprintf_l(locale_t, const wchar_t * __restrict,
5804 __va_list);
5805size_t wcrtomb_l(char * __restrict, wchar_t,
5806 mbstate_t * __restrict, locale_t);
5807size_t wcsftime_l(wchar_t * __restrict, size_t,
5808 const wchar_t * __restrict,
5809 const struct tm * __restrict, locale_t);
5810size_t wcsrtombs_l(char * __restrict,
5811 const wchar_t ** __restrict, size_t,
5812 mbstate_t * __restrict, locale_t);
5813double wcstod_l(const wchar_t * __restrict,
5814 wchar_t ** __restrict, locale_t);
5815long wcstol_l(const wchar_t * __restrict,
5816 wchar_t ** __restrict, int, locale_t);
5817unsigned long wcstoul_l(const wchar_t * __restrict,
5818 wchar_t ** __restrict, int, locale_t);
5819int wcswidth_l(const wchar_t *, size_t, locale_t);
5820int wctob_l(wint_t, locale_t);
5821int wcwidth_l(wchar_t, locale_t);
5822int wprintf_l(locale_t, const wchar_t * __restrict, ...);
5823int wscanf_l(locale_t, const wchar_t * __restrict, ...);
5824int vfwscanf_l(FILE * __restrict, locale_t,
5825 const wchar_t * __restrict, __va_list);
5826int vswscanf_l(const wchar_t * __restrict, locale_t,
5827 const wchar_t *__restrict, __va_list);
5828int vwscanf_l(locale_t, const wchar_t * __restrict,
5829 __va_list);
5830float wcstof_l(const wchar_t * __restrict,
5831 wchar_t ** __restrict, locale_t);
5832long double wcstold_l(const wchar_t * __restrict,
5833 wchar_t ** __restrict, locale_t);
5834long long wcstoll_l(const wchar_t * __restrict,
5835 wchar_t ** __restrict, int, locale_t);
5836unsigned long long wcstoull_l(const wchar_t * __restrict,
5837 wchar_t ** __restrict, int, locale_t);
5838size_t mbsnrtowcs_l(wchar_t * __restrict,
5839 const char ** __restrict, size_t, size_t,
5840 mbstate_t * __restrict, locale_t);
5841size_t wcsnrtombs_l(char * __restrict,
5842 const wchar_t ** __restrict, size_t, size_t,
5843 mbstate_t * __restrict, locale_t);
5844
5845#endif /* _XLOCALE_WCHAR_H */
5846# 133 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
5847#endif /* _XLOCALE_H_ */
5848# 134 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
5849# 229 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h" 2
5850#endif
5851# 230 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5852__END_DECLS
5853
5854#endif /* !_WCHAR_H_ */
5855# 233 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wchar.h"
5856# 56 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
5857#if 0 /* expanded by -frewrite-includes */
5858#include <wctype.h>
5859#endif /* expanded by -frewrite-includes */
5860# 56 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
5861# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h" 1
5862/*-
5863 * Copyright (c)1999 Citrus Project,
5864 * All rights reserved.
5865 *
5866 * Redistribution and use in source and binary forms, with or without
5867 * modification, are permitted provided that the following conditions
5868 * are met:
5869 * 1. Redistributions of source code must retain the above copyright
5870 * notice, this list of conditions and the following disclaimer.
5871 * 2. Redistributions in binary form must reproduce the above copyright
5872 * notice, this list of conditions and the following disclaimer in the
5873 * documentation and/or other materials provided with the distribution.
5874 *
5875 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5876 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5877 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5878 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5879 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5880 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5881 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5882 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5883 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5884 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5885 * SUCH DAMAGE.
5886 *
5887 * citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
5888 * $NetBSD: wctype.h,v 1.3 2000/12/22 14:16:16 itojun Exp $
5889 * $FreeBSD$
5890 */
5891
5892#ifndef _WCTYPE_H_
5893#define _WCTYPE_H_
5894
5895#if 0 /* expanded by -frewrite-includes */
5896#include <sys/cdefs.h>
5897#endif /* expanded by -frewrite-includes */
5898# 34 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5899# 35 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5900#if 0 /* expanded by -frewrite-includes */
5901#include <sys/_types.h>
5902#endif /* expanded by -frewrite-includes */
5903# 35 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5904# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5905
5906#if 0 /* expanded by -frewrite-includes */
5907#include <_ctype.h>
5908#endif /* expanded by -frewrite-includes */
5909# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5910# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5911
5912#ifndef _WCTRANS_T
5913typedef int wctrans_t;
5914#define _WCTRANS_T
5915#endif
5916# 43 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5917
5918#ifndef _WCTYPE_T
5919typedef unsigned long wctype_t;
5920#define _WCTYPE_T
5921#endif
5922# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5923
5924#ifndef _WINT_T_DECLARED
5925typedef __wint_t wint_t;
5926#define _WINT_T_DECLARED
5927#endif
5928# 53 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5929
5930#ifndef WEOF
5931#define WEOF ((wint_t)-1)
5932#endif
5933# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5934
5935__BEGIN_DECLS
5936int iswalnum(wint_t);
5937int iswalpha(wint_t);
5938int iswblank(wint_t);
5939int iswcntrl(wint_t);
5940int iswctype(wint_t, wctype_t);
5941int iswdigit(wint_t);
5942int iswgraph(wint_t);
5943int iswlower(wint_t);
5944int iswprint(wint_t);
5945int iswpunct(wint_t);
5946int iswspace(wint_t);
5947int iswupper(wint_t);
5948int iswxdigit(wint_t);
5949wint_t towctrans(wint_t, wctrans_t);
5950wint_t towlower(wint_t);
5951wint_t towupper(wint_t);
5952wctrans_t
5953 wctrans(const char *);
5954wctype_t
5955 wctype(const char *);
5956
5957#if __BSD_VISIBLE
5958wint_t iswascii(wint_t);
5959wint_t iswhexnumber(wint_t);
5960wint_t iswideogram(wint_t);
5961wint_t iswnumber(wint_t);
5962wint_t iswphonogram(wint_t);
5963wint_t iswrune(wint_t);
5964wint_t iswspecial(wint_t);
5965wint_t nextwctype(wint_t, wctype_t);
5966#endif
5967# 90 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5968
5969#if __POSIX_VISIBLE >= 200809
5970#define _XLOCALE_WCTYPES 1
5971#if 0 /* expanded by -frewrite-includes */
5972#include <xlocale/_ctype.h>
5973#endif /* expanded by -frewrite-includes */
5974# 93 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
5975# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h" 1
5976/*-
5977 * Copyright (c) 2011 The FreeBSD Foundation
5978 * All rights reserved.
5979 *
5980 * This software was developed by David Chisnall under sponsorship from
5981 * the FreeBSD Foundation.
5982 *
5983 * Redistribution and use in source and binary forms, with or without
5984 * modification, are permitted provided that the following conditions
5985 * are met:
5986 * 1. Redistributions of source code must retain the above copyright
5987 * notice, this list of conditions and the following disclaimer.
5988 * 2. Redistributions in binary form must reproduce the above copyright
5989 * notice, this list of conditions and the following disclaimer in the
5990 * documentation and/or other materials provided with the distribution.
5991 *
5992 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5993 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5994 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5995 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5996 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5997 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5998 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5999 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6000 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6001 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6002 * SUCH DAMAGE.
6003 *
6004 * $FreeBSD$
6005 */
6006
6007
6008#if (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
6009 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H))
6010
6011#ifdef _XLOCALE_WCTYPES
6012#define _XLOCALE_WCTYPE_H
6013#else
6014# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6015#define _XLOCALE_CTYPE_H
6016#endif
6017# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6018
6019#ifndef _LOCALE_T_DEFINED
6020#define _LOCALE_T_DEFINED
6021typedef struct _xlocale *locale_t;
6022#endif
6023# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6024
6025#ifndef _XLOCALE_RUN_FUNCTIONS_DEFINED
6026#define _XLOCALE_RUN_FUNCTIONS_DEFINED 1
6027unsigned long ___runetype_l(__ct_rune_t, locale_t) __pure;
6028__ct_rune_t ___tolower_l(__ct_rune_t, locale_t) __pure;
6029__ct_rune_t ___toupper_l(__ct_rune_t, locale_t) __pure;
6030_RuneLocale *__runes_for_locale(locale_t, int*);
6031#endif
6032# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6033
6034#ifndef _XLOCALE_INLINE
6035#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
6036/* GNU89 inline has nonstandard semantics. */
6037#define _XLOCALE_INLINE extern __inline
6038#else
6039# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6040/* Hack to work around people who define inline away */
6041#ifdef inline
6042#define _XLOCALE_INLINE static __inline
6043#else
6044# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6045/* Define with C++ / C99 compatible semantics */
6046#define _XLOCALE_INLINE inline
6047#endif
6048# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6049#endif
6050# 68 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6051#endif /* _XLOCALE_INLINE */
6052# 69 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6053
6054#ifdef _XLOCALE_WCTYPES
6055_XLOCALE_INLINE int
6056__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6057_XLOCALE_INLINE int
6058__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6059
6060_XLOCALE_INLINE int
6061__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6062{
6063 int __limit;
6064 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
6065 return ((__c < 0 || __c >= _CACHED_RUNES) ? ___runetype_l(__c, __loc) :
6066 runes->__runetype[__c]) & __f;
6067}
6068
6069_XLOCALE_INLINE int
6070__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6071{
6072 return (!!__maskrune_l(__c, __f, __loc));
6073}
6074
6075#define XLOCALE_ISCTYPE(fname, cat) \
6076 _XLOCALE_INLINE int isw##fname##_l(int, locale_t);\
6077 _XLOCALE_INLINE int isw##fname##_l(int __c, locale_t __l)\
6078 { return __istype_l(__c, cat, __l); }
6079#else
6080# 96 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6081_XLOCALE_INLINE int
6082__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6083_XLOCALE_INLINE int
6084__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6085
6086_XLOCALE_INLINE int
6087__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6088{
6089 int __limit;
6090 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
6091 return (__c < 0 || __c >= __limit) ? 0 :
6092 runes->__runetype[__c] & __f;
6093}
6094
6095_XLOCALE_INLINE int
6096__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6097{
6098 return (!!__sbmaskrune_l(__c, __f, __loc));
6099}
6100
6101#define XLOCALE_ISCTYPE(__fname, __cat) \
6102 _XLOCALE_INLINE int is##__fname##_l(int, locale_t); \
6103 _XLOCALE_INLINE int is##__fname##_l(int __c, locale_t __l)\
6104 { return __sbistype_l(__c, __cat, __l); }
6105#endif
6106# 121 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6107
6108XLOCALE_ISCTYPE(alnum, _CTYPE_A|_CTYPE_D|_CTYPE_N)
6109XLOCALE_ISCTYPE(alpha, _CTYPE_A)
6110XLOCALE_ISCTYPE(blank, _CTYPE_B)
6111XLOCALE_ISCTYPE(cntrl, _CTYPE_C)
6112XLOCALE_ISCTYPE(digit, _CTYPE_D)
6113XLOCALE_ISCTYPE(graph, _CTYPE_G)
6114XLOCALE_ISCTYPE(hexnumber, _CTYPE_X)
6115XLOCALE_ISCTYPE(ideogram, _CTYPE_I)
6116XLOCALE_ISCTYPE(lower, _CTYPE_L)
6117XLOCALE_ISCTYPE(number, _CTYPE_D|_CTYPE_N)
6118XLOCALE_ISCTYPE(phonogram, _CTYPE_Q)
6119XLOCALE_ISCTYPE(print, _CTYPE_R)
6120XLOCALE_ISCTYPE(punct, _CTYPE_P)
6121XLOCALE_ISCTYPE(rune, 0xFFFFFF00L)
6122XLOCALE_ISCTYPE(space, _CTYPE_S)
6123XLOCALE_ISCTYPE(special, _CTYPE_T)
6124XLOCALE_ISCTYPE(upper, _CTYPE_U)
6125XLOCALE_ISCTYPE(xdigit, _CTYPE_X)
6126#undef XLOCALE_ISCTYPE
6127
6128#ifdef _XLOCALE_WCTYPES
6129_XLOCALE_INLINE int towlower_l(int, locale_t);
6130_XLOCALE_INLINE int __wcwidth_l(__ct_rune_t, locale_t);
6131_XLOCALE_INLINE int towupper_l(int, locale_t);
6132
6133_XLOCALE_INLINE int towlower_l(int __c, locale_t __l)
6134{
6135 int __limit;
6136 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6137 return (__c < 0 || __c >= _CACHED_RUNES) ? ___tolower_l(__c, __l) :
6138 __runes->__maplower[__c];
6139}
6140_XLOCALE_INLINE int towupper_l(int __c, locale_t __l)
6141{
6142 int __limit;
6143 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6144 return (__c < 0 || __c >= _CACHED_RUNES) ? ___toupper_l(__c, __l) :
6145 __runes->__mapupper[__c];
6146}
6147_XLOCALE_INLINE int
6148__wcwidth_l(__ct_rune_t _c, locale_t __l)
6149{
6150 unsigned int _x;
6151
6152 if (_c == 0)
6153 return (0);
6154 _x = (unsigned int)__maskrune_l(_c, _CTYPE_SWM|_CTYPE_R, __l);
6155 if ((_x & _CTYPE_SWM) != 0)
6156 return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
6157 return ((_x & _CTYPE_R) != 0 ? 1 : -1);
6158}
6159int iswctype_l(wint_t __wc, wctype_t __charclass, locale_t __l);
6160wctype_t wctype_l(const char *property, locale_t __l);
6161wint_t towctrans_l(wint_t __wc, wctrans_t desc, locale_t __l);
6162wint_t nextwctype_l(wint_t __wc, wctype_t wct, locale_t __l);
6163wctrans_t wctrans_l(const char *__charclass, locale_t __l);
6164#undef _XLOCALE_WCTYPES
6165#else
6166# 180 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6167_XLOCALE_INLINE int digittoint_l(int, locale_t);
6168_XLOCALE_INLINE int tolower_l(int, locale_t);
6169_XLOCALE_INLINE int toupper_l(int, locale_t);
6170
6171_XLOCALE_INLINE int digittoint_l(int __c, locale_t __l)
6172{ return __sbmaskrune_l((__c), 0xFF, __l); }
6173
6174_XLOCALE_INLINE int tolower_l(int __c, locale_t __l)
6175{
6176 int __limit;
6177 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6178 return (__c < 0 || __c >= __limit) ? __c :
6179 __runes->__maplower[__c];
6180}
6181_XLOCALE_INLINE int toupper_l(int __c, locale_t __l)
6182{
6183 int __limit;
6184 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6185 return (__c < 0 || __c >= __limit) ? __c :
6186 __runes->__mapupper[__c];
6187}
6188#endif
6189# 202 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6190#endif /* (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
6191 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H)) */
6192# 204 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6193# 94 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h" 2
6194#endif /* __POSIX_VISIBLE >= 200809 */
6195# 95 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
6196__END_DECLS
6197
6198#ifndef __cplusplus
6199#define iswalnum(wc) __istype((wc), _CTYPE_A|_CTYPE_D|_CTYPE_N)
6200#define iswalpha(wc) __istype((wc), _CTYPE_A)
6201#define iswblank(wc) __istype((wc), _CTYPE_B)
6202#define iswcntrl(wc) __istype((wc), _CTYPE_C)
6203#define iswctype(wc, charclass) __istype((wc), (charclass))
6204#define iswdigit(wc) __istype((wc), _CTYPE_D)
6205#define iswgraph(wc) __istype((wc), _CTYPE_G)
6206#define iswlower(wc) __istype((wc), _CTYPE_L)
6207#define iswprint(wc) __istype((wc), _CTYPE_R)
6208#define iswpunct(wc) __istype((wc), _CTYPE_P)
6209#define iswspace(wc) __istype((wc), _CTYPE_S)
6210#define iswupper(wc) __istype((wc), _CTYPE_U)
6211#define iswxdigit(wc) __istype((wc), _CTYPE_X)
6212#define towlower(wc) __tolower(wc)
6213#define towupper(wc) __toupper(wc)
6214
6215#if __BSD_VISIBLE
6216#define iswascii(wc) (((wc) & ~0x7F) == 0)
6217#define iswhexnumber(wc) __istype((wc), _CTYPE_X) /* alias of iswxdigit */
6218#define iswideogram(wc) __istype((wc), _CTYPE_I)
6219#define iswnumber(wc) __istype((wc), _CTYPE_D|_CTYPE_N)
6220#define iswphonogram(wc) __istype((wc), _CTYPE_Q)
6221#define iswrune(wc) __istype((wc), 0xFFFFFF00L)
6222#define iswspecial(wc) __istype((wc), _CTYPE_T)
6223#endif /* __BSD_VISIBLE */
6224# 123 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
6225#endif /* __cplusplus */
6226# 124 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
6227
6228#endif /* _WCTYPE_H_ */
6229# 126 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/wctype.h"
6230# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
6231
6232#if 0 /* expanded by -frewrite-includes */
6233#include "collate.h"
6234#endif /* expanded by -frewrite-includes */
6235# 58 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
6236# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h" 1
6237/*-
6238 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
6239 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
6240 * at Electronni Visti IA, Kiev, Ukraine.
6241 * All rights reserved.
6242 *
6243 * Copyright (c) 2011 The FreeBSD Foundation
6244 * All rights reserved.
6245 * Portions of this software were developed by David Chisnall
6246 * under sponsorship from the FreeBSD Foundation.
6247 *
6248 * Redistribution and use in source and binary forms, with or without
6249 * modification, are permitted provided that the following conditions
6250 * are met:
6251 * 1. Redistributions of source code must retain the above copyright
6252 * notice, this list of conditions and the following disclaimer.
6253 * 2. Redistributions in binary form must reproduce the above copyright
6254 * notice, this list of conditions and the following disclaimer in the
6255 * documentation and/or other materials provided with the distribution.
6256 *
6257 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
6258 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6259 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6260 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
6261 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6262 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6263 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6264 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6265 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6266 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6267 * SUCH DAMAGE.
6268 *
6269 * $FreeBSD$
6270 */
6271
6272#ifndef _COLLATE_H_
6273#define _COLLATE_H_
6274
6275#if 0 /* expanded by -frewrite-includes */
6276#include <sys/cdefs.h>
6277#endif /* expanded by -frewrite-includes */
6278# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6279# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6280#if 0 /* expanded by -frewrite-includes */
6281#include <sys/types.h>
6282#endif /* expanded by -frewrite-includes */
6283# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6284# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6285#if 0 /* expanded by -frewrite-includes */
6286#include <limits.h>
6287#endif /* expanded by -frewrite-includes */
6288# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6289# 42 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6290#if 0 /* expanded by -frewrite-includes */
6291#include "xlocale_private.h"
6292#endif /* expanded by -frewrite-includes */
6293# 42 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
6294# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h" 1
6295/*-
6296 * Copyright (c) 2011 The FreeBSD Foundation
6297 * All rights reserved.
6298 *
6299 * This software was developed by David Chisnall under sponsorship from
6300 * the FreeBSD Foundation.
6301 *
6302 * Redistribution and use in source and binary forms, with or without
6303 * modification, are permitted provided that the following conditions
6304 * are met:
6305 * 1. Redistributions of source code must retain the above copyright
6306 * notice, this list of conditions and the following disclaimer.
6307 * 2. Redistributions in binary form must reproduce the above copyright
6308 * notice, this list of conditions and the following disclaimer in the
6309 * documentation and/or other materials provided with the distribution.
6310 *
6311 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6312 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6313 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6314 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6315 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6316 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6317 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6318 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6319 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6320 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6321 * SUCH DAMAGE.
6322 *
6323 * $FreeBSD$
6324 */
6325
6326#ifndef _XLOCALE_PRIVATE__H_
6327#define _XLOCALE_PRIVATE__H_
6328
6329#if 0 /* expanded by -frewrite-includes */
6330#include <xlocale.h>
6331#endif /* expanded by -frewrite-includes */
6332# 35 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
6333# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 1
6334/*-
6335 * Copyright (c) 2011, 2012 The FreeBSD Foundation
6336 * All rights reserved.
6337 *
6338 * This software was developed by David Chisnall under sponsorship from
6339 * the FreeBSD Foundation.
6340 *
6341 * Redistribution and use in source and binary forms, with or without
6342 * modification, are permitted provided that the following conditions
6343 * are met:
6344 * 1. Redistributions of source code must retain the above copyright
6345 * notice, this list of conditions and the following disclaimer.
6346 * 2. Redistributions in binary form must reproduce the above copyright
6347 * notice, this list of conditions and the following disclaimer in the
6348 * documentation and/or other materials provided with the distribution.
6349 *
6350 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6351 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6352 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6353 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6354 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6355 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6356 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6357 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6358 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6359 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6360 * SUCH DAMAGE.
6361 *
6362 * $FreeBSD$
6363 */
6364
6365#ifndef _XLOCALE_H_
6366#define _XLOCALE_H_
6367
6368#if 0 /* expanded by -frewrite-includes */
6369#include <locale.h>
6370#endif /* expanded by -frewrite-includes */
6371# 35 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6372# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h" 1
6373/*
6374 * Copyright (c) 1991, 1993
6375 * The Regents of the University of California. All rights reserved.
6376 *
6377 * Redistribution and use in source and binary forms, with or without
6378 * modification, are permitted provided that the following conditions
6379 * are met:
6380 * 1. Redistributions of source code must retain the above copyright
6381 * notice, this list of conditions and the following disclaimer.
6382 * 2. Redistributions in binary form must reproduce the above copyright
6383 * notice, this list of conditions and the following disclaimer in the
6384 * documentation and/or other materials provided with the distribution.
6385 * 3. Neither the name of the University nor the names of its contributors
6386 * may be used to endorse or promote products derived from this software
6387 * without specific prior written permission.
6388 *
6389 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
6390 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6391 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6392 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
6393 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6394 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6395 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6396 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6397 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6398 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6399 * SUCH DAMAGE.
6400 *
6401 * @(#)locale.h 8.1 (Berkeley) 6/2/93
6402 * $FreeBSD$
6403 */
6404
6405#ifndef _LOCALE_H_
6406#define _LOCALE_H_
6407
6408#if 0 /* expanded by -frewrite-includes */
6409#include <sys/_null.h>
6410#endif /* expanded by -frewrite-includes */
6411# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6412# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6413
6414struct lconv {
6415 char *decimal_point;
6416 char *thousands_sep;
6417 char *grouping;
6418 char *int_curr_symbol;
6419 char *currency_symbol;
6420 char *mon_decimal_point;
6421 char *mon_thousands_sep;
6422 char *mon_grouping;
6423 char *positive_sign;
6424 char *negative_sign;
6425 char int_frac_digits;
6426 char frac_digits;
6427 char p_cs_precedes;
6428 char p_sep_by_space;
6429 char n_cs_precedes;
6430 char n_sep_by_space;
6431 char p_sign_posn;
6432 char n_sign_posn;
6433 char int_p_cs_precedes;
6434 char int_n_cs_precedes;
6435 char int_p_sep_by_space;
6436 char int_n_sep_by_space;
6437 char int_p_sign_posn;
6438 char int_n_sign_posn;
6439};
6440
6441#define LC_ALL 0
6442#define LC_COLLATE 1
6443#define LC_CTYPE 2
6444#define LC_MONETARY 3
6445#define LC_NUMERIC 4
6446#define LC_TIME 5
6447#define LC_MESSAGES 6
6448
6449#define _LC_LAST 7 /* marks end */
6450
6451#if 0 /* expanded by -frewrite-includes */
6452#include <sys/cdefs.h>
6453#endif /* expanded by -frewrite-includes */
6454# 75 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6455# 76 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6456
6457__BEGIN_DECLS
6458struct lconv *localeconv(void);
6459char *setlocale(int, const char *);
6460
6461#if __POSIX_VISIBLE >= 200809
6462#if 0 /* expanded by -frewrite-includes */
6463#include <xlocale/_locale.h>
6464#endif /* expanded by -frewrite-includes */
6465# 82 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6466# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_locale.h" 1
6467/*-
6468 * Copyright (c) 2011, 2012 The FreeBSD Foundation
6469 * All rights reserved.
6470 *
6471 * This software was developed by David Chisnall under sponsorship from
6472 * the FreeBSD Foundation.
6473 *
6474 * Redistribution and use in source and binary forms, with or without
6475 * modification, are permitted provided that the following conditions
6476 * are met:
6477 * 1. Redistributions of source code must retain the above copyright
6478 * notice, this list of conditions and the following disclaimer.
6479 * 2. Redistributions in binary form must reproduce the above copyright
6480 * notice, this list of conditions and the following disclaimer in the
6481 * documentation and/or other materials provided with the distribution.
6482 *
6483 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6484 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6485 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6486 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6487 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6488 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6489 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6490 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6491 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6492 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6493 * SUCH DAMAGE.
6494 *
6495 * $FreeBSD$
6496 */
6497
6498#ifndef _XLOCALE_LOCALE_H
6499#define _XLOCALE_LOCALE_H
6500
6501#define LC_COLLATE_MASK (1<<0)
6502#define LC_CTYPE_MASK (1<<1)
6503#define LC_MESSAGES_MASK (1<<2)
6504#define LC_MONETARY_MASK (1<<3)
6505#define LC_NUMERIC_MASK (1<<4)
6506#define LC_TIME_MASK (1<<5)
6507#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | \
6508 LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
6509#define LC_GLOBAL_LOCALE ((locale_t)-1)
6510
6511#ifndef _LOCALE_T_DEFINED
6512#define _LOCALE_T_DEFINED
6513typedef struct _xlocale *locale_t;
6514#endif
6515# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_locale.h"
6516
6517locale_t duplocale(locale_t base);
6518int freelocale(locale_t loc);
6519locale_t newlocale(int mask, const char *locale, locale_t base);
6520const char *querylocale(int mask, locale_t loc);
6521locale_t uselocale(locale_t loc);
6522
6523#endif /* _XLOCALE_LOCALE_H */
6524# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_locale.h"
6525# 83 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h" 2
6526#endif
6527# 84 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6528__END_DECLS
6529
6530
6531#endif /* _LOCALE_H_ */
6532# 88 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/locale.h"
6533# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
6534__BEGIN_DECLS
6535#if 0 /* expanded by -frewrite-includes */
6536#include <xlocale/_locale.h>
6537#endif /* expanded by -frewrite-includes */
6538# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6539# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6540
6541#ifdef _STRING_H_
6542#if 0 /* expanded by -frewrite-includes */
6543#include <xlocale/_string.h>
6544#endif /* expanded by -frewrite-includes */
6545# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6546# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h" 1
6547/*-
6548 * Copyright (c) 2011, 2012 The FreeBSD Foundation
6549 * All rights reserved.
6550 *
6551 * Redistribution and use in source and binary forms, with or without
6552 * modification, are permitted provided that the following conditions
6553 * are met:
6554 * 1. Redistributions of source code must retain the above copyright
6555 * notice, this list of conditions and the following disclaimer.
6556 * 2. Redistributions in binary form must reproduce the above copyright
6557 * notice, this list of conditions and the following disclaimer in the
6558 * documentation and/or other materials provided with the distribution.
6559 *
6560 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6561 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6562 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6563 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6564 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6565 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6566 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6567 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6568 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6569 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6570 * SUCH DAMAGE.
6571 *
6572 * $FreeBSD$
6573 */
6574
6575#ifndef _LOCALE_T_DEFINED
6576#define _LOCALE_T_DEFINED
6577typedef struct _xlocale *locale_t;
6578#endif
6579# 33 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
6580
6581/*
6582 * This file is included from both string.h and xlocale.h. We need to expose
6583 * the declarations unconditionally if we are included from xlocale.h, but only
6584 * if we are in POSIX2008 mode if included from string.h.
6585 */
6586
6587#ifndef _XLOCALE_STRING1_H
6588#define _XLOCALE_STRING1_H
6589
6590/*
6591 * POSIX2008 functions
6592 */
6593int strcoll_l(const char *, const char *, locale_t);
6594size_t strxfrm_l(char *, const char *, size_t, locale_t);
6595#endif /* _XLOCALE_STRING1_H */
6596# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
6597
6598/*
6599 * xlocale extensions
6600 */
6601#ifdef _XLOCALE_H_
6602#ifndef _XLOCALE_STRING2_H
6603#define _XLOCALE_STRING2_H
6604char *strcasestr_l(const char *, const char *, locale_t);
6605
6606#endif /* _XLOCALE_STRING2_H */
6607# 59 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
6608#endif /* _XLOCALE_H_ */
6609# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_string.h"
6610# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
6611#endif
6612# 42 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6613
6614#ifdef _INTTYPES_H_
6615#if 0 /* expanded by -frewrite-includes */
6616#include <xlocale/_inttypes.h>
6617#endif /* expanded by -frewrite-includes */
6618# 44 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6619# 45 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6620#endif
6621# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6622
6623#ifdef _MONETARY_H_
6624#if 0 /* expanded by -frewrite-includes */
6625#include <xlocale/_monetary.h>
6626#endif /* expanded by -frewrite-includes */
6627# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6628# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6629#endif
6630# 50 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6631
6632#ifdef _STDLIB_H_
6633#if 0 /* expanded by -frewrite-includes */
6634#include <xlocale/_stdlib.h>
6635#endif /* expanded by -frewrite-includes */
6636# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6637# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_stdlib.h" 1
6638/*-
6639 * Copyright (c) 2011, 2012 The FreeBSD Foundation
6640 * All rights reserved.
6641 *
6642 * This software was developed by David Chisnall under sponsorship from
6643 * the FreeBSD Foundation.
6644 *
6645 * Redistribution and use in source and binary forms, with or without
6646 * modification, are permitted provided that the following conditions
6647 * are met:
6648 * 1. Redistributions of source code must retain the above copyright
6649 * notice, this list of conditions and the following disclaimer.
6650 * 2. Redistributions in binary form must reproduce the above copyright
6651 * notice, this list of conditions and the following disclaimer in the
6652 * documentation and/or other materials provided with the distribution.
6653 *
6654 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6655 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6656 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6657 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6658 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6659 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6660 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6661 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6662 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6663 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6664 * SUCH DAMAGE.
6665 *
6666 * $FreeBSD$
6667 */
6668
6669/*
6670 * Extended locale versions of the locale-aware functions from stdlib.h.
6671 *
6672 * Include <stdlib.h> before <xlocale.h> to expose these.
6673 */
6674double atof_l(const char *, locale_t);
6675int atoi_l(const char *, locale_t);
6676long atol_l(const char *, locale_t);
6677long long atoll_l(const char *, locale_t);
6678int mblen_l(const char *, size_t, locale_t);
6679size_t mbstowcs_l(wchar_t * __restrict,
6680 const char * __restrict, size_t, locale_t);
6681int mbtowc_l(wchar_t * __restrict,
6682 const char * __restrict, size_t, locale_t);
6683double strtod_l(const char *, char **, locale_t);
6684float strtof_l(const char *, char **, locale_t);
6685long strtol_l(const char *, char **, int, locale_t);
6686long double strtold_l(const char *, char **, locale_t);
6687long long strtoll_l(const char *, char **, int, locale_t);
6688unsigned long strtoul_l(const char *, char **, int, locale_t);
6689unsigned long long strtoull_l(const char *, char **, int, locale_t);
6690size_t wcstombs_l(char * __restrict,
6691 const wchar_t * __restrict, size_t, locale_t);
6692int wctomb_l(char *, wchar_t, locale_t);
6693
6694int ___mb_cur_max_l(locale_t);
6695#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
6696
6697#if __has_feature(capabilities)
6698long strtol_l_c(__capability const char *,
6699 __capability char **, int, locale_t);
6700#endif
6701# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_stdlib.h"
6702# 53 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
6703#endif
6704# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6705
6706#ifdef _TIME_H_
6707#if 0 /* expanded by -frewrite-includes */
6708#include <xlocale/_time.h>
6709#endif /* expanded by -frewrite-includes */
6710# 56 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6711# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6712#endif
6713# 58 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6714
6715#ifdef _LANGINFO_H_
6716#if 0 /* expanded by -frewrite-includes */
6717#include <xlocale/_langinfo.h>
6718#endif /* expanded by -frewrite-includes */
6719# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6720# 61 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6721#endif
6722# 62 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6723
6724#ifdef _CTYPE_H_
6725#if 0 /* expanded by -frewrite-includes */
6726#include <xlocale/_ctype.h>
6727#endif /* expanded by -frewrite-includes */
6728# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6729# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h" 1
6730/*-
6731 * Copyright (c) 2011 The FreeBSD Foundation
6732 * All rights reserved.
6733 *
6734 * This software was developed by David Chisnall under sponsorship from
6735 * the FreeBSD Foundation.
6736 *
6737 * Redistribution and use in source and binary forms, with or without
6738 * modification, are permitted provided that the following conditions
6739 * are met:
6740 * 1. Redistributions of source code must retain the above copyright
6741 * notice, this list of conditions and the following disclaimer.
6742 * 2. Redistributions in binary form must reproduce the above copyright
6743 * notice, this list of conditions and the following disclaimer in the
6744 * documentation and/or other materials provided with the distribution.
6745 *
6746 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6747 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6748 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6749 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6750 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6751 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6752 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6753 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6754 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6755 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6756 * SUCH DAMAGE.
6757 *
6758 * $FreeBSD$
6759 */
6760
6761
6762#if (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
6763 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H))
6764
6765#ifdef _XLOCALE_WCTYPES
6766#define _XLOCALE_WCTYPE_H
6767#else
6768# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6769#define _XLOCALE_CTYPE_H
6770#endif
6771# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6772
6773#ifndef _LOCALE_T_DEFINED
6774#define _LOCALE_T_DEFINED
6775typedef struct _xlocale *locale_t;
6776#endif
6777# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6778
6779#ifndef _XLOCALE_RUN_FUNCTIONS_DEFINED
6780#define _XLOCALE_RUN_FUNCTIONS_DEFINED 1
6781unsigned long ___runetype_l(__ct_rune_t, locale_t) __pure;
6782__ct_rune_t ___tolower_l(__ct_rune_t, locale_t) __pure;
6783__ct_rune_t ___toupper_l(__ct_rune_t, locale_t) __pure;
6784_RuneLocale *__runes_for_locale(locale_t, int*);
6785#endif
6786# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6787
6788#ifndef _XLOCALE_INLINE
6789#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
6790/* GNU89 inline has nonstandard semantics. */
6791#define _XLOCALE_INLINE extern __inline
6792#else
6793# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6794/* Hack to work around people who define inline away */
6795#ifdef inline
6796#define _XLOCALE_INLINE static __inline
6797#else
6798# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6799/* Define with C++ / C99 compatible semantics */
6800#define _XLOCALE_INLINE inline
6801#endif
6802# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6803#endif
6804# 68 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6805#endif /* _XLOCALE_INLINE */
6806# 69 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6807
6808#ifdef _XLOCALE_WCTYPES
6809_XLOCALE_INLINE int
6810__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6811_XLOCALE_INLINE int
6812__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6813
6814_XLOCALE_INLINE int
6815__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6816{
6817 int __limit;
6818 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
6819 return ((__c < 0 || __c >= _CACHED_RUNES) ? ___runetype_l(__c, __loc) :
6820 runes->__runetype[__c]) & __f;
6821}
6822
6823_XLOCALE_INLINE int
6824__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6825{
6826 return (!!__maskrune_l(__c, __f, __loc));
6827}
6828
6829#define XLOCALE_ISCTYPE(fname, cat) \
6830 _XLOCALE_INLINE int isw##fname##_l(int, locale_t);\
6831 _XLOCALE_INLINE int isw##fname##_l(int __c, locale_t __l)\
6832 { return __istype_l(__c, cat, __l); }
6833#else
6834# 96 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6835_XLOCALE_INLINE int
6836__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6837_XLOCALE_INLINE int
6838__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
6839
6840_XLOCALE_INLINE int
6841__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6842{
6843 int __limit;
6844 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
6845 return (__c < 0 || __c >= __limit) ? 0 :
6846 runes->__runetype[__c] & __f;
6847}
6848
6849_XLOCALE_INLINE int
6850__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
6851{
6852 return (!!__sbmaskrune_l(__c, __f, __loc));
6853}
6854
6855#define XLOCALE_ISCTYPE(__fname, __cat) \
6856 _XLOCALE_INLINE int is##__fname##_l(int, locale_t); \
6857 _XLOCALE_INLINE int is##__fname##_l(int __c, locale_t __l)\
6858 { return __sbistype_l(__c, __cat, __l); }
6859#endif
6860# 121 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6861
6862XLOCALE_ISCTYPE(alnum, _CTYPE_A|_CTYPE_D|_CTYPE_N)
6863XLOCALE_ISCTYPE(alpha, _CTYPE_A)
6864XLOCALE_ISCTYPE(blank, _CTYPE_B)
6865XLOCALE_ISCTYPE(cntrl, _CTYPE_C)
6866XLOCALE_ISCTYPE(digit, _CTYPE_D)
6867XLOCALE_ISCTYPE(graph, _CTYPE_G)
6868XLOCALE_ISCTYPE(hexnumber, _CTYPE_X)
6869XLOCALE_ISCTYPE(ideogram, _CTYPE_I)
6870XLOCALE_ISCTYPE(lower, _CTYPE_L)
6871XLOCALE_ISCTYPE(number, _CTYPE_D|_CTYPE_N)
6872XLOCALE_ISCTYPE(phonogram, _CTYPE_Q)
6873XLOCALE_ISCTYPE(print, _CTYPE_R)
6874XLOCALE_ISCTYPE(punct, _CTYPE_P)
6875XLOCALE_ISCTYPE(rune, 0xFFFFFF00L)
6876XLOCALE_ISCTYPE(space, _CTYPE_S)
6877XLOCALE_ISCTYPE(special, _CTYPE_T)
6878XLOCALE_ISCTYPE(upper, _CTYPE_U)
6879XLOCALE_ISCTYPE(xdigit, _CTYPE_X)
6880#undef XLOCALE_ISCTYPE
6881
6882#ifdef _XLOCALE_WCTYPES
6883_XLOCALE_INLINE int towlower_l(int, locale_t);
6884_XLOCALE_INLINE int __wcwidth_l(__ct_rune_t, locale_t);
6885_XLOCALE_INLINE int towupper_l(int, locale_t);
6886
6887_XLOCALE_INLINE int towlower_l(int __c, locale_t __l)
6888{
6889 int __limit;
6890 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6891 return (__c < 0 || __c >= _CACHED_RUNES) ? ___tolower_l(__c, __l) :
6892 __runes->__maplower[__c];
6893}
6894_XLOCALE_INLINE int towupper_l(int __c, locale_t __l)
6895{
6896 int __limit;
6897 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6898 return (__c < 0 || __c >= _CACHED_RUNES) ? ___toupper_l(__c, __l) :
6899 __runes->__mapupper[__c];
6900}
6901_XLOCALE_INLINE int
6902__wcwidth_l(__ct_rune_t _c, locale_t __l)
6903{
6904 unsigned int _x;
6905
6906 if (_c == 0)
6907 return (0);
6908 _x = (unsigned int)__maskrune_l(_c, _CTYPE_SWM|_CTYPE_R, __l);
6909 if ((_x & _CTYPE_SWM) != 0)
6910 return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
6911 return ((_x & _CTYPE_R) != 0 ? 1 : -1);
6912}
6913int iswctype_l(wint_t __wc, wctype_t __charclass, locale_t __l);
6914wctype_t wctype_l(const char *property, locale_t __l);
6915wint_t towctrans_l(wint_t __wc, wctrans_t desc, locale_t __l);
6916wint_t nextwctype_l(wint_t __wc, wctype_t wct, locale_t __l);
6917wctrans_t wctrans_l(const char *__charclass, locale_t __l);
6918#undef _XLOCALE_WCTYPES
6919#else
6920# 180 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6921_XLOCALE_INLINE int digittoint_l(int, locale_t);
6922_XLOCALE_INLINE int tolower_l(int, locale_t);
6923_XLOCALE_INLINE int toupper_l(int, locale_t);
6924
6925_XLOCALE_INLINE int digittoint_l(int __c, locale_t __l)
6926{ return __sbmaskrune_l((__c), 0xFF, __l); }
6927
6928_XLOCALE_INLINE int tolower_l(int __c, locale_t __l)
6929{
6930 int __limit;
6931 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6932 return (__c < 0 || __c >= __limit) ? __c :
6933 __runes->__maplower[__c];
6934}
6935_XLOCALE_INLINE int toupper_l(int __c, locale_t __l)
6936{
6937 int __limit;
6938 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
6939 return (__c < 0 || __c >= __limit) ? __c :
6940 __runes->__mapupper[__c];
6941}
6942#endif
6943# 202 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6944#endif /* (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
6945 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H)) */
6946# 204 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6947# 65 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
6948#endif
6949# 66 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6950
6951#ifdef _WCTYPE_H_
6952#define _XLOCALE_WCTYPES 1
6953#if 0 /* expanded by -frewrite-includes */
6954#include <xlocale/_ctype.h>
6955#endif /* expanded by -frewrite-includes */
6956# 69 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
6957# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h" 1
6958/*-
6959 * Copyright (c) 2011 The FreeBSD Foundation
6960 * All rights reserved.
6961 *
6962 * This software was developed by David Chisnall under sponsorship from
6963 * the FreeBSD Foundation.
6964 *
6965 * Redistribution and use in source and binary forms, with or without
6966 * modification, are permitted provided that the following conditions
6967 * are met:
6968 * 1. Redistributions of source code must retain the above copyright
6969 * notice, this list of conditions and the following disclaimer.
6970 * 2. Redistributions in binary form must reproduce the above copyright
6971 * notice, this list of conditions and the following disclaimer in the
6972 * documentation and/or other materials provided with the distribution.
6973 *
6974 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6975 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6976 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6977 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6978 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6979 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6980 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6981 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6982 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6983 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6984 * SUCH DAMAGE.
6985 *
6986 * $FreeBSD$
6987 */
6988
6989
6990#if (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
6991 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H))
6992
6993#ifdef _XLOCALE_WCTYPES
6994#define _XLOCALE_WCTYPE_H
6995#else
6996# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
6997#define _XLOCALE_CTYPE_H
6998#endif
6999# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7000
7001#ifndef _LOCALE_T_DEFINED
7002#define _LOCALE_T_DEFINED
7003typedef struct _xlocale *locale_t;
7004#endif
7005# 46 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7006
7007#ifndef _XLOCALE_RUN_FUNCTIONS_DEFINED
7008#define _XLOCALE_RUN_FUNCTIONS_DEFINED 1
7009unsigned long ___runetype_l(__ct_rune_t, locale_t) __pure;
7010__ct_rune_t ___tolower_l(__ct_rune_t, locale_t) __pure;
7011__ct_rune_t ___toupper_l(__ct_rune_t, locale_t) __pure;
7012_RuneLocale *__runes_for_locale(locale_t, int*);
7013#endif
7014# 54 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7015
7016#ifndef _XLOCALE_INLINE
7017#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
7018/* GNU89 inline has nonstandard semantics. */
7019#define _XLOCALE_INLINE extern __inline
7020#else
7021# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7022/* Hack to work around people who define inline away */
7023#ifdef inline
7024#define _XLOCALE_INLINE static __inline
7025#else
7026# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7027/* Define with C++ / C99 compatible semantics */
7028#define _XLOCALE_INLINE inline
7029#endif
7030# 67 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7031#endif
7032# 68 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7033#endif /* _XLOCALE_INLINE */
7034# 69 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7035
7036#ifdef _XLOCALE_WCTYPES
7037_XLOCALE_INLINE int
7038__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
7039_XLOCALE_INLINE int
7040__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
7041
7042_XLOCALE_INLINE int
7043__maskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
7044{
7045 int __limit;
7046 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
7047 return ((__c < 0 || __c >= _CACHED_RUNES) ? ___runetype_l(__c, __loc) :
7048 runes->__runetype[__c]) & __f;
7049}
7050
7051_XLOCALE_INLINE int
7052__istype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
7053{
7054 return (!!__maskrune_l(__c, __f, __loc));
7055}
7056
7057#define XLOCALE_ISCTYPE(fname, cat) \
7058 _XLOCALE_INLINE int isw##fname##_l(int, locale_t);\
7059 _XLOCALE_INLINE int isw##fname##_l(int __c, locale_t __l)\
7060 { return __istype_l(__c, cat, __l); }
7061#else
7062# 96 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7063_XLOCALE_INLINE int
7064__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
7065_XLOCALE_INLINE int
7066__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc);
7067
7068_XLOCALE_INLINE int
7069__sbmaskrune_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
7070{
7071 int __limit;
7072 _RuneLocale *runes = __runes_for_locale(__loc, &__limit);
7073 return (__c < 0 || __c >= __limit) ? 0 :
7074 runes->__runetype[__c] & __f;
7075}
7076
7077_XLOCALE_INLINE int
7078__sbistype_l(__ct_rune_t __c, unsigned long __f, locale_t __loc)
7079{
7080 return (!!__sbmaskrune_l(__c, __f, __loc));
7081}
7082
7083#define XLOCALE_ISCTYPE(__fname, __cat) \
7084 _XLOCALE_INLINE int is##__fname##_l(int, locale_t); \
7085 _XLOCALE_INLINE int is##__fname##_l(int __c, locale_t __l)\
7086 { return __sbistype_l(__c, __cat, __l); }
7087#endif
7088# 121 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7089
7090XLOCALE_ISCTYPE(alnum, _CTYPE_A|_CTYPE_D|_CTYPE_N)
7091XLOCALE_ISCTYPE(alpha, _CTYPE_A)
7092XLOCALE_ISCTYPE(blank, _CTYPE_B)
7093XLOCALE_ISCTYPE(cntrl, _CTYPE_C)
7094XLOCALE_ISCTYPE(digit, _CTYPE_D)
7095XLOCALE_ISCTYPE(graph, _CTYPE_G)
7096XLOCALE_ISCTYPE(hexnumber, _CTYPE_X)
7097XLOCALE_ISCTYPE(ideogram, _CTYPE_I)
7098XLOCALE_ISCTYPE(lower, _CTYPE_L)
7099XLOCALE_ISCTYPE(number, _CTYPE_D|_CTYPE_N)
7100XLOCALE_ISCTYPE(phonogram, _CTYPE_Q)
7101XLOCALE_ISCTYPE(print, _CTYPE_R)
7102XLOCALE_ISCTYPE(punct, _CTYPE_P)
7103XLOCALE_ISCTYPE(rune, 0xFFFFFF00L)
7104XLOCALE_ISCTYPE(space, _CTYPE_S)
7105XLOCALE_ISCTYPE(special, _CTYPE_T)
7106XLOCALE_ISCTYPE(upper, _CTYPE_U)
7107XLOCALE_ISCTYPE(xdigit, _CTYPE_X)
7108#undef XLOCALE_ISCTYPE
7109
7110#ifdef _XLOCALE_WCTYPES
7111_XLOCALE_INLINE int towlower_l(int, locale_t);
7112_XLOCALE_INLINE int __wcwidth_l(__ct_rune_t, locale_t);
7113_XLOCALE_INLINE int towupper_l(int, locale_t);
7114
7115_XLOCALE_INLINE int towlower_l(int __c, locale_t __l)
7116{
7117 int __limit;
7118 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
7119 return (__c < 0 || __c >= _CACHED_RUNES) ? ___tolower_l(__c, __l) :
7120 __runes->__maplower[__c];
7121}
7122_XLOCALE_INLINE int towupper_l(int __c, locale_t __l)
7123{
7124 int __limit;
7125 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
7126 return (__c < 0 || __c >= _CACHED_RUNES) ? ___toupper_l(__c, __l) :
7127 __runes->__mapupper[__c];
7128}
7129_XLOCALE_INLINE int
7130__wcwidth_l(__ct_rune_t _c, locale_t __l)
7131{
7132 unsigned int _x;
7133
7134 if (_c == 0)
7135 return (0);
7136 _x = (unsigned int)__maskrune_l(_c, _CTYPE_SWM|_CTYPE_R, __l);
7137 if ((_x & _CTYPE_SWM) != 0)
7138 return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
7139 return ((_x & _CTYPE_R) != 0 ? 1 : -1);
7140}
7141int iswctype_l(wint_t __wc, wctype_t __charclass, locale_t __l);
7142wctype_t wctype_l(const char *property, locale_t __l);
7143wint_t towctrans_l(wint_t __wc, wctrans_t desc, locale_t __l);
7144wint_t nextwctype_l(wint_t __wc, wctype_t wct, locale_t __l);
7145wctrans_t wctrans_l(const char *__charclass, locale_t __l);
7146#undef _XLOCALE_WCTYPES
7147#else
7148# 180 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7149_XLOCALE_INLINE int digittoint_l(int, locale_t);
7150_XLOCALE_INLINE int tolower_l(int, locale_t);
7151_XLOCALE_INLINE int toupper_l(int, locale_t);
7152
7153_XLOCALE_INLINE int digittoint_l(int __c, locale_t __l)
7154{ return __sbmaskrune_l((__c), 0xFF, __l); }
7155
7156_XLOCALE_INLINE int tolower_l(int __c, locale_t __l)
7157{
7158 int __limit;
7159 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
7160 return (__c < 0 || __c >= __limit) ? __c :
7161 __runes->__maplower[__c];
7162}
7163_XLOCALE_INLINE int toupper_l(int __c, locale_t __l)
7164{
7165 int __limit;
7166 _RuneLocale *__runes = __runes_for_locale(__l, &__limit);
7167 return (__c < 0 || __c >= __limit) ? __c :
7168 __runes->__mapupper[__c];
7169}
7170#endif
7171# 202 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7172#endif /* (defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_WCTYPE_H)) || \
7173 (!defined(_XLOCALE_WCTYPES) && !defined(_XLOCALE_CTYPE_H)) */
7174# 204 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_ctype.h"
7175# 70 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
7176#endif
7177# 71 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
7178
7179#ifdef _STDIO_H_
7180#if 0 /* expanded by -frewrite-includes */
7181#include <xlocale/_stdio.h>
7182#endif /* expanded by -frewrite-includes */
7183# 73 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
7184# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_stdio.h" 1
7185/*-
7186 * Copyright (c) 2011, 2012 The FreeBSD Foundation
7187 * All rights reserved.
7188 *
7189 * This software was developed by David Chisnall under sponsorship from
7190 * the FreeBSD Foundation.
7191 *
7192 * Redistribution and use in source and binary forms, with or without
7193 * modification, are permitted provided that the following conditions
7194 * are met:
7195 * 1. Redistributions of source code must retain the above copyright
7196 * notice, this list of conditions and the following disclaimer.
7197 * 2. Redistributions in binary form must reproduce the above copyright
7198 * notice, this list of conditions and the following disclaimer in the
7199 * documentation and/or other materials provided with the distribution.
7200 *
7201 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7202 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7203 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7204 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7205 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7206 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7207 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7208 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7209 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7210 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7211 * SUCH DAMAGE.
7212 *
7213 * $FreeBSD$
7214 */
7215
7216int asprintf_l(char **, locale_t, const char *, ...) __printflike(3, 4);
7217int dprintf_l(int, locale_t, const char * __restrict, ...)
7218 __printflike(3, 4);
7219int fprintf_l(FILE * __restrict, locale_t, const char * __restrict, ...)
7220 __printflike(3, 4);
7221int fscanf_l(FILE * __restrict, locale_t, const char * __restrict, ...)
7222 __scanflike(3, 4);
7223int printf_l(locale_t, const char * __restrict, ...) __printflike(2, 3);
7224int scanf_l(locale_t, const char * __restrict, ...) __scanflike(2, 3);
7225int snprintf_l(char * __restrict, size_t, locale_t,
7226 const char * __restrict, ...) __printflike(4, 5);
7227int sprintf_l(char * __restrict, locale_t, const char * __restrict, ...)
7228 __printflike(3, 4);
7229int sscanf_l(const char * __restrict, locale_t, const char * __restrict,
7230 ...) __scanflike(3, 4);
7231int vfprintf_l(FILE * __restrict, locale_t, const char * __restrict,
7232 __va_list) __printflike(3, 0);
7233int vprintf_l(locale_t, const char * __restrict, __va_list)
7234 __printflike(2, 0);
7235int vsprintf_l(char * __restrict, locale_t, const char * __restrict,
7236 __va_list) __printflike(3, 0);
7237int vfscanf_l(FILE * __restrict, locale_t, const char * __restrict,
7238 __va_list) __scanflike(3, 0);
7239int vscanf_l(locale_t, const char * __restrict, __va_list)
7240 __scanflike(2, 0);
7241int vsnprintf_l(char * __restrict, size_t, locale_t,
7242 const char * __restrict, __va_list) __printflike(4, 0);
7243int vsscanf_l(const char * __restrict, locale_t, const char * __restrict,
7244 __va_list) __scanflike(3, 0);
7245int vdprintf_l(int, locale_t, const char * __restrict, __va_list)
7246 __printflike(3, 0);
7247int vasprintf_l(char **, locale_t, const char *, __va_list)
7248 __printflike(3, 0);
7249# 74 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
7250#endif
7251# 75 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
7252
7253#ifdef _WCHAR_H_
7254#if 0 /* expanded by -frewrite-includes */
7255#include <xlocale/_wchar.h>
7256#endif /* expanded by -frewrite-includes */
7257# 77 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
7258# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h" 1
7259/*-
7260 * Copyright (c) 2011, 2012 The FreeBSD Foundation
7261 * All rights reserved.
7262 *
7263 * This software was developed by David Chisnall under sponsorship from
7264 * the FreeBSD Foundation.
7265 *
7266 * Redistribution and use in source and binary forms, with or without
7267 * modification, are permitted provided that the following conditions
7268 * are met:
7269 * 1. Redistributions of source code must retain the above copyright
7270 * notice, this list of conditions and the following disclaimer.
7271 * 2. Redistributions in binary form must reproduce the above copyright
7272 * notice, this list of conditions and the following disclaimer in the
7273 * documentation and/or other materials provided with the distribution.
7274 *
7275 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7276 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7277 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7278 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7279 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7280 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7281 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7282 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7283 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7284 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7285 * SUCH DAMAGE.
7286 *
7287 * $FreeBSD$
7288 */
7289
7290#ifndef _LOCALE_T_DEFINED
7291#define _LOCALE_T_DEFINED
7292typedef struct _xlocale *locale_t;
7293#endif
7294# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
7295
7296#ifndef _XLOCALE_WCHAR1_H
7297#define _XLOCALE_WCHAR1_H
7298int wcscasecmp_l(const wchar_t *, const wchar_t *,
7299 locale_t);
7300int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t,
7301 locale_t);
7302int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
7303size_t wcsxfrm_l(wchar_t * __restrict,
7304 const wchar_t * __restrict, size_t, locale_t);
7305
7306#endif /* _XLOCALE_WCHAR1_H */
7307# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
7308
7309/*
7310 * Only declare the non-POSIX functions if we're included from xlocale.h.
7311 */
7312
7313#ifdef _XLOCALE_H_
7314#ifndef _XLOCALE_WCHAR2_H
7315#define _XLOCALE_WCHAR2_H
7316
7317wint_t btowc_l(int, locale_t);
7318wint_t fgetwc_l(FILE *, locale_t);
7319wchar_t *fgetws_l(wchar_t * __restrict, int, FILE * __restrict,
7320 locale_t);
7321wint_t fputwc_l(wchar_t, FILE *, locale_t);
7322int fputws_l(const wchar_t * __restrict, FILE * __restrict,
7323 locale_t);
7324int fwprintf_l(FILE * __restrict, locale_t,
7325 const wchar_t * __restrict, ...);
7326int fwscanf_l(FILE * __restrict, locale_t,
7327 const wchar_t * __restrict, ...);
7328wint_t getwc_l(FILE *, locale_t);
7329wint_t getwchar_l(locale_t);
7330size_t mbrlen_l(const char * __restrict, size_t,
7331 mbstate_t * __restrict, locale_t);
7332size_t mbrtowc_l(wchar_t * __restrict,
7333 const char * __restrict, size_t,
7334 mbstate_t * __restrict, locale_t);
7335int mbsinit_l(const mbstate_t *, locale_t);
7336size_t mbsrtowcs_l(wchar_t * __restrict,
7337 const char ** __restrict, size_t,
7338 mbstate_t * __restrict, locale_t);
7339wint_t putwc_l(wchar_t, FILE *, locale_t);
7340wint_t putwchar_l(wchar_t, locale_t);
7341int swprintf_l(wchar_t * __restrict, size_t n, locale_t,
7342 const wchar_t * __restrict, ...);
7343int swscanf_l(const wchar_t * __restrict, locale_t,
7344 const wchar_t * __restrict, ...);
7345wint_t ungetwc_l(wint_t, FILE *, locale_t);
7346int vfwprintf_l(FILE * __restrict, locale_t,
7347 const wchar_t * __restrict, __va_list);
7348int vswprintf_l(wchar_t * __restrict, size_t n, locale_t,
7349 const wchar_t * __restrict, __va_list);
7350int vwprintf_l(locale_t, const wchar_t * __restrict,
7351 __va_list);
7352size_t wcrtomb_l(char * __restrict, wchar_t,
7353 mbstate_t * __restrict, locale_t);
7354size_t wcsftime_l(wchar_t * __restrict, size_t,
7355 const wchar_t * __restrict,
7356 const struct tm * __restrict, locale_t);
7357size_t wcsrtombs_l(char * __restrict,
7358 const wchar_t ** __restrict, size_t,
7359 mbstate_t * __restrict, locale_t);
7360double wcstod_l(const wchar_t * __restrict,
7361 wchar_t ** __restrict, locale_t);
7362long wcstol_l(const wchar_t * __restrict,
7363 wchar_t ** __restrict, int, locale_t);
7364unsigned long wcstoul_l(const wchar_t * __restrict,
7365 wchar_t ** __restrict, int, locale_t);
7366int wcswidth_l(const wchar_t *, size_t, locale_t);
7367int wctob_l(wint_t, locale_t);
7368int wcwidth_l(wchar_t, locale_t);
7369int wprintf_l(locale_t, const wchar_t * __restrict, ...);
7370int wscanf_l(locale_t, const wchar_t * __restrict, ...);
7371int vfwscanf_l(FILE * __restrict, locale_t,
7372 const wchar_t * __restrict, __va_list);
7373int vswscanf_l(const wchar_t * __restrict, locale_t,
7374 const wchar_t *__restrict, __va_list);
7375int vwscanf_l(locale_t, const wchar_t * __restrict,
7376 __va_list);
7377float wcstof_l(const wchar_t * __restrict,
7378 wchar_t ** __restrict, locale_t);
7379long double wcstold_l(const wchar_t * __restrict,
7380 wchar_t ** __restrict, locale_t);
7381long long wcstoll_l(const wchar_t * __restrict,
7382 wchar_t ** __restrict, int, locale_t);
7383unsigned long long wcstoull_l(const wchar_t * __restrict,
7384 wchar_t ** __restrict, int, locale_t);
7385size_t mbsnrtowcs_l(wchar_t * __restrict,
7386 const char ** __restrict, size_t, size_t,
7387 mbstate_t * __restrict, locale_t);
7388size_t wcsnrtombs_l(char * __restrict,
7389 const wchar_t ** __restrict, size_t, size_t,
7390 mbstate_t * __restrict, locale_t);
7391
7392#endif /* _XLOCALE_WCHAR_H */
7393# 133 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
7394#endif /* _XLOCALE_H_ */
7395# 134 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale/_wchar.h"
7396# 78 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h" 2
7397#endif
7398# 79 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
7399
7400
7401
7402struct lconv *localeconv_l(locale_t);
7403__END_DECLS
7404
7405#endif
7406# 86 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/xlocale.h"
7407# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h" 2
7408#if 0 /* expanded by -frewrite-includes */
7409#include <locale.h>
7410#endif /* expanded by -frewrite-includes */
7411# 36 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7412# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7413#if 0 /* expanded by -frewrite-includes */
7414#include <stdlib.h>
7415#endif /* expanded by -frewrite-includes */
7416# 37 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7417# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7418#if 0 /* expanded by -frewrite-includes */
7419#include <stdint.h>
7420#endif /* expanded by -frewrite-includes */
7421# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7422# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 1 3 4
7423/*-
7424 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
7425 * All rights reserved.
7426 *
7427 * Redistribution and use in source and binary forms, with or without
7428 * modification, are permitted provided that the following conditions
7429 * are met:
7430 * 1. Redistributions of source code must retain the above copyright
7431 * notice, this list of conditions and the following disclaimer.
7432 * 2. Redistributions in binary form must reproduce the above copyright
7433 * notice, this list of conditions and the following disclaimer in the
7434 * documentation and/or other materials provided with the distribution.
7435 *
7436 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7437 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7438 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7439 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7440 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7441 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7442 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7443 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7444 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7445 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7446 * SUCH DAMAGE.
7447 *
7448 * $FreeBSD$
7449 */
7450
7451#ifndef _SYS_STDINT_H_
7452#define _SYS_STDINT_H_
7453
7454#if 0 /* expanded by -frewrite-includes */
7455#include <sys/cdefs.h>
7456#endif /* expanded by -frewrite-includes */
7457# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7458# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7459#if 0 /* expanded by -frewrite-includes */
7460#include <sys/_types.h>
7461#endif /* expanded by -frewrite-includes */
7462# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7463# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7464
7465#if 0 /* expanded by -frewrite-includes */
7466#include <machine/_stdint.h>
7467#endif /* expanded by -frewrite-includes */
7468# 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7469# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 1 3 4
7470/*-
7471 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
7472 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7473 * All rights reserved.
7474 *
7475 * This code is derived from software contributed to The NetBSD Foundation
7476 * by Klaus Klein.
7477 *
7478 * Redistribution and use in source and binary forms, with or without
7479 * modification, are permitted provided that the following conditions
7480 * are met:
7481 * 1. Redistributions of source code must retain the above copyright
7482 * notice, this list of conditions and the following disclaimer.
7483 * 2. Redistributions in binary form must reproduce the above copyright
7484 * notice, this list of conditions and the following disclaimer in the
7485 * documentation and/or other materials provided with the distribution.
7486 * 3. All advertising materials mentioning features or use of this software
7487 * must display the following acknowledgement:
7488 * This product includes software developed by the NetBSD
7489 * Foundation, Inc. and its contributors.
7490 * 4. Neither the name of The NetBSD Foundation nor the names of its
7491 * contributors may be used to endorse or promote products derived
7492 * from this software without specific prior written permission.
7493 *
7494 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
7495 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
7496 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
7497 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
7498 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
7499 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
7500 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7501 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
7502 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7503 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
7504 * POSSIBILITY OF SUCH DAMAGE.
7505 *
7506 * from: src/sys/i386/include/_stdint.h,v 1.2 2004/05/18 16:04:57 stefanf
7507 * $FreeBSD$
7508 */
7509
7510#ifndef _MACHINE__STDINT_H_
7511#define _MACHINE__STDINT_H_
7512
7513#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
7514
7515#define INT8_C(c) (c)
7516#define INT16_C(c) (c)
7517#define INT32_C(c) (c)
7518
7519#define UINT8_C(c) (c)
7520#define UINT16_C(c) (c)
7521#define UINT32_C(c) (c ## U)
7522
7523#ifdef __mips_n64
7524#define INT64_C(c) (c ## L)
7525#define UINT64_C(c) (c ## UL)
7526#else
7527# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7528#define INT64_C(c) (c ## LL)
7529#define UINT64_C(c) (c ## ULL)
7530#endif
7531# 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7532
7533#define INTMAX_C(c) INT64_C(c)
7534#define UINTMAX_C(c) UINT64_C(c)
7535
7536#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
7537# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7538
7539#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
7540
7541#ifndef __INT64_C
7542#ifdef __mips_n64
7543#define __INT64_C(c) (c ## L)
7544#define __UINT64_C(c) (c ## UL)
7545#else
7546# 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7547#define __INT64_C(c) (c ## LL)
7548#define __UINT64_C(c) (c ## ULL)
7549#endif
7550# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7551#endif
7552# 78 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7553
7554/*
7555 * ISO/IEC 9899:1999
7556 * 7.18.2.1 Limits of exact-width integer types
7557 */
7558/* Minimum values of exact-width signed integer types. */
7559#define INT8_MIN (-0x7f-1)
7560#define INT16_MIN (-0x7fff-1)
7561#define INT32_MIN (-0x7fffffff-1)
7562#define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1)
7563
7564/* Maximum values of exact-width signed integer types. */
7565#define INT8_MAX 0x7f
7566#define INT16_MAX 0x7fff
7567#define INT32_MAX 0x7fffffff
7568#define INT64_MAX __INT64_C(0x7fffffffffffffff)
7569
7570/* Maximum values of exact-width unsigned integer types. */
7571#define UINT8_MAX 0xff
7572#define UINT16_MAX 0xffff
7573#define UINT32_MAX 0xffffffff
7574#define UINT64_MAX __UINT64_C(0xffffffffffffffff)
7575
7576/*
7577 * ISO/IEC 9899:1999
7578 * 7.18.2.2 Limits of minimum-width integer types
7579 */
7580/* Minimum values of minimum-width signed integer types. */
7581#define INT_LEAST8_MIN INT8_MIN
7582#define INT_LEAST16_MIN INT16_MIN
7583#define INT_LEAST32_MIN INT32_MIN
7584#define INT_LEAST64_MIN INT64_MIN
7585
7586/* Maximum values of minimum-width signed integer types. */
7587#define INT_LEAST8_MAX INT8_MAX
7588#define INT_LEAST16_MAX INT16_MAX
7589#define INT_LEAST32_MAX INT32_MAX
7590#define INT_LEAST64_MAX INT64_MAX
7591
7592/* Maximum values of minimum-width unsigned integer types. */
7593#define UINT_LEAST8_MAX UINT8_MAX
7594#define UINT_LEAST16_MAX UINT16_MAX
7595#define UINT_LEAST32_MAX UINT32_MAX
7596#define UINT_LEAST64_MAX UINT64_MAX
7597
7598/*
7599 * ISO/IEC 9899:1999
7600 * 7.18.2.3 Limits of fastest minimum-width integer types
7601 */
7602/* Minimum values of fastest minimum-width signed integer types. */
7603#define INT_FAST8_MIN INT32_MIN
7604#define INT_FAST16_MIN INT32_MIN
7605#define INT_FAST32_MIN INT32_MIN
7606#define INT_FAST64_MIN INT64_MIN
7607
7608/* Maximum values of fastest minimum-width signed integer types. */
7609#define INT_FAST8_MAX INT32_MAX
7610#define INT_FAST16_MAX INT32_MAX
7611#define INT_FAST32_MAX INT32_MAX
7612#define INT_FAST64_MAX INT64_MAX
7613
7614/* Maximum values of fastest minimum-width unsigned integer types. */
7615#define UINT_FAST8_MAX UINT32_MAX
7616#define UINT_FAST16_MAX UINT32_MAX
7617#define UINT_FAST32_MAX UINT32_MAX
7618#define UINT_FAST64_MAX UINT64_MAX
7619
7620/*
7621 * ISO/IEC 9899:1999
7622 * 7.18.2.4 Limits of integer types capable of holding object pointers
7623 */
7624#ifdef __mips_n64
7625#define INTPTR_MIN INT64_MIN
7626#define INTPTR_MAX INT64_MAX
7627#define UINTPTR_MAX UINT64_MAX
7628#else
7629# 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7630#define INTPTR_MIN INT32_MIN
7631#define INTPTR_MAX INT32_MAX
7632#define UINTPTR_MAX UINT32_MAX
7633#endif
7634# 158 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7635
7636/*
7637 * ISO/IEC 9899:1999
7638 * 7.18.2.5 Limits of greatest-width integer types
7639 */
7640#define INTMAX_MIN INT64_MIN
7641#define INTMAX_MAX INT64_MAX
7642#define UINTMAX_MAX UINT64_MAX
7643
7644/*
7645 * ISO/IEC 9899:1999
7646 * 7.18.3 Limits of other integer types
7647 */
7648#ifdef __mips_n64
7649/* Limits of ptrdiff_t. */
7650#define PTRDIFF_MIN INT64_MIN
7651#define PTRDIFF_MAX INT64_MAX
7652
7653/* Limit of size_t. */
7654#define SIZE_MAX UINT64_MAX
7655#else
7656# 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7657/* Limits of ptrdiff_t. */
7658#define PTRDIFF_MIN INT32_MIN
7659#define PTRDIFF_MAX INT32_MAX
7660
7661/* Limit of size_t. */
7662#define SIZE_MAX UINT32_MAX
7663#endif
7664# 186 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7665
7666/* Limits of sig_atomic_t. */
7667#define SIG_ATOMIC_MIN INT32_MIN
7668#define SIG_ATOMIC_MAX INT32_MAX
7669
7670/* Limits of wint_t. */
7671#define WINT_MIN INT32_MIN
7672#define WINT_MAX INT32_MAX
7673
7674#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
7675# 196 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7676
7677#endif /* !_MACHINE__STDINT_H_ */
7678# 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
7679# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 2 3 4
7680#if 0 /* expanded by -frewrite-includes */
7681#include <sys/_stdint.h>
7682#endif /* expanded by -frewrite-includes */
7683# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7684# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7685
7686typedef __int_least8_t int_least8_t;
7687typedef __int_least16_t int_least16_t;
7688typedef __int_least32_t int_least32_t;
7689typedef __int_least64_t int_least64_t;
7690
7691typedef __uint_least8_t uint_least8_t;
7692typedef __uint_least16_t uint_least16_t;
7693typedef __uint_least32_t uint_least32_t;
7694typedef __uint_least64_t uint_least64_t;
7695
7696typedef __int_fast8_t int_fast8_t;
7697typedef __int_fast16_t int_fast16_t;
7698typedef __int_fast32_t int_fast32_t;
7699typedef __int_fast64_t int_fast64_t;
7700
7701typedef __uint_fast8_t uint_fast8_t;
7702typedef __uint_fast16_t uint_fast16_t;
7703typedef __uint_fast32_t uint_fast32_t;
7704typedef __uint_fast64_t uint_fast64_t;
7705
7706/* GNU and Darwin define this and people seem to think it's portable */
7707#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)
7708#define __WORDSIZE 64
7709#else
7710# 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7711#define __WORDSIZE 32
7712#endif
7713# 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7714
7715/* Limits of wchar_t. */
7716#define WCHAR_MIN __WCHAR_MIN
7717#define WCHAR_MAX __WCHAR_MAX
7718
7719#endif /* !_SYS_STDINT_H_ */
7720# 70 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdint.h" 3 4
7721# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h" 2
7722#if 0 /* expanded by -frewrite-includes */
7723#include <sys/types.h>
7724#endif /* expanded by -frewrite-includes */
7725# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7726# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7727#if 0 /* expanded by -frewrite-includes */
7728#include <machine/atomic.h>
7729#endif /* expanded by -frewrite-includes */
7730# 40 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
7731# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 1 3 4
7732/*-
7733 * Copyright (c) 1998 Doug Rabson
7734 * All rights reserved.
7735 *
7736 * Redistribution and use in source and binary forms, with or without
7737 * modification, are permitted provided that the following conditions
7738 * are met:
7739 * 1. Redistributions of source code must retain the above copyright
7740 * notice, this list of conditions and the following disclaimer.
7741 * 2. Redistributions in binary form must reproduce the above copyright
7742 * notice, this list of conditions and the following disclaimer in the
7743 * documentation and/or other materials provided with the distribution.
7744 *
7745 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7746 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7747 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7748 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7749 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7750 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7751 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7752 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7753 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7754 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7755 * SUCH DAMAGE.
7756 *
7757 * from: src/sys/alpha/include/atomic.h,v 1.21.2.3 2005/10/06 18:12:05 jhb
7758 * $FreeBSD$
7759 */
7760
7761#ifndef _MACHINE_ATOMIC_H_
7762#define _MACHINE_ATOMIC_H_
7763
7764#ifndef _SYS_CDEFS_H_
7765#error this file needs sys/cdefs.h as a prerequisite
7766#endif
7767# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7768
7769/*
7770 * Note: All the 64-bit atomic operations are only atomic when running
7771 * in 64-bit mode. It is assumed that code compiled for n32 and n64
7772 * fits into this definition and no further safeties are needed.
7773 *
7774 * It is also assumed that the add, subtract and other arithmetic is
7775 * done on numbers not pointers. The special rules for n32 pointers
7776 * do not have atomic operations defined for them, but generally shouldn't
7777 * need atomic operations.
7778 */
7779#ifndef __MIPS_PLATFORM_SYNC_NOPS
7780#define __MIPS_PLATFORM_SYNC_NOPS ""
7781#endif
7782# 50 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7783
7784static __inline void
7785mips_sync(void)
7786{
7787 __asm __volatile (".set noreorder\n"
7788 "\tsync\n"
7789 __MIPS_PLATFORM_SYNC_NOPS
7790 ".set reorder\n"
7791 : : : "memory");
7792}
7793
7794#define mb() mips_sync()
7795#define wmb() mips_sync()
7796#define rmb() mips_sync()
7797
7798/*
7799 * Various simple arithmetic on memory which is atomic in the presence
7800 * of interrupts and SMP safe.
7801 */
7802
7803void atomic_set_8(__volatile uint8_t *, uint8_t);
7804void atomic_clear_8(__volatile uint8_t *, uint8_t);
7805void atomic_add_8(__volatile uint8_t *, uint8_t);
7806void atomic_subtract_8(__volatile uint8_t *, uint8_t);
7807
7808void atomic_set_16(__volatile uint16_t *, uint16_t);
7809void atomic_clear_16(__volatile uint16_t *, uint16_t);
7810void atomic_add_16(__volatile uint16_t *, uint16_t);
7811void atomic_subtract_16(__volatile uint16_t *, uint16_t);
7812
7813static __inline void
7814atomic_set_32(__volatile uint32_t *p, uint32_t v)
7815{
7816 uint32_t temp;
7817
7818#ifndef __CHERI_PURE_CAPABILITY__
7819 __asm __volatile (
7820 "1:\tll %0, %3\n\t" /* load old value */
7821 "or %0, %2, %0\n\t" /* calculate new value */
7822 "sc %0, %1\n\t" /* attempt to store */
7823 "beqz %0, 1b\n\t" /* spin if failed */
7824 : "=&r" (temp), "=m" (*p)
7825 : "r" (v), "m" (*p)
7826 : "memory");
7827#else
7828# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7829 __asm __volatile (
7830 "1:\n\t"
7831 "cllw %0, %3\n\t" /* load old value */
7832 "or %0, %2, %0\n\t" /* calculate new value */
7833 "cscw %0, %0, %1\n\t" /* attempt to store */
7834 "beqz %0, 1b\n\t" /* spin if failed */
7835 : "=&r" (temp), "=C" (p)
7836 : "r" (v), "C" (p)
7837 : "memory");
7838#endif
7839# 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7840
7841}
7842
7843static __inline void
7844atomic_clear_32(__volatile uint32_t *p, uint32_t v)
7845{
7846 uint32_t temp;
7847 v = ~v;
7848
7849#ifndef __CHERI_PURE_CAPABILITY__
7850 __asm __volatile (
7851 "1:\tll %0, %3\n\t" /* load old value */
7852 "and %0, %2, %0\n\t" /* calculate new value */
7853 "sc %0, %1\n\t" /* attempt to store */
7854 "beqz %0, 1b\n\t" /* spin if failed */
7855 : "=&r" (temp), "=m" (*p)
7856 : "r" (v), "m" (*p)
7857 : "memory");
7858#else
7859# 124 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7860 __asm __volatile (
7861 "1:\n\t"
7862 "cllw %0, %3\n\t" /* load old value */
7863 "and %0, %2, %0\n\t" /* calculate new value */
7864 "cscw %0, %0, %1\n\t" /* attempt to store */
7865 "beqz %0, 1b\n\t" /* spin if failed */
7866 : "=&r" (temp), "=C" (p)
7867 : "r" (v), "C" (p)
7868 : "memory");
7869#endif
7870# 134 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7871}
7872
7873static __inline void
7874atomic_add_32(__volatile uint32_t *p, uint32_t v)
7875{
7876 uint32_t temp;
7877
7878#ifndef __CHERI_PURE_CAPABILITY__
7879 __asm __volatile (
7880 "1:\tll %0, %3\n\t" /* load old value */
7881 "addu %0, %2, %0\n\t" /* calculate new value */
7882 "sc %0, %1\n\t" /* attempt to store */
7883 "beqz %0, 1b\n\t" /* spin if failed */
7884 : "=&r" (temp), "=m" (*p)
7885 : "r" (v), "m" (*p)
7886 : "memory");
7887#else
7888# 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7889 __asm __volatile (
7890 "1:\n\t"
7891 "cllw %0, %3\n\t" /* load old value */
7892 "addu %0, %2, %0\n\t" /* calculate new value */
7893 "cscw %0, %0, %1\n\t" /* attempt to store */
7894 "beqz %0, 1b\n\t" /* spin if failed */
7895 : "=&r" (temp), "=C" (p)
7896 : "r" (v), "C" (p)
7897 : "memory");
7898#endif
7899# 161 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7900}
7901
7902static __inline void
7903atomic_subtract_32(__volatile uint32_t *p, uint32_t v)
7904{
7905 uint32_t temp;
7906
7907#ifndef __CHERI_PURE_CAPABILITY__
7908 __asm __volatile (
7909 "1:\tll %0, %3\n\t" /* load old value */
7910 "subu %0, %2\n\t" /* calculate new value */
7911 "sc %0, %1\n\t" /* attempt to store */
7912 "beqz %0, 1b\n\t" /* spin if failed */
7913 : "=&r" (temp), "=m" (*p)
7914 : "r" (v), "m" (*p)
7915 : "memory");
7916#else
7917# 178 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7918 __asm __volatile (
7919 "1:\n\t"
7920 "cllw %0, %3\n\t" /* load old value */
7921 "subu %0, %2\n\t" /* calculate new value */
7922 "cscw %0, %0, %1\n\t" /* attempt to store */
7923 "beqz %0, 1b\n\t" /* spin if failed */
7924 : "=&r" (temp), "=C" (p)
7925 : "r" (v), "C" (p)
7926 : "memory");
7927#endif
7928# 188 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7929}
7930
7931static __inline uint32_t
7932atomic_readandclear_32(__volatile uint32_t *addr)
7933{
7934 uint32_t result,temp;
7935
7936#ifndef __CHERI_PURE_CAPABILITY__
7937 __asm __volatile (
7938 "1:\tll %0,%3\n\t" /* load current value, asserting lock */
7939 "li %1,0\n\t" /* value to store */
7940 "sc %1,%2\n\t" /* attempt to store */
7941 "beqz %1, 1b\n\t" /* if the store failed, spin */
7942 : "=&r"(result), "=&r"(temp), "=m" (*addr)
7943 : "m" (*addr)
7944 : "memory");
7945#else
7946# 205 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7947 __asm __volatile (
7948 "1:\n\t"
7949 "cllw %0, %3\n\t" /* load current value, asserting lock */
7950 "li %1, 0\n\t" /* value to store */
7951 "cscw %1, %1, %2\n\t" /* attempt to store */
7952 "beqz %1, 1b\n\t" /* if the store failed, spin */
7953 : "=&r"(result), "=&r"(temp), "=C" (addr)
7954 : "C" (addr)
7955 : "memory");
7956#endif
7957# 215 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7958
7959 return result;
7960}
7961
7962static __inline uint32_t
7963atomic_readandset_32(__volatile uint32_t *addr, uint32_t value)
7964{
7965 uint32_t result,temp;
7966
7967#ifndef __CHERI_PURE_CAPABILITY__
7968 __asm __volatile (
7969 "1:\tll %0,%3\n\t" /* load current value, asserting lock */
7970 "or %1,$0,%4\n\t"
7971 "sc %1,%2\n\t" /* attempt to store */
7972 "beqz %1, 1b\n\t" /* if the store failed, spin */
7973 : "=&r"(result), "=&r"(temp), "=m" (*addr)
7974 : "m" (*addr), "r" (value)
7975 : "memory");
7976#else
7977# 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7978 __asm __volatile (
7979 "1:\n\t"
7980 "cllw %0, %3\n\t" /* load current value, asserting lock */
7981 "or %1, $0, %4\n\t"
7982 "cscw %1, %1, %2\n\t" /* attempt to store */
7983 "beqz %1, 1b\n\t" /* if the store failed, spin */
7984 : "=&r"(result), "=&r"(temp), "=C" (addr)
7985 : "C" (addr), "r" (value)
7986 : "memory");
7987#endif
7988# 244 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
7989
7990 return result;
7991}
7992
7993#if defined(__mips_n64) || defined(__mips_n32)
7994static __inline void
7995atomic_set_64(__volatile uint64_t *p, uint64_t v)
7996{
7997 uint64_t temp;
7998
7999#ifndef __CHERI_PURE_CAPABILITY__
8000 __asm __volatile (
8001 "1:\n\t"
8002 "lld %0, %3\n\t" /* load old value */
8003 "or %0, %2, %0\n\t" /* calculate new value */
8004 "scd %0, %1\n\t" /* attempt to store */
8005 "beqz %0, 1b\n\t" /* spin if failed */
8006 : "=&r" (temp), "=m" (*p)
8007 : "r" (v), "m" (*p)
8008 : "memory");
8009#else
8010# 265 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8011 __asm __volatile (
8012 "1:\n\t"
8013 "clld %0, %3\n\t" /* load old value */
8014 "or %0, %2, %0\n\t" /* calculate new value */
8015 "cscd %0, %0, %1\n\t" /* attempt to store */
8016 "beqz %0, 1b\n\t" /* spin if failed */
8017 : "=&r" (temp), "=C" (p)
8018 : "r" (v), "C" (p)
8019 : "memory");
8020#endif
8021# 275 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8022
8023}
8024
8025static __inline void
8026atomic_clear_64(__volatile uint64_t *p, uint64_t v)
8027{
8028 uint64_t temp;
8029 v = ~v;
8030
8031#ifndef __CHERI_PURE_CAPABILITY__
8032 __asm __volatile (
8033 "1:\n\t"
8034 "lld %0, %3\n\t" /* load old value */
8035 "and %0, %2, %0\n\t" /* calculate new value */
8036 "scd %0, %1\n\t" /* attempt to store */
8037 "beqz %0, 1b\n\t" /* spin if failed */
8038 : "=&r" (temp), "=m" (*p)
8039 : "r" (v), "m" (*p)
8040 : "memory");
8041#else
8042# 295 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8043 __asm __volatile (
8044 "1:\n\t"
8045 "clld %0, %3\n\t" /* load old value */
8046 "and %0, %2, %0\n\t" /* calculate new value */
8047 "cscd %0, %0, %1\n\t" /* attempt to store */
8048 "beqz %0, 1b\n\t" /* spin if failed */
8049 : "=&r" (temp), "=C" (p)
8050 : "r" (v), "C" (p)
8051 : "memory");
8052#endif
8053# 305 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8054}
8055
8056static __inline void
8057atomic_add_64(__volatile uint64_t *p, uint64_t v)
8058{
8059 uint64_t temp;
8060
8061#ifndef __CHERI_PURE_CAPABILITY__
8062 __asm __volatile (
8063 "1:\n\t"
8064 "lld %0, %3\n\t" /* load old value */
8065 "daddu %0, %2, %0\n\t" /* calculate new value */
8066 "scd %0, %1\n\t" /* attempt to store */
8067 "beqz %0, 1b\n\t" /* spin if failed */
8068 : "=&r" (temp), "=m" (*p)
8069 : "r" (v), "m" (*p)
8070 : "memory");
8071#else
8072# 323 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8073 __asm __volatile (
8074 "1:\n\t"
8075 "clld %0, %3\n\t" /* load old value */
8076 "daddu %0, %2, %0\n\t" /* calculate new value */
8077 "cscd %0, %0, %1\n\t" /* attempt to store */
8078 "beqz %0, 1b\n\t" /* spin if failed */
8079 : "=&r" (temp), "=C" (p)
8080 : "r" (v), "C" (p)
8081 : "memory");
8082#endif
8083# 333 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8084}
8085
8086static __inline void
8087atomic_subtract_64(__volatile uint64_t *p, uint64_t v)
8088{
8089 uint64_t temp;
8090
8091#ifndef __CHERI_PURE_CAPABILITY__
8092 __asm __volatile (
8093 "1:\n\t"
8094 "lld %0, %3\n\t" /* load old value */
8095 "dsubu %0, %2\n\t" /* calculate new value */
8096 "scd %0, %1\n\t" /* attempt to store */
8097 "beqz %0, 1b\n\t" /* spin if failed */
8098 : "=&r" (temp), "=m" (*p)
8099 : "r" (v), "m" (*p)
8100 : "memory");
8101#else
8102# 351 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8103 __asm __volatile (
8104 "1:\n\t"
8105 "clld %0, %3\n\t" /* load old value */
8106 "dsubu %0, %2\n\t" /* calculate new value */
8107 "cscd %0, %0, %1\n\t" /* attempt to store */
8108 "beqz %0, 1b\n\t" /* spin if failed */
8109 : "=&r" (temp), "=C" (p)
8110 : "r" (v), "C" (p)
8111 : "memory");
8112#endif
8113# 361 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8114}
8115
8116static __inline uint64_t
8117atomic_readandclear_64(__volatile uint64_t *addr)
8118{
8119 uint64_t result,temp;
8120
8121#ifndef __CHERI_PURE_CAPABILITY__
8122 __asm __volatile (
8123 "1:\n\t"
8124 "lld %0, %3\n\t" /* load old value */
8125 "li %1, 0\n\t" /* value to store */
8126 "scd %1, %2\n\t" /* attempt to store */
8127 "beqz %1, 1b\n\t" /* if the store failed, spin */
8128 : "=&r"(result), "=&r"(temp), "=m" (*addr)
8129 : "m" (*addr)
8130 : "memory");
8131#else
8132# 379 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8133 __asm __volatile (
8134 "1:\n\t"
8135 "clld %0, %3\n\t" /* load old value */
8136 "li %1, 0\n\t" /* value to store */
8137 "cscd %1, %1, %2\n\t" /* attempt to store */
8138 "beqz %1, 1b\n\t" /* if the store failed, spin */
8139 : "=&r"(result), "=&r"(temp), "=C" (addr)
8140 : "C" (addr)
8141 : "memory");
8142#endif
8143# 389 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8144
8145 return result;
8146}
8147
8148static __inline uint64_t
8149atomic_readandset_64(__volatile uint64_t *addr, uint64_t value)
8150{
8151 uint64_t result,temp;
8152
8153#ifndef __CHERI_PURE_CAPABILITY__
8154 __asm __volatile (
8155 "1:\n\t"
8156 "lld %0,%3\n\t" /* Load old value*/
8157 "or %1,$0,%4\n\t"
8158 "scd %1,%2\n\t" /* attempt to store */
8159 "beqz %1, 1b\n\t" /* if the store failed, spin */
8160 : "=&r"(result), "=&r"(temp), "=m" (*addr)
8161 : "m" (*addr), "r" (value)
8162 : "memory");
8163#else
8164# 409 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8165 __asm __volatile (
8166 "1:\n\t"
8167 "clld %0, %3\n\t" /* load old value*/
8168 "or %1, $0, %4\n\t"
8169 "cscd %1, %1, %2\n\t" /* attempt to store */
8170 "beqz %1, 1b\n\t" /* if the store failed, spin */
8171 : "=&r"(result), "=&r"(temp), "=C" (addr)
8172 : "C" (addr), "r" (value)
8173 : "memory");
8174#endif
8175# 419 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8176
8177 return result;
8178}
8179#endif
8180# 423 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8181
8182#define ATOMIC_ACQ_REL(NAME, WIDTH) \
8183static __inline void \
8184atomic_##NAME##_acq_##WIDTH(__volatile uint##WIDTH##_t *p, uint##WIDTH##_t v)\
8185{ \
8186 atomic_##NAME##_##WIDTH(p, v); \
8187 mips_sync(); \
8188} \
8189 \
8190static __inline void \
8191atomic_##NAME##_rel_##WIDTH(__volatile uint##WIDTH##_t *p, uint##WIDTH##_t v)\
8192{ \
8193 mips_sync(); \
8194 atomic_##NAME##_##WIDTH(p, v); \
8195}
8196
8197/* Variants of simple arithmetic with memory barriers. */
8198ATOMIC_ACQ_REL(set, 8)
8199ATOMIC_ACQ_REL(clear, 8)
8200ATOMIC_ACQ_REL(add, 8)
8201ATOMIC_ACQ_REL(subtract, 8)
8202ATOMIC_ACQ_REL(set, 16)
8203ATOMIC_ACQ_REL(clear, 16)
8204ATOMIC_ACQ_REL(add, 16)
8205ATOMIC_ACQ_REL(subtract, 16)
8206ATOMIC_ACQ_REL(set, 32)
8207ATOMIC_ACQ_REL(clear, 32)
8208ATOMIC_ACQ_REL(add, 32)
8209ATOMIC_ACQ_REL(subtract, 32)
8210#if defined(__mips_n64) || defined(__mips_n32)
8211ATOMIC_ACQ_REL(set, 64)
8212ATOMIC_ACQ_REL(clear, 64)
8213ATOMIC_ACQ_REL(add, 64)
8214ATOMIC_ACQ_REL(subtract, 64)
8215#endif
8216# 458 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8217
8218#undef ATOMIC_ACQ_REL
8219
8220/*
8221 * We assume that a = b will do atomic loads and stores.
8222 */
8223#define ATOMIC_STORE_LOAD(WIDTH) \
8224static __inline uint##WIDTH##_t \
8225atomic_load_acq_##WIDTH(__volatile uint##WIDTH##_t *p) \
8226{ \
8227 uint##WIDTH##_t v; \
8228 \
8229 v = *p; \
8230 mips_sync(); \
8231 return (v); \
8232} \
8233 \
8234static __inline void \
8235atomic_store_rel_##WIDTH(__volatile uint##WIDTH##_t *p, uint##WIDTH##_t v)\
8236{ \
8237 mips_sync(); \
8238 *p = v; \
8239}
8240
8241ATOMIC_STORE_LOAD(32)
8242ATOMIC_STORE_LOAD(64)
8243#if !defined(__mips_n64) && !defined(__mips_n32)
8244void atomic_store_64(__volatile uint64_t *, uint64_t *);
8245void atomic_load_64(__volatile uint64_t *, uint64_t *);
8246#else
8247# 488 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8248static __inline void
8249atomic_store_64(__volatile uint64_t *p, uint64_t *v)
8250{
8251 *p = *v;
8252}
8253
8254static __inline void
8255atomic_load_64(__volatile uint64_t *p, uint64_t *v)
8256{
8257 *v = *p;
8258}
8259#endif
8260# 500 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8261
8262#undef ATOMIC_STORE_LOAD
8263
8264/*
8265 * Atomically compare the value stored at *p with cmpval and if the
8266 * two values are equal, update the value of *p with newval. Returns
8267 * zero if the compare failed, nonzero otherwise.
8268 */
8269static __inline uint32_t
8270atomic_cmpset_32(__volatile uint32_t* p, uint32_t cmpval, uint32_t newval)
8271{
8272 uint32_t ret;
8273
8274#ifndef __CHERI_PURE_CAPABILITY__
8275 __asm __volatile (
8276 "1:\tll %0, %4\n\t" /* load old value */
8277 "bne %0, %2, 2f\n\t" /* compare */
8278 "move %0, %3\n\t" /* value to store */
8279 "sc %0, %1\n\t" /* attempt to store */
8280 "beqz %0, 1b\n\t" /* if it failed, spin */
8281 "j 3f\n\t"
8282 "2:\n\t"
8283 "li %0, 0\n\t"
8284 "3:\n"
8285 : "=&r" (ret), "=m" (*p)
8286 : "r" (cmpval), "r" (newval), "m" (*p)
8287 : "memory");
8288#else
8289# 528 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8290 __asm __volatile (
8291 "1:\n\t"
8292 "cllw %0, %4\n\t" /* load old value */
8293 "bne %0, %2, 2f\n\t" /* compare */
8294 "move %0, %3\n\t" /* value to store */
8295 "cscw %0, %0, %1\n\t" /* attempt to store */
8296 "beqz %0, 1b\n\t" /* if it failed, spin */
8297 "j 3f\n\t"
8298 "2:\n\t"
8299 "li %0, 0\n\t"
8300 "3:\n"
8301 : "=&r" (ret), "=C" (p)
8302 : "r" (cmpval), "r" (newval), "C" (p)
8303 : "memory");
8304#endif
8305# 543 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8306
8307 return ret;
8308}
8309
8310/*
8311 * Atomically compare the value stored at *p with cmpval and if the
8312 * two values are equal, update the value of *p with newval. Returns
8313 * zero if the compare failed, nonzero otherwise.
8314 */
8315static __inline uint32_t
8316atomic_cmpset_acq_32(__volatile uint32_t *p, uint32_t cmpval, uint32_t newval)
8317{
8318 int retval;
8319
8320 retval = atomic_cmpset_32(p, cmpval, newval);
8321 mips_sync();
8322 return (retval);
8323}
8324
8325static __inline uint32_t
8326atomic_cmpset_rel_32(__volatile uint32_t *p, uint32_t cmpval, uint32_t newval)
8327{
8328 mips_sync();
8329 return (atomic_cmpset_32(p, cmpval, newval));
8330}
8331
8332/*
8333 * Atomically add the value of v to the integer pointed to by p and return
8334 * the previous value of *p.
8335 */
8336static __inline uint32_t
8337atomic_fetchadd_32(__volatile uint32_t *p, uint32_t v)
8338{
8339 uint32_t value, temp;
8340
8341#ifndef __CHERI_PURE_CAPABILITY__
8342 __asm __volatile (
8343 "1:\tll %0, %1\n\t" /* load old value */
8344 "addu %2, %3, %0\n\t" /* calculate new value */
8345 "sc %2, %1\n\t" /* attempt to store */
8346 "beqz %2, 1b\n\t" /* spin if failed */
8347 : "=&r" (value), "=m" (*p), "=&r" (temp)
8348 : "r" (v), "m" (*p));
8349#else
8350# 587 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8351 __asm __volatile (
8352 "1:\n\t"
8353 "cllw %0, %1\n\t" /* load old value */
8354 "addu %2, %3, %0\n\t" /* calculate new value */
8355 "cscw %2, %2, %1\n\t" /* attempt to store */
8356 "beqz %2, 1b\n\t" /* spin if failed */
8357 : "=&r" (value), "=C" (p), "=&r" (temp)
8358 : "r" (v), "C" (p));
8359#endif
8360# 596 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8361 return (value);
8362}
8363
8364#if defined(__mips_n64) || defined(__mips_n32)
8365/*
8366 * Atomically compare the value stored at *p with cmpval and if the
8367 * two values are equal, update the value of *p with newval. Returns
8368 * zero if the compare failed, nonzero otherwise.
8369 */
8370static __inline uint64_t
8371atomic_cmpset_64(__volatile uint64_t* p, uint64_t cmpval, uint64_t newval)
8372{
8373 uint64_t ret;
8374
8375#ifndef __CHERI_PURE_CAPABILITY__
8376 __asm __volatile (
8377 "1:\n\t"
8378 "lld %0, %4\n\t" /* load old value */
8379 "bne %0, %2, 2f\n\t" /* compare */
8380 "move %0, %3\n\t" /* value to store */
8381 "scd %0, %1\n\t" /* attempt to store */
8382 "beqz %0, 1b\n\t" /* if it failed, spin */
8383 "j 3f\n\t"
8384 "2:\n\t"
8385 "li %0, 0\n\t"
8386 "3:\n"
8387 : "=&r" (ret), "=m" (*p)
8388 : "r" (cmpval), "r" (newval), "m" (*p)
8389 : "memory");
8390#else
8391# 626 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8392 __asm __volatile (
8393 "1:\n\t"
8394 "clld %0, %4\n\t" /* load old value */
8395 "bne %0, %2, 2f\n\t" /* compare */
8396 "move %0, %3\n\t" /* value to store */
8397 "cscd %0, %0, %1\n\t" /* attempt to store */
8398 "beqz %0, 1b\n\t" /* if it failed, spin */
8399 "j 3f\n\t"
8400 "2:\n\t"
8401 "li %0, 0\n\t"
8402 "3:\n"
8403 : "=&r" (ret), "=C" (p)
8404 : "r" (cmpval), "r" (newval), "C" (p)
8405 : "memory");
8406#endif
8407# 641 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8408
8409 return ret;
8410}
8411
8412/*
8413 * Atomically compare the value stored at *p with cmpval and if the
8414 * two values are equal, update the value of *p with newval. Returns
8415 * zero if the compare failed, nonzero otherwise.
8416 */
8417static __inline uint64_t
8418atomic_cmpset_acq_64(__volatile uint64_t *p, uint64_t cmpval, uint64_t newval)
8419{
8420 int retval;
8421
8422 retval = atomic_cmpset_64(p, cmpval, newval);
8423 mips_sync();
8424 return (retval);
8425}
8426
8427static __inline uint64_t
8428atomic_cmpset_rel_64(__volatile uint64_t *p, uint64_t cmpval, uint64_t newval)
8429{
8430 mips_sync();
8431 return (atomic_cmpset_64(p, cmpval, newval));
8432}
8433
8434/*
8435 * Atomically add the value of v to the integer pointed to by p and return
8436 * the previous value of *p.
8437 */
8438static __inline uint64_t
8439atomic_fetchadd_64(__volatile uint64_t *p, uint64_t v)
8440{
8441 uint64_t value, temp;
8442
8443#ifndef __CHERI_PURE_CAPABILITY__
8444 __asm __volatile (
8445 "1:\n\t"
8446 "lld %0, %1\n\t" /* load old value */
8447 "daddu %2, %3, %0\n\t" /* calculate new value */
8448 "scd %2, %1\n\t" /* attempt to store */
8449 "beqz %2, 1b\n\t" /* spin if failed */
8450 : "=&r" (value), "=m" (*p), "=&r" (temp)
8451 : "r" (v), "m" (*p));
8452#else
8453# 686 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8454 __asm __volatile (
8455 "1:\n\t"
8456 "clld %0, %1\n\t" /* load old value */
8457 "daddu %2, %3, %0\n\t" /* calculate new value */
8458 "cscd %2, %2, %1\n\t" /* attempt to store */
8459 "beqz %2, 1b\n\t" /* spin if failed */
8460 : "=&r" (value), "=C" (p), "=&r" (temp)
8461 : "r" (v), "C" (p));
8462#endif
8463# 695 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8464 return (value);
8465}
8466#endif
8467# 698 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8468
8469static __inline void
8470atomic_thread_fence_acq(void)
8471{
8472
8473 mips_sync();
8474}
8475
8476static __inline void
8477atomic_thread_fence_rel(void)
8478{
8479
8480 mips_sync();
8481}
8482
8483static __inline void
8484atomic_thread_fence_acq_rel(void)
8485{
8486
8487 mips_sync();
8488}
8489
8490static __inline void
8491atomic_thread_fence_seq_cst(void)
8492{
8493
8494 mips_sync();
8495}
8496
8497/* Operations on chars. */
8498#define atomic_set_char atomic_set_8
8499#define atomic_set_acq_char atomic_set_acq_8
8500#define atomic_set_rel_char atomic_set_rel_8
8501#define atomic_clear_char atomic_clear_8
8502#define atomic_clear_acq_char atomic_clear_acq_8
8503#define atomic_clear_rel_char atomic_clear_rel_8
8504#define atomic_add_char atomic_add_8
8505#define atomic_add_acq_char atomic_add_acq_8
8506#define atomic_add_rel_char atomic_add_rel_8
8507#define atomic_subtract_char atomic_subtract_8
8508#define atomic_subtract_acq_char atomic_subtract_acq_8
8509#define atomic_subtract_rel_char atomic_subtract_rel_8
8510
8511/* Operations on shorts. */
8512#define atomic_set_short atomic_set_16
8513#define atomic_set_acq_short atomic_set_acq_16
8514#define atomic_set_rel_short atomic_set_rel_16
8515#define atomic_clear_short atomic_clear_16
8516#define atomic_clear_acq_short atomic_clear_acq_16
8517#define atomic_clear_rel_short atomic_clear_rel_16
8518#define atomic_add_short atomic_add_16
8519#define atomic_add_acq_short atomic_add_acq_16
8520#define atomic_add_rel_short atomic_add_rel_16
8521#define atomic_subtract_short atomic_subtract_16
8522#define atomic_subtract_acq_short atomic_subtract_acq_16
8523#define atomic_subtract_rel_short atomic_subtract_rel_16
8524
8525/* Operations on ints. */
8526#define atomic_set_int atomic_set_32
8527#define atomic_set_acq_int atomic_set_acq_32
8528#define atomic_set_rel_int atomic_set_rel_32
8529#define atomic_clear_int atomic_clear_32
8530#define atomic_clear_acq_int atomic_clear_acq_32
8531#define atomic_clear_rel_int atomic_clear_rel_32
8532#define atomic_add_int atomic_add_32
8533#define atomic_add_acq_int atomic_add_acq_32
8534#define atomic_add_rel_int atomic_add_rel_32
8535#define atomic_subtract_int atomic_subtract_32
8536#define atomic_subtract_acq_int atomic_subtract_acq_32
8537#define atomic_subtract_rel_int atomic_subtract_rel_32
8538#define atomic_cmpset_int atomic_cmpset_32
8539#define atomic_cmpset_acq_int atomic_cmpset_acq_32
8540#define atomic_cmpset_rel_int atomic_cmpset_rel_32
8541#define atomic_load_acq_int atomic_load_acq_32
8542#define atomic_store_rel_int atomic_store_rel_32
8543#define atomic_readandclear_int atomic_readandclear_32
8544#define atomic_readandset_int atomic_readandset_32
8545#define atomic_fetchadd_int atomic_fetchadd_32
8546
8547/*
8548 * I think the following is right, even for n32. For n32 the pointers
8549 * are still 32-bits, so we need to operate on them as 32-bit quantities,
8550 * even though they are sign extended in operation. For longs, there's
8551 * no question because they are always 32-bits.
8552 */
8553#ifdef __mips_n64
8554/* Operations on longs. */
8555#define atomic_set_long atomic_set_64
8556#define atomic_set_acq_long atomic_set_acq_64
8557#define atomic_set_rel_long atomic_set_rel_64
8558#define atomic_clear_long atomic_clear_64
8559#define atomic_clear_acq_long atomic_clear_acq_64
8560#define atomic_clear_rel_long atomic_clear_rel_64
8561#define atomic_add_long atomic_add_64
8562#define atomic_add_acq_long atomic_add_acq_64
8563#define atomic_add_rel_long atomic_add_rel_64
8564#define atomic_subtract_long atomic_subtract_64
8565#define atomic_subtract_acq_long atomic_subtract_acq_64
8566#define atomic_subtract_rel_long atomic_subtract_rel_64
8567#define atomic_cmpset_long atomic_cmpset_64
8568#define atomic_cmpset_acq_long atomic_cmpset_acq_64
8569#define atomic_cmpset_rel_long atomic_cmpset_rel_64
8570#define atomic_load_acq_long atomic_load_acq_64
8571#define atomic_store_rel_long atomic_store_rel_64
8572#define atomic_fetchadd_long atomic_fetchadd_64
8573#define atomic_readandclear_long atomic_readandclear_64
8574
8575#else /* !__mips_n64 */
8576# 806 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8577
8578/* Operations on longs. */
8579#define atomic_set_long(p, v) \
8580 atomic_set_32((volatile u_int *)(p), (u_int)(v))
8581#define atomic_set_acq_long(p, v) \
8582 atomic_set_acq_32((volatile u_int *)(p), (u_int)(v))
8583#define atomic_set_rel_long(p, v) \
8584 atomic_set_rel_32((volatile u_int *)(p), (u_int)(v))
8585#define atomic_clear_long(p, v) \
8586 atomic_clear_32((volatile u_int *)(p), (u_int)(v))
8587#define atomic_clear_acq_long(p, v) \
8588 atomic_clear_acq_32((volatile u_int *)(p), (u_int)(v))
8589#define atomic_clear_rel_long(p, v) \
8590 atomic_clear_rel_32((volatile u_int *)(p), (u_int)(v))
8591#define atomic_add_long(p, v) \
8592 atomic_add_32((volatile u_int *)(p), (u_int)(v))
8593#define atomic_add_acq_long(p, v) \
8594 atomic_add_32((volatile u_int *)(p), (u_int)(v))
8595#define atomic_add_rel_long(p, v) \
8596 atomic_add_32((volatile u_int *)(p), (u_int)(v))
8597#define atomic_subtract_long(p, v) \
8598 atomic_subtract_32((volatile u_int *)(p), (u_int)(v))
8599#define atomic_subtract_acq_long(p, v) \
8600 atomic_subtract_acq_32((volatile u_int *)(p), (u_int)(v))
8601#define atomic_subtract_rel_long(p, v) \
8602 atomic_subtract_rel_32((volatile u_int *)(p), (u_int)(v))
8603#define atomic_cmpset_long(p, cmpval, newval) \
8604 atomic_cmpset_32((volatile u_int *)(p), (u_int)(cmpval), \
8605 (u_int)(newval))
8606#define atomic_cmpset_acq_long(p, cmpval, newval) \
8607 atomic_cmpset_acq_32((volatile u_int *)(p), (u_int)(cmpval), \
8608 (u_int)(newval))
8609#define atomic_cmpset_rel_long(p, cmpval, newval) \
8610 atomic_cmpset_rel_32((volatile u_int *)(p), (u_int)(cmpval), \
8611 (u_int)(newval))
8612#define atomic_load_acq_long(p) \
8613 (u_long)atomic_load_acq_32((volatile u_int *)(p))
8614#define atomic_store_rel_long(p, v) \
8615 atomic_store_rel_32((volatile u_int *)(p), (u_int)(v))
8616#define atomic_fetchadd_long(p, v) \
8617 atomic_fetchadd_32((volatile u_int *)(p), (u_int)(v))
8618#define atomic_readandclear_long(p) \
8619 atomic_readandclear_32((volatile u_int *)(p))
8620
8621#endif /* __mips_n64 */
8622# 851 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8623
8624/* Operations on pointers. */
8625#define atomic_set_ptr atomic_set_long
8626#define atomic_set_acq_ptr atomic_set_acq_long
8627#define atomic_set_rel_ptr atomic_set_rel_long
8628#define atomic_clear_ptr atomic_clear_long
8629#define atomic_clear_acq_ptr atomic_clear_acq_long
8630#define atomic_clear_rel_ptr atomic_clear_rel_long
8631#define atomic_add_ptr atomic_add_long
8632#define atomic_add_acq_ptr atomic_add_acq_long
8633#define atomic_add_rel_ptr atomic_add_rel_long
8634#define atomic_subtract_ptr atomic_subtract_long
8635#define atomic_subtract_acq_ptr atomic_subtract_acq_long
8636#define atomic_subtract_rel_ptr atomic_subtract_rel_long
8637#define atomic_cmpset_ptr atomic_cmpset_long
8638#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long
8639#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long
8640#define atomic_load_acq_ptr atomic_load_acq_long
8641#define atomic_store_rel_ptr atomic_store_rel_long
8642#define atomic_readandclear_ptr atomic_readandclear_long
8643
8644#endif /* ! _MACHINE_ATOMIC_H_ */
8645# 873 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/atomic.h" 3 4
8646# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h" 2
8647#if 0 /* expanded by -frewrite-includes */
8648#include "setlocale.h"
8649#endif /* expanded by -frewrite-includes */
8650# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
8651# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/setlocale.h" 1
8652/*-
8653 * Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia.
8654 * All rights reserved.
8655 *
8656 * Redistribution and use in source and binary forms, with or without
8657 * modification, are permitted provided that the following conditions
8658 * are met:
8659 * 1. Redistributions of source code must retain the above copyright
8660 * notice, this list of conditions and the following disclaimer.
8661 * 2. Redistributions in binary form must reproduce the above copyright
8662 * notice, this list of conditions and the following disclaimer in the
8663 * documentation and/or other materials provided with the distribution.
8664 *
8665 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
8666 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8667 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
8668 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
8669 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
8670 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
8671 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
8672 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
8673 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
8674 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
8675 * SUCH DAMAGE.
8676 *
8677 * $FreeBSD$
8678 */
8679
8680#ifndef _SETLOCALE_H_
8681#define _SETLOCALE_H_
8682
8683#define ENCODING_LEN 31
8684#define CATEGORY_LEN 11
8685
8686extern char *_PathLocale;
8687
8688int __detect_path_locale(void);
8689int __wrap_setrunelocale(const char *);
8690
8691#endif /* !_SETLOCALE_H_ */
8692# 41 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/setlocale.h"
8693# 42 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h" 2
8694
8695enum {
8696 XLC_COLLATE = 0,
8697 XLC_CTYPE,
8698 XLC_MONETARY,
8699 XLC_NUMERIC,
8700 XLC_TIME,
8701 XLC_MESSAGES,
8702 XLC_LAST
8703};
8704
8705
8706/**
8707 * Header used for objects that are reference counted. Objects may optionally
8708 * have a destructor associated, which is responsible for destroying the
8709 * structure. Global / static versions of the structure should have no
8710 * destructor set - they can then have their reference counts manipulated as
8711 * normal, but will not do anything with them.
8712 *
8713 * The header stores a retain count - objects are assumed to have a reference
8714 * count of 1 when they are created, but the retain count is 0. When the
8715 * retain count is less than 0, they are freed.
8716 */
8717struct xlocale_refcounted {
8718 /** Number of references to this component. */
8719 long retain_count;
8720 /** Function used to destroy this component, if one is required*/
8721 void(*destructor)(void*);
8722};
8723/**
8724 * Header for a locale component. All locale components must begin with this
8725 * header.
8726 */
8727struct xlocale_component {
8728 struct xlocale_refcounted header;
8729 /** Name of the locale used for this component. */
8730 char locale[ENCODING_LEN+1];
8731};
8732
8733/**
8734 * xlocale structure, stores per-thread locale information.
8735 */
8736struct _xlocale {
8737 struct xlocale_refcounted header;
8738 /** Components for the locale. */
8739 struct xlocale_component *components[XLC_LAST];
8740 /** Flag indicating if components[XLC_MONETARY] has changed since the
8741 * last call to localeconv_l() with this locale. */
8742 int monetary_locale_changed;
8743 /** Flag indicating whether this locale is actually using a locale for
8744 * LC_MONETARY (1), or if it should use the C default instead (0). */
8745 int using_monetary_locale;
8746 /** Flag indicating if components[XLC_NUMERIC] has changed since the
8747 * last call to localeconv_l() with this locale. */
8748 int numeric_locale_changed;
8749 /** Flag indicating whether this locale is actually using a locale for
8750 * LC_NUMERIC (1), or if it should use the C default instead (0). */
8751 int using_numeric_locale;
8752 /** Flag indicating whether this locale is actually using a locale for
8753 * LC_TIME (1), or if it should use the C default instead (0). */
8754 int using_time_locale;
8755 /** Flag indicating whether this locale is actually using a locale for
8756 * LC_MESSAGES (1), or if it should use the C default instead (0). */
8757 int using_messages_locale;
8758 /** The structure to be returned from localeconv_l() for this locale. */
8759 struct lconv lconv;
8760 /** Persistent state used by mblen() calls. */
8761 __mbstate_t mblen;
8762 /** Persistent state used by mbrlen() calls. */
8763 __mbstate_t mbrlen;
8764 /** Persistent state used by mbrtoc16() calls. */
8765 __mbstate_t mbrtoc16;
8766 /** Persistent state used by mbrtoc32() calls. */
8767 __mbstate_t mbrtoc32;
8768 /** Persistent state used by mbrtowc() calls. */
8769 __mbstate_t mbrtowc;
8770 /** Persistent state used by mbsnrtowcs() calls. */
8771 __mbstate_t mbsnrtowcs;
8772 /** Persistent state used by mbsrtowcs() calls. */
8773 __mbstate_t mbsrtowcs;
8774 /** Persistent state used by mbtowc() calls. */
8775 __mbstate_t mbtowc;
8776 /** Persistent state used by c16rtomb() calls. */
8777 __mbstate_t c16rtomb;
8778 /** Persistent state used by c32rtomb() calls. */
8779 __mbstate_t c32rtomb;
8780 /** Persistent state used by wcrtomb() calls. */
8781 __mbstate_t wcrtomb;
8782 /** Persistent state used by wcsnrtombs() calls. */
8783 __mbstate_t wcsnrtombs;
8784 /** Persistent state used by wcsrtombs() calls. */
8785 __mbstate_t wcsrtombs;
8786 /** Persistent state used by wctomb() calls. */
8787 __mbstate_t wctomb;
8788 /** Buffer used by nl_langinfo_l() */
8789 char *csym;
8790};
8791
8792/**
8793 * Increments the reference count of a reference-counted structure.
8794 */
8795__attribute__((unused)) static void*
8796xlocale_retain(void *val)
8797{
8798 struct xlocale_refcounted *obj = val;
8799 atomic_add_long(&(obj->retain_count), 1);
8800 return (val);
8801}
8802/**
8803 * Decrements the reference count of a reference-counted structure, freeing it
8804 * if this is the last reference, calling its destructor if it has one.
8805 */
8806__attribute__((unused)) static void
8807xlocale_release(void *val)
8808{
8809 struct xlocale_refcounted *obj = val;
8810 long count = atomic_fetchadd_long(&(obj->retain_count), -1) - 1;
8811 if (count < 0) {
8812 if (0 != obj->destructor) {
8813 obj->destructor(obj);
8814 }
8815 }
8816}
8817
8818/**
8819 * Load functions. Each takes the name of a locale and a pointer to the data
8820 * to be initialised as arguments. Two special values are allowed for the
8821 */
8822extern void* __collate_load(const char*, locale_t);
8823extern void* __ctype_load(const char*, locale_t);
8824extern void* __messages_load(const char*, locale_t);
8825extern void* __monetary_load(const char*, locale_t);
8826extern void* __numeric_load(const char*, locale_t);
8827extern void* __time_load(const char*, locale_t);
8828
8829extern struct _xlocale __xlocale_global_locale;
8830extern struct _xlocale __xlocale_C_locale;
8831
8832/**
8833 * Caches the rune table in TLS for fast access.
8834 */
8835void __set_thread_rune_locale(locale_t loc);
8836/**
8837 * Flag indicating whether a per-thread locale has been set. If no per-thread
8838 * locale has ever been set, then we always use the global locale.
8839 */
8840extern int __has_thread_locale;
8841#ifndef __NO_TLS
8842/**
8843 * The per-thread locale. Avoids the need to use pthread lookup functions when
8844 * getting the per-thread locale.
8845 */
8846extern _Thread_local locale_t __thread_locale;
8847
8848/**
8849 * Returns the current locale for this thread, or the global locale if none is
8850 * set. The caller does not have to free the locale. The return value from
8851 * this call is not guaranteed to remain valid after the locale changes. As
8852 * such, this should only be called within libc functions.
8853 */
8854static inline locale_t __get_locale(void)
8855{
8856
8857#ifdef FORCE_C_LOCALE
8858 return (&__xlocale_C_locale);
8859#else
8860# 208 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
8861 if (!__has_thread_locale) {
8862 return (&__xlocale_global_locale);
8863 }
8864 return (__thread_locale ? __thread_locale : &__xlocale_global_locale);
8865#endif
8866# 213 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
8867}
8868#else
8869# 215 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
8870locale_t __get_locale(void);
8871#endif
8872# 217 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
8873
8874/**
8875 * Two magic values are allowed for locale_t objects. NULL and -1. This
8876 * function maps those to the real locales that they represent.
8877 */
8878static inline locale_t get_real_locale(locale_t locale)
8879{
8880 switch ((intptr_t)locale) {
8881 case 0: return (&__xlocale_C_locale);
8882 case -1: return (&__xlocale_global_locale);
8883 default: return (locale);
8884 }
8885}
8886
8887/**
8888 * Replace a placeholder locale with the real global or thread-local locale_t.
8889 */
8890#define FIX_LOCALE(l) (l = get_real_locale(l))
8891
8892#endif
8893# 237 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/xlocale_private.h"
8894# 43 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h" 2
8895
8896/*
8897 * Work around buildworld bootstrapping from older systems whose limits.h
8898 * sets COLL_WEIGHTS_MAX to 0.
8899 */
8900#if COLL_WEIGHTS_MAX == 0
8901#undef COLL_WEIGHTS_MAX
8902#define COLL_WEIGHTS_MAX 10
8903#endif
8904# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
8905
8906#define COLLATE_STR_LEN 24 /* should be 64-bit multiple */
8907#define COLLATE_VERSION "BSD 1.0\n"
8908
8909#define COLLATE_MAX_PRIORITY (0x7fffffff) /* max signed value */
8910#define COLLATE_SUBST_PRIORITY (0x40000000) /* bit indicates subst table */
8911
8912#define DIRECTIVE_UNDEF 0x00
8913#define DIRECTIVE_FORWARD 0x01
8914#define DIRECTIVE_BACKWARD 0x02
8915#define DIRECTIVE_POSITION 0x04
8916#define DIRECTIVE_UNDEFINED 0x08 /* special last weight for UNDEFINED */
8917
8918#define DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD)
8919
8920/*
8921 * The collate file format is as follows:
8922 *
8923 * char version[COLLATE_STR_LEN]; // must be COLLATE_VERSION
8924 * collate_info_t info; // see below, includes padding
8925 * collate_char_pri_t char_data[256]; // 8 bit char values
8926 * collate_subst_t subst[*]; // 0 or more substitutions
8927 * collate_chain_pri_t chains[*]; // 0 or more chains
8928 * collate_large_pri_t large[*]; // extended char priorities
8929 *
8930 * Note that all structures must be 32-bit aligned, as each structure
8931 * contains 32-bit member fields. The entire file is mmap'd, so its
8932 * critical that alignment be observed. It is not generally safe to
8933 * use any 64-bit values in the structures.
8934 */
8935
8936typedef struct collate_info {
8937 uint8_t directive_count;
8938 uint8_t directive[COLL_WEIGHTS_MAX];
8939 int32_t pri_count[COLL_WEIGHTS_MAX];
8940 int32_t flags;
8941 int32_t chain_count;
8942 int32_t large_count;
8943 int32_t subst_count[COLL_WEIGHTS_MAX];
8944 int32_t undef_pri[COLL_WEIGHTS_MAX];
8945} collate_info_t;
8946
8947typedef struct collate_char {
8948 int32_t pri[COLL_WEIGHTS_MAX];
8949} collate_char_t;
8950
8951typedef struct collate_chain {
8952 wchar_t str[COLLATE_STR_LEN];
8953 int32_t pri[COLL_WEIGHTS_MAX];
8954} collate_chain_t;
8955
8956typedef struct collate_large {
8957 int32_t val;
8958 collate_char_t pri;
8959} collate_large_t;
8960
8961typedef struct collate_subst {
8962 int32_t key;
8963 int32_t pri[COLLATE_STR_LEN];
8964} collate_subst_t;
8965
8966struct xlocale_collate {
8967 struct xlocale_component header;
8968 int __collate_load_error;
8969 char * map;
8970 size_t maplen;
8971
8972 collate_info_t *info;
8973 collate_char_t *char_pri_table;
8974 collate_large_t *large_pri_table;
8975 collate_chain_t *chain_pri_table;
8976 collate_subst_t *subst_table[COLL_WEIGHTS_MAX];
8977};
8978
8979__BEGIN_DECLS
8980int __collate_load_tables(const char *);
8981int __collate_equiv_value(locale_t, const wchar_t *, size_t);
8982void _collate_lookup(struct xlocale_collate *,const wchar_t *, int *, int *,
8983 int, const int **);
8984int __collate_range_cmp(struct xlocale_collate *, wchar_t, wchar_t);
8985size_t _collate_wxfrm(struct xlocale_collate *, const wchar_t *, wchar_t *,
8986 size_t);
8987size_t _collate_sxfrm(struct xlocale_collate *, const wchar_t *, char *,
8988 size_t);
8989__END_DECLS
8990
8991#endif /* !_COLLATE_H_ */
8992# 139 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/locale/collate.h"
8993# 59 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
8994
8995#if 0 /* expanded by -frewrite-includes */
8996#include "utils.h"
8997#endif /* expanded by -frewrite-includes */
8998# 60 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
8999# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/utils.h" 1
9000/*-
9001 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
9002 * Copyright (c) 1992, 1993, 1994
9003 * The Regents of the University of California. All rights reserved.
9004 *
9005 * This code is derived from software contributed to Berkeley by
9006 * Henry Spencer.
9007 *
9008 * Redistribution and use in source and binary forms, with or without
9009 * modification, are permitted provided that the following conditions
9010 * are met:
9011 * 1. Redistributions of source code must retain the above copyright
9012 * notice, this list of conditions and the following disclaimer.
9013 * 2. Redistributions in binary form must reproduce the above copyright
9014 * notice, this list of conditions and the following disclaimer in the
9015 * documentation and/or other materials provided with the distribution.
9016 * 4. Neither the name of the University nor the names of its contributors
9017 * may be used to endorse or promote products derived from this software
9018 * without specific prior written permission.
9019 *
9020 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
9021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9023 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
9024 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9025 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9026 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9027 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9028 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9029 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9030 * SUCH DAMAGE.
9031 *
9032 * @(#)utils.h 8.3 (Berkeley) 3/20/94
9033 * $FreeBSD$
9034 */
9035
9036/* utility definitions */
9037#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
9038#define INFINITY (DUPMAX + 1)
9039#define NC (CHAR_MAX - CHAR_MIN + 1)
9040typedef unsigned char uch;
9041
9042/* switch off assertions (if not already off) if no REDEBUG */
9043#ifndef REDEBUG
9044#ifndef NDEBUG
9045#define NDEBUG /* no assertions please */
9046#endif
9047# 48 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/utils.h"
9048#endif
9049# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/utils.h"
9050#if 0 /* expanded by -frewrite-includes */
9051#include <assert.h>
9052#endif /* expanded by -frewrite-includes */
9053# 49 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/utils.h"
9054# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h" 1
9055/*-
9056 * Copyright (c) 1992, 1993
9057 * The Regents of the University of California. All rights reserved.
9058 * (c) UNIX System Laboratories, Inc.
9059 * All or some portions of this file are derived from material licensed
9060 * to the University of California by American Telephone and Telegraph
9061 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
9062 * the permission of UNIX System Laboratories, Inc.
9063 *
9064 * Redistribution and use in source and binary forms, with or without
9065 * modification, are permitted provided that the following conditions
9066 * are met:
9067 * 1. Redistributions of source code must retain the above copyright
9068 * notice, this list of conditions and the following disclaimer.
9069 * 2. Redistributions in binary form must reproduce the above copyright
9070 * notice, this list of conditions and the following disclaimer in the
9071 * documentation and/or other materials provided with the distribution.
9072 * 3. Neither the name of the University nor the names of its contributors
9073 * may be used to endorse or promote products derived from this software
9074 * without specific prior written permission.
9075 *
9076 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
9077 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9078 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9079 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
9080 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9081 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9082 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9083 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9084 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9085 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9086 * SUCH DAMAGE.
9087 *
9088 * @(#)assert.h 8.2 (Berkeley) 1/21/94
9089 * $FreeBSD$
9090 */
9091
9092#if 0 /* expanded by -frewrite-includes */
9093#include <sys/cdefs.h>
9094#endif /* expanded by -frewrite-includes */
9095# 38 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h"
9096# 39 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h"
9097
9098/*
9099 * Unlike other ANSI header files, <assert.h> may usefully be included
9100 * multiple times, with and without NDEBUG defined.
9101 */
9102
9103#undef assert
9104#undef _assert
9105
9106#ifdef NDEBUG
9107#define assert(e) ((void)0)
9108#define _assert(e) ((void)0)
9109#else
9110# 52 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h"
9111#define _assert(e) assert(e)
9112
9113#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
9114 __LINE__, #e))
9115#endif /* NDEBUG */
9116# 57 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h"
9117
9118#ifndef _ASSERT_H_
9119#define _ASSERT_H_
9120
9121/*
9122 * Static assertions. In principle we could define static_assert for
9123 * C++ older than C++11, but this breaks if _Static_assert is
9124 * implemented as a macro.
9125 *
9126 * C++ template parameters may contain commas, even if not enclosed in
9127 * parentheses, causing the _Static_assert macro to be invoked with more
9128 * than two parameters.
9129 */
9130#if __ISO_C_VISIBLE >= 2011 && !defined(__cplusplus)
9131#define static_assert _Static_assert
9132#endif
9133# 73 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h"
9134
9135__BEGIN_DECLS
9136void __assert(const char *, const char *, int, const char *) __dead2;
9137__END_DECLS
9138
9139#endif /* !_ASSERT_H_ */
9140# 79 "/home/rnw24/git/cheribsd/lib/libc_cheri/../../include/assert.h"
9141# 50 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/utils.h" 2
9142
9143/* for old systems with bcopy() but no memmove() */
9144#ifdef USEBCOPY
9145#define memmove(d, s, c) bcopy(s, d, c)
9146#endif
9147# 55 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/utils.h"
9148# 61 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
9149#if 0 /* expanded by -frewrite-includes */
9150#include "regex2.h"
9151#endif /* expanded by -frewrite-includes */
9152# 61 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9153# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regex2.h" 1
9154/*-
9155 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
9156 * Copyright (c) 1992, 1993, 1994
9157 * The Regents of the University of California. All rights reserved.
9158 *
9159 * This code is derived from software contributed to Berkeley by
9160 * Henry Spencer.
9161 *
9162 * Redistribution and use in source and binary forms, with or without
9163 * modification, are permitted provided that the following conditions
9164 * are met:
9165 * 1. Redistributions of source code must retain the above copyright
9166 * notice, this list of conditions and the following disclaimer.
9167 * 2. Redistributions in binary form must reproduce the above copyright
9168 * notice, this list of conditions and the following disclaimer in the
9169 * documentation and/or other materials provided with the distribution.
9170 * 4. Neither the name of the University nor the names of its contributors
9171 * may be used to endorse or promote products derived from this software
9172 * without specific prior written permission.
9173 *
9174 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
9175 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9176 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9177 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
9178 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9179 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9180 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9181 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9182 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9183 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9184 * SUCH DAMAGE.
9185 *
9186 * @(#)regex2.h 8.4 (Berkeley) 3/20/94
9187 * $FreeBSD$
9188 */
9189
9190/*
9191 * First, the stuff that ends up in the outside-world include file
9192 = typedef off_t regoff_t;
9193 = typedef struct {
9194 = int re_magic;
9195 = size_t re_nsub; // number of parenthesized subexpressions
9196 = const char *re_endp; // end pointer for REG_PEND
9197 = struct re_guts *re_g; // none of your business :-)
9198 = } regex_t;
9199 = typedef struct {
9200 = regoff_t rm_so; // start of match
9201 = regoff_t rm_eo; // end of match
9202 = } regmatch_t;
9203 */
9204/*
9205 * internals of regex_t
9206 */
9207#define MAGIC1 ((('r'^0200)<<8) | 'e')
9208
9209/*
9210 * The internal representation is a *strip*, a sequence of
9211 * operators ending with an endmarker. (Some terminology etc. is a
9212 * historical relic of earlier versions which used multiple strips.)
9213 * Certain oddities in the representation are there to permit running
9214 * the machinery backwards; in particular, any deviation from sequential
9215 * flow must be marked at both its source and its destination. Some
9216 * fine points:
9217 *
9218 * - OPLUS_ and O_PLUS are *inside* the loop they create.
9219 * - OQUEST_ and O_QUEST are *outside* the bypass they create.
9220 * - OCH_ and O_CH are *outside* the multi-way branch they create, while
9221 * OOR1 and OOR2 are respectively the end and the beginning of one of
9222 * the branches. Note that there is an implicit OOR2 following OCH_
9223 * and an implicit OOR1 preceding O_CH.
9224 *
9225 * In state representations, an operator's bit is on to signify a state
9226 * immediately *preceding* "execution" of that operator.
9227 */
9228typedef unsigned long sop; /* strip operator */
9229typedef long sopno;
9230#define OPRMASK 0xf8000000L
9231#define OPDMASK 0x07ffffffL
9232#define OPSHIFT ((unsigned)27)
9233#define OP(n) ((n)&OPRMASK)
9234#define OPND(n) ((n)&OPDMASK)
9235#define SOP(op, opnd) ((op)|(opnd))
9236/* operators meaning operand */
9237/* (back, fwd are offsets) */
9238#define OEND (1L<<OPSHIFT) /* endmarker - */
9239#define OCHAR (2L<<OPSHIFT) /* character wide character */
9240#define OBOL (3L<<OPSHIFT) /* left anchor - */
9241#define OEOL (4L<<OPSHIFT) /* right anchor - */
9242#define OANY (5L<<OPSHIFT) /* . - */
9243#define OANYOF (6L<<OPSHIFT) /* [...] set number */
9244#define OBACK_ (7L<<OPSHIFT) /* begin \d paren number */
9245#define O_BACK (8L<<OPSHIFT) /* end \d paren number */
9246#define OPLUS_ (9L<<OPSHIFT) /* + prefix fwd to suffix */
9247#define O_PLUS (10L<<OPSHIFT) /* + suffix back to prefix */
9248#define OQUEST_ (11L<<OPSHIFT) /* ? prefix fwd to suffix */
9249#define O_QUEST (12L<<OPSHIFT) /* ? suffix back to prefix */
9250#define OLPAREN (13L<<OPSHIFT) /* ( fwd to ) */
9251#define ORPAREN (14L<<OPSHIFT) /* ) back to ( */
9252#define OCH_ (15L<<OPSHIFT) /* begin choice fwd to OOR2 */
9253#define OOR1 (16L<<OPSHIFT) /* | pt. 1 back to OOR1 or OCH_ */
9254#define OOR2 (17L<<OPSHIFT) /* | pt. 2 fwd to OOR2 or O_CH */
9255#define O_CH (18L<<OPSHIFT) /* end choice back to OOR1 */
9256#define OBOW (19L<<OPSHIFT) /* begin word - */
9257#define OEOW (20L<<OPSHIFT) /* end word - */
9258
9259/*
9260 * Structures for [] character-set representation.
9261 */
9262typedef struct {
9263 wint_t min;
9264 wint_t max;
9265} crange;
9266typedef struct {
9267 unsigned char bmp[NC / 8];
9268 wctype_t *types;
9269 int ntypes;
9270 wint_t *wides;
9271 int nwides;
9272 crange *ranges;
9273 int nranges;
9274 int invert;
9275 int icase;
9276} cset;
9277
9278static int
9279CHIN1(cset *cs, wint_t ch)
9280{
9281 int i;
9282
9283 assert(ch >= 0);
9284 if (ch < NC)
9285 return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^
9286 cs->invert);
9287 for (i = 0; i < cs->nwides; i++)
9288 if (ch == cs->wides[i])
9289 return (!cs->invert);
9290 for (i = 0; i < cs->nranges; i++)
9291 if (cs->ranges[i].min <= ch && ch <= cs->ranges[i].max)
9292 return (!cs->invert);
9293 for (i = 0; i < cs->ntypes; i++)
9294 if (iswctype(ch, cs->types[i]))
9295 return (!cs->invert);
9296 return (cs->invert);
9297}
9298
9299static __inline int
9300CHIN(cset *cs, wint_t ch)
9301{
9302
9303 assert(ch >= 0);
9304 if (ch < NC)
9305 return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^
9306 cs->invert);
9307 else if (cs->icase)
9308 return (CHIN1(cs, ch) || CHIN1(cs, towlower(ch)) ||
9309 CHIN1(cs, towupper(ch)));
9310 else
9311 return (CHIN1(cs, ch));
9312}
9313
9314/*
9315 * main compiled-expression structure
9316 */
9317struct re_guts {
9318 int magic;
9319# define MAGIC2 ((('R'^0200)<<8)|'E')
9320 sop *strip; /* malloced area for strip */
9321 int ncsets; /* number of csets in use */
9322 cset *sets; /* -> cset [ncsets] */
9323 int cflags; /* copy of regcomp() cflags argument */
9324 sopno nstates; /* = number of sops */
9325 sopno firststate; /* the initial OEND (normally 0) */
9326 sopno laststate; /* the final OEND */
9327 int iflags; /* internal flags */
9328# define USEBOL 01 /* used ^ */
9329# define USEEOL 02 /* used $ */
9330# define BAD 04 /* something wrong */
9331 int nbol; /* number of ^ used */
9332 int neol; /* number of $ used */
9333 char *must; /* match must contain this string */
9334 int moffset; /* latest point at which must may be located */
9335 int *charjump; /* Boyer-Moore char jump table */
9336 int *matchjump; /* Boyer-Moore match jump table */
9337 int mlen; /* length of must */
9338 size_t nsub; /* copy of re_nsub */
9339 int backrefs; /* does it use back references? */
9340 sopno nplus; /* how deep does it nest +s? */
9341};
9342
9343/* misc utilities */
9344#define OUT (CHAR_MIN - 1) /* a non-character value */
9345#define ISWORD(c) (iswalnum((uch)(c)) || (c) == '_')
9346# 62 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
9347
9348#if 0 /* expanded by -frewrite-includes */
9349#include "cname.h"
9350#endif /* expanded by -frewrite-includes */
9351# 63 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9352# 1 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/cname.h" 1
9353/*-
9354 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
9355 * Copyright (c) 1992, 1993, 1994
9356 * The Regents of the University of California. All rights reserved.
9357 *
9358 * This code is derived from software contributed to Berkeley by
9359 * Henry Spencer.
9360 *
9361 * Redistribution and use in source and binary forms, with or without
9362 * modification, are permitted provided that the following conditions
9363 * are met:
9364 * 1. Redistributions of source code must retain the above copyright
9365 * notice, this list of conditions and the following disclaimer.
9366 * 2. Redistributions in binary form must reproduce the above copyright
9367 * notice, this list of conditions and the following disclaimer in the
9368 * documentation and/or other materials provided with the distribution.
9369 * 4. Neither the name of the University nor the names of its contributors
9370 * may be used to endorse or promote products derived from this software
9371 * without specific prior written permission.
9372 *
9373 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
9374 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9375 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9376 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
9377 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9378 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9379 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9380 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9381 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9382 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9383 * SUCH DAMAGE.
9384 *
9385 * @(#)cname.h 8.3 (Berkeley) 3/20/94
9386 * $FreeBSD$
9387 */
9388
9389/* character-name table */
9390static struct cname {
9391 char *name;
9392 char code;
9393} cnames[] = {
9394 {"NUL", '\0'},
9395 {"SOH", '\001'},
9396 {"STX", '\002'},
9397 {"ETX", '\003'},
9398 {"EOT", '\004'},
9399 {"ENQ", '\005'},
9400 {"ACK", '\006'},
9401 {"BEL", '\007'},
9402 {"alert", '\007'},
9403 {"BS", '\010'},
9404 {"backspace", '\b'},
9405 {"HT", '\011'},
9406 {"tab", '\t'},
9407 {"LF", '\012'},
9408 {"newline", '\n'},
9409 {"VT", '\013'},
9410 {"vertical-tab", '\v'},
9411 {"FF", '\014'},
9412 {"form-feed", '\f'},
9413 {"CR", '\015'},
9414 {"carriage-return", '\r'},
9415 {"SO", '\016'},
9416 {"SI", '\017'},
9417 {"DLE", '\020'},
9418 {"DC1", '\021'},
9419 {"DC2", '\022'},
9420 {"DC3", '\023'},
9421 {"DC4", '\024'},
9422 {"NAK", '\025'},
9423 {"SYN", '\026'},
9424 {"ETB", '\027'},
9425 {"CAN", '\030'},
9426 {"EM", '\031'},
9427 {"SUB", '\032'},
9428 {"ESC", '\033'},
9429 {"IS4", '\034'},
9430 {"FS", '\034'},
9431 {"IS3", '\035'},
9432 {"GS", '\035'},
9433 {"IS2", '\036'},
9434 {"RS", '\036'},
9435 {"IS1", '\037'},
9436 {"US", '\037'},
9437 {"space", ' '},
9438 {"exclamation-mark", '!'},
9439 {"quotation-mark", '"'},
9440 {"number-sign", '#'},
9441 {"dollar-sign", '$'},
9442 {"percent-sign", '%'},
9443 {"ampersand", '&'},
9444 {"apostrophe", '\''},
9445 {"left-parenthesis", '('},
9446 {"right-parenthesis", ')'},
9447 {"asterisk", '*'},
9448 {"plus-sign", '+'},
9449 {"comma", ','},
9450 {"hyphen", '-'},
9451 {"hyphen-minus", '-'},
9452 {"period", '.'},
9453 {"full-stop", '.'},
9454 {"slash", '/'},
9455 {"solidus", '/'},
9456 {"zero", '0'},
9457 {"one", '1'},
9458 {"two", '2'},
9459 {"three", '3'},
9460 {"four", '4'},
9461 {"five", '5'},
9462 {"six", '6'},
9463 {"seven", '7'},
9464 {"eight", '8'},
9465 {"nine", '9'},
9466 {"colon", ':'},
9467 {"semicolon", ';'},
9468 {"less-than-sign", '<'},
9469 {"equals-sign", '='},
9470 {"greater-than-sign", '>'},
9471 {"question-mark", '?'},
9472 {"commercial-at", '@'},
9473 {"left-square-bracket", '['},
9474 {"backslash", '\\'},
9475 {"reverse-solidus", '\\'},
9476 {"right-square-bracket",']'},
9477 {"circumflex", '^'},
9478 {"circumflex-accent", '^'},
9479 {"underscore", '_'},
9480 {"low-line", '_'},
9481 {"grave-accent", '`'},
9482 {"left-brace", '{'},
9483 {"left-curly-bracket", '{'},
9484 {"vertical-line", '|'},
9485 {"right-brace", '}'},
9486 {"right-curly-bracket", '}'},
9487 {"tilde", '~'},
9488 {"DEL", '\177'},
9489 {NULL, 0}
9490};
9491# 64 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c" 2
9492
9493/*
9494 * parse structure, passed up and down to avoid global variables and
9495 * other clumsinesses
9496 */
9497struct parse {
9498 char *next; /* next character in RE */
9499 char *end; /* end of string (-> NUL normally) */
9500 int error; /* has an error been seen? */
9501 sop *strip; /* malloced strip */
9502 sopno ssize; /* malloced strip size (allocated) */
9503 sopno slen; /* malloced strip length (used) */
9504 int ncsalloc; /* number of csets allocated */
9505 struct re_guts *g;
9506# define NPAREN 10 /* we need to remember () 1-9 for back refs */
9507 sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
9508 sopno pend[NPAREN]; /* -> ) ([0] unused) */
9509};
9510
9511/* ========= begin header generated by ./mkh ========= */
9512#ifdef __cplusplus
9513extern "C" {
9514#endif
9515# 87 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9516
9517/* === regcomp.c === */
9518static void p_ere(struct parse *p, int stop);
9519static void p_ere_exp(struct parse *p);
9520static void p_str(struct parse *p);
9521static void p_bre(struct parse *p, int end1, int end2);
9522static int p_simp_re(struct parse *p, int starordinary);
9523static int p_count(struct parse *p);
9524static void p_bracket(struct parse *p);
9525static void p_b_term(struct parse *p, cset *cs);
9526static void p_b_cclass(struct parse *p, cset *cs);
9527static void p_b_eclass(struct parse *p, cset *cs);
9528static wint_t p_b_symbol(struct parse *p);
9529static wint_t p_b_coll_elem(struct parse *p, wint_t endc);
9530static wint_t othercase(wint_t ch);
9531static void bothcases(struct parse *p, wint_t ch);
9532static void ordinary(struct parse *p, wint_t ch);
9533static void nonnewline(struct parse *p);
9534static void repeat(struct parse *p, sopno start, int from, int to);
9535static int seterr(struct parse *p, int e);
9536static cset *allocset(struct parse *p);
9537static void freeset(struct parse *p, cset *cs);
9538static void CHadd(struct parse *p, cset *cs, wint_t ch);
9539static void CHaddrange(struct parse *p, cset *cs, wint_t min, wint_t max);
9540static void CHaddtype(struct parse *p, cset *cs, wctype_t wct);
9541static wint_t singleton(cset *cs);
9542static sopno dupl(struct parse *p, sopno start, sopno finish);
9543static void doemit(struct parse *p, sop op, size_t opnd);
9544static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos);
9545static void dofwd(struct parse *p, sopno pos, sop value);
9546static int enlarge(struct parse *p, sopno size);
9547static void stripsnug(struct parse *p, struct re_guts *g);
9548static void findmust(struct parse *p, struct re_guts *g);
9549static int altoffset(sop *scan, int offset);
9550static void computejumps(struct parse *p, struct re_guts *g);
9551static void computematchjumps(struct parse *p, struct re_guts *g);
9552static sopno pluscount(struct parse *p, struct re_guts *g);
9553static wint_t wgetnext(struct parse *p);
9554
9555#ifdef __cplusplus
9556}
9557#endif
9558# 129 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9559/* ========= end header generated by ./mkh ========= */
9560
9561static char nuls[10]; /* place to point scanner in event of error */
9562
9563/*
9564 * macros for use with parse structure
9565 * BEWARE: these know that the parse structure is named `p' !!!
9566 */
9567#define PEEK() (*p->next)
9568#define PEEK2() (*(p->next+1))
9569#define MORE() (p->next < p->end)
9570#define MORE2() (p->next+1 < p->end)
9571#define SEE(c) (MORE() && PEEK() == (c))
9572#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
9573#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0)
9574#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
9575#define NEXT() (p->next++)
9576#define NEXT2() (p->next += 2)
9577#define NEXTn(n) (p->next += (n))
9578#define GETNEXT() (*p->next++)
9579#define WGETNEXT() wgetnext(p)
9580#define SETERROR(e) seterr(p, (e))
9581#define REQUIRE(co, e) ((co) || SETERROR(e))
9582#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
9583#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e))
9584#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
9585#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
9586#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
9587#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
9588#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
9589#define HERE() (p->slen)
9590#define THERE() (p->slen - 1)
9591#define THERETHERE() (p->slen - 2)
9592#define DROP(n) (p->slen -= (n))
9593
9594#ifndef NDEBUG
9595static int never = 0; /* for use in asserts; shuts lint up */
9596#else
9597# 167 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9598#define never 0 /* some <assert.h>s have bugs too */
9599#endif
9600# 169 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9601
9602/* Macro used by computejump()/computematchjump() */
9603#define MIN(a,b) ((a)<(b)?(a):(b))
9604
9605/*
9606 - regcomp - interface for parser and compilation
9607 = extern int regcomp(regex_t *, const char *, int);
9608 = #define REG_BASIC 0000
9609 = #define REG_EXTENDED 0001
9610 = #define REG_ICASE 0002
9611 = #define REG_NOSUB 0004
9612 = #define REG_NEWLINE 0010
9613 = #define REG_NOSPEC 0020
9614 = #define REG_PEND 0040
9615 = #define REG_DUMP 0200
9616 */
9617int /* 0 success, otherwise REG_something */
9618regcomp(regex_t * __restrict preg,
9619 const char * __restrict pattern,
9620 int cflags)
9621{
9622 struct parse pa;
9623 struct re_guts *g;
9624 struct parse *p = &pa;
9625 int i;
9626 size_t len;
9627 size_t maxlen;
9628#ifdef REDEBUG
9629# define GOODFLAGS(f) (f)
9630#else
9631# 199 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9632# define GOODFLAGS(f) ((f)&~REG_DUMP)
9633#endif
9634# 201 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9635
9636 cflags = GOODFLAGS(cflags);
9637 if ((cflags®_EXTENDED) && (cflags®_NOSPEC))
9638 return(REG_INVARG);
9639
9640 if (cflags®_PEND) {
9641 if (preg->re_endp < pattern)
9642 return(REG_INVARG);
9643 len = preg->re_endp - pattern;
9644 } else
9645 len = strlen((char *)pattern);
9646
9647 /* do the mallocs early so failure handling is easy */
9648 g = (struct re_guts *)malloc(sizeof(struct re_guts));
9649 if (g == NULL)
9650 return(REG_ESPACE);
9651 /*
9652 * Limit the pattern space to avoid a 32-bit overflow on buffer
9653 * extension. Also avoid any signed overflow in case of conversion
9654 * so make the real limit based on a 31-bit overflow.
9655 *
9656 * Likely not applicable on 64-bit systems but handle the case
9657 * generically (who are we to stop people from using ~715MB+
9658 * patterns?).
9659 */
9660 maxlen = ((size_t)-1 >> 1) / sizeof(sop) * 2 / 3;
9661 if (len >= maxlen) {
9662 free((char *)g);
9663 return(REG_ESPACE);
9664 }
9665 p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
9666 assert(p->ssize >= len);
9667
9668 p->strip = (sop *)malloc(p->ssize * sizeof(sop));
9669 p->slen = 0;
9670 if (p->strip == NULL) {
9671 free((char *)g);
9672 return(REG_ESPACE);
9673 }
9674
9675 /* set things up */
9676 p->g = g;
9677 p->next = (char *)pattern; /* convenience; we do not modify it */
9678 p->end = p->next + len;
9679 p->error = 0;
9680 p->ncsalloc = 0;
9681 for (i = 0; i < NPAREN; i++) {
9682 p->pbegin[i] = 0;
9683 p->pend[i] = 0;
9684 }
9685 g->sets = NULL;
9686 g->ncsets = 0;
9687 g->cflags = cflags;
9688 g->iflags = 0;
9689 g->nbol = 0;
9690 g->neol = 0;
9691 g->must = NULL;
9692 g->moffset = -1;
9693 g->charjump = NULL;
9694 g->matchjump = NULL;
9695 g->mlen = 0;
9696 g->nsub = 0;
9697 g->backrefs = 0;
9698
9699 /* do it */
9700 EMIT(OEND, 0);
9701 g->firststate = THERE();
9702 if (cflags®_EXTENDED)
9703 p_ere(p, OUT);
9704 else if (cflags®_NOSPEC)
9705 p_str(p);
9706 else
9707 p_bre(p, OUT, OUT);
9708 EMIT(OEND, 0);
9709 g->laststate = THERE();
9710
9711 /* tidy up loose ends and fill things in */
9712 stripsnug(p, g);
9713 findmust(p, g);
9714 /* only use Boyer-Moore algorithm if the pattern is bigger
9715 * than three characters
9716 */
9717 if(g->mlen > 3) {
9718 computejumps(p, g);
9719 computematchjumps(p, g);
9720 if(g->matchjump == NULL && g->charjump != NULL) {
9721 free(g->charjump);
9722 g->charjump = NULL;
9723 }
9724 }
9725 g->nplus = pluscount(p, g);
9726 g->magic = MAGIC2;
9727 preg->re_nsub = g->nsub;
9728 preg->re_g = g;
9729 preg->re_magic = MAGIC1;
9730#ifndef REDEBUG
9731 /* not debugging, so can't rely on the assert() in regexec() */
9732 if (g->iflags&BAD)
9733 SETERROR(REG_ASSERT);
9734#endif
9735# 301 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9736
9737 /* win or lose, we're done */
9738 if (p->error != 0) /* lose */
9739 regfree(preg);
9740 return(p->error);
9741}
9742
9743/*
9744 - p_ere - ERE parser top level, concatenation and alternation
9745 == static void p_ere(struct parse *p, int_t stop);
9746 */
9747static void
9748p_ere(struct parse *p,
9749 int stop) /* character this ERE should end at */
9750{
9751 char c;
9752 sopno prevback;
9753 sopno prevfwd;
9754 sopno conc;
9755 int first = 1; /* is this the first alternative? */
9756
9757 for (;;) {
9758 /* do a bunch of concatenated expressions */
9759 conc = HERE();
9760 while (MORE() && (c = PEEK()) != '|' && c != stop)
9761 p_ere_exp(p);
9762 (void)REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
9763
9764 if (!EAT('|'))
9765 break; /* NOTE BREAK OUT */
9766
9767 if (first) {
9768 INSERT(OCH_, conc); /* offset is wrong */
9769 prevfwd = conc;
9770 prevback = conc;
9771 first = 0;
9772 }
9773 ASTERN(OOR1, prevback);
9774 prevback = THERE();
9775 AHEAD(prevfwd); /* fix previous offset */
9776 prevfwd = HERE();
9777 EMIT(OOR2, 0); /* offset is very wrong */
9778 }
9779
9780 if (!first) { /* tail-end fixups */
9781 AHEAD(prevfwd);
9782 ASTERN(O_CH, prevback);
9783 }
9784
9785 assert(!MORE() || SEE(stop));
9786}
9787
9788/*
9789 - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
9790 == static void p_ere_exp(struct parse *p);
9791 */
9792static void
9793p_ere_exp(struct parse *p)
9794{
9795 char c;
9796 wint_t wc;
9797 sopno pos;
9798 int count;
9799 int count2;
9800 sopno subno;
9801 int wascaret = 0;
9802
9803 assert(MORE()); /* caller should have ensured this */
9804 c = GETNEXT();
9805
9806 pos = HERE();
9807 switch (c) {
9808 case '(':
9809 (void)REQUIRE(MORE(), REG_EPAREN);
9810 p->g->nsub++;
9811 subno = p->g->nsub;
9812 if (subno < NPAREN)
9813 p->pbegin[subno] = HERE();
9814 EMIT(OLPAREN, subno);
9815 if (!SEE(')'))
9816 p_ere(p, ')');
9817 if (subno < NPAREN) {
9818 p->pend[subno] = HERE();
9819 assert(p->pend[subno] != 0);
9820 }
9821 EMIT(ORPAREN, subno);
9822 (void)MUSTEAT(')', REG_EPAREN);
9823 break;
9824#ifndef POSIX_MISTAKE
9825 case ')': /* happens only if no current unmatched ( */
9826 /*
9827 * You may ask, why the ifndef? Because I didn't notice
9828 * this until slightly too late for 1003.2, and none of the
9829 * other 1003.2 regular-expression reviewers noticed it at
9830 * all. So an unmatched ) is legal POSIX, at least until
9831 * we can get it fixed.
9832 */
9833 SETERROR(REG_EPAREN);
9834 break;
9835#endif
9836# 401 "/home/rnw24/git/cheribsd/lib/libc_cheri/../libc/regex/regcomp.c"
9837 case '^':
9838 EMIT(OBOL, 0);
9839 p->g->iflags |= USEBOL;
9840 p->g->nbol++;
9841 wascaret = 1;
9842 break;
9843 case '$':
9844 EMIT(OEOL, 0);
9845 p->g->iflags |= USEEOL;
9846 p->g->neol++;
9847 break;
9848 case '|':
9849 SETERROR(REG_EMPTY);
9850 break;
9851 case '*':
9852 case '+':
9853 case '?':
9854 SETERROR(REG_BADRPT);
9855 break;
9856 case '.':
9857 if (p->g->cflags®_NEWLINE)
9858 nonnewline(p);
9859 else
9860 EMIT(OANY, 0);
9861 break;
9862 case '[':
9863 p_bracket(p);
9864 break;
9865 case '\\':
9866 (void)REQUIRE(MORE(), REG_EESCAPE);
9867 wc = WGETNEXT();
9868 switch (wc) {
9869 case '<':
9870 EMIT(OBOW, 0);
9871 break;
9872 case '>':
9873 EMIT(OEOW, 0);
9874 break;
9875 default:
9876 ordinary(p, wc);
9877 break;
9878 }
9879 break;
9880 case '{': /* okay as ordinary except if digit follows */
9881 (void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
9882 /* FALLTHROUGH */
9883 default:
9884 p->next--;
9885 wc = WGETNEXT();
9886 ordinary(p, wc);
9887 break;
9888 }
9889
9890 if (!MORE())
9891 return;
9892 c = PEEK();
9893 /* we call { a repetition if followed by a digit */
9894 if (!( c == '*' || c == '+' || c == '?' ||
9895 (c == '{' && MORE2() && isdigit((uch)PEEK2())) ))
9896 return; /* no repetition, we're done */
9897 NEXT();
9898
9899 (void)REQUIRE(!wascaret, REG_BADRPT);
9900 switch (c) {
9901 case '*': /* implemented as +? */
9902 /* this case does not require the (y|) trick, noKLUDGE */
9903 INSERT(OPLUS_, pos);
9904 ASTERN(O_PLUS, pos);
9905 INSERT(OQUEST_, pos);
9906 ASTERN(O_QUEST, pos);
9907 break;
9908 case '+':
9909 INSERT(OPLUS_, pos);
9910 ASTERN(O_PLUS, pos);
9911 break;
9912 case '?':
9913 /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
9914 INSERT(OCH_, pos); /* offset slightly wrong */
9915 ASTERN(OOR1, pos); /* this one's right */
9916 AHEAD(pos); /* fix the OCH_ */
9917 EMIT(OOR2, 0); /* offset very wrong... */
9918 AHEAD(THERE()); /* ...so fix it */
9919 ASTERN(O_CH, THERETHERE());
9920 break;
9921 case '{':
9922 count = p_count(p);
9923 if (EAT(',')) {
9924 if (isdigit((uch)PEEK())) {
9925 count2 = p_count(p);
9926 (void)REQUIRE(count <= count2, REG_BADBR);
9927 } else /* single number with comma */
9928 count2 = INFINITY;
9929 } else /* just a single number */
9930 count2 = count;
9931 repeat(p, pos, count, count2);
9932 if (!EAT('}')) { /* error heuristics */
9933 while (MORE() && PEEK() != '}')
9934 NEXT();
9935 (void)REQUIRE(MORE(), REG_EBRACE);
9936 SETERROR(REG_BADBR);
9937 }
9938 break;
9939 }
9940
9941 if (!MORE())
9942 return;
9943 c = PEEK();
9944 if (!( c == '*' || c == '+' || c == '?' ||
9945 (c == '{' && MORE2() && isdigit((uch)PEEK2())) ) )
9946 return;
9947 SETERROR(REG_BADRPT);
9948}
9949
9950/*
9951 - p_str - string (no metacharacters) "parser"
9952 == static void p_str(struct parse *p);
9953 */
9954static void
9955p_str(struct parse *p)
9956{
9957 (void)REQUIRE(MORE(), REG_EMPTY);
9958 while (MORE())
9959 ordinary(p, WGETNEXT());
9960}
9961
9962/*
9963 - p_bre - BRE parser top level, anchoring and concatenation
9964 == static void p_bre(struct parse *p, int end1, \
9965 == int end2);
9966 * Giving end1 as OUT essentially eliminates the end1/end2 check.
9967 *
9968 * This implementation is a bit of a kludge, in that a trailing $ is first
9969 * taken as an ordinary character and then revised to be an anchor.
9970 * The amount of lookahead needed to avoid this kludge is excessive.
9971 */
9972static void
9973p_bre(struct parse *p,
9974 int end1, /* first terminating character */
9975 int end2) /* second terminating character */
9976{
9977 sopno start = HERE();
9978 int first = 1; /* first subexpression? */
9979 int wasdollar = 0;
9980
9981 if (EAT('^')) {
9982 EMIT(OBOL, 0);
9983 p->g->iflags |= USEBOL;
9984 p->g->nbol++;
9985 }
9986 while (MORE() && !SEETWO(end1, end2)) {
9987 wasdollar = p_simp_re(p, first);
9988 first = 0;
9989 }
9990 if (wasdollar) { /* oops, that was a trailing anchor */
9991 DROP(1);
9992 EMIT(OEOL, 0);
9993 p->g->iflags |= USEEOL;
9994 p->g->neol++;
9995 }
9996
9997 (void)REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
9998}
9999
10000/*
10001 - p_simp_re - parse a simple RE, an atom possibly followed by a repetition
10002 == static int p_simp_re(struct parse *p, int starordinary);
10003 */
10004static int /* was the simple RE an unbackslashed $? */
10005p_simp_re(struct parse *p,
10006 int starordinary) /* is a leading * an ordinary character? */
10007{
10008 int c;
10009 int count;
10010 int count2;
10011 sopno pos;
10012 int i;
10013 wint_t wc;
10014 sopno subno;
10015# define BACKSL (1<<CHAR_BIT)
10016
10017 pos = HERE(); /* repetion op, if any, covers from here */
10018
10019 assert(MORE()); /* caller should have ensured this */
10020 c = GETNEXT();
10021 if (c == '\\') {
10022 (void)REQUIRE(MORE(), REG_EESCAPE);
10023 c = BACKSL | GETNEXT();
10024 }
10025 switch (c) {
10026 case '.':
10027 if (p->g->cflags®_NEWLINE)
10028 nonnewline(p);
10029 else
10030 EMIT(OANY, 0);
10031 break;
10032 case '[':
10033 p_bracket(p);
10034 break;
10035 case BACKSL|'<':
10036 EMIT(OBOW, 0);
10037 break;
10038 case BACKSL|'>':
10039 EMIT(OEOW, 0);
10040 break;
10041 case BACKSL|'{':
10042 SETERROR(REG_BADRPT);
10043 break;
10044 case BACKSL|'(':
10045 p->g->nsub++;
10046 subno = p->g->nsub;
10047 if (subno < NPAREN)
10048 p->pbegin[subno] = HERE();
10049 EMIT(OLPAREN, subno);
10050 /* the MORE here is an error heuristic */
10051 if (MORE() && !SEETWO('\\', ')'))
10052 p_bre(p, '\\', ')');
10053 if (subno < NPAREN) {
10054 p->pend[subno] = HERE();
10055 assert(p->pend[subno] != 0);
10056 }
10057 EMIT(ORPAREN, subno);
10058 (void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
10059 break;
10060 case BACKSL|')': /* should not get here -- must be user */
10061 case BACKSL|'}':
10062 SETERROR(REG_EPAREN);
10063 break;
10064 case BACKSL|'1':
10065 case BACKSL|'2':
10066 case BACKSL|'3':
10067 case BACKSL|'4':
10068 case BACKSL|'5':
10069 case BACKSL|'6':
10070 case BACKSL|'7':
10071 case BACKSL|'8':
10072 case BACKSL|'9':
10073 i = (c&~BACKSL) - '0';
10074 assert(i < NPAREN);
10075 if (p->pend[i] != 0) {
10076 assert(i <= p->g->nsub);
10077 EMIT(OBACK_, i);
10078 assert(p->pbegin[i] != 0);
10079 assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
10080 assert(OP(p->strip[p->pend[i]]) == ORPAREN);
10081 (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
10082 EMIT(O_BACK, i);
10083 } else
10084 SETERROR(REG_ESUBREG);
10085 p->g->backrefs = 1;
10086 break;
10087 case '*':
10088 (void)REQUIRE(starordinary, REG_BADRPT);
10089 /* FALLTHROUGH */
10090 default:
10091 p->next--;
10092 wc = WGETNEXT();
10093 ordinary(p, wc);
10094 break;
10095 }
10096
10097 if (EAT('*')) { /* implemented as +? */
10098 /* this case does not require the (y|) trick, noKLUDGE */
10099 INSERT(OPLUS_, pos);
10100 ASTERN(O_PLUS, pos);
10101 INSERT(OQUEST_, pos);
10102 ASTERN(O_QUEST, pos);
10103 } else if (EATTWO('\\', '{')) {
10104 count = p_count(p);
10105 if (EAT(',')) {
10106 if (MORE() && isdigit((uch)PEEK())) {
10107 count2 = p_count(p);
10108 (void)REQUIRE(count <= count2, REG_BADBR);
10109 } else /* single number with comma */
10110 count2 = INFINITY;
10111 } else /* just a single number */
10112 count2 = count;
10113 repeat(p, pos, count, count2);
10114 if (!EATTWO('\\', '}')) { /* error heuristics */
10115 while (MORE() && !SEETWO('\\', '}'))
10116 NEXT();
10117 (void)REQUIRE(MORE(), REG_EBRACE);
10118 SETERROR(REG_BADBR);
10119 }
10120 } else if (c == '$') /* $ (but not \$) ends it */
10121 return(1);
10122
10123 return(0);
10124}
10125
10126/*
10127 - p_count - parse a repetition count
10128 == static int p_count(struct parse *p);
10129 */
10130static int /* the value */
10131p_count(struct parse *p)
10132{
10133 int count = 0;
10134 int ndigits = 0;
10135
10136 while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) {
10137 count = count*10 + (GETNEXT() - '0');
10138 ndigits++;
10139 }
10140
10141 (void)REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
10142 return(count);
10143}
10144
10145/*
10146 - p_bracket - parse a bracketed character list
10147 == static void p_bracket(struct parse *p);
10148 */
10149static void
10150p_bracket(struct parse *p)
10151{
10152 cset *cs;
10153 wint_t ch;
10154
10155 /* Dept of Truly Sickening Special-Case Kludges */
10156 if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) {
10157 EMIT(OBOW, 0);
10158 NEXTn(6);
10159 return;
10160 }
10161 if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) {
10162 EMIT(OEOW, 0);
10163 NEXTn(6);
10164 return;
10165 }
10166
10167 if ((cs = allocset(p)) == NULL)
10168 return;
10169
10170 if (p->g->cflags®_ICASE)
10171 cs->icase = 1;
10172 if (EAT('^'))
10173 cs->invert = 1;
10174 if (EAT(']'))
10175 CHadd(p, cs, ']');
10176 else if (EAT('-'))
10177 CHadd(p, cs, '-');
10178 while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
10179 p_b_term(p, cs);
10180 if (EAT('-'))
10181 CHadd(p, cs, '-');
10182 (void)MUSTEAT(']', REG_EBRACK);
10183
10184 if (p->error != 0) /* don't mess things up further */
10185 return;
10186
10187 if (cs->invert && p->g->cflags®_NEWLINE)
10188 cs->bmp['\n' >> 3] |= 1 << ('\n' & 7);
10189
10190 if ((ch = singleton(cs)) != OUT) { /* optimize singleton sets */
10191 ordinary(p, ch);
10192 freeset(p, cs);
10193 } else
10194 EMIT(OANYOF, (int)(cs - p->g->sets));
10195}
10196
10197/*
10198 - p_b_term - parse one term of a bracketed character list
10199 == static void p_b_term(struct parse *p, cset *cs);
10200 */
10201static void
10202p_b_term(struct parse *p, cset *cs)
10203{
10204 char c;
10205 wint_t start, finish;
10206 wint_t i;
10207 struct xlocale_collate *table =
10208 (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE];
10209
10210 /* classify what we've got */
10211 switch ((MORE()) ? PEEK() : '\0') {
10212 case '[':
10213 c = (MORE2()) ? PEEK2() : '\0';
10214 break;
10215 case '-':
10216 SETERROR(REG_ERANGE);
10217 return; /* NOTE RETURN */
10218 default:
10219 c = '\0';
10220 break;
10221 }
10222
10223 switch (c) {
10224 case ':': /* character class */
10225 NEXT2();
10226 (void)REQUIRE(MORE(), REG_EBRACK);
10227 c = PEEK();
10228 (void)REQUIRE(c != '-' && c != ']', REG_ECTYPE);
10229 p_b_cclass(p, cs);
10230 (void)REQUIRE(MORE(), REG_EBRACK);
10231 (void)REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
10232 break;
10233 case '=': /* equivalence class */
10234 NEXT2();
10235 (void)REQUIRE(MORE(), REG_EBRACK);
10236 c = PEEK();
10237 (void)REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
10238 p_b_eclass(p, cs);
10239 (void)REQUIRE(MORE(), REG_EBRACK);
10240 (void)REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
10241 break;
10242 default: /* symbol, ordinary character, or range */
10243 start = p_b_symbol(p);
10244 if (SEE('-') && MORE2() && PEEK2() != ']') {
10245 /* range */
10246 NEXT();
10247 if (EAT('-'))
10248 finish = '-';
10249 else
10250 finish = p_b_symbol(p);
10251 } else
10252 finish = start;
10253 if (start == finish)
10254 CHadd(p, cs, start);
10255 else {
10256 if (table->__collate_load_error) {
10257 (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE);
10258 CHaddrange(p, cs, start, finish);
10259 } else {
10260 (void)REQUIRE(__collate_range_cmp(table, start, finish) <= 0, REG_ERANGE);
10261 for (i = 0; i <= UCHAR_MAX; i++) {
10262 if ( __collate_range_cmp(table, start, i) <= 0
10263 && __collate_range_cmp(table, i, finish) <= 0
10264 )
10265 CHadd(p, cs, i);
10266 }
10267 }
10268 }
10269 break;
10270 }
10271}
10272
10273/*
10274 - p_b_cclass - parse a character-class name and deal with it
10275 == static void p_b_cclass(struct parse *p, cset *cs);
10276 */
10277static void
10278p_b_cclass(struct parse *p, cset *cs)
10279{
10280 char *sp = p->next;
10281 size_t len;
10282 wctype_t wct;
10283 char clname[16];
10284
10285 while (MORE() && isalpha((uch)PEEK()))
10286 NEXT();
10287 len = p->next - sp;
10288 if (len >= sizeof(clname) - 1) {
10289 SETERROR(REG_ECTYPE);
10290 return;
10291 }
10292 memcpy(clname, sp, len);
10293 clname[len] = '\0';
10294 if ((wct = wctype(clname)) == 0) {
10295 SETERROR(REG_ECTYPE);
10296 return;
10297 }
10298 CHaddtype(p, cs, wct);
10299}
10300
10301/*
10302 - p_b_eclass - parse an equivalence-class name and deal with it
10303 == static void p_b_eclass(struct parse *p, cset *cs);
10304 *
10305 * This implementation is incomplete. xxx
10306 */
10307static void
10308p_b_eclass(struct parse *p, cset *cs)
10309{
10310 wint_t c;
10311
10312 c = p_b_coll_elem(p, '=');
10313 CHadd(p, cs, c);
10314}
10315
10316/*
10317 - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
10318 == static wint_t p_b_symbol(struct parse *p);
10319 */
10320static wint_t /* value of symbol */
10321p_b_symbol(struct parse *p)
10322{
10323 wint_t value;
10324
10325 (void)REQUIRE(MORE(), REG_EBRACK);
10326 if (!EATTWO('[', '.'))
10327 return(WGETNEXT());
10328
10329 /* collating symbol */
10330 value = p_b_coll_elem(p, '.');
10331 (void)REQUIRE(EATTWO('.', ']'), REG_ECOLLATE);
10332 return(value);
10333}
10334
10335/*
10336 - p_b_coll_elem - parse a collating-element name and look it up
10337 == static wint_t p_b_coll_elem(struct parse *p, wint_t endc);
10338 */
10339static wint_t /* value of collating element */
10340p_b_coll_elem(struct parse *p,
10341 wint_t endc) /* name ended by endc,']' */
10342{
10343 char *sp = p->next;
10344 struct cname *cp;
10345 int len;
10346 mbstate_t mbs;
10347 wchar_t wc;
10348 size_t clen;
10349
10350 while (MORE() && !SEETWO(endc, ']'))
10351 NEXT();
10352 if (!MORE()) {
10353 SETERROR(REG_EBRACK);
10354 return(0);
10355 }
10356 len = p->next - sp;
10357 for (cp = cnames; cp->name != NULL; cp++)
10358 if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
10359 return(cp->code); /* known name */
10360 memset(&mbs, 0, sizeof(mbs));
10361 if ((clen = mbrtowc(&wc, sp, len, &mbs)) == len)
10362 return (wc); /* single character */
10363 else if (clen == (size_t)-1 || clen == (size_t)-2)
10364 SETERROR(REG_ILLSEQ);
10365 else
10366 SETERROR(REG_ECOLLATE); /* neither */
10367 return(0);
10368}
10369
10370/*
10371 - othercase - return the case counterpart of an alphabetic
10372 == static wint_t othercase(wint_t ch);
10373 */
10374static wint_t /* if no counterpart, return ch */
10375othercase(wint_t ch)
10376{
10377 assert(iswalpha(ch));
10378 if (iswupper(ch))
10379 return(towlower(ch));
10380 else if (iswlower(ch))
10381 return(towupper(ch));
10382 else /* peculiar, but could happen */
10383 return(ch);
10384}
10385
10386/*
10387 - bothcases - emit a dualcase version of a two-case character
10388 == static void bothcases(struct parse *p, wint_t ch);
10389 *
10390 * Boy, is this implementation ever a kludge...
10391 */
10392static void
10393bothcases(struct parse *p, wint_t ch)
10394{
10395 char *oldnext = p->next;
10396 char *oldend = p->end;
10397 char bracket[3 + MB_LEN_MAX];
10398 size_t n;
10399 mbstate_t mbs;
10400
10401 assert(othercase(ch) != ch); /* p_bracket() would recurse */
10402 p->next = bracket;
10403 memset(&mbs, 0, sizeof(mbs));
10404 n = wcrtomb(bracket, ch, &mbs);
10405 assert(n != (size_t)-1);
10406 bracket[n] = ']';
10407 bracket[n + 1] = '\0';
10408 p->end = bracket+n+1;
10409 p_bracket(p);
10410 assert(p->next == p->end);
10411 p->next = oldnext;
10412 p->end = oldend;
10413}
10414
10415/*
10416 - ordinary - emit an ordinary character
10417 == static void ordinary(struct parse *p, wint_t ch);
10418 */
10419static void
10420ordinary(struct parse *p, wint_t ch)
10421{
10422 cset *cs;
10423
10424 if ((p->g->cflags®_ICASE) && iswalpha(ch) && othercase(ch) != ch)
10425 bothcases(p, ch);
10426 else if ((ch & OPDMASK) == ch)
10427 EMIT(OCHAR, ch);
10428 else {
10429 /*
10430 * Kludge: character is too big to fit into an OCHAR operand.
10431 * Emit a singleton set.
10432 */
10433 if ((cs = allocset(p)) == NULL)
10434 return;
10435 CHadd(p, cs, ch);
10436 EMIT(OANYOF, (int)(cs - p->g->sets));
10437 }
10438}
10439
10440/*
10441 - nonnewline - emit REG_NEWLINE version of OANY
10442 == static void nonnewline(struct parse *p);
10443 *
10444 * Boy, is this implementation ever a kludge...
10445 */
10446static void
10447nonnewline(struct parse *p)
10448{
10449 char *oldnext = p->next;
10450 char *oldend = p->end;
10451 char bracket[4];
10452
10453 p->next = bracket;
10454 p->end = bracket+3;
10455 bracket[0] = '^';
10456 bracket[1] = '\n';
10457 bracket[2] = ']';
10458 bracket[3] = '\0';
10459 p_bracket(p);
10460 assert(p->next == bracket+3);
10461 p->next = oldnext;
10462 p->end = oldend;
10463}
10464
10465/*
10466 - repeat - generate code for a bounded repetition, recursively if needed
10467 == static void repeat(struct parse *p, sopno start, int from, int to);
10468 */
10469static void
10470repeat(struct parse *p,
10471 sopno start, /* operand from here to end of strip */
10472 int from, /* repeated from this number */
10473 int to) /* to this number of times (maybe INFINITY) */
10474{
10475 sopno finish = HERE();
10476# define N 2
10477# define INF 3
10478# define REP(f, t) ((f)*8 + (t))
10479# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)
10480 sopno copy;
10481
10482 if (p->error != 0) /* head off possible runaway recursion */
10483 return;
10484
10485 assert(from <= to);
10486
10487 switch (REP(MAP(from), MAP(to))) {
10488 case REP(0, 0): /* must be user doing this */
10489 DROP(finish-start); /* drop the operand */
10490 break;
10491 case REP(0, 1): /* as x{1,1}? */
10492 case REP(0, N): /* as x{1,n}? */
10493 case REP(0, INF): /* as x{1,}? */
10494 /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
10495 INSERT(OCH_, start); /* offset is wrong... */
10496 repeat(p, start+1, 1, to);
10497 ASTERN(OOR1, start);
10498 AHEAD(start); /* ... fix it */
10499 EMIT(OOR2, 0);
10500 AHEAD(THERE());
10501 ASTERN(O_CH, THERETHERE());
10502 break;
10503 case REP(1, 1): /* trivial case */
10504 /* done */
10505 break;
10506 case REP(1, N): /* as x?x{1,n-1} */
10507 /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
10508 INSERT(OCH_, start);
10509 ASTERN(OOR1, start);
10510 AHEAD(start);
10511 EMIT(OOR2, 0); /* offset very wrong... */
10512 AHEAD(THERE()); /* ...so fix it */
10513 ASTERN(O_CH, THERETHERE());
10514 copy = dupl(p, start+1, finish+1);
10515 assert(copy == finish+4);
10516 repeat(p, copy, 1, to-1);
10517 break;
10518 case REP(1, INF): /* as x+ */
10519 INSERT(OPLUS_, start);
10520 ASTERN(O_PLUS, start);
10521 break;
10522 case REP(N, N): /* as xx{m-1,n-1} */
10523 copy = dupl(p, start, finish);
10524 repeat(p, copy, from-1, to-1);
10525 break;
10526 case REP(N, INF): /* as xx{n-1,INF} */
10527 copy = dupl(p, start, finish);
10528 repeat(p, copy, from-1, to);
10529 break;
10530 default: /* "can't happen" */
10531 SETERROR(REG_ASSERT); /* just in case */
10532 break;
10533 }
10534}
10535
10536/*
10537 - wgetnext - helper function for WGETNEXT() macro. Gets the next wide
10538 - character from the parse struct, signals a REG_ILLSEQ error if the
10539 - character can't be converted. Returns the number of bytes consumed.
10540 */
10541static wint_t
10542wgetnext(struct parse *p)
10543{
10544 mbstate_t mbs;
10545 wchar_t wc;
10546 size_t n;
10547
10548 memset(&mbs, 0, sizeof(mbs));
10549 n = mbrtowc(&wc, p->next, p->end - p->next, &mbs);
10550 if (n == (size_t)-1 || n == (size_t)-2) {
10551 SETERROR(REG_ILLSEQ);
10552 return (0);
10553 }
10554 if (n == 0)
10555 n = 1;
10556 p->next += n;
10557 return (wc);
10558}
10559
10560/*
10561 - seterr - set an error condition
10562 == static int seterr(struct parse *p, int e);
10563 */
10564static int /* useless but makes type checking happy */
10565seterr(struct parse *p, int e)
10566{
10567 if (p->error == 0) /* keep earliest error condition */
10568 p->error = e;
10569 p->next = nuls; /* try to bring things to a halt */
10570 p->end = nuls;
10571 return(0); /* make the return value well-defined */
10572}
10573
10574/*
10575 - allocset - allocate a set of characters for []
10576 == static cset *allocset(struct parse *p);
10577 */
10578static cset *
10579allocset(struct parse *p)
10580{
10581 cset *cs, *ncs;
10582
10583 ncs = realloc(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs));
10584 if (ncs == NULL) {
10585 SETERROR(REG_ESPACE);
10586 return (NULL);
10587 }
10588 p->g->sets = ncs;
10589 cs = &p->g->sets[p->g->ncsets++];
10590 memset(cs, 0, sizeof(*cs));
10591
10592 return(cs);
10593}
10594
10595/*
10596 - freeset - free a now-unused set
10597 == static void freeset(struct parse *p, cset *cs);
10598 */
10599static void
10600freeset(struct parse *p, cset *cs)
10601{
10602 cset *top = &p->g->sets[p->g->ncsets];
10603
10604 free(cs->wides);
10605 free(cs->ranges);
10606 free(cs->types);
10607 memset(cs, 0, sizeof(*cs));
10608 if (cs == top-1) /* recover only the easy case */
10609 p->g->ncsets--;
10610}
10611
10612/*
10613 - singleton - Determine whether a set contains only one character,
10614 - returning it if so, otherwise returning OUT.
10615 */
10616static wint_t
10617singleton(cset *cs)
10618{
10619 wint_t i, s, n;
10620
10621 for (i = n = 0; i < NC; i++)
10622 if (CHIN(cs, i)) {
10623 n++;
10624 s = i;
10625 }
10626 if (n == 1)
10627 return (s);
10628 if (cs->nwides == 1 && cs->nranges == 0 && cs->ntypes == 0 &&
10629 cs->icase == 0)
10630 return (cs->wides[0]);
10631 /* Don't bother handling the other cases. */
10632 return (OUT);
10633}
10634
10635/*
10636 - CHadd - add character to character set.
10637 */
10638static void
10639CHadd(struct parse *p, cset *cs, wint_t ch)
10640{
10641 wint_t nch, *newwides;
10642 assert(ch >= 0);
10643 if (ch < NC)
10644 cs->bmp[ch >> 3] |= 1 << (ch & 7);
10645 else {
10646 newwides = realloc(cs->wides, (cs->nwides + 1) *
10647 sizeof(*cs->wides));
10648 if (newwides == NULL) {
10649 SETERROR(REG_ESPACE);
10650 return;
10651 }
10652 cs->wides = newwides;
10653 cs->wides[cs->nwides++] = ch;
10654 }
10655 if (cs->icase) {
10656 if ((nch = towlower(ch)) < NC)
10657 cs->bmp[nch >> 3] |= 1 << (nch & 7);
10658 if ((nch = towupper(ch)) < NC)
10659 cs->bmp[nch >> 3] |= 1 << (nch & 7);
10660 }
10661}
10662
10663/*
10664 - CHaddrange - add all characters in the range [min,max] to a character set.
10665 */
10666static void
10667CHaddrange(struct parse *p, cset *cs, wint_t min, wint_t max)
10668{
10669 crange *newranges;
10670
10671 for (; min < NC && min <= max; min++)
10672 CHadd(p, cs, min);
10673 if (min >= max)
10674 return;
10675 newranges = realloc(cs->ranges, (cs->nranges + 1) *
10676 sizeof(*cs->ranges));
10677 if (newranges == NULL) {
10678 SETERROR(REG_ESPACE);
10679 return;
10680 }
10681 cs->ranges = newranges;
10682 cs->ranges[cs->nranges].min = min;
10683 cs->ranges[cs->nranges].max = max;
10684 cs->nranges++;
10685}
10686
10687/*
10688 - CHaddtype - add all characters of a certain type to a character set.
10689 */
10690static void
10691CHaddtype(struct parse *p, cset *cs, wctype_t wct)
10692{
10693 wint_t i;
10694 wctype_t *newtypes;
10695
10696 for (i = 0; i < NC; i++)
10697 if (iswctype(i, wct))
10698 CHadd(p, cs, i);
10699 newtypes = realloc(cs->types, (cs->ntypes + 1) *
10700 sizeof(*cs->types));
10701 if (newtypes == NULL) {
10702 SETERROR(REG_ESPACE);
10703 return;
10704 }
10705 cs->types = newtypes;
10706 cs->types[cs->ntypes++] = wct;
10707}
10708
10709/*
10710 - dupl - emit a duplicate of a bunch of sops
10711 == static sopno dupl(struct parse *p, sopno start, sopno finish);
10712 */
10713static sopno /* start of duplicate */
10714dupl(struct parse *p,
10715 sopno start, /* from here */
10716 sopno finish) /* to this less one */
10717{
10718 sopno ret = HERE();
10719 sopno len = finish - start;
10720
10721 assert(finish >= start);
10722 if (len == 0)
10723 return(ret);
10724 if (!enlarge(p, p->ssize + len)) /* this many unexpected additions */
10725 return(ret);
10726 (void) memcpy((char *)(p->strip + p->slen),
10727 (char *)(p->strip + start), (size_t)len*sizeof(sop));
10728 p->slen += len;
10729 return(ret);
10730}
10731
10732/*
10733 - doemit - emit a strip operator
10734 == static void doemit(struct parse *p, sop op, size_t opnd);
10735 *
10736 * It might seem better to implement this as a macro with a function as
10737 * hard-case backup, but it's just too big and messy unless there are
10738 * some changes to the data structures. Maybe later.
10739 */
10740static void
10741doemit(struct parse *p, sop op, size_t opnd)
10742{
10743 /* avoid making error situations worse */
10744 if (p->error != 0)
10745 return;
10746
10747 /* deal with oversize operands ("can't happen", more or less) */
10748 assert(opnd < 1<<OPSHIFT);
10749
10750 /* deal with undersized strip */
10751 if (p->slen >= p->ssize)
10752 if (!enlarge(p, (p->ssize+1) / 2 * 3)) /* +50% */
10753 return;
10754
10755 /* finally, it's all reduced to the easy case */
10756 p->strip[p->slen++] = SOP(op, opnd);
10757}
10758
10759/*
10760 - doinsert - insert a sop into the strip
10761 == static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos);
10762 */
10763static void
10764doinsert(struct parse *p, sop op, size_t opnd, sopno pos)
10765{
10766 sopno sn;
10767 sop s;
10768 int i;
10769
10770 /* avoid making error situations worse */
10771 if (p->error != 0)
10772 return;
10773
10774 sn = HERE();
10775 EMIT(op, opnd); /* do checks, ensure space */
10776 assert(HERE() == sn+1);
10777 s = p->strip[sn];
10778
10779 /* adjust paren pointers */
10780 assert(pos > 0);
10781 for (i = 1; i < NPAREN; i++) {
10782 if (p->pbegin[i] >= pos) {
10783 p->pbegin[i]++;
10784 }
10785 if (p->pend[i] >= pos) {
10786 p->pend[i]++;
10787 }
10788 }
10789
10790 memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
10791 (HERE()-pos-1)*sizeof(sop));
10792 p->strip[pos] = s;
10793}
10794
10795/*
10796 - dofwd - complete a forward reference
10797 == static void dofwd(struct parse *p, sopno pos, sop value);
10798 */
10799static void
10800dofwd(struct parse *p, sopno pos, sop value)
10801{
10802 /* avoid making error situations worse */
10803 if (p->error != 0)
10804 return;
10805
10806 assert(value < 1<<OPSHIFT);
10807 p->strip[pos] = OP(p->strip[pos]) | value;
10808}
10809
10810/*
10811 - enlarge - enlarge the strip
10812 == static int enlarge(struct parse *p, sopno size);
10813 */
10814static int
10815enlarge(struct parse *p, sopno size)
10816{
10817 sop *sp;
10818
10819 if (p->ssize >= size)
10820 return 1;
10821
10822 sp = (sop *)realloc(p->strip, size*sizeof(sop));
10823 if (sp == NULL) {
10824 SETERROR(REG_ESPACE);
10825 return 0;
10826 }
10827 p->strip = sp;
10828 p->ssize = size;
10829 return 1;
10830}
10831
10832/*
10833 - stripsnug - compact the strip
10834 == static void stripsnug(struct parse *p, struct re_guts *g);
10835 */
10836static void
10837stripsnug(struct parse *p, struct re_guts *g)
10838{
10839 g->nstates = p->slen;
10840 g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop));
10841 if (g->strip == NULL) {
10842 SETERROR(REG_ESPACE);
10843 g->strip = p->strip;
10844 }
10845}
10846
10847/*
10848 - findmust - fill in must and mlen with longest mandatory literal string
10849 == static void findmust(struct parse *p, struct re_guts *g);
10850 *
10851 * This algorithm could do fancy things like analyzing the operands of |
10852 * for common subsequences. Someday. This code is simple and finds most
10853 * of the interesting cases.
10854 *
10855 * Note that must and mlen got initialized during setup.
10856 */
10857static void
10858findmust(struct parse *p, struct re_guts *g)
10859{
10860 sop *scan;
10861 sop *start = NULL;
10862 sop *newstart = NULL;
10863 sopno newlen;
10864 sop s;
10865 char *cp;
10866 int offset;
10867 char buf[MB_LEN_MAX];
10868 size_t clen;
10869 mbstate_t mbs;
10870
10871 /* avoid making error situations worse */
10872 if (p->error != 0)
10873 return;
10874
10875 /*
10876 * It's not generally safe to do a ``char'' substring search on
10877 * multibyte character strings, but it's safe for at least
10878 * UTF-8 (see RFC 3629).
10879 */
10880 if (MB_CUR_MAX > 1 &&
10881 strcmp(_CurrentRuneLocale->__encoding, "UTF-8") != 0)
10882 return;
10883
10884 /* find the longest OCHAR sequence in strip */
10885 newlen = 0;
10886 offset = 0;
10887 g->moffset = 0;
10888 scan = g->strip + 1;
10889 do {
10890 s = *scan++;
10891 switch (OP(s)) {
10892 case OCHAR: /* sequence member */
10893 if (newlen == 0) { /* new sequence */
10894 memset(&mbs, 0, sizeof(mbs));
10895 newstart = scan - 1;
10896 }
10897 clen = wcrtomb(buf, OPND(s), &mbs);
10898 if (clen == (size_t)-1)
10899 goto toohard;
10900 newlen += clen;
10901 break;
10902 case OPLUS_: /* things that don't break one */
10903 case OLPAREN:
10904 case ORPAREN:
10905 break;
10906 case OQUEST_: /* things that must be skipped */
10907 case OCH_:
10908 offset = altoffset(scan, offset);
10909 scan--;
10910 do {
10911 scan += OPND(s);
10912 s = *scan;
10913 /* assert() interferes w debug printouts */
10914 if (OP(s) != O_QUEST && OP(s) != O_CH &&
10915 OP(s) != OOR2) {
10916 g->iflags |= BAD;
10917 return;
10918 }
10919 } while (OP(s) != O_QUEST && OP(s) != O_CH);
10920 /* FALLTHROUGH */
10921 case OBOW: /* things that break a sequence */
10922 case OEOW:
10923 case OBOL:
10924 case OEOL:
10925 case O_QUEST:
10926 case O_CH:
10927 case OEND:
10928 if (newlen > g->mlen) { /* ends one */
10929 start = newstart;
10930 g->mlen = newlen;
10931 if (offset > -1) {
10932 g->moffset += offset;
10933 offset = newlen;
10934 } else
10935 g->moffset = offset;
10936 } else {
10937 if (offset > -1)
10938 offset += newlen;
10939 }
10940 newlen = 0;
10941 break;
10942 case OANY:
10943 if (newlen > g->mlen) { /* ends one */
10944 start = newstart;
10945 g->mlen = newlen;
10946 if (offset > -1) {
10947 g->moffset += offset;
10948 offset = newlen;
10949 } else
10950 g->moffset = offset;
10951 } else {
10952 if (offset > -1)
10953 offset += newlen;
10954 }
10955 if (offset > -1)
10956 offset++;
10957 newlen = 0;
10958 break;
10959 case OANYOF: /* may or may not invalidate offset */
10960 /* First, everything as OANY */
10961 if (newlen > g->mlen) { /* ends one */
10962 start = newstart;
10963 g->mlen = newlen;
10964 if (offset > -1) {
10965 g->moffset += offset;
10966 offset = newlen;
10967 } else
10968 g->moffset = offset;
10969 } else {
10970 if (offset > -1)
10971 offset += newlen;
10972 }
10973 if (offset > -1)
10974 offset++;
10975 newlen = 0;
10976 break;
10977 toohard:
10978 default:
10979 /* Anything here makes it impossible or too hard
10980 * to calculate the offset -- so we give up;
10981 * save the last known good offset, in case the
10982 * must sequence doesn't occur later.
10983 */
10984 if (newlen > g->mlen) { /* ends one */
10985 start = newstart;
10986 g->mlen = newlen;
10987 if (offset > -1)
10988 g->moffset += offset;
10989 else
10990 g->moffset = offset;
10991 }
10992 offset = -1;
10993 newlen = 0;
10994 break;
10995 }
10996 } while (OP(s) != OEND);
10997
10998 if (g->mlen == 0) { /* there isn't one */
10999 g->moffset = -1;
11000 return;
11001 }
11002
11003 /* turn it into a character string */
11004 g->must = malloc((size_t)g->mlen + 1);
11005 if (g->must == NULL) { /* argh; just forget it */
11006 g->mlen = 0;
11007 g->moffset = -1;
11008 return;
11009 }
11010 cp = g->must;
11011 scan = start;
11012 memset(&mbs, 0, sizeof(mbs));
11013 while (cp < g->must + g->mlen) {
11014 while (OP(s = *scan++) != OCHAR)
11015 continue;
11016 clen = wcrtomb(cp, OPND(s), &mbs);
11017 assert(clen != (size_t)-1);
11018 cp += clen;
11019 }
11020 assert(cp == g->must + g->mlen);
11021 *cp++ = '\0'; /* just on general principles */
11022}
11023
11024/*
11025 - altoffset - choose biggest offset among multiple choices
11026 == static int altoffset(sop *scan, int offset);
11027 *
11028 * Compute, recursively if necessary, the largest offset among multiple
11029 * re paths.
11030 */
11031static int
11032altoffset(sop *scan, int offset)
11033{
11034 int largest;
11035 int try;
11036 sop s;
11037
11038 /* If we gave up already on offsets, return */
11039 if (offset == -1)
11040 return -1;
11041
11042 largest = 0;
11043 try = 0;
11044 s = *scan++;
11045 while (OP(s) != O_QUEST && OP(s) != O_CH) {
11046 switch (OP(s)) {
11047 case OOR1:
11048 if (try > largest)
11049 largest = try;
11050 try = 0;
11051 break;
11052 case OQUEST_:
11053 case OCH_:
11054 try = altoffset(scan, try);
11055 if (try == -1)
11056 return -1;
11057 scan--;
11058 do {
11059 scan += OPND(s);
11060 s = *scan;
11061 if (OP(s) != O_QUEST && OP(s) != O_CH &&
11062 OP(s) != OOR2)
11063 return -1;
11064 } while (OP(s) != O_QUEST && OP(s) != O_CH);
11065 /* We must skip to the next position, or we'll
11066 * leave altoffset() too early.
11067 */
11068 scan++;
11069 break;
11070 case OANYOF:
11071 case OCHAR:
11072 case OANY:
11073 try++;
11074 case OBOW:
11075 case OEOW:
11076 case OLPAREN:
11077 case ORPAREN:
11078 case OOR2:
11079 break;
11080 default:
11081 try = -1;
11082 break;
11083 }
11084 if (try == -1)
11085 return -1;
11086 s = *scan++;
11087 }
11088
11089 if (try > largest)
11090 largest = try;
11091
11092 return largest+offset;
11093}
11094
11095/*
11096 - computejumps - compute char jumps for BM scan
11097 == static void computejumps(struct parse *p, struct re_guts *g);
11098 *
11099 * This algorithm assumes g->must exists and is has size greater than
11100 * zero. It's based on the algorithm found on Computer Algorithms by
11101 * Sara Baase.
11102 *
11103 * A char jump is the number of characters one needs to jump based on
11104 * the value of the character from the text that was mismatched.
11105 */
11106static void
11107computejumps(struct parse *p, struct re_guts *g)
11108{
11109 int ch;
11110 int mindex;
11111
11112 /* Avoid making errors worse */
11113 if (p->error != 0)
11114 return;
11115
11116 g->charjump = (int*) malloc((NC + 1) * sizeof(int));
11117 if (g->charjump == NULL) /* Not a fatal error */
11118 return;
11119 /* Adjust for signed chars, if necessary */
11120 g->charjump = &g->charjump[-(CHAR_MIN)];
11121
11122 /* If the character does not exist in the pattern, the jump
11123 * is equal to the number of characters in the pattern.
11124 */
11125 for (ch = CHAR_MIN; ch < (CHAR_MAX + 1); ch++)
11126 g->charjump[ch] = g->mlen;
11127
11128 /* If the character does exist, compute the jump that would
11129 * take us to the last character in the pattern equal to it
11130 * (notice that we match right to left, so that last character
11131 * is the first one that would be matched).
11132 */
11133 for (mindex = 0; mindex < g->mlen; mindex++)
11134 g->charjump[(int)g->must[mindex]] = g->mlen - mindex - 1;
11135}
11136
11137/*
11138 - computematchjumps - compute match jumps for BM scan
11139 == static void computematchjumps(struct parse *p, struct re_guts *g);
11140 *
11141 * This algorithm assumes g->must exists and is has size greater than
11142 * zero. It's based on the algorithm found on Computer Algorithms by
11143 * Sara Baase.
11144 *
11145 * A match jump is the number of characters one needs to advance based
11146 * on the already-matched suffix.
11147 * Notice that all values here are minus (g->mlen-1), because of the way
11148 * the search algorithm works.
11149 */
11150static void
11151computematchjumps(struct parse *p, struct re_guts *g)
11152{
11153 int mindex; /* General "must" iterator */
11154 int suffix; /* Keeps track of matching suffix */
11155 int ssuffix; /* Keeps track of suffixes' suffix */
11156 int* pmatches; /* pmatches[k] points to the next i
11157 * such that i+1...mlen is a substring
11158 * of k+1...k+mlen-i-1
11159 */
11160
11161 /* Avoid making errors worse */
11162 if (p->error != 0)
11163 return;
11164
11165 pmatches = (int*) malloc(g->mlen * sizeof(int));
11166 if (pmatches == NULL) {
11167 g->matchjump = NULL;
11168 return;
11169 }
11170
11171 g->matchjump = (int*) malloc(g->mlen * sizeof(int));
11172 if (g->matchjump == NULL) { /* Not a fatal error */
11173 free(pmatches);
11174 return;
11175 }
11176
11177 /* Set maximum possible jump for each character in the pattern */
11178 for (mindex = 0; mindex < g->mlen; mindex++)
11179 g->matchjump[mindex] = 2*g->mlen - mindex - 1;
11180
11181 /* Compute pmatches[] */
11182 for (mindex = g->mlen - 1, suffix = g->mlen; mindex >= 0;
11183 mindex--, suffix--) {
11184 pmatches[mindex] = suffix;
11185
11186 /* If a mismatch is found, interrupting the substring,
11187 * compute the matchjump for that position. If no
11188 * mismatch is found, then a text substring mismatched
11189 * against the suffix will also mismatch against the
11190 * substring.
11191 */
11192 while (suffix < g->mlen
11193 && g->must[mindex] != g->must[suffix]) {
11194 g->matchjump[suffix] = MIN(g->matchjump[suffix],
11195 g->mlen - mindex - 1);
11196 suffix = pmatches[suffix];
11197 }
11198 }
11199
11200 /* Compute the matchjump up to the last substring found to jump
11201 * to the beginning of the largest must pattern prefix matching
11202 * it's own suffix.
11203 */
11204 for (mindex = 0; mindex <= suffix; mindex++)
11205 g->matchjump[mindex] = MIN(g->matchjump[mindex],
11206 g->mlen + suffix - mindex);
11207
11208 ssuffix = pmatches[suffix];
11209 while (suffix < g->mlen) {
11210 while (suffix <= ssuffix && suffix < g->mlen) {
11211 g->matchjump[suffix] = MIN(g->matchjump[suffix],
11212 g->mlen + ssuffix - suffix);
11213 suffix++;
11214 }
11215 if (suffix < g->mlen)
11216 ssuffix = pmatches[ssuffix];
11217 }
11218
11219 free(pmatches);
11220}
11221
11222/*
11223 - pluscount - count + nesting
11224 == static sopno pluscount(struct parse *p, struct re_guts *g);
11225 */
11226static sopno /* nesting depth */
11227pluscount(struct parse *p, struct re_guts *g)
11228{
11229 sop *scan;
11230 sop s;
11231 sopno plusnest = 0;
11232 sopno maxnest = 0;
11233
11234 if (p->error != 0)
11235 return(0); /* there may not be an OEND */
11236
11237 scan = g->strip + 1;
11238 do {
11239 s = *scan++;
11240 switch (OP(s)) {
11241 case OPLUS_:
11242 plusnest++;
11243 break;
11244 case O_PLUS:
11245 if (plusnest > maxnest)
11246 maxnest = plusnest;
11247 plusnest--;
11248 break;
11249 }
11250 } while (OP(s) != OEND);
11251 if (plusnest != 0)
11252 g->iflags |= BAD;
11253 return(maxnest);
11254}