· 10 years ago · Nov 02, 2015, 10:57 AM
1# 1 "<built-in>"
2# 1 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
3/*-
4 * Copyright (c) 2012-2015 Robert N. M. Watson
5 * Copyright (c) 2014 SRI International
6 * All rights reserved.
7 *
8 * This software was developed by SRI International and the University of
9 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
10 * ("CTSRD"), as part of the DARPA CRASH research programme.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if 0 /* expanded by -frewrite-includes */
35#include <sys/cdefs.h>
36#endif /* expanded by -frewrite-includes */
37# 32 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
38# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 1 3 4
39/*-
40 * Copyright (c) 1991, 1993
41 * The Regents of the University of California. All rights reserved.
42 *
43 * This code is derived from software contributed to Berkeley by
44 * Berkeley Software Design, Inc.
45 *
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
48 * are met:
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 4. Neither the name of the University nor the names of its contributors
55 * may be used to endorse or promote products derived from this software
56 * without specific prior written permission.
57 *
58 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 *
70 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
71 * $FreeBSD$
72 */
73
74#ifndef _SYS_CDEFS_H_
75#define _SYS_CDEFS_H_
76
77/*
78 * Testing against Clang-specific extensions.
79 */
80
81#ifndef __has_attribute
82#define __has_attribute(x) 0
83#endif
84# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
85#ifndef __has_extension
86#define __has_extension __has_feature
87#endif
88# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
89#ifndef __has_feature
90#define __has_feature(x) 0
91#endif
92# 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
93#ifndef __has_include
94#define __has_include(x) 0
95#endif
96# 55 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
97#ifndef __has_builtin
98#define __has_builtin(x) 0
99#endif
100# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
101
102#if defined(__cplusplus)
103#define __BEGIN_DECLS extern "C" {
104#define __END_DECLS }
105#else
106# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
107#define __BEGIN_DECLS
108#define __END_DECLS
109#endif
110# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
111
112/*
113 * This code has been put in place to help reduce the addition of
114 * compiler specific defines in FreeBSD code. It helps to aid in
115 * having a compiler-agnostic source tree.
116 */
117
118#if defined(__GNUC__) || defined(__INTEL_COMPILER)
119
120#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
121#define __GNUCLIKE_ASM 3
122#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
123#else
124# 79 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
125#define __GNUCLIKE_ASM 2
126#endif
127# 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
128#define __GNUCLIKE___TYPEOF 1
129#define __GNUCLIKE___OFFSETOF 1
130#define __GNUCLIKE___SECTION 1
131
132#ifndef __INTEL_COMPILER
133#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
134#endif
135# 88 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
136
137#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
138#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
139 __INTEL_COMPILER < 800
140#undef __GNUCLIKE_BUILTIN_CONSTANT_P
141#endif
142# 94 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
143
144#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
145#define __GNUCLIKE_BUILTIN_VARARGS 1
146#define __GNUCLIKE_BUILTIN_STDARG 1
147#define __GNUCLIKE_BUILTIN_VAALIST 1
148#endif
149# 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
150
151#if defined(__GNUC__)
152#define __GNUC_VA_LIST_COMPATIBILITY 1
153#endif
154# 104 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
155
156/*
157 * Compiler memory barriers, specific to gcc and clang.
158 */
159#if defined(__GNUC__)
160#define __compiler_membar() __asm __volatile(" " : : : "memory")
161#endif
162# 111 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
163
164#ifndef __INTEL_COMPILER
165#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
166#define __GNUCLIKE_MATH_BUILTIN_RELOPS
167#endif
168# 116 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
169
170#define __GNUCLIKE_BUILTIN_MEMCPY 1
171
172/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
173#define __CC_SUPPORTS_INLINE 1
174#define __CC_SUPPORTS___INLINE 1
175#define __CC_SUPPORTS___INLINE__ 1
176
177#define __CC_SUPPORTS___FUNC__ 1
178#define __CC_SUPPORTS_WARNING 1
179
180#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
181
182#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
183
184#endif /* __GNUC__ || __INTEL_COMPILER */
185# 132 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
186
187/*
188 * Macro to test if we're using a specific version of gcc or later.
189 */
190#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
191#define __GNUC_PREREQ__(ma, mi) \
192 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
193#else
194# 140 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
195#define __GNUC_PREREQ__(ma, mi) 0
196#endif
197# 142 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
198
199/*
200 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
201 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
202 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
203 * mode -- there must be no spaces between its arguments, and for nested
204 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
205 * concatenate double-quoted strings produced by the __STRING macro, but
206 * this only works with ANSI C.
207 *
208 * __XSTRING is like __STRING, but it expands any macros in its argument
209 * first. It is only available with ANSI C.
210 */
211#if defined(__STDC__) || defined(__cplusplus)
212#define __P(protos) protos /* full-blown ANSI C */
213#define __CONCAT1(x,y) x ## y
214#define __CONCAT(x,y) __CONCAT1(x,y)
215#define __STRING(x) #x /* stringify without expanding x */
216#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
217
218#define __const const /* define reserved names to standard */
219#define __signed signed
220#define __volatile volatile
221#if defined(__cplusplus)
222#define __inline inline /* convert to C++ keyword */
223#else
224# 168 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
225#if !(defined(__CC_SUPPORTS___INLINE))
226#define __inline /* delete GCC keyword */
227#endif /* ! __CC_SUPPORTS___INLINE */
228# 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
229#endif /* !__cplusplus */
230# 172 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
231
232#else /* !(__STDC__ || __cplusplus) */
233# 174 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
234#define __P(protos) () /* traditional C preprocessor */
235#define __CONCAT(x,y) x/**/y
236#define __STRING(x) "x"
237
238#if !defined(__CC_SUPPORTS___INLINE)
239#define __const /* delete pseudo-ANSI C keywords */
240#define __inline
241#define __signed
242#define __volatile
243/*
244 * In non-ANSI C environments, new programs will want ANSI-only C keywords
245 * deleted from the program and old programs will want them left alone.
246 * When using a compiler other than gcc, programs using the ANSI C keywords
247 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
248 * When using "gcc -traditional", we assume that this is the intent; if
249 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
250 */
251#ifndef NO_ANSI_KEYWORDS
252#define const /* delete ANSI C keywords */
253#define inline
254#define signed
255#define volatile
256#endif /* !NO_ANSI_KEYWORDS */
257# 197 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
258#endif /* !__CC_SUPPORTS___INLINE */
259# 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
260#endif /* !(__STDC__ || __cplusplus) */
261# 199 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
262
263/*
264 * Compiler-dependent macros to help declare dead (non-returning) and
265 * pure (no side effects) functions, and unused variables. They are
266 * null except for versions of gcc that are known to support the features
267 * properly (old versions of gcc-2 supported the dead and pure features
268 * in a different (wrong) way). If we do not provide an implementation
269 * for a given compiler, let the compile fail if it is told to use
270 * a feature that we cannot live without.
271 */
272#ifdef lint
273#define __dead2
274#define __pure2
275#define __unused
276#define __packed
277#define __aligned(x)
278#define __section(x)
279#define __weak_symbol
280#else
281# 218 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
282#define __weak_symbol __attribute__((__weak__))
283#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
284#define __dead2
285#define __pure2
286#define __unused
287#endif
288# 224 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
289#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
290#define __dead2 __attribute__((__noreturn__))
291#define __pure2 __attribute__((__const__))
292#define __unused
293/* XXX Find out what to do for __packed, __aligned and __section */
294#endif
295# 230 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
296#if __GNUC_PREREQ__(2, 7)
297#define __dead2 __attribute__((__noreturn__))
298#define __pure2 __attribute__((__const__))
299#define __unused __attribute__((__unused__))
300#define __used __attribute__((__used__))
301#define __packed __attribute__((__packed__))
302#define __aligned(x) __attribute__((__aligned__(x)))
303#define __section(x) __attribute__((__section__(x)))
304#endif
305# 239 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
306#if defined(__INTEL_COMPILER)
307#define __dead2 __attribute__((__noreturn__))
308#define __pure2 __attribute__((__const__))
309#define __unused __attribute__((__unused__))
310#define __used __attribute__((__used__))
311#define __packed __attribute__((__packed__))
312#define __aligned(x) __attribute__((__aligned__(x)))
313#define __section(x) __attribute__((__section__(x)))
314#endif
315# 248 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
316#endif /* lint */
317# 249 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
318
319#if !__GNUC_PREREQ__(2, 95)
320#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
321#endif
322# 253 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
323
324/*
325 * Keywords added in C11.
326 */
327
328#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
329
330#if !__has_extension(c_alignas)
331#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
332 __has_extension(cxx_alignas)
333#define _Alignas(x) alignas(x)
334#else
335# 265 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
336/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
337#define _Alignas(x) __aligned(x)
338#endif
339# 268 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
340#endif
341# 269 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
342
343#if defined(__cplusplus) && __cplusplus >= 201103L
344#define _Alignof(x) alignof(x)
345#else
346# 273 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
347#define _Alignof(x) __alignof(x)
348#endif
349# 275 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
350
351#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
352/*
353 * No native support for _Atomic(). Place object in structure to prevent
354 * most forms of direct non-atomic access.
355 */
356#define _Atomic(T) struct { T volatile __val; }
357#endif
358# 283 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
359
360#if defined(__cplusplus) && __cplusplus >= 201103L
361#define _Noreturn [[noreturn]]
362#else
363# 287 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
364#define _Noreturn __dead2
365#endif
366# 289 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
367
368#if !__has_extension(c_static_assert)
369#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
370 __has_extension(cxx_static_assert)
371#define _Static_assert(x, y) static_assert(x, y)
372#elif __GNUC_PREREQ__(4,6)
373# 295 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
374/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
375#elif defined(__COUNTER__)
376# 297 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
377#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
378#define __Static_assert(x, y) ___Static_assert(x, y)
379#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \
380 __unused
381#else
382# 302 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
383#define _Static_assert(x, y) struct __hack
384#endif
385# 304 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
386#endif
387# 305 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
388
389#if !__has_extension(c_thread_local)
390/*
391 * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
392 * without actually supporting the thread_local keyword. Don't check for
393 * the presence of C++11 when defining _Thread_local.
394 */
395#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
396 __has_extension(cxx_thread_local)
397#define _Thread_local thread_local
398#else
399# 316 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
400#define _Thread_local __thread
401#endif
402# 318 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
403#endif
404# 319 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
405
406#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
407# 321 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
408
409/*
410 * Emulation of C11 _Generic(). Unlike the previously defined C11
411 * keywords, it is not possible to implement this using exactly the same
412 * syntax. Therefore implement something similar under the name
413 * __generic(). Unlike _Generic(), this macro can only distinguish
414 * between a single type, so it requires nested invocations to
415 * distinguish multiple cases.
416 */
417
418#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
419 __has_extension(c_generic_selections)
420#define __generic(expr, t, yes, no) \
421 _Generic(expr, t: yes, default: no)
422#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
423# 336 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
424#define __generic(expr, t, yes, no) \
425 __builtin_choose_expr( \
426 __builtin_types_compatible_p(__typeof(expr), t), yes, no)
427#endif
428# 340 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
429
430#if __GNUC_PREREQ__(2, 96)
431#define __malloc_like __attribute__((__malloc__))
432#define __pure __attribute__((__pure__))
433#else
434# 345 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
435#define __malloc_like
436#define __pure
437#endif
438# 348 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
439
440#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
441#define __always_inline __attribute__((__always_inline__))
442#else
443# 352 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
444#define __always_inline
445#endif
446# 354 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
447
448#if __GNUC_PREREQ__(3, 1)
449#define __noinline __attribute__ ((__noinline__))
450#else
451# 358 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
452#define __noinline
453#endif
454# 360 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
455
456#if __GNUC_PREREQ__(3, 3)
457#define __nonnull(x) __attribute__((__nonnull__(x)))
458#define __nonnull_all __attribute__((__nonnull__))
459#else
460# 365 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
461#define __nonnull(x)
462#define __nonnull_all
463#endif
464# 368 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
465
466#if __GNUC_PREREQ__(3, 4)
467#define __fastcall __attribute__((__fastcall__))
468#define __result_use_check __attribute__((__warn_unused_result__))
469#else
470# 373 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
471#define __fastcall
472#define __result_use_check
473#endif
474# 376 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
475
476#if __GNUC_PREREQ__(4, 1)
477#define __returns_twice __attribute__((__returns_twice__))
478#else
479# 380 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
480#define __returns_twice
481#endif
482# 382 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
483
484#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
485#define __alloc_size(x) __attribute__((__alloc_size__(x)))
486#else
487# 386 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
488#define __alloc_size(x)
489#endif
490# 388 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
491
492#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
493#define __unreachable() __builtin_unreachable()
494#else
495# 392 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
496#define __unreachable() ((void)0)
497#endif
498# 394 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
499
500#if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
501#define __alloc_align(x) __attribute__((__alloc_align__(x)))
502#else
503# 398 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
504#define __alloc_align(x)
505#endif
506# 400 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
507
508/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
509#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
510#define __func__ NULL
511#endif
512# 405 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
513
514#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
515#define __LONG_LONG_SUPPORTED
516#endif
517# 409 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
518
519/* C++11 exposes a load of C99 stuff */
520#if defined(__cplusplus) && __cplusplus >= 201103L
521#define __LONG_LONG_SUPPORTED
522#ifndef __STDC_LIMIT_MACROS
523#define __STDC_LIMIT_MACROS
524#endif
525# 416 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
526#ifndef __STDC_CONSTANT_MACROS
527#define __STDC_CONSTANT_MACROS
528#endif
529# 419 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
530#endif
531# 420 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
532
533/*
534 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
535 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
536 * a way to define the `restrict' type qualifier without disturbing older
537 * software that is unaware of C99 keywords.
538 */
539#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
540#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
541#define __restrict
542#else
543# 431 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
544#define __restrict restrict
545#endif
546# 433 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
547#endif
548# 434 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
549
550/*
551 * GNU C version 2.96 adds explicit branch prediction so that
552 * the CPU back-end can hint the processor and also so that
553 * code blocks can be reordered such that the predicted path
554 * sees a more linear flow, thus improving cache behavior, etc.
555 *
556 * The following two macros provide us with a way to utilize this
557 * compiler feature. Use __predict_true() if you expect the expression
558 * to evaluate to true, and __predict_false() if you expect the
559 * expression to evaluate to false.
560 *
561 * A few notes about usage:
562 *
563 * * Generally, __predict_false() error condition checks (unless
564 * you have some _strong_ reason to do otherwise, in which case
565 * document it), and/or __predict_true() `no-error' condition
566 * checks, assuming you want to optimize for the no-error case.
567 *
568 * * Other than that, if you don't know the likelihood of a test
569 * succeeding from empirical or other `hard' evidence, don't
570 * make predictions.
571 *
572 * * These are meant to be used in places that are run `a lot'.
573 * It is wasteful to make predictions in code that is run
574 * seldomly (e.g. at subsystem initialization time) as the
575 * basic block reordering that this affects can often generate
576 * larger code.
577 */
578#if __GNUC_PREREQ__(2, 96)
579#define __predict_true(exp) __builtin_expect((exp), 1)
580#define __predict_false(exp) __builtin_expect((exp), 0)
581#else
582# 467 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
583#define __predict_true(exp) (exp)
584#define __predict_false(exp) (exp)
585#endif
586# 470 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
587
588#if __GNUC_PREREQ__(4, 0)
589#define __sentinel __attribute__((__sentinel__))
590#define __exported __attribute__((__visibility__("default")))
591#define __hidden __attribute__((__visibility__("hidden")))
592#else
593# 476 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
594#define __sentinel
595#define __exported
596#define __hidden
597#endif
598# 480 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
599
600/*
601 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
602 * require it.
603 */
604#if __GNUC_PREREQ__(4, 1)
605#define __offsetof(type, field) __builtin_offsetof(type, field)
606#else
607# 488 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
608#ifndef __cplusplus
609#define __offsetof(type, field) \
610 ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
611#else
612# 492 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
613#define __offsetof(type, field) \
614 (__offsetof__ (reinterpret_cast <__size_t> \
615 (&reinterpret_cast <const volatile char &> \
616 (static_cast<type *> (0)->field))))
617#endif
618# 497 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
619#endif
620# 498 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
621#define __rangeof(type, start, end) \
622 (__offsetof(type, end) - __offsetof(type, start))
623
624/*
625 * Given the pointer x to the member m of the struct s, return
626 * a pointer to the containing structure. When using GCC, we first
627 * assign pointer x to a local variable, to check that its type is
628 * compatible with member m.
629 */
630#if __GNUC_PREREQ__(3, 1)
631#define __containerof(x, s, m) ({ \
632 const volatile __typeof(((s *)0)->m) *__x = (x); \
633 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
634})
635#else
636# 513 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
637#define __containerof(x, s, m) \
638 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
639#endif
640# 516 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
641
642/*
643 * Compiler-dependent macros to declare that functions take printf-like
644 * or scanf-like arguments. They are null except for versions of gcc
645 * that are known to support the features properly (old versions of gcc-2
646 * didn't permit keeping the keywords out of the application namespace).
647 */
648#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
649#define __printflike(fmtarg, firstvararg)
650#define __scanflike(fmtarg, firstvararg)
651#define __format_arg(fmtarg)
652#define __strfmonlike(fmtarg, firstvararg)
653#define __strftimelike(fmtarg, firstvararg)
654#else
655# 530 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
656#define __printflike(fmtarg, firstvararg) \
657 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
658#define __scanflike(fmtarg, firstvararg) \
659 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
660#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
661#define __strfmonlike(fmtarg, firstvararg) \
662 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
663#define __strftimelike(fmtarg, firstvararg) \
664 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
665#endif
666# 540 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
667
668/*
669 * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
670 * the use of non-standard inlining. In general we should try to avoid
671 * using these but GCC-compatible compilers tend to support the extensions
672 * well enough to use them in limited cases.
673 */
674#if defined(__GNUC_GNU_INLINE__) || defined(__GNUC_STDC_INLINE__)
675#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
676#define __gnu_inline __attribute__((__gnu_inline__, __artificial__))
677#else
678# 551 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
679#define __gnu_inline __attribute__((__gnu_inline__))
680#endif /* artificial */
681# 553 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
682#else
683# 554 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
684#define __gnu_inline
685#endif
686# 556 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
687
688/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
689#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
690 defined(__GNUC__) && !defined(__INTEL_COMPILER)
691#define __printf0like(fmtarg, firstvararg) \
692 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
693#else
694# 563 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
695#define __printf0like(fmtarg, firstvararg)
696#endif
697# 565 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
698
699#if defined(__GNUC__) || defined(__INTEL_COMPILER)
700#ifndef __INTEL_COMPILER
701#define __strong_reference(sym,aliassym) \
702 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
703#endif
704# 571 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
705#ifdef __STDC__
706#define __weak_reference(sym,alias) \
707 __asm__(".weak " #alias); \
708 __asm__(".equ " #alias ", " #sym)
709#define __warn_references(sym,msg) \
710 __asm__(".section .gnu.warning." #sym); \
711 __asm__(".asciz \"" msg "\""); \
712 __asm__(".previous")
713#define __sym_compat(sym,impl,verid) \
714 __asm__(".symver " #impl ", " #sym "@" #verid)
715#define __sym_default(sym,impl,verid) \
716 __asm__(".symver " #impl ", " #sym "@@" #verid)
717#else
718# 584 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
719#define __weak_reference(sym,alias) \
720 __asm__(".weak alias"); \
721 __asm__(".equ alias, sym")
722#define __warn_references(sym,msg) \
723 __asm__(".section .gnu.warning.sym"); \
724 __asm__(".asciz \"msg\""); \
725 __asm__(".previous")
726#define __sym_compat(sym,impl,verid) \
727 __asm__(".symver impl, sym@verid")
728#define __sym_default(impl,sym,verid) \
729 __asm__(".symver impl, sym@@verid")
730#endif /* __STDC__ */
731# 596 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
732#endif /* __GNUC__ || __INTEL_COMPILER */
733# 597 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
734
735#define __GLOBL1(sym) __asm__(".globl " #sym)
736#define __GLOBL(sym) __GLOBL1(sym)
737
738#if defined(__GNUC__) || defined(__INTEL_COMPILER)
739#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
740#else
741# 604 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
742/*
743 * The following definition might not work well if used in header files,
744 * but it should be better than nothing. If you want a "do nothing"
745 * version, then it should generate some harmless declaration, such as:
746 * #define __IDSTRING(name,string) struct __hack
747 */
748#define __IDSTRING(name,string) static const char name[] __unused = string
749#endif
750# 612 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
751
752/*
753 * Embed the rcs id of a source file in the resulting library. Note that in
754 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
755 * Usage:
756 * __FBSDID("$FreeBSD$");
757 */
758#ifndef __FBSDID
759#if !defined(lint) && !defined(STRIP_FBSDID)
760#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
761#else
762# 623 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
763#define __FBSDID(s) struct __hack
764#endif
765# 625 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
766#endif
767# 626 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
768
769#ifndef __RCSID
770#ifndef NO__RCSID
771#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
772#else
773# 631 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
774#define __RCSID(s) struct __hack
775#endif
776# 633 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
777#endif
778# 634 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
779
780#ifndef __RCSID_SOURCE
781#ifndef NO__RCSID_SOURCE
782#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
783#else
784# 639 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
785#define __RCSID_SOURCE(s) struct __hack
786#endif
787# 641 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
788#endif
789# 642 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
790
791#ifndef __SCCSID
792#ifndef NO__SCCSID
793#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
794#else
795# 647 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
796#define __SCCSID(s) struct __hack
797#endif
798# 649 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
799#endif
800# 650 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
801
802#ifndef __COPYRIGHT
803#ifndef NO__COPYRIGHT
804#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
805#else
806# 655 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
807#define __COPYRIGHT(s) struct __hack
808#endif
809# 657 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
810#endif
811# 658 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
812
813#ifndef __DECONST
814#if !__has_feature(capabilities)
815#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
816#else
817# 663 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
818#define __DECONST(type, var) ((type)(__intcap_t)(__capability const void *)(var))
819#endif
820# 665 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
821#endif
822# 666 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
823
824#ifndef __DEVOLATILE
825#if !__has_feature(capabilities)
826#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
827#else
828# 671 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
829#define __DEVOLATILE(type, var) ((type)(__intcap_t)(__capability volatile void *)(var))
830#endif
831# 673 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
832#endif
833# 674 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
834
835#ifndef __DEQUALIFY
836#if !__has_feature(capabilities)
837#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
838#else
839# 679 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
840#define __DEQUALIFY(type, var) ((type)(__intcap_t)(__capability const volatile void *)(var))
841#endif
842# 681 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
843#endif
844# 682 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
845
846/*-
847 * The following definitions are an extension of the behavior originally
848 * implemented in <sys/_posix.h>, but with a different level of granularity.
849 * POSIX.1 requires that the macros we test be defined before any standard
850 * header file is included.
851 *
852 * Here's a quick run-down of the versions:
853 * defined(_POSIX_SOURCE) 1003.1-1988
854 * _POSIX_C_SOURCE == 1 1003.1-1990
855 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
856 * _POSIX_C_SOURCE == 199309 1003.1b-1993
857 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
858 * and the omnibus ISO/IEC 9945-1: 1996
859 * _POSIX_C_SOURCE == 200112 1003.1-2001
860 * _POSIX_C_SOURCE == 200809 1003.1-2008
861 *
862 * In addition, the X/Open Portability Guide, which is now the Single UNIX
863 * Specification, defines a feature-test macro which indicates the version of
864 * that specification, and which subsumes _POSIX_C_SOURCE.
865 *
866 * Our macros begin with two underscores to avoid namespace screwage.
867 */
868
869/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
870#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
871#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
872#define _POSIX_C_SOURCE 199009
873#endif
874# 711 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
875
876/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
877#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
878#undef _POSIX_C_SOURCE
879#define _POSIX_C_SOURCE 199209
880#endif
881# 717 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
882
883/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
884#ifdef _XOPEN_SOURCE
885#if _XOPEN_SOURCE - 0 >= 700
886#define __XSI_VISIBLE 700
887#undef _POSIX_C_SOURCE
888#define _POSIX_C_SOURCE 200809
889#elif _XOPEN_SOURCE - 0 >= 600
890# 725 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
891#define __XSI_VISIBLE 600
892#undef _POSIX_C_SOURCE
893#define _POSIX_C_SOURCE 200112
894#elif _XOPEN_SOURCE - 0 >= 500
895# 729 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
896#define __XSI_VISIBLE 500
897#undef _POSIX_C_SOURCE
898#define _POSIX_C_SOURCE 199506
899#endif
900# 733 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
901#endif
902# 734 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
903
904/*
905 * Deal with all versions of POSIX. The ordering relative to the tests above is
906 * important.
907 */
908#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
909#define _POSIX_C_SOURCE 198808
910#endif
911# 742 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
912#ifdef _POSIX_C_SOURCE
913#if _POSIX_C_SOURCE >= 200809
914#define __POSIX_VISIBLE 200809
915#define __ISO_C_VISIBLE 1999
916#elif _POSIX_C_SOURCE >= 200112
917# 747 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
918#define __POSIX_VISIBLE 200112
919#define __ISO_C_VISIBLE 1999
920#elif _POSIX_C_SOURCE >= 199506
921# 750 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
922#define __POSIX_VISIBLE 199506
923#define __ISO_C_VISIBLE 1990
924#elif _POSIX_C_SOURCE >= 199309
925# 753 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
926#define __POSIX_VISIBLE 199309
927#define __ISO_C_VISIBLE 1990
928#elif _POSIX_C_SOURCE >= 199209
929# 756 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
930#define __POSIX_VISIBLE 199209
931#define __ISO_C_VISIBLE 1990
932#elif _POSIX_C_SOURCE >= 199009
933# 759 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
934#define __POSIX_VISIBLE 199009
935#define __ISO_C_VISIBLE 1990
936#else
937# 762 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
938#define __POSIX_VISIBLE 198808
939#define __ISO_C_VISIBLE 0
940#endif /* _POSIX_C_SOURCE */
941# 765 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
942#else
943# 766 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
944/*-
945 * Deal with _ANSI_SOURCE:
946 * If it is defined, and no other compilation environment is explicitly
947 * requested, then define our internal feature-test macros to zero. This
948 * makes no difference to the preprocessor (undefined symbols in preprocessing
949 * expressions are defined to have value zero), but makes it more convenient for
950 * a test program to print out the values.
951 *
952 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
953 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
954 * environment (and in fact we will never get here).
955 */
956#if defined(_ANSI_SOURCE) /* Hide almost everything. */
957#define __POSIX_VISIBLE 0
958#define __XSI_VISIBLE 0
959#define __BSD_VISIBLE 0
960#define __ISO_C_VISIBLE 1990
961#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
962# 784 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
963#define __POSIX_VISIBLE 0
964#define __XSI_VISIBLE 0
965#define __BSD_VISIBLE 0
966#define __ISO_C_VISIBLE 1999
967#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
968# 789 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
969#define __POSIX_VISIBLE 0
970#define __XSI_VISIBLE 0
971#define __BSD_VISIBLE 0
972#define __ISO_C_VISIBLE 2011
973#else /* Default environment: show everything. */
974# 794 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
975#define __POSIX_VISIBLE 200809
976#define __XSI_VISIBLE 700
977#define __BSD_VISIBLE 1
978#define __ISO_C_VISIBLE 2011
979#endif
980# 799 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
981#endif
982# 800 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
983
984#if defined(__mips) || defined(__powerpc64__)
985#define __NO_TLS 1
986#endif
987# 804 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
988
989/*
990 * Type Safety Checking
991 *
992 * Clang provides additional attributes to enable checking type safety
993 * properties that cannot be enforced by the C type system.
994 */
995
996#if __has_attribute(argument_with_type_tag) && \
997 __has_attribute(type_tag_for_datatype) && !defined(lint)
998#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
999 __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
1000#define __datatype_type_tag(kind, type) \
1001 __attribute__((__type_tag_for_datatype__(kind, type)))
1002#else
1003# 819 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1004#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
1005#define __datatype_type_tag(kind, type)
1006#endif
1007# 822 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1008
1009/*
1010 * Lock annotations.
1011 *
1012 * Clang provides support for doing basic thread-safety tests at
1013 * compile-time, by marking which locks will/should be held when
1014 * entering/leaving a functions.
1015 *
1016 * Furthermore, it is also possible to annotate variables and structure
1017 * members to enforce that they are only accessed when certain locks are
1018 * held.
1019 */
1020
1021#if __has_extension(c_thread_safety_attributes)
1022#define __lock_annotate(x) __attribute__((x))
1023#else
1024# 838 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1025#define __lock_annotate(x)
1026#endif
1027# 840 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1028
1029/* Structure implements a lock. */
1030#define __lockable __lock_annotate(lockable)
1031
1032/* Function acquires an exclusive or shared lock. */
1033#define __locks_exclusive(...) \
1034 __lock_annotate(exclusive_lock_function(__VA_ARGS__))
1035#define __locks_shared(...) \
1036 __lock_annotate(shared_lock_function(__VA_ARGS__))
1037
1038/* Function attempts to acquire an exclusive or shared lock. */
1039#define __trylocks_exclusive(...) \
1040 __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
1041#define __trylocks_shared(...) \
1042 __lock_annotate(shared_trylock_function(__VA_ARGS__))
1043
1044/* Function releases a lock. */
1045#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
1046
1047/* Function asserts that an exclusive or shared lock is held. */
1048#define __asserts_exclusive(...) \
1049 __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
1050#define __asserts_shared(...) \
1051 __lock_annotate(assert_shared_lock(__VA_ARGS__))
1052
1053/* Function requires that an exclusive or shared lock is or is not held. */
1054#define __requires_exclusive(...) \
1055 __lock_annotate(exclusive_locks_required(__VA_ARGS__))
1056#define __requires_shared(...) \
1057 __lock_annotate(shared_locks_required(__VA_ARGS__))
1058#define __requires_unlocked(...) \
1059 __lock_annotate(locks_excluded(__VA_ARGS__))
1060
1061/* Function should not be analyzed. */
1062#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
1063
1064/* Guard variables and structure members by lock. */
1065#define __guarded_by(x) __lock_annotate(guarded_by(x))
1066#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
1067
1068#endif /* !_SYS_CDEFS_H_ */
1069# 881 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
1070# 33 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
1071
1072#if !__has_feature(capabilities)
1073#error "This code requires a CHERI-aware compiler"
1074#endif
1075# 37 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
1076
1077#if 0 /* expanded by -frewrite-includes */
1078#include <sys/types.h>
1079#endif /* expanded by -frewrite-includes */
1080# 38 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
1081# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 1 3 4
1082/*-
1083 * Copyright (c) 1982, 1986, 1991, 1993, 1994
1084 * The Regents of the University of California. All rights reserved.
1085 * (c) UNIX System Laboratories, Inc.
1086 * All or some portions of this file are derived from material licensed
1087 * to the University of California by American Telephone and Telegraph
1088 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
1089 * the permission of UNIX System Laboratories, Inc.
1090 *
1091 * Redistribution and use in source and binary forms, with or without
1092 * modification, are permitted provided that the following conditions
1093 * are met:
1094 * 1. Redistributions of source code must retain the above copyright
1095 * notice, this list of conditions and the following disclaimer.
1096 * 2. Redistributions in binary form must reproduce the above copyright
1097 * notice, this list of conditions and the following disclaimer in the
1098 * documentation and/or other materials provided with the distribution.
1099 * 4. Neither the name of the University nor the names of its contributors
1100 * may be used to endorse or promote products derived from this software
1101 * without specific prior written permission.
1102 *
1103 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1104 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1105 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1106 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1107 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1108 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1109 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1110 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1111 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1112 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1113 * SUCH DAMAGE.
1114 *
1115 * @(#)types.h 8.6 (Berkeley) 2/19/95
1116 * $FreeBSD$
1117 */
1118
1119#ifndef _SYS_TYPES_H_
1120#define _SYS_TYPES_H_
1121
1122#if 0 /* expanded by -frewrite-includes */
1123#include <sys/cdefs.h>
1124#endif /* expanded by -frewrite-includes */
1125# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1126# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1127
1128/* Machine type dependent parameters. */
1129#if 0 /* expanded by -frewrite-includes */
1130#include <machine/endian.h>
1131#endif /* expanded by -frewrite-includes */
1132# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1133# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 1 3 4
1134/*-
1135 * Copyright (c) 1987, 1991 Regents of the University of California.
1136 * All rights reserved.
1137 *
1138 * Redistribution and use in source and binary forms, with or without
1139 * modification, are permitted provided that the following conditions
1140 * are met:
1141 * 1. Redistributions of source code must retain the above copyright
1142 * notice, this list of conditions and the following disclaimer.
1143 * 2. Redistributions in binary form must reproduce the above copyright
1144 * notice, this list of conditions and the following disclaimer in the
1145 * documentation and/or other materials provided with the distribution.
1146 * 4. Neither the name of the University nor the names of its contributors
1147 * may be used to endorse or promote products derived from this software
1148 * without specific prior written permission.
1149 *
1150 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1151 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1152 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1153 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1154 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1155 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1156 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1157 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1158 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1159 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1160 * SUCH DAMAGE.
1161 *
1162 * @(#)endian.h 7.8 (Berkeley) 4/3/91
1163 * $FreeBSD$
1164 */
1165
1166#ifndef _MACHINE_ENDIAN_H_
1167#define _MACHINE_ENDIAN_H_
1168
1169#if 0 /* expanded by -frewrite-includes */
1170#include <sys/cdefs.h>
1171#endif /* expanded by -frewrite-includes */
1172# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1173# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1174#ifndef __ASSEMBLER__
1175#if 0 /* expanded by -frewrite-includes */
1176#include <sys/_types.h>
1177#endif /* expanded by -frewrite-includes */
1178# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1179# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 1 3 4
1180/*-
1181 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
1182 * All rights reserved.
1183 *
1184 * Redistribution and use in source and binary forms, with or without
1185 * modification, are permitted provided that the following conditions
1186 * are met:
1187 * 1. Redistributions of source code must retain the above copyright
1188 * notice, this list of conditions and the following disclaimer.
1189 * 2. Redistributions in binary form must reproduce the above copyright
1190 * notice, this list of conditions and the following disclaimer in the
1191 * documentation and/or other materials provided with the distribution.
1192 *
1193 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1194 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1195 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1196 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1197 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1198 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1199 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1200 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1201 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1202 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1203 * SUCH DAMAGE.
1204 *
1205 * $FreeBSD$
1206 */
1207
1208#ifndef _SYS__TYPES_H_
1209#define _SYS__TYPES_H_
1210
1211#if 0 /* expanded by -frewrite-includes */
1212#include <sys/cdefs.h>
1213#endif /* expanded by -frewrite-includes */
1214# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1215# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1216#if 0 /* expanded by -frewrite-includes */
1217#include <machine/_types.h>
1218#endif /* expanded by -frewrite-includes */
1219# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1220# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 1 3 4
1221/*-
1222 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
1223 * Copyright (c) 1990, 1993
1224 * The Regents of the University of California. All rights reserved.
1225 *
1226 * Redistribution and use in source and binary forms, with or without
1227 * modification, are permitted provided that the following conditions
1228 * are met:
1229 * 1. Redistributions of source code must retain the above copyright
1230 * notice, this list of conditions and the following disclaimer.
1231 * 2. Redistributions in binary form must reproduce the above copyright
1232 * notice, this list of conditions and the following disclaimer in the
1233 * documentation and/or other materials provided with the distribution.
1234 * 3. All advertising materials mentioning features or use of this software
1235 * must display the following acknowledgement:
1236 * This product includes software developed by the University of
1237 * California, Berkeley and its contributors.
1238 * 4. Neither the name of the University nor the names of its contributors
1239 * may be used to endorse or promote products derived from this software
1240 * without specific prior written permission.
1241 *
1242 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1243 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1244 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1245 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1246 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1247 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1248 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1249 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1250 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1251 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1252 * SUCH DAMAGE.
1253 *
1254 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
1255 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
1256 * from: src/sys/i386/include/_types.h,v 1.12 2005/07/02 23:13:31 thompsa
1257 * $FreeBSD$
1258 */
1259
1260#ifndef _MACHINE__TYPES_H_
1261#define _MACHINE__TYPES_H_
1262
1263#ifndef _SYS_CDEFS_H_
1264#error this file needs sys/cdefs.h as a prerequisite
1265#endif
1266# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1267
1268/*
1269 * Basic types upon which most other types are built.
1270 */
1271typedef signed char __int8_t;
1272typedef unsigned char __uint8_t;
1273typedef short __int16_t;
1274typedef unsigned short __uint16_t;
1275typedef int __int32_t;
1276typedef unsigned int __uint32_t;
1277#ifdef __mips_n64
1278typedef long __int64_t;
1279typedef unsigned long __uint64_t;
1280#else
1281# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1282#ifndef lint
1283__extension__
1284#endif
1285# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1286/* LONGLONG */
1287typedef long long __int64_t;
1288#ifndef lint
1289__extension__
1290#endif
1291# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1292/* LONGLONG */
1293typedef unsigned long long __uint64_t;
1294#endif
1295# 71 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1296
1297/*
1298 * Standard type definitions.
1299 */
1300typedef __int32_t __clock_t; /* clock()... */
1301typedef double __double_t;
1302typedef float __float_t;
1303#ifdef __mips_n64
1304typedef __int64_t __critical_t;
1305typedef __int64_t __intfptr_t;
1306typedef __int64_t __intptr_t;
1307#else
1308# 83 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1309typedef __int32_t __critical_t;
1310typedef __int32_t __intfptr_t;
1311typedef __int32_t __intptr_t;
1312#endif
1313# 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1314typedef __int64_t __intmax_t;
1315typedef __int32_t __int_fast8_t;
1316typedef __int32_t __int_fast16_t;
1317typedef __int32_t __int_fast32_t;
1318typedef __int64_t __int_fast64_t;
1319typedef __int8_t __int_least8_t;
1320typedef __int16_t __int_least16_t;
1321typedef __int32_t __int_least32_t;
1322typedef __int64_t __int_least64_t;
1323#if defined(__mips_n64) || defined(__mips_n32)
1324typedef __int64_t __register_t;
1325typedef __int64_t f_register_t;
1326#else
1327# 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1328typedef __int32_t __register_t;
1329typedef __int32_t f_register_t;
1330#endif
1331# 103 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1332#ifdef __mips_n64
1333typedef __int64_t __ptrdiff_t;
1334typedef __int64_t __segsz_t;
1335typedef __int64_t __semid_t; /* historically intptr_t */
1336typedef __uint64_t __size_t;
1337typedef __int64_t __ssize_t;
1338typedef __uint64_t __uintfptr_t;
1339typedef __uint64_t __uintptr_t;
1340#else
1341# 112 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1342typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
1343typedef __int32_t __segsz_t; /* segment size (in pages) */
1344typedef __int32_t __semid_t; /* historically intptr_t */
1345typedef __uint32_t __size_t; /* sizeof() */
1346typedef __int32_t __ssize_t; /* byte count or error */
1347typedef __uint32_t __uintfptr_t;
1348typedef __uint32_t __uintptr_t;
1349#endif
1350# 120 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1351typedef __int64_t __time_t; /* time()... */
1352typedef __uint64_t __uintmax_t;
1353typedef __uint32_t __uint_fast8_t;
1354typedef __uint32_t __uint_fast16_t;
1355typedef __uint32_t __uint_fast32_t;
1356typedef __uint64_t __uint_fast64_t;
1357typedef __uint8_t __uint_least8_t;
1358typedef __uint16_t __uint_least16_t;
1359typedef __uint32_t __uint_least32_t;
1360typedef __uint64_t __uint_least64_t;
1361#if defined(__mips_n64) || defined(__mips_n32)
1362typedef __uint64_t __u_register_t;
1363#else
1364# 133 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1365typedef __uint32_t __u_register_t;
1366#endif
1367# 135 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1368#ifdef __mips_n64
1369typedef __uint64_t __vm_offset_t;
1370typedef __uint64_t __vm_size_t;
1371#else
1372# 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1373typedef __uint32_t __vm_offset_t;
1374typedef __uint32_t __vm_size_t;
1375#endif
1376# 142 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1377#if defined(__mips_n64) || defined(__mips_n32) /* PHYSADDR_64_BIT */
1378typedef __uint64_t __vm_paddr_t;
1379#else
1380# 145 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1381typedef __uint32_t __vm_paddr_t;
1382#endif
1383# 147 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1384
1385typedef __int64_t __vm_ooffset_t;
1386typedef __uint64_t __vm_pindex_t;
1387typedef int ___wchar_t;
1388
1389#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
1390#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */
1391
1392/*
1393 * Unusual type definitions.
1394 */
1395#ifdef __GNUCLIKE_BUILTIN_VARARGS
1396typedef __builtin_va_list __va_list; /* internally known to gcc */
1397#else
1398# 161 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1399typedef char * __va_list;
1400#endif /* __GNUCLIKE_BUILTIN_VARARGS */
1401# 163 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1402#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
1403 && !defined(__NO_GNUC_VA_LIST)
1404#define __GNUC_VA_LIST
1405typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
1406#endif
1407# 168 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1408
1409#endif /* !_MACHINE__TYPES_H_ */
1410# 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
1411# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 2 3 4
1412
1413/*
1414 * Standard type definitions.
1415 */
1416typedef __int32_t __blksize_t; /* file block size */
1417typedef __int64_t __blkcnt_t; /* file block count */
1418typedef __int32_t __clockid_t; /* clock_gettime()... */
1419typedef __uint32_t __fflags_t; /* file flags */
1420typedef __uint64_t __fsblkcnt_t;
1421typedef __uint64_t __fsfilcnt_t;
1422typedef __uint32_t __gid_t;
1423typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
1424typedef __uint32_t __ino_t; /* inode number */
1425typedef long __key_t; /* IPC key (for Sys V IPC) */
1426typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
1427typedef __uint16_t __mode_t; /* permissions */
1428typedef int __accmode_t; /* access permissions */
1429typedef int __nl_item;
1430typedef __uint16_t __nlink_t; /* link count */
1431typedef __int64_t __off_t; /* file offset */
1432typedef __int32_t __pid_t; /* process [group] */
1433typedef __int64_t __rlim_t; /* resource limit - intentionally */
1434 /* signed, because of legacy code */
1435 /* that uses -1 for RLIM_INFINITY */
1436typedef __uint8_t __sa_family_t;
1437typedef __uint32_t __socklen_t;
1438typedef long __suseconds_t; /* microseconds (signed) */
1439typedef struct __timer *__timer_t; /* timer_gettime()... */
1440typedef struct __mq *__mqd_t; /* mq_open()... */
1441typedef __uint32_t __uid_t;
1442typedef unsigned int __useconds_t; /* microseconds (unsigned) */
1443typedef int __cpuwhich_t; /* which parameter for cpuset. */
1444typedef int __cpulevel_t; /* level parameter for cpuset. */
1445typedef int __cpusetid_t; /* cpuset identifier. */
1446
1447/*
1448 * Unusual type definitions.
1449 */
1450/*
1451 * rune_t is declared to be an ``int'' instead of the more natural
1452 * ``unsigned long'' or ``long''. Two things are happening here. It is not
1453 * unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
1454 * it looks like 10646 will be a 31 bit standard. This means that if your
1455 * ints cannot hold 32 bits, you will be in trouble. The reason an int was
1456 * chosen over a long is that the is*() and to*() routines take ints (says
1457 * ANSI C), but they use __ct_rune_t instead of int.
1458 *
1459 * NOTE: rune_t is not covered by ANSI nor other standards, and should not
1460 * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and
1461 * rune_t must be the same type. Also, wint_t should be able to hold all
1462 * members of the largest character set plus one extra value (WEOF), and
1463 * must be at least 16 bits.
1464 */
1465typedef int __ct_rune_t; /* arg type for ctype funcs */
1466typedef __ct_rune_t __rune_t; /* rune_t (see above) */
1467typedef __ct_rune_t __wint_t; /* wint_t (see above) */
1468
1469/* Clang already provides these types as built-ins, but only in C++ mode. */
1470#if !defined(__clang__) || !defined(__cplusplus)
1471typedef __uint_least16_t __char16_t;
1472typedef __uint_least32_t __char32_t;
1473#endif
1474# 96 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1475/* In C++11, char16_t and char32_t are built-in types. */
1476#if defined(__cplusplus) && __cplusplus >= 201103L
1477#define _CHAR16_T_DECLARED
1478#define _CHAR32_T_DECLARED
1479#endif
1480# 101 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1481
1482typedef __uint32_t __dev_t; /* device number */
1483
1484typedef __uint32_t __fixpt_t; /* fixed point number */
1485
1486/*
1487 * mbstate_t is an opaque object to keep conversion state during multibyte
1488 * stream conversions.
1489 */
1490typedef union {
1491 char __mbstate8[128];
1492 __int64_t _mbstateL; /* for alignment */
1493} __mbstate_t;
1494
1495#endif /* !_SYS__TYPES_H_ */
1496# 116 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
1497# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 2 3 4
1498#endif
1499# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1500
1501#ifdef __cplusplus
1502extern "C" {
1503#endif
1504# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1505
1506/*
1507 * Definitions for byte order, according to byte significance from low
1508 * address to high.
1509 */
1510#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
1511#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
1512#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
1513
1514#ifdef __MIPSEB__
1515#define _BYTE_ORDER _BIG_ENDIAN
1516#else
1517# 56 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1518#define _BYTE_ORDER _LITTLE_ENDIAN
1519#endif /* __MIBSEB__ */
1520# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1521
1522/*
1523 * Deprecated variants that don't have enough underscores to be useful in more
1524 * strict namespaces.
1525 */
1526#if __BSD_VISIBLE
1527#define LITTLE_ENDIAN _LITTLE_ENDIAN
1528#define BIG_ENDIAN _BIG_ENDIAN
1529#define PDP_ENDIAN _PDP_ENDIAN
1530#define BYTE_ORDER _BYTE_ORDER
1531#endif
1532# 69 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1533
1534#ifndef __ASSEMBLER__
1535#if defined(__GNUCLIKE_BUILTIN_CONSTANT_P) && defined(__OPTIMIZE__)
1536#define __is_constant(x) __builtin_constant_p(x)
1537#else
1538# 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1539#define __is_constant(x) 0
1540#endif
1541# 76 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1542
1543#define __bswap16_const(x) (((x) >> 8) | (((x) << 8) & 0xff00))
1544#define __bswap32_const(x) (((x) >> 24) | (((x) >> 8) & 0xff00) | \
1545 (((x) << 8) & 0xff0000) | (((x) << 24) & 0xff000000))
1546#define __bswap64_const(x) (((x) >> 56) | (((x) >> 40) & 0xff00) | \
1547 (((x) >> 24) & 0xff0000) | (((x) >> 8) & 0xff000000) | \
1548 (((x) << 8) & ((__uint64_t)0xff << 32)) | \
1549 (((x) << 24) & ((__uint64_t)0xff << 40)) | \
1550 (((x) << 40) & ((__uint64_t)0xff << 48)) | (((x) << 56)))
1551
1552static __inline __uint16_t
1553__bswap16_var(__uint16_t _x)
1554{
1555
1556 return ((_x >> 8) | ((_x << 8) & 0xff00));
1557}
1558
1559static __inline __uint32_t
1560__bswap32_var(__uint32_t _x)
1561{
1562
1563 return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff0000) |
1564 ((_x << 24) & 0xff000000));
1565}
1566
1567static __inline __uint64_t
1568__bswap64_var(__uint64_t _x)
1569{
1570
1571 return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
1572 ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
1573 ((_x << 24) & ((__uint64_t)0xff << 40)) |
1574 ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
1575}
1576
1577#define __bswap16(x) ((__uint16_t)(__is_constant((x)) ? \
1578 __bswap16_const((__uint16_t)(x)) : __bswap16_var((__uint16_t)(x))))
1579#define __bswap32(x) ((__uint32_t)(__is_constant((x)) ? \
1580 __bswap32_const((__uint32_t)(x)) : __bswap32_var((__uint32_t)(x))))
1581#define __bswap64(x) ((__uint64_t)(__is_constant((x)) ? \
1582 __bswap64_const((__uint64_t)(x)) : __bswap64_var((__uint64_t)(x))))
1583
1584#ifdef __MIPSEB__
1585#define __htonl(x) ((__uint32_t)(x))
1586#define __htons(x) ((__uint16_t)(x))
1587#define __ntohl(x) ((__uint32_t)(x))
1588#define __ntohs(x) ((__uint16_t)(x))
1589/*
1590 * Define the order of 32-bit words in 64-bit words.
1591 */
1592/*
1593 * XXXMIPS: Additional parentheses to make gcc more happy.
1594 */
1595#define _QUAD_HIGHWORD 0
1596#define _QUAD_LOWWORD 1
1597#else
1598# 132 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1599#define _QUAD_HIGHWORD 1
1600#define _QUAD_LOWWORD 0
1601#define __ntohl(x) (__bswap32((x)))
1602#define __ntohs(x) (__bswap16((x)))
1603#define __htonl(x) (__bswap32((x)))
1604#define __htons(x) (__bswap16((x)))
1605#endif /* _MIPSEB */
1606# 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1607
1608#endif /* _ASSEMBLER_ */
1609# 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1610
1611#ifdef __cplusplus
1612}
1613#endif
1614# 145 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1615
1616#endif /* !_MACHINE_ENDIAN_H_ */
1617# 147 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
1618# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
1619#if 0 /* expanded by -frewrite-includes */
1620#include <sys/_types.h>
1621#endif /* expanded by -frewrite-includes */
1622# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1623# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1624
1625#if 0 /* expanded by -frewrite-includes */
1626#include <sys/_pthreadtypes.h>
1627#endif /* expanded by -frewrite-includes */
1628# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1629# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 1 3 4
1630/*
1631 * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
1632 * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au>
1633 * All rights reserved.
1634 *
1635 * Redistribution and use in source and binary forms, with or without
1636 * modification, are permitted provided that the following conditions
1637 * are met:
1638 * 1. Redistributions of source code must retain the above copyright
1639 * notice, this list of conditions and the following disclaimer.
1640 * 2. Redistributions in binary form must reproduce the above copyright
1641 * notice, this list of conditions and the following disclaimer in the
1642 * documentation and/or other materials provided with the distribution.
1643 * 3. All advertising materials mentioning features or use of this software
1644 * must display the following acknowledgement:
1645 * This product includes software developed by Chris Provenzano.
1646 * 4. The name of Chris Provenzano may not be used to endorse or promote
1647 * products derived from this software without specific prior written
1648 * permission.
1649 *
1650 * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
1651 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1652 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1653 * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
1654 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1655 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1656 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1657 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1658 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1659 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1660 * SUCH DAMAGE.
1661 *
1662 * $FreeBSD$
1663 */
1664
1665#ifndef _SYS__PTHREADTYPES_H_
1666#define _SYS__PTHREADTYPES_H_
1667
1668/*
1669 * Forward structure definitions.
1670 *
1671 * These are mostly opaque to the user.
1672 */
1673struct pthread;
1674struct pthread_attr;
1675struct pthread_cond;
1676struct pthread_cond_attr;
1677struct pthread_mutex;
1678struct pthread_mutex_attr;
1679struct pthread_once;
1680struct pthread_rwlock;
1681struct pthread_rwlockattr;
1682struct pthread_barrier;
1683struct pthread_barrier_attr;
1684struct pthread_spinlock;
1685
1686/*
1687 * Primitive system data type definitions required by P1003.1c.
1688 *
1689 * Note that P1003.1c specifies that there are no defined comparison
1690 * or assignment operators for the types pthread_attr_t, pthread_cond_t,
1691 * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
1692 */
1693#ifndef _PTHREAD_T_DECLARED
1694typedef struct pthread *pthread_t;
1695#define _PTHREAD_T_DECLARED
1696#endif
1697# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 3 4
1698typedef struct pthread_attr *pthread_attr_t;
1699typedef struct pthread_mutex *pthread_mutex_t;
1700typedef struct pthread_mutex_attr *pthread_mutexattr_t;
1701typedef struct pthread_cond *pthread_cond_t;
1702typedef struct pthread_cond_attr *pthread_condattr_t;
1703typedef int pthread_key_t;
1704typedef struct pthread_once pthread_once_t;
1705typedef struct pthread_rwlock *pthread_rwlock_t;
1706typedef struct pthread_rwlockattr *pthread_rwlockattr_t;
1707typedef struct pthread_barrier *pthread_barrier_t;
1708typedef struct pthread_barrierattr *pthread_barrierattr_t;
1709typedef struct pthread_spinlock *pthread_spinlock_t;
1710
1711/*
1712 * Additional type definitions:
1713 *
1714 * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for
1715 * use in header symbols.
1716 */
1717typedef void *pthread_addr_t;
1718typedef void *(*pthread_startroutine_t)(void *);
1719
1720/*
1721 * Once definitions.
1722 */
1723struct pthread_once {
1724 int state;
1725 pthread_mutex_t mutex;
1726};
1727
1728#endif /* ! _SYS__PTHREADTYPES_H_ */
1729# 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 3 4
1730# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
1731
1732#if __BSD_VISIBLE
1733typedef unsigned char u_char;
1734typedef unsigned short u_short;
1735typedef unsigned int u_int;
1736typedef unsigned long u_long;
1737#ifndef _KERNEL
1738typedef unsigned short ushort; /* Sys V compatibility */
1739typedef unsigned int uint; /* Sys V compatibility */
1740#endif
1741# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1742#endif
1743# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1744
1745/*
1746 * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
1747 */
1748#if 0 /* expanded by -frewrite-includes */
1749#include <sys/_stdint.h>
1750#endif /* expanded by -frewrite-includes */
1751# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1752# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 1 3 4
1753/*-
1754 * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org>
1755 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
1756 * All rights reserved.
1757 *
1758 * Redistribution and use in source and binary forms, with or without
1759 * modification, are permitted provided that the following conditions
1760 * are met:
1761 * 1. Redistributions of source code must retain the above copyright
1762 * notice, this list of conditions and the following disclaimer.
1763 * 2. Redistributions in binary form must reproduce the above copyright
1764 * notice, this list of conditions and the following disclaimer in the
1765 * documentation and/or other materials provided with the distribution.
1766 *
1767 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1768 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1769 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1770 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1771 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1772 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1773 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1774 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1775 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1776 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1777 * SUCH DAMAGE.
1778 *
1779 * $FreeBSD$
1780 */
1781
1782#ifndef _SYS__STDINT_H_
1783#define _SYS__STDINT_H_
1784
1785#ifndef _INT8_T_DECLARED
1786typedef __int8_t int8_t;
1787#define _INT8_T_DECLARED
1788#endif
1789# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1790
1791#ifndef _INT16_T_DECLARED
1792typedef __int16_t int16_t;
1793#define _INT16_T_DECLARED
1794#endif
1795# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1796
1797#ifndef _INT32_T_DECLARED
1798typedef __int32_t int32_t;
1799#define _INT32_T_DECLARED
1800#endif
1801# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1802
1803#ifndef _INT64_T_DECLARED
1804typedef __int64_t int64_t;
1805#define _INT64_T_DECLARED
1806#endif
1807# 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1808
1809#ifndef _UINT8_T_DECLARED
1810typedef __uint8_t uint8_t;
1811#define _UINT8_T_DECLARED
1812#endif
1813# 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1814
1815#ifndef _UINT16_T_DECLARED
1816typedef __uint16_t uint16_t;
1817#define _UINT16_T_DECLARED
1818#endif
1819# 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1820
1821#ifndef _UINT32_T_DECLARED
1822typedef __uint32_t uint32_t;
1823#define _UINT32_T_DECLARED
1824#endif
1825# 67 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1826
1827#ifndef _UINT64_T_DECLARED
1828typedef __uint64_t uint64_t;
1829#define _UINT64_T_DECLARED
1830#endif
1831# 72 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1832
1833#ifndef _INTPTR_T_DECLARED
1834typedef __intptr_t intptr_t;
1835#define _INTPTR_T_DECLARED
1836#endif
1837# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1838#ifndef _UINTPTR_T_DECLARED
1839typedef __uintptr_t uintptr_t;
1840#define _UINTPTR_T_DECLARED
1841#endif
1842# 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1843
1844#endif /* !_SYS__STDINT_H_ */
1845# 83 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
1846# 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
1847
1848typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */
1849typedef __uint16_t u_int16_t;
1850typedef __uint32_t u_int32_t;
1851typedef __uint64_t u_int64_t;
1852
1853typedef __uint64_t u_quad_t; /* quads (deprecated) */
1854typedef __int64_t quad_t;
1855typedef quad_t * qaddr_t;
1856
1857typedef char * caddr_t; /* core address */
1858typedef const char * c_caddr_t; /* core address, pointer to const */
1859
1860#ifndef _BLKSIZE_T_DECLARED
1861typedef __blksize_t blksize_t;
1862#define _BLKSIZE_T_DECLARED
1863#endif
1864# 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1865
1866typedef __cpuwhich_t cpuwhich_t;
1867typedef __cpulevel_t cpulevel_t;
1868typedef __cpusetid_t cpusetid_t;
1869
1870#ifndef _BLKCNT_T_DECLARED
1871typedef __blkcnt_t blkcnt_t;
1872#define _BLKCNT_T_DECLARED
1873#endif
1874# 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1875
1876#ifndef _CLOCK_T_DECLARED
1877typedef __clock_t clock_t;
1878#define _CLOCK_T_DECLARED
1879#endif
1880# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1881
1882#ifndef _CLOCKID_T_DECLARED
1883typedef __clockid_t clockid_t;
1884#define _CLOCKID_T_DECLARED
1885#endif
1886# 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1887
1888typedef __critical_t critical_t; /* Critical section value */
1889typedef __int64_t daddr_t; /* disk address */
1890
1891#ifndef _DEV_T_DECLARED
1892typedef __dev_t dev_t; /* device number or struct cdev */
1893#define _DEV_T_DECLARED
1894#endif
1895# 108 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1896
1897#ifndef _FFLAGS_T_DECLARED
1898typedef __fflags_t fflags_t; /* file flags */
1899#define _FFLAGS_T_DECLARED
1900#endif
1901# 113 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1902
1903typedef __fixpt_t fixpt_t; /* fixed point number */
1904
1905#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
1906typedef __fsblkcnt_t fsblkcnt_t;
1907typedef __fsfilcnt_t fsfilcnt_t;
1908#define _FSBLKCNT_T_DECLARED
1909#endif
1910# 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1911
1912#ifndef _GID_T_DECLARED
1913typedef __gid_t gid_t; /* group id */
1914#define _GID_T_DECLARED
1915#endif
1916# 126 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1917
1918#ifndef _IN_ADDR_T_DECLARED
1919typedef __uint32_t in_addr_t; /* base type for internet address */
1920#define _IN_ADDR_T_DECLARED
1921#endif
1922# 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1923
1924#ifndef _IN_PORT_T_DECLARED
1925typedef __uint16_t in_port_t;
1926#define _IN_PORT_T_DECLARED
1927#endif
1928# 136 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1929
1930#ifndef _ID_T_DECLARED
1931typedef __id_t id_t; /* can hold a uid_t or pid_t */
1932#define _ID_T_DECLARED
1933#endif
1934# 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1935
1936#ifndef _INO_T_DECLARED
1937typedef __ino_t ino_t; /* inode number */
1938#define _INO_T_DECLARED
1939#endif
1940# 146 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1941
1942#ifndef _KEY_T_DECLARED
1943typedef __key_t key_t; /* IPC key (for Sys V IPC) */
1944#define _KEY_T_DECLARED
1945#endif
1946# 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1947
1948#ifndef _LWPID_T_DECLARED
1949typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */
1950#define _LWPID_T_DECLARED
1951#endif
1952# 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1953
1954#ifndef _MODE_T_DECLARED
1955typedef __mode_t mode_t; /* permissions */
1956#define _MODE_T_DECLARED
1957#endif
1958# 161 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1959
1960#ifndef _ACCMODE_T_DECLARED
1961typedef __accmode_t accmode_t; /* access permissions */
1962#define _ACCMODE_T_DECLARED
1963#endif
1964# 166 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1965
1966#ifndef _NLINK_T_DECLARED
1967typedef __nlink_t nlink_t; /* link count */
1968#define _NLINK_T_DECLARED
1969#endif
1970# 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1971
1972#ifndef _OFF_T_DECLARED
1973typedef __off_t off_t; /* file offset */
1974#define _OFF_T_DECLARED
1975#endif
1976# 176 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1977
1978#ifndef _PID_T_DECLARED
1979typedef __pid_t pid_t; /* process id */
1980#define _PID_T_DECLARED
1981#endif
1982# 181 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1983
1984typedef __register_t register_t;
1985
1986#ifndef _RLIM_T_DECLARED
1987typedef __rlim_t rlim_t; /* resource limit */
1988#define _RLIM_T_DECLARED
1989#endif
1990# 188 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
1991
1992typedef __int64_t sbintime_t;
1993
1994typedef __segsz_t segsz_t; /* segment size (in pages) */
1995
1996#ifndef _SIZE_T_DECLARED
1997typedef __size_t size_t;
1998#define _SIZE_T_DECLARED
1999#endif
2000# 197 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2001
2002#ifndef _SSIZE_T_DECLARED
2003typedef __ssize_t ssize_t;
2004#define _SSIZE_T_DECLARED
2005#endif
2006# 202 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2007
2008#ifndef _SUSECONDS_T_DECLARED
2009typedef __suseconds_t suseconds_t; /* microseconds (signed) */
2010#define _SUSECONDS_T_DECLARED
2011#endif
2012# 207 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2013
2014#ifndef _TIME_T_DECLARED
2015typedef __time_t time_t;
2016#define _TIME_T_DECLARED
2017#endif
2018# 212 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2019
2020#ifndef _TIMER_T_DECLARED
2021typedef __timer_t timer_t;
2022#define _TIMER_T_DECLARED
2023#endif
2024# 217 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2025
2026#ifndef _MQD_T_DECLARED
2027typedef __mqd_t mqd_t;
2028#define _MQD_T_DECLARED
2029#endif
2030# 222 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2031
2032typedef __u_register_t u_register_t;
2033
2034#ifndef _UID_T_DECLARED
2035typedef __uid_t uid_t; /* user id */
2036#define _UID_T_DECLARED
2037#endif
2038# 229 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2039
2040#ifndef _USECONDS_T_DECLARED
2041typedef __useconds_t useconds_t; /* microseconds (unsigned) */
2042#define _USECONDS_T_DECLARED
2043#endif
2044# 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2045
2046#ifndef _CAP_IOCTL_T_DECLARED
2047#define _CAP_IOCTL_T_DECLARED
2048typedef unsigned long cap_ioctl_t;
2049#endif
2050# 239 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2051
2052#ifndef _CAP_RIGHTS_T_DECLARED
2053#define _CAP_RIGHTS_T_DECLARED
2054struct cap_rights;
2055
2056typedef struct cap_rights cap_rights_t;
2057#endif
2058# 246 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2059
2060typedef __vm_offset_t vm_offset_t;
2061typedef __vm_ooffset_t vm_ooffset_t;
2062typedef __vm_paddr_t vm_paddr_t;
2063typedef __vm_pindex_t vm_pindex_t;
2064typedef __vm_size_t vm_size_t;
2065
2066#ifdef _KERNEL
2067typedef int boolean_t;
2068typedef struct device *device_t;
2069typedef __intfptr_t intfptr_t;
2070
2071/*
2072 * XXX this is fixed width for historical reasons. It should have had type
2073 * __int_fast32_t. Fixed-width types should not be used unless binary
2074 * compatibility is essential. Least-width types should be used even less
2075 * since they provide smaller benefits.
2076 *
2077 * XXX should be MD.
2078 *
2079 * XXX this is bogus in -current, but still used for spl*().
2080 */
2081typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */
2082
2083typedef __uintfptr_t uintfptr_t;
2084typedef __uint64_t uoff_t;
2085typedef char vm_memattr_t; /* memory attribute codes */
2086typedef struct vm_page *vm_page_t;
2087
2088#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
2089#define __bool_true_false_are_defined 1
2090#define false 0
2091#define true 1
2092#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
2093typedef int _Bool;
2094#endif
2095# 282 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2096typedef _Bool bool;
2097#endif /* !__bool_true_false_are_defined && !__cplusplus */
2098# 284 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2099
2100#define offsetof(type, field) __offsetof(type, field)
2101
2102#endif /* !_KERNEL */
2103# 288 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2104
2105/*
2106 * The following are all things that really shouldn't exist in this header,
2107 * since its purpose is to provide typedefs, not miscellaneous doodads.
2108 */
2109#if __BSD_VISIBLE
2110
2111#if 0 /* expanded by -frewrite-includes */
2112#include <sys/select.h>
2113#endif /* expanded by -frewrite-includes */
2114# 295 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2115# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 1 3 4
2116/*-
2117 * Copyright (c) 1992, 1993
2118 * The Regents of the University of California. All rights reserved.
2119 *
2120 * Redistribution and use in source and binary forms, with or without
2121 * modification, are permitted provided that the following conditions
2122 * are met:
2123 * 1. Redistributions of source code must retain the above copyright
2124 * notice, this list of conditions and the following disclaimer.
2125 * 2. Redistributions in binary form must reproduce the above copyright
2126 * notice, this list of conditions and the following disclaimer in the
2127 * documentation and/or other materials provided with the distribution.
2128 * 4. Neither the name of the University nor the names of its contributors
2129 * may be used to endorse or promote products derived from this software
2130 * without specific prior written permission.
2131 *
2132 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2133 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2134 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2135 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2136 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2137 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2138 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2139 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2140 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2141 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2142 * SUCH DAMAGE.
2143 *
2144 * $FreeBSD$
2145 */
2146
2147#ifndef _SYS_SELECT_H_
2148#define _SYS_SELECT_H_
2149
2150#if 0 /* expanded by -frewrite-includes */
2151#include <sys/cdefs.h>
2152#endif /* expanded by -frewrite-includes */
2153# 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2154# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2155#if 0 /* expanded by -frewrite-includes */
2156#include <sys/_types.h>
2157#endif /* expanded by -frewrite-includes */
2158# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2159# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2160
2161#if 0 /* expanded by -frewrite-includes */
2162#include <sys/_sigset.h>
2163#endif /* expanded by -frewrite-includes */
2164# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2165# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 1 3 4
2166/*-
2167 * Copyright (c) 1982, 1986, 1989, 1991, 1993
2168 * The Regents of the University of California. All rights reserved.
2169 * (c) UNIX System Laboratories, Inc.
2170 * All or some portions of this file are derived from material licensed
2171 * to the University of California by American Telephone and Telegraph
2172 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
2173 * the permission of UNIX System Laboratories, Inc.
2174 *
2175 * Redistribution and use in source and binary forms, with or without
2176 * modification, are permitted provided that the following conditions
2177 * are met:
2178 * 1. Redistributions of source code must retain the above copyright
2179 * notice, this list of conditions and the following disclaimer.
2180 * 2. Redistributions in binary form must reproduce the above copyright
2181 * notice, this list of conditions and the following disclaimer in the
2182 * documentation and/or other materials provided with the distribution.
2183 * 4. Neither the name of the University nor the names of its contributors
2184 * may be used to endorse or promote products derived from this software
2185 * without specific prior written permission.
2186 *
2187 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2188 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2189 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2190 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2191 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2192 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2193 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2194 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2195 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2196 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2197 * SUCH DAMAGE.
2198 *
2199 * @(#)signal.h 8.4 (Berkeley) 5/4/95
2200 * $FreeBSD$
2201 */
2202
2203#ifndef _SYS__SIGSET_H_
2204#define _SYS__SIGSET_H_
2205
2206/*
2207 * sigset_t macros.
2208 */
2209#define _SIG_WORDS 4
2210#define _SIG_MAXSIG 128
2211#define _SIG_IDX(sig) ((sig) - 1)
2212#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
2213#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
2214#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0)
2215
2216typedef struct __sigset {
2217 __uint32_t __bits[_SIG_WORDS];
2218} __sigset_t;
2219
2220#if defined(_KERNEL) && defined(COMPAT_43)
2221typedef unsigned int osigset_t;
2222#endif
2223# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 3 4
2224
2225#endif /* !_SYS__SIGSET_H_ */
2226# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 3 4
2227# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
2228#if 0 /* expanded by -frewrite-includes */
2229#include <sys/_timeval.h>
2230#endif /* expanded by -frewrite-includes */
2231# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2232# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 1 3 4
2233/*-
2234 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
2235 * All rights reserved.
2236 *
2237 * Redistribution and use in source and binary forms, with or without
2238 * modification, are permitted provided that the following conditions
2239 * are met:
2240 * 1. Redistributions of source code must retain the above copyright
2241 * notice, this list of conditions and the following disclaimer.
2242 * 2. Redistributions in binary form must reproduce the above copyright
2243 * notice, this list of conditions and the following disclaimer in the
2244 * documentation and/or other materials provided with the distribution.
2245 *
2246 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2247 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2248 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2249 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2250 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2251 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2252 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2253 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2254 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2255 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2256 * SUCH DAMAGE.
2257 *
2258 * $FreeBSD$
2259 */
2260
2261#ifndef _SYS__TIMEVAL_H_
2262#define _SYS__TIMEVAL_H_
2263
2264#if 0 /* expanded by -frewrite-includes */
2265#include <sys/_types.h>
2266#endif /* expanded by -frewrite-includes */
2267# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2268# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2269
2270#ifndef _SUSECONDS_T_DECLARED
2271typedef __suseconds_t suseconds_t;
2272#define _SUSECONDS_T_DECLARED
2273#endif
2274# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2275
2276#ifndef _TIME_T_DECLARED
2277typedef __time_t time_t;
2278#define _TIME_T_DECLARED
2279#endif
2280# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2281
2282/*
2283 * Structure returned by gettimeofday(2) system call, and used in other calls.
2284 */
2285struct timeval {
2286 time_t tv_sec; /* seconds */
2287 suseconds_t tv_usec; /* and microseconds */
2288};
2289
2290#endif /* !_SYS__TIMEVAL_H_ */
2291# 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
2292# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
2293#if 0 /* expanded by -frewrite-includes */
2294#include <sys/timespec.h>
2295#endif /* expanded by -frewrite-includes */
2296# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2297# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 1 3 4
2298/*-
2299 * Copyright (c) 1982, 1986, 1993
2300 * The Regents of the University of California. All rights reserved.
2301 *
2302 * Redistribution and use in source and binary forms, with or without
2303 * modification, are permitted provided that the following conditions
2304 * are met:
2305 * 1. Redistributions of source code must retain the above copyright
2306 * notice, this list of conditions and the following disclaimer.
2307 * 2. Redistributions in binary form must reproduce the above copyright
2308 * notice, this list of conditions and the following disclaimer in the
2309 * documentation and/or other materials provided with the distribution.
2310 * 4. Neither the name of the University nor the names of its contributors
2311 * may be used to endorse or promote products derived from this software
2312 * without specific prior written permission.
2313 *
2314 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2315 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2316 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2317 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2318 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2319 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2320 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2321 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2322 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2323 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2324 * SUCH DAMAGE.
2325 *
2326 * @(#)time.h 8.5 (Berkeley) 5/4/95
2327 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
2328 * $FreeBSD$
2329 */
2330
2331#ifndef _SYS_TIMESPEC_H_
2332#define _SYS_TIMESPEC_H_
2333
2334#if 0 /* expanded by -frewrite-includes */
2335#include <sys/cdefs.h>
2336#endif /* expanded by -frewrite-includes */
2337# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2338# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2339#if 0 /* expanded by -frewrite-includes */
2340#include <sys/_timespec.h>
2341#endif /* expanded by -frewrite-includes */
2342# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2343# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 1 3 4
2344/*-
2345 * Copyright (c) 1982, 1986, 1993
2346 * The Regents of the University of California. All rights reserved.
2347 *
2348 * Redistribution and use in source and binary forms, with or without
2349 * modification, are permitted provided that the following conditions
2350 * are met:
2351 * 1. Redistributions of source code must retain the above copyright
2352 * notice, this list of conditions and the following disclaimer.
2353 * 2. Redistributions in binary form must reproduce the above copyright
2354 * notice, this list of conditions and the following disclaimer in the
2355 * documentation and/or other materials provided with the distribution.
2356 * 4. Neither the name of the University nor the names of its contributors
2357 * may be used to endorse or promote products derived from this software
2358 * without specific prior written permission.
2359 *
2360 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2361 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2362 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2363 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2364 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2365 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2366 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2367 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2368 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2369 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2370 * SUCH DAMAGE.
2371 *
2372 * @(#)time.h 8.5 (Berkeley) 5/4/95
2373 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
2374 * $FreeBSD$
2375 */
2376
2377#ifndef _SYS__TIMESPEC_H_
2378#define _SYS__TIMESPEC_H_
2379
2380#if 0 /* expanded by -frewrite-includes */
2381#include <sys/_types.h>
2382#endif /* expanded by -frewrite-includes */
2383# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2384# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2385
2386#ifndef _TIME_T_DECLARED
2387typedef __time_t time_t;
2388#define _TIME_T_DECLARED
2389#endif
2390# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2391
2392struct timespec {
2393 time_t tv_sec; /* seconds */
2394 long tv_nsec; /* and nanoseconds */
2395};
2396
2397#endif /* !_SYS__TIMESPEC_H_ */
2398# 50 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
2399# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 2 3 4
2400
2401#if __BSD_VISIBLE
2402#define TIMEVAL_TO_TIMESPEC(tv, ts) \
2403 do { \
2404 (ts)->tv_sec = (tv)->tv_sec; \
2405 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
2406 } while (0)
2407#define TIMESPEC_TO_TIMEVAL(tv, ts) \
2408 do { \
2409 (tv)->tv_sec = (ts)->tv_sec; \
2410 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
2411 } while (0)
2412
2413#endif /* __BSD_VISIBLE */
2414# 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2415
2416/*
2417 * Structure defined by POSIX.1b to be like a itimerval, but with
2418 * timespecs. Used in the timer_*() system calls.
2419 */
2420struct itimerspec {
2421 struct timespec it_interval;
2422 struct timespec it_value;
2423};
2424
2425#endif /* _SYS_TIMESPEC_H_ */
2426# 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
2427# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
2428
2429typedef unsigned long __fd_mask;
2430#if __BSD_VISIBLE
2431typedef __fd_mask fd_mask;
2432#endif
2433# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2434
2435#ifndef _SIGSET_T_DECLARED
2436#define _SIGSET_T_DECLARED
2437typedef __sigset_t sigset_t;
2438#endif
2439# 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2440
2441/*
2442 * Select uses bit masks of file descriptors in longs. These macros
2443 * manipulate such bit fields (the filesystem macros use chars).
2444 * FD_SETSIZE may be defined by the user, but the default here should
2445 * be enough for most uses.
2446 */
2447#ifndef FD_SETSIZE
2448#define FD_SETSIZE 1024
2449#endif
2450# 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2451
2452#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
2453#if __BSD_VISIBLE
2454#define NFDBITS _NFDBITS
2455#endif
2456# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2457
2458#ifndef _howmany
2459#define _howmany(x, y) (((x) + ((y) - 1)) / (y))
2460#endif
2461# 70 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2462
2463typedef struct fd_set {
2464 __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
2465} fd_set;
2466#if __BSD_VISIBLE
2467#define fds_bits __fds_bits
2468#endif
2469# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2470
2471#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
2472#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
2473#if __BSD_VISIBLE
2474#define FD_COPY(f, t) (void)(*(t) = *(f))
2475#endif
2476# 83 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2477#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)
2478#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
2479#define FD_ZERO(p) do { \
2480 fd_set *_p; \
2481 __size_t _n; \
2482 \
2483 _p = (p); \
2484 _n = _howmany(FD_SETSIZE, _NFDBITS); \
2485 while (_n > 0) \
2486 _p->__fds_bits[--_n] = 0; \
2487} while (0)
2488
2489#ifndef _KERNEL
2490
2491__BEGIN_DECLS
2492int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict,
2493 const struct timespec *__restrict, const sigset_t *__restrict);
2494#ifndef _SELECT_DECLARED
2495#define _SELECT_DECLARED
2496/* XXX missing restrict type-qualifier */
2497int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
2498#endif
2499# 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2500__END_DECLS
2501#endif /* !_KERNEL */
2502# 107 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2503
2504#endif /* _SYS_SELECT_H_ */
2505# 109 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
2506# 296 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
2507
2508#ifdef __POPCNT__
2509#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x))
2510#define __bitcount32(x) __builtin_popcount((__uint32_t)(x))
2511#define __bitcount16(x) __builtin_popcount((__uint16_t)(x))
2512#define __bitcountl(x) __builtin_popcountl((unsigned long)(x))
2513#define __bitcount(x) __builtin_popcount((unsigned int)(x))
2514#else
2515# 304 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2516/*
2517 * Population count algorithm using SWAR approach
2518 * - "SIMD Within A Register".
2519 */
2520static __inline __uint16_t
2521__bitcount16(__uint16_t _x)
2522{
2523
2524 _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1);
2525 _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2);
2526 _x = (_x + (_x >> 4)) & 0x0f0f;
2527 _x = (_x + (_x >> 8)) & 0x00ff;
2528 return (_x);
2529}
2530
2531static __inline __uint32_t
2532__bitcount32(__uint32_t _x)
2533{
2534
2535 _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1);
2536 _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2);
2537 _x = (_x + (_x >> 4)) & 0x0f0f0f0f;
2538 _x = (_x + (_x >> 8));
2539 _x = (_x + (_x >> 16)) & 0x000000ff;
2540 return (_x);
2541}
2542
2543#ifdef __LP64__
2544static __inline __uint64_t
2545__bitcount64(__uint64_t _x)
2546{
2547
2548 _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1);
2549 _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2);
2550 _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f;
2551 _x = (_x + (_x >> 8));
2552 _x = (_x + (_x >> 16));
2553 _x = (_x + (_x >> 32)) & 0x000000ff;
2554 return (_x);
2555}
2556
2557#define __bitcountl(x) __bitcount64((unsigned long)(x))
2558#else
2559# 347 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2560static __inline __uint64_t
2561__bitcount64(__uint64_t _x)
2562{
2563
2564 return (__bitcount32(_x >> 32) + __bitcount32(_x));
2565}
2566
2567#define __bitcountl(x) __bitcount32((unsigned long)(x))
2568#endif
2569# 356 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2570#define __bitcount(x) __bitcount32((unsigned int)(x))
2571#endif
2572# 358 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2573
2574/*
2575 * minor() gives a cookie instead of an index since we don't want to
2576 * change the meanings of bits 0-15 or waste time and space shifting
2577 * bits 16-31 for devices that don't use them.
2578 */
2579#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
2580#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
2581#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
2582
2583/*
2584 * These declarations belong elsewhere, but are repeated here and in
2585 * <stdio.h> to give broken programs a better chance of working with
2586 * 64-bit off_t's.
2587 */
2588#ifndef _KERNEL
2589__BEGIN_DECLS
2590#ifndef _FTRUNCATE_DECLARED
2591#define _FTRUNCATE_DECLARED
2592int ftruncate(int, off_t);
2593#endif
2594# 379 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2595#ifndef _LSEEK_DECLARED
2596#define _LSEEK_DECLARED
2597off_t lseek(int, off_t, int);
2598#endif
2599# 383 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2600#ifndef _MMAP_DECLARED
2601#define _MMAP_DECLARED
2602void * mmap(void *, size_t, int, int, int, off_t);
2603#endif
2604# 387 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2605#ifndef _TRUNCATE_DECLARED
2606#define _TRUNCATE_DECLARED
2607int truncate(const char *, off_t);
2608#endif
2609# 391 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2610__END_DECLS
2611#endif /* !_KERNEL */
2612# 393 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2613
2614#endif /* __BSD_VISIBLE */
2615# 395 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2616
2617#endif /* !_SYS_TYPES_H_ */
2618# 397 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
2619# 39 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
2620#if 0 /* expanded by -frewrite-includes */
2621#include <sys/sysctl.h>
2622#endif /* expanded by -frewrite-includes */
2623# 39 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
2624# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 1 3 4
2625/*-
2626 * Copyright (c) 1989, 1993
2627 * The Regents of the University of California. All rights reserved.
2628 *
2629 * This code is derived from software contributed to Berkeley by
2630 * Mike Karels at Berkeley Software Design, Inc.
2631 *
2632 * Redistribution and use in source and binary forms, with or without
2633 * modification, are permitted provided that the following conditions
2634 * are met:
2635 * 1. Redistributions of source code must retain the above copyright
2636 * notice, this list of conditions and the following disclaimer.
2637 * 2. Redistributions in binary form must reproduce the above copyright
2638 * notice, this list of conditions and the following disclaimer in the
2639 * documentation and/or other materials provided with the distribution.
2640 * 4. Neither the name of the University nor the names of its contributors
2641 * may be used to endorse or promote products derived from this software
2642 * without specific prior written permission.
2643 *
2644 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2645 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2646 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2647 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2648 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2649 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2650 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2651 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2652 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2653 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2654 * SUCH DAMAGE.
2655 *
2656 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
2657 * $FreeBSD$
2658 */
2659
2660#ifndef _SYS_SYSCTL_H_
2661#define _SYS_SYSCTL_H_
2662
2663#if 0 /* expanded by -frewrite-includes */
2664#include <sys/queue.h>
2665#endif /* expanded by -frewrite-includes */
2666# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
2667# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 1 3 4
2668/*-
2669 * Copyright (c) 1991, 1993
2670 * The Regents of the University of California. All rights reserved.
2671 *
2672 * Redistribution and use in source and binary forms, with or without
2673 * modification, are permitted provided that the following conditions
2674 * are met:
2675 * 1. Redistributions of source code must retain the above copyright
2676 * notice, this list of conditions and the following disclaimer.
2677 * 2. Redistributions in binary form must reproduce the above copyright
2678 * notice, this list of conditions and the following disclaimer in the
2679 * documentation and/or other materials provided with the distribution.
2680 * 4. Neither the name of the University nor the names of its contributors
2681 * may be used to endorse or promote products derived from this software
2682 * without specific prior written permission.
2683 *
2684 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2685 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2686 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2687 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2688 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2689 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2690 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2691 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2692 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2693 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2694 * SUCH DAMAGE.
2695 *
2696 * @(#)queue.h 8.5 (Berkeley) 8/20/94
2697 * $FreeBSD$
2698 */
2699
2700#ifndef _SYS_QUEUE_H_
2701#define _SYS_QUEUE_H_
2702
2703#if 0 /* expanded by -frewrite-includes */
2704#include <sys/cdefs.h>
2705#endif /* expanded by -frewrite-includes */
2706# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
2707# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
2708
2709/*
2710 * This file defines four types of data structures: singly-linked lists,
2711 * singly-linked tail queues, lists and tail queues.
2712 *
2713 * A singly-linked list is headed by a single forward pointer. The elements
2714 * are singly linked for minimum space and pointer manipulation overhead at
2715 * the expense of O(n) removal for arbitrary elements. New elements can be
2716 * added to the list after an existing element or at the head of the list.
2717 * Elements being removed from the head of the list should use the explicit
2718 * macro for this purpose for optimum efficiency. A singly-linked list may
2719 * only be traversed in the forward direction. Singly-linked lists are ideal
2720 * for applications with large datasets and few or no removals or for
2721 * implementing a LIFO queue.
2722 *
2723 * A singly-linked tail queue is headed by a pair of pointers, one to the
2724 * head of the list and the other to the tail of the list. The elements are
2725 * singly linked for minimum space and pointer manipulation overhead at the
2726 * expense of O(n) removal for arbitrary elements. New elements can be added
2727 * to the list after an existing element, at the head of the list, or at the
2728 * end of the list. Elements being removed from the head of the tail queue
2729 * should use the explicit macro for this purpose for optimum efficiency.
2730 * A singly-linked tail queue may only be traversed in the forward direction.
2731 * Singly-linked tail queues are ideal for applications with large datasets
2732 * and few or no removals or for implementing a FIFO queue.
2733 *
2734 * A list is headed by a single forward pointer (or an array of forward
2735 * pointers for a hash table header). The elements are doubly linked
2736 * so that an arbitrary element can be removed without a need to
2737 * traverse the list. New elements can be added to the list before
2738 * or after an existing element or at the head of the list. A list
2739 * may be traversed in either direction.
2740 *
2741 * A tail queue is headed by a pair of pointers, one to the head of the
2742 * list and the other to the tail of the list. The elements are doubly
2743 * linked so that an arbitrary element can be removed without a need to
2744 * traverse the list. New elements can be added to the list before or
2745 * after an existing element, at the head of the list, or at the end of
2746 * the list. A tail queue may be traversed in either direction.
2747 *
2748 * For details on the use of these macros, see the queue(3) manual page.
2749 *
2750 *
2751 * SLIST LIST STAILQ TAILQ
2752 * _HEAD + + + +
2753 * _CLASS_HEAD + + + +
2754 * _HEAD_INITIALIZER + + + +
2755 * _ENTRY + + + +
2756 * _CLASS_ENTRY + + + +
2757 * _INIT + + + +
2758 * _EMPTY + + + +
2759 * _FIRST + + + +
2760 * _NEXT + + + +
2761 * _PREV - + - +
2762 * _LAST - - + +
2763 * _FOREACH + + + +
2764 * _FOREACH_FROM + + + +
2765 * _FOREACH_SAFE + + + +
2766 * _FOREACH_FROM_SAFE + + + +
2767 * _FOREACH_REVERSE - - - +
2768 * _FOREACH_REVERSE_FROM - - - +
2769 * _FOREACH_REVERSE_SAFE - - - +
2770 * _FOREACH_REVERSE_FROM_SAFE - - - +
2771 * _INSERT_HEAD + + + +
2772 * _INSERT_BEFORE - + - +
2773 * _INSERT_AFTER + + + +
2774 * _INSERT_TAIL - - + +
2775 * _CONCAT - - + +
2776 * _REMOVE_AFTER + - + -
2777 * _REMOVE_HEAD + - + -
2778 * _REMOVE + + + +
2779 * _SWAP + + + +
2780 *
2781 */
2782#ifdef QUEUE_MACRO_DEBUG
2783/* Store the last 2 places the queue element or head was altered */
2784struct qm_trace {
2785 unsigned long lastline;
2786 unsigned long prevline;
2787 const char *lastfile;
2788 const char *prevfile;
2789};
2790
2791#define TRACEBUF struct qm_trace trace;
2792#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
2793#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
2794#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
2795
2796#define QMD_TRACE_HEAD(head) do { \
2797 (head)->trace.prevline = (head)->trace.lastline; \
2798 (head)->trace.prevfile = (head)->trace.lastfile; \
2799 (head)->trace.lastline = __LINE__; \
2800 (head)->trace.lastfile = __FILE__; \
2801} while (0)
2802
2803#define QMD_TRACE_ELEM(elem) do { \
2804 (elem)->trace.prevline = (elem)->trace.lastline; \
2805 (elem)->trace.prevfile = (elem)->trace.lastfile; \
2806 (elem)->trace.lastline = __LINE__; \
2807 (elem)->trace.lastfile = __FILE__; \
2808} while (0)
2809
2810#else
2811# 140 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
2812#define QMD_TRACE_ELEM(elem)
2813#define QMD_TRACE_HEAD(head)
2814#define QMD_SAVELINK(name, link)
2815#define TRACEBUF
2816#define TRACEBUF_INITIALIZER
2817#define TRASHIT(x)
2818#endif /* QUEUE_MACRO_DEBUG */
2819# 147 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
2820
2821#ifdef __cplusplus
2822/*
2823 * In C++ there can be structure lists and class lists:
2824 */
2825#define QUEUE_TYPEOF(type) type
2826#else
2827# 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
2828#define QUEUE_TYPEOF(type) struct type
2829#endif
2830# 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
2831
2832/*
2833 * Singly-linked List declarations.
2834 */
2835#define SLIST_HEAD(name, type) \
2836struct name { \
2837 struct type *slh_first; /* first element */ \
2838}
2839
2840#define SLIST_CLASS_HEAD(name, type) \
2841struct name { \
2842 class type *slh_first; /* first element */ \
2843}
2844
2845#define SLIST_HEAD_INITIALIZER(head) \
2846 { NULL }
2847
2848#define SLIST_ENTRY(type) \
2849struct { \
2850 struct type *sle_next; /* next element */ \
2851}
2852
2853#define SLIST_CLASS_ENTRY(type) \
2854struct { \
2855 class type *sle_next; /* next element */ \
2856}
2857
2858/*
2859 * Singly-linked List functions.
2860 */
2861#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
2862
2863#define SLIST_FIRST(head) ((head)->slh_first)
2864
2865#define SLIST_FOREACH(var, head, field) \
2866 for ((var) = SLIST_FIRST((head)); \
2867 (var); \
2868 (var) = SLIST_NEXT((var), field))
2869
2870#define SLIST_FOREACH_FROM(var, head, field) \
2871 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
2872 (var); \
2873 (var) = SLIST_NEXT((var), field))
2874
2875#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
2876 for ((var) = SLIST_FIRST((head)); \
2877 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
2878 (var) = (tvar))
2879
2880#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
2881 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
2882 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
2883 (var) = (tvar))
2884
2885#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
2886 for ((varp) = &SLIST_FIRST((head)); \
2887 ((var) = *(varp)) != NULL; \
2888 (varp) = &SLIST_NEXT((var), field))
2889
2890#define SLIST_INIT(head) do { \
2891 SLIST_FIRST((head)) = NULL; \
2892} while (0)
2893
2894#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
2895 SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
2896 SLIST_NEXT((slistelm), field) = (elm); \
2897} while (0)
2898
2899#define SLIST_INSERT_HEAD(head, elm, field) do { \
2900 SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
2901 SLIST_FIRST((head)) = (elm); \
2902} while (0)
2903
2904#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
2905
2906#define SLIST_REMOVE(head, elm, type, field) do { \
2907 QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
2908 if (SLIST_FIRST((head)) == (elm)) { \
2909 SLIST_REMOVE_HEAD((head), field); \
2910 } \
2911 else { \
2912 QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \
2913 while (SLIST_NEXT(curelm, field) != (elm)) \
2914 curelm = SLIST_NEXT(curelm, field); \
2915 SLIST_REMOVE_AFTER(curelm, field); \
2916 } \
2917 TRASHIT(*oldnext); \
2918} while (0)
2919
2920#define SLIST_REMOVE_AFTER(elm, field) do { \
2921 SLIST_NEXT(elm, field) = \
2922 SLIST_NEXT(SLIST_NEXT(elm, field), field); \
2923} while (0)
2924
2925#define SLIST_REMOVE_HEAD(head, field) do { \
2926 SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
2927} while (0)
2928
2929#define SLIST_SWAP(head1, head2, type) do { \
2930 QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \
2931 SLIST_FIRST(head1) = SLIST_FIRST(head2); \
2932 SLIST_FIRST(head2) = swap_first; \
2933} while (0)
2934
2935/*
2936 * Singly-linked Tail queue declarations.
2937 */
2938#define STAILQ_HEAD(name, type) \
2939struct name { \
2940 struct type *stqh_first;/* first element */ \
2941 struct type **stqh_last;/* addr of last next element */ \
2942}
2943
2944#define STAILQ_CLASS_HEAD(name, type) \
2945struct name { \
2946 class type *stqh_first; /* first element */ \
2947 class type **stqh_last; /* addr of last next element */ \
2948}
2949
2950#define STAILQ_HEAD_INITIALIZER(head) \
2951 { NULL, &(head).stqh_first }
2952
2953#define STAILQ_ENTRY(type) \
2954struct { \
2955 struct type *stqe_next; /* next element */ \
2956}
2957
2958#define STAILQ_CLASS_ENTRY(type) \
2959struct { \
2960 class type *stqe_next; /* next element */ \
2961}
2962
2963/*
2964 * Singly-linked Tail queue functions.
2965 */
2966#define STAILQ_CONCAT(head1, head2) do { \
2967 if (!STAILQ_EMPTY((head2))) { \
2968 *(head1)->stqh_last = (head2)->stqh_first; \
2969 (head1)->stqh_last = (head2)->stqh_last; \
2970 STAILQ_INIT((head2)); \
2971 } \
2972} while (0)
2973
2974#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
2975
2976#define STAILQ_FIRST(head) ((head)->stqh_first)
2977
2978#define STAILQ_FOREACH(var, head, field) \
2979 for((var) = STAILQ_FIRST((head)); \
2980 (var); \
2981 (var) = STAILQ_NEXT((var), field))
2982
2983#define STAILQ_FOREACH_FROM(var, head, field) \
2984 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
2985 (var); \
2986 (var) = STAILQ_NEXT((var), field))
2987
2988#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
2989 for ((var) = STAILQ_FIRST((head)); \
2990 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
2991 (var) = (tvar))
2992
2993#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
2994 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
2995 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
2996 (var) = (tvar))
2997
2998#define STAILQ_INIT(head) do { \
2999 STAILQ_FIRST((head)) = NULL; \
3000 (head)->stqh_last = &STAILQ_FIRST((head)); \
3001} while (0)
3002
3003#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
3004 if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
3005 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
3006 STAILQ_NEXT((tqelm), field) = (elm); \
3007} while (0)
3008
3009#define STAILQ_INSERT_HEAD(head, elm, field) do { \
3010 if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
3011 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
3012 STAILQ_FIRST((head)) = (elm); \
3013} while (0)
3014
3015#define STAILQ_INSERT_TAIL(head, elm, field) do { \
3016 STAILQ_NEXT((elm), field) = NULL; \
3017 *(head)->stqh_last = (elm); \
3018 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
3019} while (0)
3020
3021#define STAILQ_LAST(head, type, field) \
3022 (STAILQ_EMPTY((head)) ? NULL : \
3023 __containerof((head)->stqh_last, \
3024 QUEUE_TYPEOF(type), field.stqe_next))
3025
3026#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
3027
3028#define STAILQ_REMOVE(head, elm, type, field) do { \
3029 QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
3030 if (STAILQ_FIRST((head)) == (elm)) { \
3031 STAILQ_REMOVE_HEAD((head), field); \
3032 } \
3033 else { \
3034 QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \
3035 while (STAILQ_NEXT(curelm, field) != (elm)) \
3036 curelm = STAILQ_NEXT(curelm, field); \
3037 STAILQ_REMOVE_AFTER(head, curelm, field); \
3038 } \
3039 TRASHIT(*oldnext); \
3040} while (0)
3041
3042#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
3043 if ((STAILQ_NEXT(elm, field) = \
3044 STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
3045 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
3046} while (0)
3047
3048#define STAILQ_REMOVE_HEAD(head, field) do { \
3049 if ((STAILQ_FIRST((head)) = \
3050 STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
3051 (head)->stqh_last = &STAILQ_FIRST((head)); \
3052} while (0)
3053
3054#define STAILQ_SWAP(head1, head2, type) do { \
3055 QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \
3056 QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \
3057 STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
3058 (head1)->stqh_last = (head2)->stqh_last; \
3059 STAILQ_FIRST(head2) = swap_first; \
3060 (head2)->stqh_last = swap_last; \
3061 if (STAILQ_EMPTY(head1)) \
3062 (head1)->stqh_last = &STAILQ_FIRST(head1); \
3063 if (STAILQ_EMPTY(head2)) \
3064 (head2)->stqh_last = &STAILQ_FIRST(head2); \
3065} while (0)
3066
3067
3068/*
3069 * List declarations.
3070 */
3071#define LIST_HEAD(name, type) \
3072struct name { \
3073 struct type *lh_first; /* first element */ \
3074}
3075
3076#define LIST_CLASS_HEAD(name, type) \
3077struct name { \
3078 class type *lh_first; /* first element */ \
3079}
3080
3081#define LIST_HEAD_INITIALIZER(head) \
3082 { NULL }
3083
3084#define LIST_ENTRY(type) \
3085struct { \
3086 struct type *le_next; /* next element */ \
3087 struct type **le_prev; /* address of previous next element */ \
3088}
3089
3090#define LIST_CLASS_ENTRY(type) \
3091struct { \
3092 class type *le_next; /* next element */ \
3093 class type **le_prev; /* address of previous next element */ \
3094}
3095
3096/*
3097 * List functions.
3098 */
3099
3100#if (defined(_KERNEL) && defined(INVARIANTS))
3101#define QMD_LIST_CHECK_HEAD(head, field) do { \
3102 if (LIST_FIRST((head)) != NULL && \
3103 LIST_FIRST((head))->field.le_prev != \
3104 &LIST_FIRST((head))) \
3105 panic("Bad list head %p first->prev != head", (head)); \
3106} while (0)
3107
3108#define QMD_LIST_CHECK_NEXT(elm, field) do { \
3109 if (LIST_NEXT((elm), field) != NULL && \
3110 LIST_NEXT((elm), field)->field.le_prev != \
3111 &((elm)->field.le_next)) \
3112 panic("Bad link elm %p next->prev != elm", (elm)); \
3113} while (0)
3114
3115#define QMD_LIST_CHECK_PREV(elm, field) do { \
3116 if (*(elm)->field.le_prev != (elm)) \
3117 panic("Bad link elm %p prev->next != elm", (elm)); \
3118} while (0)
3119#else
3120# 445 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
3121#define QMD_LIST_CHECK_HEAD(head, field)
3122#define QMD_LIST_CHECK_NEXT(elm, field)
3123#define QMD_LIST_CHECK_PREV(elm, field)
3124#endif /* (_KERNEL && INVARIANTS) */
3125# 449 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
3126
3127#define LIST_EMPTY(head) ((head)->lh_first == NULL)
3128
3129#define LIST_FIRST(head) ((head)->lh_first)
3130
3131#define LIST_FOREACH(var, head, field) \
3132 for ((var) = LIST_FIRST((head)); \
3133 (var); \
3134 (var) = LIST_NEXT((var), field))
3135
3136#define LIST_FOREACH_FROM(var, head, field) \
3137 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
3138 (var); \
3139 (var) = LIST_NEXT((var), field))
3140
3141#define LIST_FOREACH_SAFE(var, head, field, tvar) \
3142 for ((var) = LIST_FIRST((head)); \
3143 (var) && ((tvar) = LIST_NEXT((var), field), 1); \
3144 (var) = (tvar))
3145
3146#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
3147 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
3148 (var) && ((tvar) = LIST_NEXT((var), field), 1); \
3149 (var) = (tvar))
3150
3151#define LIST_INIT(head) do { \
3152 LIST_FIRST((head)) = NULL; \
3153} while (0)
3154
3155#define LIST_INSERT_AFTER(listelm, elm, field) do { \
3156 QMD_LIST_CHECK_NEXT(listelm, field); \
3157 if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
3158 LIST_NEXT((listelm), field)->field.le_prev = \
3159 &LIST_NEXT((elm), field); \
3160 LIST_NEXT((listelm), field) = (elm); \
3161 (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
3162} while (0)
3163
3164#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
3165 QMD_LIST_CHECK_PREV(listelm, field); \
3166 (elm)->field.le_prev = (listelm)->field.le_prev; \
3167 LIST_NEXT((elm), field) = (listelm); \
3168 *(listelm)->field.le_prev = (elm); \
3169 (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
3170} while (0)
3171
3172#define LIST_INSERT_HEAD(head, elm, field) do { \
3173 QMD_LIST_CHECK_HEAD((head), field); \
3174 if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
3175 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
3176 LIST_FIRST((head)) = (elm); \
3177 (elm)->field.le_prev = &LIST_FIRST((head)); \
3178} while (0)
3179
3180#define LIST_NEXT(elm, field) ((elm)->field.le_next)
3181
3182#define LIST_PREV(elm, head, type, field) \
3183 ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
3184 __containerof((elm)->field.le_prev, \
3185 QUEUE_TYPEOF(type), field.le_next))
3186
3187#define LIST_REMOVE(elm, field) do { \
3188 QMD_SAVELINK(oldnext, (elm)->field.le_next); \
3189 QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
3190 QMD_LIST_CHECK_NEXT(elm, field); \
3191 QMD_LIST_CHECK_PREV(elm, field); \
3192 if (LIST_NEXT((elm), field) != NULL) \
3193 LIST_NEXT((elm), field)->field.le_prev = \
3194 (elm)->field.le_prev; \
3195 *(elm)->field.le_prev = LIST_NEXT((elm), field); \
3196 TRASHIT(*oldnext); \
3197 TRASHIT(*oldprev); \
3198} while (0)
3199
3200#define LIST_SWAP(head1, head2, type, field) do { \
3201 QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \
3202 LIST_FIRST((head1)) = LIST_FIRST((head2)); \
3203 LIST_FIRST((head2)) = swap_tmp; \
3204 if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
3205 swap_tmp->field.le_prev = &LIST_FIRST((head1)); \
3206 if ((swap_tmp = LIST_FIRST((head2))) != NULL) \
3207 swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
3208} while (0)
3209
3210/*
3211 * Tail queue declarations.
3212 */
3213#define TAILQ_HEAD(name, type) \
3214struct name { \
3215 struct type *tqh_first; /* first element */ \
3216 struct type **tqh_last; /* addr of last next element */ \
3217 TRACEBUF \
3218}
3219
3220#define TAILQ_CLASS_HEAD(name, type) \
3221struct name { \
3222 class type *tqh_first; /* first element */ \
3223 class type **tqh_last; /* addr of last next element */ \
3224 TRACEBUF \
3225}
3226
3227#define TAILQ_HEAD_INITIALIZER(head) \
3228 { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
3229
3230#define TAILQ_ENTRY(type) \
3231struct { \
3232 struct type *tqe_next; /* next element */ \
3233 struct type **tqe_prev; /* address of previous next element */ \
3234 TRACEBUF \
3235}
3236
3237#define TAILQ_CLASS_ENTRY(type) \
3238struct { \
3239 class type *tqe_next; /* next element */ \
3240 class type **tqe_prev; /* address of previous next element */ \
3241 TRACEBUF \
3242}
3243
3244/*
3245 * Tail queue functions.
3246 */
3247#if (defined(_KERNEL) && defined(INVARIANTS))
3248#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
3249 if (!TAILQ_EMPTY(head) && \
3250 TAILQ_FIRST((head))->field.tqe_prev != \
3251 &TAILQ_FIRST((head))) \
3252 panic("Bad tailq head %p first->prev != head", (head)); \
3253} while (0)
3254
3255#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
3256 if (*(head)->tqh_last != NULL) \
3257 panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
3258} while (0)
3259
3260#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
3261 if (TAILQ_NEXT((elm), field) != NULL && \
3262 TAILQ_NEXT((elm), field)->field.tqe_prev != \
3263 &((elm)->field.tqe_next)) \
3264 panic("Bad link elm %p next->prev != elm", (elm)); \
3265} while (0)
3266
3267#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
3268 if (*(elm)->field.tqe_prev != (elm)) \
3269 panic("Bad link elm %p prev->next != elm", (elm)); \
3270} while (0)
3271#else
3272# 595 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
3273#define QMD_TAILQ_CHECK_HEAD(head, field)
3274#define QMD_TAILQ_CHECK_TAIL(head, headname)
3275#define QMD_TAILQ_CHECK_NEXT(elm, field)
3276#define QMD_TAILQ_CHECK_PREV(elm, field)
3277#endif /* (_KERNEL && INVARIANTS) */
3278# 600 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
3279
3280#define TAILQ_CONCAT(head1, head2, field) do { \
3281 if (!TAILQ_EMPTY(head2)) { \
3282 *(head1)->tqh_last = (head2)->tqh_first; \
3283 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
3284 (head1)->tqh_last = (head2)->tqh_last; \
3285 TAILQ_INIT((head2)); \
3286 QMD_TRACE_HEAD(head1); \
3287 QMD_TRACE_HEAD(head2); \
3288 } \
3289} while (0)
3290
3291#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
3292
3293#define TAILQ_FIRST(head) ((head)->tqh_first)
3294
3295#define TAILQ_FOREACH(var, head, field) \
3296 for ((var) = TAILQ_FIRST((head)); \
3297 (var); \
3298 (var) = TAILQ_NEXT((var), field))
3299
3300#define TAILQ_FOREACH_FROM(var, head, field) \
3301 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
3302 (var); \
3303 (var) = TAILQ_NEXT((var), field))
3304
3305#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
3306 for ((var) = TAILQ_FIRST((head)); \
3307 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
3308 (var) = (tvar))
3309
3310#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
3311 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
3312 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
3313 (var) = (tvar))
3314
3315#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
3316 for ((var) = TAILQ_LAST((head), headname); \
3317 (var); \
3318 (var) = TAILQ_PREV((var), headname, field))
3319
3320#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
3321 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
3322 (var); \
3323 (var) = TAILQ_PREV((var), headname, field))
3324
3325#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
3326 for ((var) = TAILQ_LAST((head), headname); \
3327 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
3328 (var) = (tvar))
3329
3330#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \
3331 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
3332 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
3333 (var) = (tvar))
3334
3335#define TAILQ_INIT(head) do { \
3336 TAILQ_FIRST((head)) = NULL; \
3337 (head)->tqh_last = &TAILQ_FIRST((head)); \
3338 QMD_TRACE_HEAD(head); \
3339} while (0)
3340
3341#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
3342 QMD_TAILQ_CHECK_NEXT(listelm, field); \
3343 if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
3344 TAILQ_NEXT((elm), field)->field.tqe_prev = \
3345 &TAILQ_NEXT((elm), field); \
3346 else { \
3347 (head)->tqh_last = &TAILQ_NEXT((elm), field); \
3348 QMD_TRACE_HEAD(head); \
3349 } \
3350 TAILQ_NEXT((listelm), field) = (elm); \
3351 (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
3352 QMD_TRACE_ELEM(&(elm)->field); \
3353 QMD_TRACE_ELEM(&(listelm)->field); \
3354} while (0)
3355
3356#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
3357 QMD_TAILQ_CHECK_PREV(listelm, field); \
3358 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
3359 TAILQ_NEXT((elm), field) = (listelm); \
3360 *(listelm)->field.tqe_prev = (elm); \
3361 (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
3362 QMD_TRACE_ELEM(&(elm)->field); \
3363 QMD_TRACE_ELEM(&(listelm)->field); \
3364} while (0)
3365
3366#define TAILQ_INSERT_HEAD(head, elm, field) do { \
3367 QMD_TAILQ_CHECK_HEAD(head, field); \
3368 if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
3369 TAILQ_FIRST((head))->field.tqe_prev = \
3370 &TAILQ_NEXT((elm), field); \
3371 else \
3372 (head)->tqh_last = &TAILQ_NEXT((elm), field); \
3373 TAILQ_FIRST((head)) = (elm); \
3374 (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
3375 QMD_TRACE_HEAD(head); \
3376 QMD_TRACE_ELEM(&(elm)->field); \
3377} while (0)
3378
3379#define TAILQ_INSERT_TAIL(head, elm, field) do { \
3380 QMD_TAILQ_CHECK_TAIL(head, field); \
3381 TAILQ_NEXT((elm), field) = NULL; \
3382 (elm)->field.tqe_prev = (head)->tqh_last; \
3383 *(head)->tqh_last = (elm); \
3384 (head)->tqh_last = &TAILQ_NEXT((elm), field); \
3385 QMD_TRACE_HEAD(head); \
3386 QMD_TRACE_ELEM(&(elm)->field); \
3387} while (0)
3388
3389#define TAILQ_LAST(head, headname) \
3390 (*(((struct headname *)((head)->tqh_last))->tqh_last))
3391
3392#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
3393
3394#define TAILQ_PREV(elm, headname, field) \
3395 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
3396
3397#define TAILQ_REMOVE(head, elm, field) do { \
3398 QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
3399 QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
3400 QMD_TAILQ_CHECK_NEXT(elm, field); \
3401 QMD_TAILQ_CHECK_PREV(elm, field); \
3402 if ((TAILQ_NEXT((elm), field)) != NULL) \
3403 TAILQ_NEXT((elm), field)->field.tqe_prev = \
3404 (elm)->field.tqe_prev; \
3405 else { \
3406 (head)->tqh_last = (elm)->field.tqe_prev; \
3407 QMD_TRACE_HEAD(head); \
3408 } \
3409 *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
3410 TRASHIT(*oldnext); \
3411 TRASHIT(*oldprev); \
3412 QMD_TRACE_ELEM(&(elm)->field); \
3413} while (0)
3414
3415#define TAILQ_SWAP(head1, head2, type, field) do { \
3416 QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \
3417 QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \
3418 (head1)->tqh_first = (head2)->tqh_first; \
3419 (head1)->tqh_last = (head2)->tqh_last; \
3420 (head2)->tqh_first = swap_first; \
3421 (head2)->tqh_last = swap_last; \
3422 if ((swap_first = (head1)->tqh_first) != NULL) \
3423 swap_first->field.tqe_prev = &(head1)->tqh_first; \
3424 else \
3425 (head1)->tqh_last = &(head1)->tqh_first; \
3426 if ((swap_first = (head2)->tqh_first) != NULL) \
3427 swap_first->field.tqe_prev = &(head2)->tqh_first; \
3428 else \
3429 (head2)->tqh_last = &(head2)->tqh_first; \
3430} while (0)
3431
3432#endif /* !_SYS_QUEUE_H_ */
3433# 754 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/queue.h" 3 4
3434# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 2 3 4
3435
3436struct thread;
3437/*
3438 * Definitions for sysctl call. The sysctl call uses a hierarchical name
3439 * for objects that can be examined or modified. The name is expressed as
3440 * a sequence of integers. Like a file path name, the meaning of each
3441 * component depends on its place in the hierarchy. The top-level and kern
3442 * identifiers are defined here, and other identifiers are defined in the
3443 * respective subsystem header files.
3444 */
3445
3446#define CTL_MAXNAME 24 /* largest number of components supported */
3447
3448/*
3449 * Each subsystem defined by sysctl defines a list of variables
3450 * for that subsystem. Each name is either a node with further
3451 * levels defined below it, or it is a leaf of some particular
3452 * type given below. Each sysctl level defines a set of name/type
3453 * pairs to be used by sysctl(8) in manipulating the subsystem.
3454 */
3455struct ctlname {
3456 char *ctl_name; /* subsystem name */
3457 int ctl_type; /* type of name */
3458};
3459
3460#define CTLTYPE 0xf /* mask for the type */
3461#define CTLTYPE_NODE 1 /* name is a node */
3462#define CTLTYPE_INT 2 /* name describes an integer */
3463#define CTLTYPE_STRING 3 /* name describes a string */
3464#define CTLTYPE_S64 4 /* name describes a signed 64-bit number */
3465#define CTLTYPE_OPAQUE 5 /* name describes a structure */
3466#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
3467#define CTLTYPE_UINT 6 /* name describes an unsigned integer */
3468#define CTLTYPE_LONG 7 /* name describes a long */
3469#define CTLTYPE_ULONG 8 /* name describes an unsigned long */
3470#define CTLTYPE_U64 9 /* name describes an unsigned 64-bit number */
3471
3472#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
3473#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
3474#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
3475#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
3476#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
3477#define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */
3478#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */
3479#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */
3480#define CTLMASK_SECURE 0x00F00000 /* Secure level */
3481#define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */
3482#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN)
3483#define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN)
3484#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */
3485#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */
3486#define CTLFLAG_DYING 0x00010000 /* Oid is being removed */
3487#define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */
3488#define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */
3489#define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */
3490#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */
3491#define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR)
3492
3493/*
3494 * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1.
3495 *
3496 * Secure when the securelevel is raised to at least N.
3497 */
3498#define CTLSHIFT_SECURE 20
3499#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE))
3500#define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE))
3501#define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE))
3502
3503/*
3504 * USE THIS instead of a hardwired number from the categories below
3505 * to get dynamically assigned sysctl entries using the linker-set
3506 * technology. This is the way nearly all new sysctl variables should
3507 * be implemented.
3508 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
3509 */
3510#define OID_AUTO (-1)
3511
3512/*
3513 * The starting number for dynamically-assigned entries. WARNING!
3514 * ALL static sysctl entries should have numbers LESS than this!
3515 */
3516#define CTL_AUTO_START 0x100
3517
3518#ifdef _KERNEL
3519#if 0 /* expanded by -frewrite-includes */
3520#include <sys/linker_set.h>
3521#endif /* expanded by -frewrite-includes */
3522# 124 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3523# 125 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3524
3525#ifdef KLD_MODULE
3526/* XXX allow overspecification of type in external kernel modules */
3527#define SYSCTL_CT_ASSERT_MASK CTLTYPE
3528#else
3529# 130 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3530#define SYSCTL_CT_ASSERT_MASK 0
3531#endif
3532# 132 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3533
3534#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \
3535 intptr_t arg2, struct sysctl_req *req
3536
3537/* definitions for sysctl_req 'lock' member */
3538#define REQ_UNWIRED 1
3539#define REQ_WIRED 2
3540
3541/* definitions for sysctl_req 'flags' member */
3542#if defined(__amd64__) || defined(__powerpc64__) ||\
3543 (defined(__mips__) && defined(__mips_n64))
3544#define SCTL_MASK32 1 /* 32 bit emulation */
3545#endif
3546# 145 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3547
3548/*
3549 * This describes the access space for a sysctl request. This is needed
3550 * so that we can use the interface from the kernel or from user-space.
3551 */
3552struct sysctl_req {
3553 struct thread *td; /* used for access checking */
3554 int lock; /* wiring state */
3555 void *oldptr;
3556 size_t oldlen;
3557 size_t oldidx;
3558 int (*oldfunc)(struct sysctl_req *, const void *, size_t);
3559 void *newptr;
3560 size_t newlen;
3561 size_t newidx;
3562 int (*newfunc)(struct sysctl_req *, void *, size_t);
3563 size_t validlen;
3564 int flags;
3565};
3566
3567SLIST_HEAD(sysctl_oid_list, sysctl_oid);
3568
3569/*
3570 * This describes one "oid" in the MIB tree. Potentially more nodes can
3571 * be hidden behind it, expanded by the handler.
3572 */
3573struct sysctl_oid {
3574 struct sysctl_oid_list oid_children;
3575 struct sysctl_oid_list *oid_parent;
3576 SLIST_ENTRY(sysctl_oid) oid_link;
3577 int oid_number;
3578 u_int oid_kind;
3579 void *oid_arg1;
3580 intptr_t oid_arg2;
3581 const char *oid_name;
3582 int (*oid_handler)(SYSCTL_HANDLER_ARGS);
3583 const char *oid_fmt;
3584 int oid_refcnt;
3585 u_int oid_running;
3586 const char *oid_descr;
3587};
3588
3589#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
3590#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
3591#define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1)
3592
3593int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
3594int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
3595int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
3596int sysctl_handle_64(SYSCTL_HANDLER_ARGS);
3597int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
3598int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
3599int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS);
3600
3601int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS);
3602int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS);
3603
3604int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS);
3605int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS);
3606int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS);
3607
3608/*
3609 * These functions are used to add/remove an oid from the mib.
3610 */
3611void sysctl_register_oid(struct sysctl_oid *oidp);
3612void sysctl_unregister_oid(struct sysctl_oid *oidp);
3613
3614/* Declare a static oid to allow child oids to be added to it. */
3615#define SYSCTL_DECL(name) \
3616 extern struct sysctl_oid sysctl__##name
3617
3618/* Hide these in macros. */
3619#define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children)
3620#define SYSCTL_PARENT(oid_ptr) \
3621 (((oid_ptr)->oid_parent != &sysctl__children) ? \
3622 __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \
3623 oid_children) : (struct sysctl_oid *)NULL)
3624#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children)
3625
3626/* === Structs and macros related to context handling. === */
3627
3628/* All dynamically created sysctls can be tracked in a context list. */
3629struct sysctl_ctx_entry {
3630 struct sysctl_oid *entry;
3631 TAILQ_ENTRY(sysctl_ctx_entry) link;
3632};
3633
3634TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
3635
3636#define SYSCTL_NODE_CHILDREN(parent, name) \
3637 sysctl__##parent##_##name.oid_children
3638
3639#ifndef NO_SYSCTL_DESCR
3640#define __DESCR(d) d
3641#else
3642# 240 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3643#define __DESCR(d) ""
3644#endif
3645# 242 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3646
3647/* This macro is only for internal use */
3648#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \
3649 struct sysctl_oid id = { \
3650 .oid_parent = (parent_child_head), \
3651 .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \
3652 .oid_number = (nbr), \
3653 .oid_kind = (kind), \
3654 .oid_arg1 = (a1), \
3655 .oid_arg2 = (a2), \
3656 .oid_name = (name), \
3657 .oid_handler = (handler), \
3658 .oid_fmt = (fmt), \
3659 .oid_descr = __DESCR(descr) \
3660 }; \
3661 DATA_SET(sysctl_set, id)
3662
3663/* This constructs a static "raw" MIB oid. */
3664#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
3665 static SYSCTL_OID_RAW(sysctl__##parent##_##name, \
3666 SYSCTL_CHILDREN(&sysctl__##parent), \
3667 nbr, #name, kind, a1, a2, handler, fmt, descr)
3668
3669/* This constructs a global "raw" MIB oid. */
3670#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
3671 SYSCTL_OID_RAW(sysctl__##parent##_##name, \
3672 SYSCTL_CHILDREN(&sysctl__##parent), \
3673 nbr, #name, kind, a1, a2, handler, fmt, descr)
3674
3675#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
3676 sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr))
3677
3678/* This constructs a root node from which other nodes can hang. */
3679#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \
3680 SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \
3681 nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \
3682 handler, "N", descr); \
3683 CTASSERT(((access) & CTLTYPE) == 0 || \
3684 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE)
3685
3686/* This constructs a node from which other oids can hang. */
3687#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \
3688 SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \
3689 NULL, 0, handler, "N", descr); \
3690 CTASSERT(((access) & CTLTYPE) == 0 || \
3691 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE)
3692
3693#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
3694({ \
3695 CTASSERT(((access) & CTLTYPE) == 0 || \
3696 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \
3697 sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \
3698 NULL, 0, handler, "N", __DESCR(descr)); \
3699})
3700
3701#define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \
3702({ \
3703 CTASSERT(((access) & CTLTYPE) == 0 || \
3704 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \
3705 sysctl_add_oid(ctx, &sysctl__children, nbr, name, \
3706 CTLTYPE_NODE|(access), \
3707 NULL, 0, handler, "N", __DESCR(descr)); \
3708})
3709
3710/* Oid for a string. len can be 0 to indicate '\0' termination. */
3711#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \
3712 SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \
3713 arg, len, sysctl_handle_string, "A", descr); \
3714 CTASSERT(((access) & CTLTYPE) == 0 || \
3715 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING)
3716
3717#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \
3718({ \
3719 char *__arg = (arg); \
3720 CTASSERT(((access) & CTLTYPE) == 0 || \
3721 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \
3722 sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \
3723 __arg, len, sysctl_handle_string, "A", __DESCR(descr)); \
3724})
3725
3726/* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */
3727#define SYSCTL_NULL_INT_PTR ((int *)NULL)
3728#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
3729 SYSCTL_OID(parent, nbr, name, \
3730 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \
3731 ptr, val, sysctl_handle_int, "I", descr); \
3732 CTASSERT((((access) & CTLTYPE) == 0 || \
3733 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) && \
3734 sizeof(int) == sizeof(*(ptr)))
3735
3736#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
3737({ \
3738 int *__ptr = (ptr); \
3739 CTASSERT(((access) & CTLTYPE) == 0 || \
3740 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \
3741 sysctl_add_oid(ctx, parent, nbr, name, \
3742 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \
3743 __ptr, val, sysctl_handle_int, "I", __DESCR(descr)); \
3744})
3745
3746/* Oid for an unsigned int. If ptr is NULL, val is returned. */
3747#define SYSCTL_NULL_UINT_PTR ((unsigned *)NULL)
3748#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \
3749 SYSCTL_OID(parent, nbr, name, \
3750 CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \
3751 ptr, val, sysctl_handle_int, "IU", descr); \
3752 CTASSERT((((access) & CTLTYPE) == 0 || \
3753 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT) && \
3754 sizeof(unsigned) == sizeof(*(ptr)))
3755
3756#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \
3757({ \
3758 unsigned *__ptr = (ptr); \
3759 CTASSERT(((access) & CTLTYPE) == 0 || \
3760 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT); \
3761 sysctl_add_oid(ctx, parent, nbr, name, \
3762 CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \
3763 __ptr, val, sysctl_handle_int, "IU", __DESCR(descr)); \
3764})
3765
3766/* Oid for a long. The pointer must be non NULL. */
3767#define SYSCTL_NULL_LONG_PTR ((long *)NULL)
3768#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \
3769 SYSCTL_OID(parent, nbr, name, \
3770 CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \
3771 ptr, val, sysctl_handle_long, "L", descr); \
3772 CTASSERT((((access) & CTLTYPE) == 0 || \
3773 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG) && \
3774 sizeof(long) == sizeof(*(ptr)))
3775
3776#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \
3777({ \
3778 long *__ptr = (ptr); \
3779 CTASSERT(((access) & CTLTYPE) == 0 || \
3780 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG); \
3781 sysctl_add_oid(ctx, parent, nbr, name, \
3782 CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \
3783 __ptr, 0, sysctl_handle_long, "L", __DESCR(descr)); \
3784})
3785
3786/* Oid for an unsigned long. The pointer must be non NULL. */
3787#define SYSCTL_NULL_ULONG_PTR ((unsigned long *)NULL)
3788#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \
3789 SYSCTL_OID(parent, nbr, name, \
3790 CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \
3791 ptr, val, sysctl_handle_long, "LU", descr); \
3792 CTASSERT((((access) & CTLTYPE) == 0 || \
3793 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG) && \
3794 sizeof(unsigned long) == sizeof(*(ptr)))
3795
3796#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \
3797({ \
3798 unsigned long *__ptr = (ptr); \
3799 CTASSERT(((access) & CTLTYPE) == 0 || \
3800 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \
3801 sysctl_add_oid(ctx, parent, nbr, name, \
3802 CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \
3803 __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)); \
3804})
3805
3806/* Oid for a quad. The pointer must be non NULL. */
3807#define SYSCTL_NULL_QUAD_PTR ((int64_t *)NULL)
3808#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \
3809 SYSCTL_OID(parent, nbr, name, \
3810 CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \
3811 ptr, val, sysctl_handle_64, "Q", descr); \
3812 CTASSERT((((access) & CTLTYPE) == 0 || \
3813 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \
3814 sizeof(int64_t) == sizeof(*(ptr)))
3815
3816#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \
3817({ \
3818 int64_t *__ptr = (ptr); \
3819 CTASSERT(((access) & CTLTYPE) == 0 || \
3820 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
3821 sysctl_add_oid(ctx, parent, nbr, name, \
3822 CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \
3823 __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr)); \
3824})
3825
3826#define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL)
3827#define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr) \
3828 SYSCTL_OID(parent, nbr, name, \
3829 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
3830 ptr, val, sysctl_handle_64, "QU", descr); \
3831 CTASSERT((((access) & CTLTYPE) == 0 || \
3832 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \
3833 sizeof(uint64_t) == sizeof(*(ptr)))
3834
3835#define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr) \
3836({ \
3837 uint64_t *__ptr = (ptr); \
3838 CTASSERT(((access) & CTLTYPE) == 0 || \
3839 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \
3840 sysctl_add_oid(ctx, parent, nbr, name, \
3841 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
3842 __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr)); \
3843})
3844
3845/* Oid for a CPU dependant variable */
3846#define SYSCTL_ADD_UAUTO(ctx, parent, nbr, name, access, ptr, descr) \
3847({ \
3848 struct sysctl_oid *__ret; \
3849 CTASSERT((sizeof(uint64_t) == sizeof(*(ptr)) || \
3850 sizeof(unsigned) == sizeof(*(ptr))) && \
3851 ((access) & CTLTYPE) == 0); \
3852 if (sizeof(uint64_t) == sizeof(*(ptr))) { \
3853 __ret = sysctl_add_oid(ctx, parent, nbr, name, \
3854 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
3855 (ptr), 0, sysctl_handle_64, "QU", \
3856 __DESCR(descr)); \
3857 } else { \
3858 __ret = sysctl_add_oid(ctx, parent, nbr, name, \
3859 CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \
3860 (ptr), 0, sysctl_handle_int, "IU", \
3861 __DESCR(descr)); \
3862 } \
3863 __ret; \
3864})
3865
3866/* Oid for a 64-bit unsigned counter(9). The pointer must be non NULL. */
3867#define SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr) \
3868 SYSCTL_OID(parent, nbr, name, \
3869 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
3870 (ptr), 0, sysctl_handle_counter_u64, "QU", descr); \
3871 CTASSERT((((access) & CTLTYPE) == 0 || \
3872 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \
3873 sizeof(counter_u64_t) == sizeof(*(ptr)) && \
3874 sizeof(uint64_t) == sizeof(**(ptr)))
3875
3876#define SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr) \
3877({ \
3878 counter_u64_t *__ptr = (ptr); \
3879 CTASSERT(((access) & CTLTYPE) == 0 || \
3880 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \
3881 sysctl_add_oid(ctx, parent, nbr, name, \
3882 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \
3883 __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \
3884})
3885
3886/* Oid for an opaque object. Specified by a pointer and a length. */
3887#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
3888 SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
3889 ptr, len, sysctl_handle_opaque, fmt, descr); \
3890 CTASSERT(((access) & CTLTYPE) == 0 || \
3891 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE)
3892
3893#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \
3894({ \
3895 CTASSERT(((access) & CTLTYPE) == 0 || \
3896 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \
3897 sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
3898 ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)); \
3899})
3900
3901/* Oid for a struct. Specified by a pointer and a type. */
3902#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \
3903 SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
3904 ptr, sizeof(struct type), sysctl_handle_opaque, \
3905 "S," #type, descr); \
3906 CTASSERT(((access) & CTLTYPE) == 0 || \
3907 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE)
3908
3909#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
3910({ \
3911 CTASSERT(((access) & CTLTYPE) == 0 || \
3912 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \
3913 sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
3914 (ptr), sizeof(struct type), \
3915 sysctl_handle_opaque, "S," #type, __DESCR(descr)); \
3916})
3917
3918/* Oid for a procedure. Specified by a pointer and an arg. */
3919#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
3920 SYSCTL_OID(parent, nbr, name, (access), \
3921 ptr, arg, handler, fmt, descr); \
3922 CTASSERT(((access) & CTLTYPE) != 0)
3923
3924#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
3925({ \
3926 CTASSERT(((access) & CTLTYPE) != 0); \
3927 sysctl_add_oid(ctx, parent, nbr, name, (access), \
3928 (ptr), (arg), (handler), (fmt), __DESCR(descr)); \
3929})
3930
3931/* Oid to handle limits on uma(9) zone specified by pointer. */
3932#define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \
3933 SYSCTL_OID(parent, nbr, name, \
3934 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \
3935 (ptr), 0, sysctl_handle_uma_zone_max, "I", descr); \
3936 CTASSERT(((access) & CTLTYPE) == 0 || \
3937 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT)
3938
3939#define SYSCTL_ADD_UMA_MAX(ctx, parent, nbr, name, access, ptr, descr) \
3940({ \
3941 uma_zone_t __ptr = (ptr); \
3942 CTASSERT(((access) & CTLTYPE) == 0 || \
3943 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \
3944 sysctl_add_oid(ctx, parent, nbr, name, \
3945 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \
3946 __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr)); \
3947})
3948
3949/* Oid to obtain current use of uma(9) zone specified by pointer. */
3950#define SYSCTL_UMA_CUR(parent, nbr, name, access, ptr, descr) \
3951 SYSCTL_OID(parent, nbr, name, \
3952 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
3953 (ptr), 0, sysctl_handle_uma_zone_cur, "I", descr); \
3954 CTASSERT(((access) & CTLTYPE) == 0 || \
3955 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT)
3956
3957#define SYSCTL_ADD_UMA_CUR(ctx, parent, nbr, name, access, ptr, descr) \
3958({ \
3959 uma_zone_t __ptr = (ptr); \
3960 CTASSERT(((access) & CTLTYPE) == 0 || \
3961 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \
3962 sysctl_add_oid(ctx, parent, nbr, name, \
3963 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
3964 __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr)); \
3965})
3966
3967/*
3968 * A macro to generate a read-only sysctl to indicate the presense of optional
3969 * kernel features.
3970 */
3971#define FEATURE(name, desc) \
3972 SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD | CTLFLAG_CAPRD, \
3973 SYSCTL_NULL_INT_PTR, 1, desc)
3974
3975#endif /* _KERNEL */
3976# 572 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
3977
3978/*
3979 * Top-level identifiers
3980 */
3981#define CTL_UNSPEC 0 /* unused */
3982#define CTL_KERN 1 /* "high kernel": proc, limits */
3983#define CTL_VM 2 /* virtual memory */
3984#define CTL_VFS 3 /* filesystem, mount type is next */
3985#define CTL_NET 4 /* network, see socket.h */
3986#define CTL_DEBUG 5 /* debugging parameters */
3987#define CTL_HW 6 /* generic cpu/io */
3988#define CTL_MACHDEP 7 /* machine dependent */
3989#define CTL_USER 8 /* user-level */
3990#define CTL_P1003_1B 9 /* POSIX 1003.1B */
3991
3992/*
3993 * CTL_KERN identifiers
3994 */
3995#define KERN_OSTYPE 1 /* string: system version */
3996#define KERN_OSRELEASE 2 /* string: system release */
3997#define KERN_OSREV 3 /* int: system revision */
3998#define KERN_VERSION 4 /* string: compile time info */
3999#define KERN_MAXVNODES 5 /* int: max vnodes */
4000#define KERN_MAXPROC 6 /* int: max processes */
4001#define KERN_MAXFILES 7 /* int: max open files */
4002#define KERN_ARGMAX 8 /* int: max arguments to exec */
4003#define KERN_SECURELVL 9 /* int: system security level */
4004#define KERN_HOSTNAME 10 /* string: hostname */
4005#define KERN_HOSTID 11 /* int: host identifier */
4006#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
4007#define KERN_VNODE 13 /* struct: vnode structures */
4008#define KERN_PROC 14 /* struct: process entries */
4009#define KERN_FILE 15 /* struct: file entries */
4010#define KERN_PROF 16 /* node: kernel profiling info */
4011#define KERN_POSIX1 17 /* int: POSIX.1 version */
4012#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
4013#define KERN_JOB_CONTROL 19 /* int: is job control available */
4014#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
4015#define KERN_BOOTTIME 21 /* struct: time kernel was booted */
4016#define KERN_NISDOMAINNAME 22 /* string: YP domain name */
4017#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */
4018#define KERN_OSRELDATE 24 /* int: kernel release date */
4019#define KERN_NTP_PLL 25 /* node: NTP PLL control */
4020#define KERN_BOOTFILE 26 /* string: name of booted kernel */
4021#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */
4022#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */
4023#define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */
4024#define KERN_IPC 30 /* node: anything related to IPC */
4025#define KERN_DUMMY 31 /* unused */
4026#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */
4027#define KERN_USRSTACK 33 /* int: address of USRSTACK */
4028#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */
4029#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */
4030#define KERN_HOSTUUID 36 /* string: host UUID identifier */
4031#define KERN_ARND 37 /* int: from arc4rand() */
4032/*
4033 * KERN_PROC subtypes
4034 */
4035#define KERN_PROC_ALL 0 /* everything */
4036#define KERN_PROC_PID 1 /* by process id */
4037#define KERN_PROC_PGRP 2 /* by process group id */
4038#define KERN_PROC_SESSION 3 /* by session of pid */
4039#define KERN_PROC_TTY 4 /* by controlling tty */
4040#define KERN_PROC_UID 5 /* by effective uid */
4041#define KERN_PROC_RUID 6 /* by real uid */
4042#define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */
4043#define KERN_PROC_PROC 8 /* only return procs */
4044#define KERN_PROC_SV_NAME 9 /* get syscall vector name */
4045#define KERN_PROC_RGID 10 /* by real group id */
4046#define KERN_PROC_GID 11 /* by effective group id */
4047#define KERN_PROC_PATHNAME 12 /* path to executable */
4048#define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */
4049#define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */
4050#define KERN_PROC_KSTACK 15 /* Kernel stacks for process */
4051#define KERN_PROC_INC_THREAD 0x10 /*
4052 * modifier for pid, pgrp, tty,
4053 * uid, ruid, gid, rgid and proc
4054 * This effectively uses 16-31
4055 */
4056#define KERN_PROC_VMMAP 32 /* VM map entries for process */
4057#define KERN_PROC_FILEDESC 33 /* File descriptors for process */
4058#define KERN_PROC_GROUPS 34 /* process groups */
4059#define KERN_PROC_ENV 35 /* get environment */
4060#define KERN_PROC_AUXV 36 /* get ELF auxiliary vector */
4061#define KERN_PROC_RLIMIT 37 /* process resource limits */
4062#define KERN_PROC_PS_STRINGS 38 /* get ps_strings location */
4063#define KERN_PROC_UMASK 39 /* process umask */
4064#define KERN_PROC_OSREL 40 /* osreldate for process binary */
4065#define KERN_PROC_SIGTRAMP 41 /* signal trampoline location */
4066#define KERN_PROC_CWD 42 /* process current working directory */
4067#define KERN_PROC_SBCLASSES 43 /* get sandbox classes */
4068#define KERN_PROC_SBMETHODS 44 /* get sandbox methods */
4069#define KERN_PROC_SBOBJECTS 45 /* get sandbox objects */
4070
4071/*
4072 * KERN_IPC identifiers
4073 */
4074#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */
4075#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */
4076#define KIPC_SOMAXCONN 3 /* int: max length of connection q */
4077#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */
4078#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */
4079#define KIPC_MAX_HDR 6 /* int: max total length of headers */
4080#define KIPC_MAX_DATALEN 7 /* int: max length of data? */
4081
4082/*
4083 * CTL_HW identifiers
4084 */
4085#define HW_MACHINE 1 /* string: machine class */
4086#define HW_MODEL 2 /* string: specific machine model */
4087#define HW_NCPU 3 /* int: number of cpus */
4088#define HW_BYTEORDER 4 /* int: machine byte order */
4089#define HW_PHYSMEM 5 /* int: total memory */
4090#define HW_USERMEM 6 /* int: non-kernel memory */
4091#define HW_PAGESIZE 7 /* int: software page size */
4092#define HW_DISKNAMES 8 /* strings: disk drive names */
4093#define HW_DISKSTATS 9 /* struct: diskstats[] */
4094#define HW_FLOATINGPT 10 /* int: has HW floating point? */
4095#define HW_MACHINE_ARCH 11 /* string: machine architecture */
4096#define HW_REALMEM 12 /* int: 'real' memory */
4097
4098/*
4099 * CTL_USER definitions
4100 */
4101#define USER_CS_PATH 1 /* string: _CS_PATH */
4102#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
4103#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
4104#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
4105#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
4106#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
4107#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
4108#define USER_LINE_MAX 8 /* int: LINE_MAX */
4109#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
4110#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
4111#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
4112#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
4113#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
4114#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
4115#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
4116#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
4117#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
4118#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
4119#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
4120#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
4121
4122#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */
4123#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */
4124#define CTL_P1003_1B_MEMLOCK 3 /* boolean */
4125#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */
4126#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */
4127#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */
4128#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */
4129#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */
4130#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */
4131#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */
4132#define CTL_P1003_1B_FSYNC 11 /* boolean */
4133#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */
4134#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */
4135#define CTL_P1003_1B_TIMERS 14 /* boolean */
4136#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */
4137#define CTL_P1003_1B_AIO_MAX 16 /* int */
4138#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */
4139#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */
4140#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */
4141#define CTL_P1003_1B_PAGESIZE 20 /* int */
4142#define CTL_P1003_1B_RTSIG_MAX 21 /* int */
4143#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */
4144#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */
4145#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */
4146#define CTL_P1003_1B_TIMER_MAX 25 /* int */
4147
4148#define CTL_P1003_1B_MAXID 26
4149
4150#ifdef _KERNEL
4151
4152/*
4153 * Declare some common oids.
4154 */
4155extern struct sysctl_oid_list sysctl__children;
4156SYSCTL_DECL(_kern);
4157SYSCTL_DECL(_kern_features);
4158SYSCTL_DECL(_kern_ipc);
4159SYSCTL_DECL(_kern_proc);
4160SYSCTL_DECL(_kern_sched);
4161SYSCTL_DECL(_kern_sched_stats);
4162SYSCTL_DECL(_sysctl);
4163SYSCTL_DECL(_vm);
4164SYSCTL_DECL(_vm_stats);
4165SYSCTL_DECL(_vm_stats_misc);
4166SYSCTL_DECL(_vfs);
4167SYSCTL_DECL(_net);
4168SYSCTL_DECL(_debug);
4169SYSCTL_DECL(_debug_sizeof);
4170SYSCTL_DECL(_dev);
4171SYSCTL_DECL(_hw);
4172SYSCTL_DECL(_hw_bus);
4173SYSCTL_DECL(_hw_bus_devices);
4174SYSCTL_DECL(_hw_bus_info);
4175SYSCTL_DECL(_machdep);
4176SYSCTL_DECL(_user);
4177SYSCTL_DECL(_compat);
4178SYSCTL_DECL(_regression);
4179SYSCTL_DECL(_security);
4180SYSCTL_DECL(_security_bsd);
4181
4182extern char machine[];
4183extern char osrelease[];
4184extern char ostype[];
4185extern char kern_ident[];
4186
4187/* Dynamic oid handling */
4188struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,
4189 struct sysctl_oid_list *parent, int nbr, const char *name, int kind,
4190 void *arg1, intptr_t arg2, int (*handler)(SYSCTL_HANDLER_ARGS),
4191 const char *fmt, const char *descr);
4192int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del,
4193 int recurse);
4194void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name);
4195int sysctl_move_oid(struct sysctl_oid *oidp,
4196 struct sysctl_oid_list *parent);
4197int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse);
4198int sysctl_ctx_init(struct sysctl_ctx_list *clist);
4199int sysctl_ctx_free(struct sysctl_ctx_list *clist);
4200struct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist,
4201 struct sysctl_oid *oidp);
4202struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist,
4203 struct sysctl_oid *oidp);
4204int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist,
4205 struct sysctl_oid *oidp);
4206
4207int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
4208 size_t *oldlenp, void *new, size_t newlen, size_t *retval,
4209 int flags);
4210int kernel_sysctlbyname(struct thread *td, char *name, void *old,
4211 size_t *oldlenp, void *new, size_t newlen, size_t *retval,
4212 int flags);
4213int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
4214 size_t *oldlenp, int inkernel, void *new, size_t newlen,
4215 size_t *retval, int flags);
4216int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
4217 int *nindx, struct sysctl_req *req);
4218void sysctl_wlock(void);
4219void sysctl_wunlock(void);
4220int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len);
4221
4222struct sbuf;
4223struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int,
4224 struct sysctl_req *);
4225#else /* !_KERNEL */
4226# 821 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
4227#if 0 /* expanded by -frewrite-includes */
4228#include <sys/cdefs.h>
4229#endif /* expanded by -frewrite-includes */
4230# 821 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
4231# 822 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
4232
4233__BEGIN_DECLS
4234int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
4235int sysctlbyname(const char *, void *, size_t *, const void *, size_t);
4236int sysctlnametomib(const char *, int *, size_t *);
4237__END_DECLS
4238#endif /* _KERNEL */
4239# 829 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
4240
4241#endif /* !_SYS_SYSCTL_H_ */
4242# 831 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/sysctl.h" 3 4
4243# 40 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
4244#if 0 /* expanded by -frewrite-includes */
4245#include <sys/time.h>
4246#endif /* expanded by -frewrite-includes */
4247# 40 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
4248# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 1 3 4
4249/*-
4250 * Copyright (c) 1982, 1986, 1993
4251 * The Regents of the University of California. All rights reserved.
4252 *
4253 * Redistribution and use in source and binary forms, with or without
4254 * modification, are permitted provided that the following conditions
4255 * are met:
4256 * 1. Redistributions of source code must retain the above copyright
4257 * notice, this list of conditions and the following disclaimer.
4258 * 2. Redistributions in binary form must reproduce the above copyright
4259 * notice, this list of conditions and the following disclaimer in the
4260 * documentation and/or other materials provided with the distribution.
4261 * 4. Neither the name of the University nor the names of its contributors
4262 * may be used to endorse or promote products derived from this software
4263 * without specific prior written permission.
4264 *
4265 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4266 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4267 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4268 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4269 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4270 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4271 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4272 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4273 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4274 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4275 * SUCH DAMAGE.
4276 *
4277 * @(#)time.h 8.5 (Berkeley) 5/4/95
4278 * $FreeBSD$
4279 */
4280
4281#ifndef _SYS_TIME_H_
4282#define _SYS_TIME_H_
4283
4284#if 0 /* expanded by -frewrite-includes */
4285#include <sys/_timeval.h>
4286#endif /* expanded by -frewrite-includes */
4287# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4288# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4289#if 0 /* expanded by -frewrite-includes */
4290#include <sys/types.h>
4291#endif /* expanded by -frewrite-includes */
4292# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4293# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4294#if 0 /* expanded by -frewrite-includes */
4295#include <sys/timespec.h>
4296#endif /* expanded by -frewrite-includes */
4297# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4298# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4299
4300struct timezone {
4301 int tz_minuteswest; /* minutes west of Greenwich */
4302 int tz_dsttime; /* type of dst correction */
4303};
4304#define DST_NONE 0 /* not on dst */
4305#define DST_USA 1 /* USA style dst */
4306#define DST_AUST 2 /* Australian style dst */
4307#define DST_WET 3 /* Western European dst */
4308#define DST_MET 4 /* Middle European dst */
4309#define DST_EET 5 /* Eastern European dst */
4310#define DST_CAN 6 /* Canada */
4311
4312#if __BSD_VISIBLE
4313struct bintime {
4314 time_t sec;
4315 uint64_t frac;
4316};
4317
4318static __inline void
4319bintime_addx(struct bintime *_bt, uint64_t _x)
4320{
4321 uint64_t _u;
4322
4323 _u = _bt->frac;
4324 _bt->frac += _x;
4325 if (_u > _bt->frac)
4326 _bt->sec++;
4327}
4328
4329static __inline void
4330bintime_add(struct bintime *_bt, const struct bintime *_bt2)
4331{
4332 uint64_t _u;
4333
4334 _u = _bt->frac;
4335 _bt->frac += _bt2->frac;
4336 if (_u > _bt->frac)
4337 _bt->sec++;
4338 _bt->sec += _bt2->sec;
4339}
4340
4341static __inline void
4342bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
4343{
4344 uint64_t _u;
4345
4346 _u = _bt->frac;
4347 _bt->frac -= _bt2->frac;
4348 if (_u < _bt->frac)
4349 _bt->sec--;
4350 _bt->sec -= _bt2->sec;
4351}
4352
4353static __inline void
4354bintime_mul(struct bintime *_bt, u_int _x)
4355{
4356 uint64_t _p1, _p2;
4357
4358 _p1 = (_bt->frac & 0xffffffffull) * _x;
4359 _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32);
4360 _bt->sec *= _x;
4361 _bt->sec += (_p2 >> 32);
4362 _bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull);
4363}
4364
4365static __inline void
4366bintime_shift(struct bintime *_bt, int _exp)
4367{
4368
4369 if (_exp > 0) {
4370 _bt->sec <<= _exp;
4371 _bt->sec |= _bt->frac >> (64 - _exp);
4372 _bt->frac <<= _exp;
4373 } else if (_exp < 0) {
4374 _bt->frac >>= -_exp;
4375 _bt->frac |= (uint64_t)_bt->sec << (64 + _exp);
4376 _bt->sec >>= -_exp;
4377 }
4378}
4379
4380#define bintime_clear(a) ((a)->sec = (a)->frac = 0)
4381#define bintime_isset(a) ((a)->sec || (a)->frac)
4382#define bintime_cmp(a, b, cmp) \
4383 (((a)->sec == (b)->sec) ? \
4384 ((a)->frac cmp (b)->frac) : \
4385 ((a)->sec cmp (b)->sec))
4386
4387#define SBT_1S ((sbintime_t)1 << 32)
4388#define SBT_1M (SBT_1S * 60)
4389#define SBT_1MS (SBT_1S / 1000)
4390#define SBT_1US (SBT_1S / 1000000)
4391#define SBT_1NS (SBT_1S / 1000000000)
4392#define SBT_MAX 0x7fffffffffffffffLL
4393
4394static __inline int
4395sbintime_getsec(sbintime_t _sbt)
4396{
4397
4398 return (_sbt >> 32);
4399}
4400
4401static __inline sbintime_t
4402bttosbt(const struct bintime _bt)
4403{
4404
4405 return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32));
4406}
4407
4408static __inline struct bintime
4409sbttobt(sbintime_t _sbt)
4410{
4411 struct bintime _bt;
4412
4413 _bt.sec = _sbt >> 32;
4414 _bt.frac = _sbt << 32;
4415 return (_bt);
4416}
4417
4418/*-
4419 * Background information:
4420 *
4421 * When converting between timestamps on parallel timescales of differing
4422 * resolutions it is historical and scientific practice to round down rather
4423 * than doing 4/5 rounding.
4424 *
4425 * The date changes at midnight, not at noon.
4426 *
4427 * Even at 15:59:59.999999999 it's not four'o'clock.
4428 *
4429 * time_second ticks after N.999999999 not after N.4999999999
4430 */
4431
4432static __inline void
4433bintime2timespec(const struct bintime *_bt, struct timespec *_ts)
4434{
4435
4436 _ts->tv_sec = _bt->sec;
4437 _ts->tv_nsec = ((uint64_t)1000000000 *
4438 (uint32_t)(_bt->frac >> 32)) >> 32;
4439}
4440
4441static __inline void
4442timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
4443{
4444
4445 _bt->sec = _ts->tv_sec;
4446 /* 18446744073 = int(2^64 / 1000000000) */
4447 _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL;
4448}
4449
4450static __inline void
4451bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
4452{
4453
4454 _tv->tv_sec = _bt->sec;
4455 _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32;
4456}
4457
4458static __inline void
4459timeval2bintime(const struct timeval *_tv, struct bintime *_bt)
4460{
4461
4462 _bt->sec = _tv->tv_sec;
4463 /* 18446744073709 = int(2^64 / 1000000) */
4464 _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL;
4465}
4466
4467static __inline struct timespec
4468sbttots(sbintime_t _sbt)
4469{
4470 struct timespec _ts;
4471
4472 _ts.tv_sec = _sbt >> 32;
4473 _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32;
4474 return (_ts);
4475}
4476
4477static __inline sbintime_t
4478tstosbt(struct timespec _ts)
4479{
4480
4481 return (((sbintime_t)_ts.tv_sec << 32) +
4482 (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32));
4483}
4484
4485static __inline struct timeval
4486sbttotv(sbintime_t _sbt)
4487{
4488 struct timeval _tv;
4489
4490 _tv.tv_sec = _sbt >> 32;
4491 _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32;
4492 return (_tv);
4493}
4494
4495static __inline sbintime_t
4496tvtosbt(struct timeval _tv)
4497{
4498
4499 return (((sbintime_t)_tv.tv_sec << 32) +
4500 (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32));
4501}
4502#endif /* __BSD_VISIBLE */
4503# 243 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4504
4505#ifdef _KERNEL
4506
4507/* Operations on timespecs */
4508#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
4509#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
4510#define timespeccmp(tvp, uvp, cmp) \
4511 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
4512 ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
4513 ((tvp)->tv_sec cmp (uvp)->tv_sec))
4514#define timespecadd(vvp, uvp) \
4515 do { \
4516 (vvp)->tv_sec += (uvp)->tv_sec; \
4517 (vvp)->tv_nsec += (uvp)->tv_nsec; \
4518 if ((vvp)->tv_nsec >= 1000000000) { \
4519 (vvp)->tv_sec++; \
4520 (vvp)->tv_nsec -= 1000000000; \
4521 } \
4522 } while (0)
4523#define timespecsub(vvp, uvp) \
4524 do { \
4525 (vvp)->tv_sec -= (uvp)->tv_sec; \
4526 (vvp)->tv_nsec -= (uvp)->tv_nsec; \
4527 if ((vvp)->tv_nsec < 0) { \
4528 (vvp)->tv_sec--; \
4529 (vvp)->tv_nsec += 1000000000; \
4530 } \
4531 } while (0)
4532
4533/* Operations on timevals. */
4534
4535#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
4536#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
4537#define timevalcmp(tvp, uvp, cmp) \
4538 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
4539 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
4540 ((tvp)->tv_sec cmp (uvp)->tv_sec))
4541
4542/* timevaladd and timevalsub are not inlined */
4543
4544#endif /* _KERNEL */
4545# 284 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4546
4547#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
4548
4549#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
4550#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
4551#define timercmp(tvp, uvp, cmp) \
4552 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
4553 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
4554 ((tvp)->tv_sec cmp (uvp)->tv_sec))
4555#define timeradd(tvp, uvp, vvp) \
4556 do { \
4557 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
4558 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
4559 if ((vvp)->tv_usec >= 1000000) { \
4560 (vvp)->tv_sec++; \
4561 (vvp)->tv_usec -= 1000000; \
4562 } \
4563 } while (0)
4564#define timersub(tvp, uvp, vvp) \
4565 do { \
4566 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
4567 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
4568 if ((vvp)->tv_usec < 0) { \
4569 (vvp)->tv_sec--; \
4570 (vvp)->tv_usec += 1000000; \
4571 } \
4572 } while (0)
4573#endif
4574# 312 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4575
4576/*
4577 * Names of the interval timers, and structure
4578 * defining a timer setting.
4579 */
4580#define ITIMER_REAL 0
4581#define ITIMER_VIRTUAL 1
4582#define ITIMER_PROF 2
4583
4584struct itimerval {
4585 struct timeval it_interval; /* timer interval */
4586 struct timeval it_value; /* current value */
4587};
4588
4589/*
4590 * Getkerninfo clock information structure
4591 */
4592struct clockinfo {
4593 int hz; /* clock frequency */
4594 int tick; /* micro-seconds per hz tick */
4595 int spare;
4596 int stathz; /* statistics clock frequency */
4597 int profhz; /* profiling clock frequency */
4598};
4599
4600/* These macros are also in time.h. */
4601#ifndef CLOCK_REALTIME
4602#define CLOCK_REALTIME 0
4603#define CLOCK_VIRTUAL 1
4604#define CLOCK_PROF 2
4605#define CLOCK_MONOTONIC 4
4606#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
4607#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
4608#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
4609#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
4610#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
4611#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
4612#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
4613#define CLOCK_SECOND 13 /* FreeBSD-specific. */
4614#define CLOCK_THREAD_CPUTIME_ID 14
4615#define CLOCK_PROCESS_CPUTIME_ID 15
4616#endif
4617# 354 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4618
4619#ifndef TIMER_ABSTIME
4620#define TIMER_RELTIME 0x0 /* relative timer */
4621#define TIMER_ABSTIME 0x1 /* absolute timer */
4622#endif
4623# 359 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4624
4625#if __BSD_VISIBLE
4626#define CPUCLOCK_WHICH_PID 0
4627#define CPUCLOCK_WHICH_TID 1
4628#endif
4629# 364 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4630
4631#ifdef _KERNEL
4632
4633/*
4634 * Kernel to clock driver interface.
4635 */
4636void inittodr(time_t base);
4637void resettodr(void);
4638
4639extern volatile time_t time_second;
4640extern volatile time_t time_uptime;
4641extern struct bintime boottimebin;
4642extern struct timeval boottime;
4643extern struct bintime tc_tick_bt;
4644extern sbintime_t tc_tick_sbt;
4645extern struct bintime tick_bt;
4646extern sbintime_t tick_sbt;
4647extern int tc_precexp;
4648extern int tc_timepercentage;
4649extern struct bintime bt_timethreshold;
4650extern struct bintime bt_tickthreshold;
4651extern sbintime_t sbt_timethreshold;
4652extern sbintime_t sbt_tickthreshold;
4653
4654/*
4655 * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
4656 *
4657 * Functions without the "get" prefix returns the best timestamp
4658 * we can produce in the given format.
4659 *
4660 * "bin" == struct bintime == seconds + 64 bit fraction of seconds.
4661 * "nano" == struct timespec == seconds + nanoseconds.
4662 * "micro" == struct timeval == seconds + microseconds.
4663 *
4664 * Functions containing "up" returns time relative to boot and
4665 * should be used for calculating time intervals.
4666 *
4667 * Functions without "up" returns UTC time.
4668 *
4669 * Functions with the "get" prefix returns a less precise result
4670 * much faster than the functions without "get" prefix and should
4671 * be used where a precision of 1/hz seconds is acceptable or where
4672 * performance is priority. (NB: "precision", _not_ "resolution" !)
4673 */
4674
4675void binuptime(struct bintime *bt);
4676void nanouptime(struct timespec *tsp);
4677void microuptime(struct timeval *tvp);
4678
4679static __inline sbintime_t
4680sbinuptime(void)
4681{
4682 struct bintime _bt;
4683
4684 binuptime(&_bt);
4685 return (bttosbt(_bt));
4686}
4687
4688void bintime(struct bintime *bt);
4689void nanotime(struct timespec *tsp);
4690void microtime(struct timeval *tvp);
4691
4692void getbinuptime(struct bintime *bt);
4693void getnanouptime(struct timespec *tsp);
4694void getmicrouptime(struct timeval *tvp);
4695
4696static __inline sbintime_t
4697getsbinuptime(void)
4698{
4699 struct bintime _bt;
4700
4701 getbinuptime(&_bt);
4702 return (bttosbt(_bt));
4703}
4704
4705void getbintime(struct bintime *bt);
4706void getnanotime(struct timespec *tsp);
4707void getmicrotime(struct timeval *tvp);
4708
4709/* Other functions */
4710int itimerdecr(struct itimerval *itp, int usec);
4711int itimerfix(struct timeval *tv);
4712int ppsratecheck(struct timeval *, int *, int);
4713int ratecheck(struct timeval *, const struct timeval *);
4714void timevaladd(struct timeval *t1, const struct timeval *t2);
4715void timevalsub(struct timeval *t1, const struct timeval *t2);
4716int tvtohz(struct timeval *tv);
4717
4718#define TC_DEFAULTPERC 5
4719
4720#define BT2FREQ(bt) \
4721 (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \
4722 ((bt)->frac >> 1))
4723
4724#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt))
4725
4726#define FREQ2BT(freq, bt) \
4727{ \
4728 (bt)->sec = 0; \
4729 (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \
4730}
4731
4732#define TIMESEL(sbt, sbt2) \
4733 (((sbt2) >= sbt_timethreshold) ? \
4734 ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))
4735
4736#else /* !_KERNEL */
4737# 471 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4738#if 0 /* expanded by -frewrite-includes */
4739#include <time.h>
4740#endif /* expanded by -frewrite-includes */
4741# 471 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
4742# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 1 3 4
4743/*
4744 * Copyright (c) 1989, 1993
4745 * The Regents of the University of California. All rights reserved.
4746 * (c) UNIX System Laboratories, Inc.
4747 * All or some portions of this file are derived from material licensed
4748 * to the University of California by American Telephone and Telegraph
4749 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
4750 * the permission of UNIX System Laboratories, Inc.
4751 *
4752 * Redistribution and use in source and binary forms, with or without
4753 * modification, are permitted provided that the following conditions
4754 * are met:
4755 * 1. Redistributions of source code must retain the above copyright
4756 * notice, this list of conditions and the following disclaimer.
4757 * 2. Redistributions in binary form must reproduce the above copyright
4758 * notice, this list of conditions and the following disclaimer in the
4759 * documentation and/or other materials provided with the distribution.
4760 * 3. Neither the name of the University nor the names of its contributors
4761 * may be used to endorse or promote products derived from this software
4762 * without specific prior written permission.
4763 *
4764 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4765 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4766 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4767 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4768 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4769 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4770 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4771 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4772 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4773 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4774 * SUCH DAMAGE.
4775 *
4776 * @(#)time.h 8.3 (Berkeley) 1/21/94
4777 */
4778
4779/*
4780 * $FreeBSD$
4781 */
4782
4783#ifndef _TIME_H_
4784#define _TIME_H_
4785
4786#if 0 /* expanded by -frewrite-includes */
4787#include <sys/cdefs.h>
4788#endif /* expanded by -frewrite-includes */
4789# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4790# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4791#if 0 /* expanded by -frewrite-includes */
4792#include <sys/_null.h>
4793#endif /* expanded by -frewrite-includes */
4794# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4795# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 1 3 4
4796/*-
4797 * Copyright (c) 2003 Marcel Moolenaar
4798 * All rights reserved.
4799 *
4800 * Redistribution and use in source and binary forms, with or without
4801 * modification, are permitted provided that the following conditions
4802 * are met:
4803 *
4804 * 1. Redistributions of source code must retain the above copyright
4805 * notice, this list of conditions and the following disclaimer.
4806 * 2. Redistributions in binary form must reproduce the above copyright
4807 * notice, this list of conditions and the following disclaimer in the
4808 * documentation and/or other materials provided with the distribution.
4809 *
4810 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4811 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4812 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4813 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
4814 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4815 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4816 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4817 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4818 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4819 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4820 *
4821 * $FreeBSD$
4822 */
4823
4824#ifndef NULL
4825
4826#if !defined(__cplusplus)
4827#define NULL ((void *)0)
4828#else
4829# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4830#if __cplusplus >= 201103L
4831#define NULL nullptr
4832#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
4833# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4834#define NULL __null
4835#else
4836# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4837#if defined(__LP64__)
4838#define NULL (0L)
4839#else
4840# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4841#define NULL 0
4842#endif /* __LP64__ */
4843# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4844#endif /* __GNUG__ */
4845# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4846#endif /* !__cplusplus */
4847# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4848
4849#endif
4850# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
4851# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 2 3 4
4852#if 0 /* expanded by -frewrite-includes */
4853#include <sys/_types.h>
4854#endif /* expanded by -frewrite-includes */
4855# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4856# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4857
4858#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
4859/*
4860 * Frequency of the clock ticks reported by times(). Deprecated - use
4861 * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
4862 */
4863#define CLK_TCK 128
4864#endif
4865# 55 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4866
4867/* Frequency of the clock ticks reported by clock(). */
4868#define CLOCKS_PER_SEC 128
4869
4870#ifndef _CLOCK_T_DECLARED
4871typedef __clock_t clock_t;
4872#define _CLOCK_T_DECLARED
4873#endif
4874# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4875
4876#ifndef _TIME_T_DECLARED
4877typedef __time_t time_t;
4878#define _TIME_T_DECLARED
4879#endif
4880# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4881
4882#ifndef _SIZE_T_DECLARED
4883typedef __size_t size_t;
4884#define _SIZE_T_DECLARED
4885#endif
4886# 73 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4887
4888#if __POSIX_VISIBLE >= 199309
4889/*
4890 * New in POSIX 1003.1b-1993.
4891 */
4892#ifndef _CLOCKID_T_DECLARED
4893typedef __clockid_t clockid_t;
4894#define _CLOCKID_T_DECLARED
4895#endif
4896# 82 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4897
4898#ifndef _TIMER_T_DECLARED
4899typedef __timer_t timer_t;
4900#define _TIMER_T_DECLARED
4901#endif
4902# 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4903
4904#if 0 /* expanded by -frewrite-includes */
4905#include <sys/timespec.h>
4906#endif /* expanded by -frewrite-includes */
4907# 88 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4908# 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4909#endif /* __POSIX_VISIBLE >= 199309 */
4910# 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4911
4912#if __POSIX_VISIBLE >= 200112
4913#ifndef _PID_T_DECLARED
4914typedef __pid_t pid_t;
4915#define _PID_T_DECLARED
4916#endif
4917# 96 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4918#endif
4919# 97 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4920
4921/* These macros are also in sys/time.h. */
4922#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
4923#define CLOCK_REALTIME 0
4924#ifdef __BSD_VISIBLE
4925#define CLOCK_VIRTUAL 1
4926#define CLOCK_PROF 2
4927#endif
4928# 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4929#define CLOCK_MONOTONIC 4
4930#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
4931#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
4932#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
4933#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
4934#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
4935#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
4936#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
4937#define CLOCK_SECOND 13 /* FreeBSD-specific. */
4938#define CLOCK_THREAD_CPUTIME_ID 14
4939#define CLOCK_PROCESS_CPUTIME_ID 15
4940#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
4941# 117 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4942
4943#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
4944#if __BSD_VISIBLE
4945#define TIMER_RELTIME 0x0 /* relative timer */
4946#endif
4947# 122 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4948#define TIMER_ABSTIME 0x1 /* absolute timer */
4949#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
4950# 124 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4951
4952struct tm {
4953 int tm_sec; /* seconds after the minute [0-60] */
4954 int tm_min; /* minutes after the hour [0-59] */
4955 int tm_hour; /* hours since midnight [0-23] */
4956 int tm_mday; /* day of the month [1-31] */
4957 int tm_mon; /* months since January [0-11] */
4958 int tm_year; /* years since 1900 */
4959 int tm_wday; /* days since Sunday [0-6] */
4960 int tm_yday; /* days since January 1 [0-365] */
4961 int tm_isdst; /* Daylight Savings Time flag */
4962 long tm_gmtoff; /* offset from UTC in seconds */
4963 char *tm_zone; /* timezone abbreviation */
4964};
4965
4966#if __POSIX_VISIBLE
4967extern char *tzname[];
4968#endif
4969# 142 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4970
4971__BEGIN_DECLS
4972char *asctime(const struct tm *);
4973clock_t clock(void);
4974char *ctime(const time_t *);
4975double difftime(time_t, time_t);
4976/* XXX missing: getdate() */
4977struct tm *gmtime(const time_t *);
4978struct tm *localtime(const time_t *);
4979time_t mktime(struct tm *);
4980size_t strftime(char * __restrict, size_t, const char * __restrict,
4981 const struct tm * __restrict);
4982time_t time(time_t *);
4983#if __POSIX_VISIBLE >= 200112
4984struct sigevent;
4985int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
4986int timer_delete(timer_t);
4987int timer_gettime(timer_t, struct itimerspec *);
4988int timer_getoverrun(timer_t);
4989int timer_settime(timer_t, int, const struct itimerspec *__restrict,
4990 struct itimerspec *__restrict);
4991#endif
4992# 164 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4993#if __POSIX_VISIBLE
4994void tzset(void);
4995#endif
4996# 167 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
4997
4998#if __POSIX_VISIBLE >= 199309
4999int clock_getres(clockid_t, struct timespec *);
5000int clock_gettime(clockid_t, struct timespec *);
5001int clock_settime(clockid_t, const struct timespec *);
5002/* XXX missing: clock_nanosleep() */
5003int nanosleep(const struct timespec *, struct timespec *);
5004#endif /* __POSIX_VISIBLE >= 199309 */
5005# 175 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5006
5007#if __POSIX_VISIBLE >= 200112
5008int clock_getcpuclockid(pid_t, clockid_t *);
5009#endif
5010# 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5011
5012#if __POSIX_VISIBLE >= 199506
5013char *asctime_r(const struct tm *, char *);
5014char *ctime_r(const time_t *, char *);
5015struct tm *gmtime_r(const time_t *, struct tm *);
5016struct tm *localtime_r(const time_t *, struct tm *);
5017#endif
5018# 186 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5019
5020#if __XSI_VISIBLE
5021char *strptime(const char * __restrict, const char * __restrict,
5022 struct tm * __restrict);
5023#endif
5024# 191 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5025
5026#if __BSD_VISIBLE
5027char *timezone(int, int); /* XXX XSI conflict */
5028void tzsetwall(void);
5029time_t timelocal(struct tm * const);
5030time_t timegm(struct tm * const);
5031#endif /* __BSD_VISIBLE */
5032# 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5033
5034#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
5035#if 0 /* expanded by -frewrite-includes */
5036#include <xlocale/_time.h>
5037#endif /* expanded by -frewrite-includes */
5038# 200 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5039# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 1 3 4
5040/*-
5041 * Copyright (c) 2011, 2012 The FreeBSD Foundation
5042 * All rights reserved.
5043 *
5044 * This software was developed by David Chisnall under sponsorship from
5045 * the FreeBSD Foundation.
5046 *
5047 * Redistribution and use in source and binary forms, with or without
5048 * modification, are permitted provided that the following conditions
5049 * are met:
5050 * 1. Redistributions of source code must retain the above copyright
5051 * notice, this list of conditions and the following disclaimer.
5052 * 2. Redistributions in binary form must reproduce the above copyright
5053 * notice, this list of conditions and the following disclaimer in the
5054 * documentation and/or other materials provided with the distribution.
5055 *
5056 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5057 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5058 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5059 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5060 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5061 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5062 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5063 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5064 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5065 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5066 * SUCH DAMAGE.
5067 *
5068 * $FreeBSD$
5069 */
5070
5071#ifndef _LOCALE_T_DEFINED
5072#define _LOCALE_T_DEFINED
5073typedef struct _xlocale *locale_t;
5074#endif
5075# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
5076
5077/*
5078 * This file is included from both locale.h and xlocale.h. We need to expose
5079 * the declarations unconditionally if we are included from xlocale.h, but only
5080 * if we are in POSIX2008 mode if included from locale.h.
5081 */
5082#ifndef _XLOCALE_LOCALE1_H
5083#define _XLOCALE_LOCALE1_H
5084
5085size_t strftime_l(char * __restrict, size_t, const char * __restrict,
5086 const struct tm * __restrict, locale_t) __strftimelike(3, 0);
5087
5088#endif /* _XLOCALE_LOCALE1_H */
5089# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
5090
5091#ifdef _XLOCALE_H_
5092#ifndef _XLOCALE_LOCALE2_H
5093#define _XLOCALE_LOCALE2_H
5094
5095char *strptime_l(const char * __restrict, const char * __restrict,
5096 struct tm * __restrict, locale_t);
5097
5098#endif /* _XLOCALE_LOCALE2_H */
5099# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
5100#endif /* _XLOCALE_H_ */
5101# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
5102# 201 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 2 3 4
5103#endif
5104# 202 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5105__END_DECLS
5106
5107#endif /* !_TIME_H_ */
5108# 205 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
5109# 472 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 2 3 4
5110
5111#if 0 /* expanded by -frewrite-includes */
5112#include <sys/cdefs.h>
5113#endif /* expanded by -frewrite-includes */
5114# 473 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5115# 474 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5116#if 0 /* expanded by -frewrite-includes */
5117#include <sys/select.h>
5118#endif /* expanded by -frewrite-includes */
5119# 474 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5120# 475 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5121
5122__BEGIN_DECLS
5123int setitimer(int, const struct itimerval *, struct itimerval *);
5124int utimes(const char *, const struct timeval *);
5125
5126#if __BSD_VISIBLE
5127int adjtime(const struct timeval *, struct timeval *);
5128int clock_getcpuclockid2(id_t, int, clockid_t *);
5129int futimes(int, const struct timeval *);
5130int futimesat(int, const char *, const struct timeval [2]);
5131int lutimes(const char *, const struct timeval *);
5132int settimeofday(const struct timeval *, const struct timezone *);
5133#endif
5134# 488 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5135
5136#if __XSI_VISIBLE
5137int getitimer(int, struct itimerval *);
5138int gettimeofday(struct timeval *, struct timezone *);
5139#endif
5140# 493 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5141
5142__END_DECLS
5143
5144#endif /* !_KERNEL */
5145# 497 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5146
5147#endif /* !_SYS_TIME_H_ */
5148# 499 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
5149# 41 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
5150
5151#if 0 /* expanded by -frewrite-includes */
5152#include <machine/cheri.h>
5153#endif /* expanded by -frewrite-includes */
5154# 42 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
5155# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 1 3 4
5156/*-
5157 * Copyright (c) 2011-2015 Robert N. M. Watson
5158 * Copyright (c) 2015 SRI International
5159 * All rights reserved.
5160 *
5161 * This software was developed by SRI International and the University of
5162 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
5163 * ("CTSRD"), as part of the DARPA CRASH research programme.
5164 *
5165 * Redistribution and use in source and binary forms, with or without
5166 * modification, are permitted provided that the following conditions
5167 * are met:
5168 * 1. Redistributions of source code must retain the above copyright
5169 * notice, this list of conditions and the following disclaimer.
5170 * 2. Redistributions in binary form must reproduce the above copyright
5171 * notice, this list of conditions and the following disclaimer in the
5172 * documentation and/or other materials provided with the distribution.
5173 *
5174 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5175 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5176 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5177 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5178 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5179 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5180 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5181 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5182 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5183 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5184 * SUCH DAMAGE.
5185 */
5186
5187#ifndef _MIPS_INCLUDE_CHERI_H_
5188#define _MIPS_INCLUDE_CHERI_H_
5189
5190#ifdef _KERNEL
5191#if 0 /* expanded by -frewrite-includes */
5192#include <sys/sysctl.h> /* SYSCTL_DECL() */
5193#endif /* expanded by -frewrite-includes */
5194# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5195# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5196#if 0 /* expanded by -frewrite-includes */
5197#include <sys/systm.h> /* CTASSERT() */
5198#endif /* expanded by -frewrite-includes */
5199# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5200# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5201#endif
5202# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5203
5204#if 0 /* expanded by -frewrite-includes */
5205#include <machine/cherireg.h>
5206#endif /* expanded by -frewrite-includes */
5207# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5208# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 1 3 4
5209/*-
5210 * Copyright (c) 2011-2015 Robert N. M. Watson
5211 * All rights reserved.
5212 *
5213 * This software was developed by SRI International and the University of
5214 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
5215 * ("CTSRD"), as part of the DARPA CRASH research programme.
5216 *
5217 * Redistribution and use in source and binary forms, with or without
5218 * modification, are permitted provided that the following conditions
5219 * are met:
5220 * 1. Redistributions of source code must retain the above copyright
5221 * notice, this list of conditions and the following disclaimer.
5222 * 2. Redistributions in binary form must reproduce the above copyright
5223 * notice, this list of conditions and the following disclaimer in the
5224 * documentation and/or other materials provided with the distribution.
5225 *
5226 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5227 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5228 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5229 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5230 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5231 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5232 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5233 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5234 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5235 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5236 * SUCH DAMAGE.
5237 */
5238
5239#ifndef _MIPS_INCLUDE_CHERIREG_H_
5240#define _MIPS_INCLUDE_CHERIREG_H_
5241
5242/*
5243 * The size of in-memory capabilities in bytes; minimum alignment is also
5244 * assumed to be this size.
5245 */
5246#if defined(_MIPS_SZCAP) && (_MIPS_SZCAP != 128) && (_MIPS_SZCAP != 256)
5247#error "_MIPS_SZCAP defined but neither 128 nor 256"
5248#endif
5249# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5250
5251#if defined(CPU_CHERI128) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 128))
5252#define CHERICAP_SIZE 16
5253#else
5254# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5255#define CHERICAP_SIZE 32
5256#endif
5257# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5258
5259/*
5260 * CHERI ISA-defined constants for capabilities -- suitable for inclusion from
5261 * assembly source code.
5262 *
5263 * XXXRW: CHERI_UNSEALED is not currently considered part of the perms word,
5264 * but perhaps it should be.
5265 */
5266#define CHERI_PERM_GLOBAL (1 << 0) /* 0x00000001 */
5267#define CHERI_PERM_EXECUTE (1 << 1) /* 0x00000002 */
5268#define CHERI_PERM_LOAD (1 << 2) /* 0x00000004 */
5269#define CHERI_PERM_STORE (1 << 3) /* 0x00000008 */
5270#define CHERI_PERM_LOAD_CAP (1 << 4) /* 0x00000010 */
5271#define CHERI_PERM_STORE_CAP (1 << 5) /* 0x00000020 */
5272#define CHERI_PERM_STORE_LOCAL_CAP (1 << 6) /* 0x00000040 */
5273#define CHERI_PERM_SEAL (1 << 7) /* 0x00000080 */
5274#define CHERI_PERM_SETTYPE (1 << 8) /* 0x00000100 */
5275#define CHERI_PERM_RESERVED1 (1 << 9) /* 0x00000200 */
5276#define CHERI_PERM_ACCESS_EPCC (1 << 10) /* 0x00000400 */
5277#define CHERI_PERM_ACCESS_KDC (1 << 11) /* 0x00000800 */
5278#define CHERI_PERM_ACCESS_KCC (1 << 12) /* 0x00001000 */
5279#define CHERI_PERM_ACCESS_KR1C (1 << 13) /* 0x00002000 */
5280#define CHERI_PERM_ACCESS_KR2C (1 << 14) /* 0x00004000 */
5281
5282/*
5283 * User-defined permission bits. The kernel actually snags one for the
5284 * purposes of authorising system calls from $pcc. This is a bit of an
5285 * oddity: normally, we check permissions on data capabilities, not code
5286 * capabilities, but aligns with 'privilege' checks: e.g., $epcc access.
5287 */
5288#define CHERI_PERM_USER0 (1 << 15) /* 0x00008000 */
5289#define CHERI_PERM_SYSCALL CHERI_PERM_USER0
5290#define CHERI_PERM_USER1 (1 << 16) /* 0x00010000 */
5291#define CHERI_PERM_USER2 (1 << 17) /* 0x00020000 */
5292#define CHERI_PERM_USER3 (1 << 18) /* 0x00040000 */
5293#define CHERI_PERM_USER4 (1 << 19) /* 0x00080000 */
5294#define CHERI_PERM_USER5 (1 << 20) /* 0x00100000 */
5295#define CHERI_PERM_USER6 (1 << 21) /* 0x00200000 */
5296#define CHERI_PERM_USER7 (1 << 22) /* 0x00400000 */
5297
5298#if defined(CPU_CHERI128) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 128))
5299/*
5300 * 128-bit CHERI supports only 8 user-defined permissions for memory
5301 * capabilities.
5302 */
5303#define CHERI_PERM_USER_PRIVS \
5304 (CHERI_PERM_USER0 | CHERI_PERM_USER1 | CHERI_PERM_USER2 | \
5305 CHERI_PERM_USER3 | CHERI_PERM_USER4 | CHERI_PERM_USER5 | \
5306 CHERI_PERM_USER6 | CHERI_PERM_USER7)
5307#else /* !CPU_CHERI128 */
5308# 97 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5309
5310/*
5311 * 256-bit CHERI supports a further 7 user-defined permissions.
5312 */
5313#define CHERI_PERM_USER8 (1 << 23) /* 0x00800000 */
5314#define CHERI_PERM_USER9 (1 << 24) /* 0x01000000 */
5315#define CHERI_PERM_USER10 (1 << 25) /* 0x02000000 */
5316#define CHERI_PERM_USER11 (1 << 26) /* 0x04000000 */
5317#define CHERI_PERM_USER12 (1 << 27) /* 0x08000000 */
5318#define CHERI_PERM_USER13 (1 << 28) /* 0x10000000 */
5319#define CHERI_PERM_USER14 (1 << 29) /* 0x20000000 */
5320#define CHERI_PERM_USER15 (1 << 30) /* 0x40000000 */
5321#define CHERI_PERM_USER_PRIVS \
5322 (CHERI_PERM_USER0 | CHERI_PERM_USER1 | CHERI_PERM_USER2 | \
5323 CHERI_PERM_USER3 | CHERI_PERM_USER4 | CHERI_PERM_USER5 | \
5324 CHERI_PERM_USER6 | CHERI_PERM_USER7 | CHERI_PERM_USER8 | \
5325 CHERI_PERM_USER9 | CHERI_PERM_USER10 | CHERI_PERM_USER11 | \
5326 CHERI_PERM_USER12 | CHERI_PERM_USER13 | CHERI_PERM_USER14 | \
5327 CHERI_PERM_USER15)
5328#endif /* !CPU_CHERI128 */
5329# 117 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5330
5331#define CHERI_PERM_PRIV \
5332 (CHERI_PERM_GLOBAL | CHERI_PERM_EXECUTE | \
5333 CHERI_PERM_LOAD | CHERI_PERM_STORE | CHERI_PERM_LOAD_CAP | \
5334 CHERI_PERM_STORE_CAP | CHERI_PERM_STORE_LOCAL_CAP | \
5335 CHERI_PERM_SEAL | CHERI_PERM_SETTYPE | CHERI_PERM_RESERVED1 | \
5336 CHERI_PERM_ACCESS_EPCC | CHERI_PERM_ACCESS_KDC | \
5337 CHERI_PERM_ACCESS_KCC | CHERI_PERM_ACCESS_KR1C | \
5338 CHERI_PERM_ACCESS_KR2C | CHERI_PERM_USER_PRIVS)
5339
5340/*
5341 * Basic userspace permission mask; CHERI_PERM_EXECUTE will be added for
5342 * executable capabilities ($pcc); CHERI_PERM_STORE, CHERI_PERM_STORE_CAP,
5343 * and CHERI_PERM_STORE_LOCAL_CAP will be added for data permissions ($c0).
5344 */
5345#define CHERI_PERM_USER \
5346 (CHERI_PERM_GLOBAL | CHERI_PERM_LOAD | CHERI_PERM_LOAD_CAP | \
5347 CHERI_PERM_SEAL | CHERI_PERM_SETTYPE | CHERI_PERM_USER_PRIVS)
5348
5349/*
5350 * XXXRW: For now, install all permissions for both data and executable
5351 * capabilities, until libcheri is ready for non-executable $c0.
5352 */
5353#ifdef NOTYET
5354#define CHERI_PERM_USER_CODE (CHERI_PERM_USER | CHERI_PERM_EXECUTE)
5355#define CHERI_PERM_USER_DATA (CHERI_PERM_USER | CHERI_PERM_STORE | \
5356 CHERI_PERM_STORE_CAP | \
5357 CHERI_PERM_STORE_LOCAL_CAP)
5358#else
5359# 146 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5360#define CHERI_PERM_USER_CODE (CHERI_PERM_USER | CHERI_PERM_STORE | \
5361 CHERI_PERM_STORE_CAP | \
5362 CHERI_PERM_STORE_LOCAL_CAP | \
5363 CHERI_PERM_EXECUTE)
5364#define CHERI_PERM_USER_DATA CHERI_PERM_USER_CODE
5365#endif
5366# 152 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5367
5368/*
5369 * Definition for kernel "privileged" capability able to name the entire
5370 * address space.
5371 */
5372#define CHERI_CAP_PRIV_PERMS CHERI_PERM_PRIV
5373#define CHERI_CAP_PRIV_OTYPE 0x0
5374#define CHERI_CAP_PRIV_BASE 0x0
5375#define CHERI_CAP_PRIV_LENGTH 0xffffffffffffffff
5376#define CHERI_CAP_PRIV_OFFSET 0x0
5377
5378/*
5379 * Definition for userspace "unprivileged" capability able to name the user
5380 * portion of the address space.
5381 */
5382#define CHERI_CAP_USER_CODE_PERMS CHERI_PERM_USER_CODE
5383#define CHERI_CAP_USER_CODE_OTYPE 0x0
5384#define CHERI_CAP_USER_CODE_BASE MIPS_XUSEG_START
5385#define CHERI_CAP_USER_CODE_LENGTH (MIPS_XUSEG_END - MIPS_XUSEG_START)
5386#define CHERI_CAP_USER_CODE_OFFSET 0x0
5387
5388#define CHERI_CAP_USER_DATA_PERMS CHERI_PERM_USER_DATA
5389#define CHERI_CAP_USER_DATA_OTYPE 0x0
5390#define CHERI_CAP_USER_DATA_BASE MIPS_XUSEG_START
5391#define CHERI_CAP_USER_DATA_LENGTH (MIPS_XUSEG_END - MIPS_XUSEG_START)
5392#define CHERI_CAP_USER_DATA_OFFSET 0x0
5393
5394/*
5395 * A blend of hardware and software allocation of capability registers.
5396 * Ideally, this list wouldn't exist here, but be purely in the assembler.
5397 */
5398#define CHERI_CR_C0 0 /* MIPS fetch/load/store capability. */
5399#define CHERI_CR_C1 1
5400#define CHERI_CR_C2 2
5401#define CHERI_CR_C3 3
5402#define CHERI_CR_C4 4
5403#define CHERI_CR_C5 5
5404#define CHERI_CR_C6 6
5405#define CHERI_CR_C7 7
5406#define CHERI_CR_C8 8
5407#define CHERI_CR_C9 9
5408#define CHERI_CR_C10 10
5409#define CHERI_CR_C11 11
5410#define CHERI_CR_C12 12
5411#define CHERI_CR_C13 13
5412#define CHERI_CR_C14 14
5413#define CHERI_CR_C15 15
5414#define CHERI_CR_C16 16
5415#define CHERI_CR_C17 17
5416#define CHERI_CR_C18 18
5417#define CHERI_CR_C19 19
5418#define CHERI_CR_C20 20
5419#define CHERI_CR_C21 21
5420#define CHERI_CR_C22 22
5421#define CHERI_CR_C23 23
5422#define CHERI_CR_RCC 24
5423#define CHERI_CR_C25 25
5424#define CHERI_CR_IDC 26
5425#define CHERI_CR_KR1C 27
5426#define CHERI_CR_KR2C 28
5427#define CHERI_CR_KCC 29
5428#define CHERI_CR_KDC 30
5429#define CHERI_CR_EPCC 31
5430
5431#define CHERI_CR_CTEMP0 CHERI_CR_C11 /* C capability manipulation. */
5432#define CHERI_CR_CTEMP1 CHERI_CR_C12 /* C capability manipulation. */
5433#define CHERI_CR_SEC0 CHERI_CR_KR2C /* Saved $c0 in exception handler. */
5434
5435/*
5436 * Offsets of registers in struct cheri_frame when treated as an array of
5437 * capabilities -- must match the definition in cheri.h.
5438 */
5439#define CHERIFRAME_OFF_C0 0
5440#define CHERIFRAME_OFF_C1 1
5441#define CHERIFRAME_OFF_C2 2
5442#define CHERIFRAME_OFF_C3 3
5443#define CHERIFRAME_OFF_C4 4
5444#define CHERIFRAME_OFF_C5 5
5445#define CHERIFRAME_OFF_C6 6
5446#define CHERIFRAME_OFF_C7 7
5447#define CHERIFRAME_OFF_C8 8
5448#define CHERIFRAME_OFF_C9 9
5449#define CHERIFRAME_OFF_C10 10
5450#define CHERIFRAME_OFF_C11 11
5451#define CHERIFRAME_OFF_C12 12
5452#define CHERIFRAME_OFF_C13 13
5453#define CHERIFRAME_OFF_C14 14
5454#define CHERIFRAME_OFF_C15 15
5455#define CHERIFRAME_OFF_C16 16
5456#define CHERIFRAME_OFF_C17 17
5457#define CHERIFRAME_OFF_C18 18
5458#define CHERIFRAME_OFF_C19 19
5459#define CHERIFRAME_OFF_C20 20
5460#define CHERIFRAME_OFF_C21 21
5461#define CHERIFRAME_OFF_C22 22
5462#define CHERIFRAME_OFF_C23 23
5463#define CHERIFRAME_OFF_RCC 24
5464#define CHERIFRAME_OFF_C25 25
5465#define CHERIFRAME_OFF_IDC 26
5466#define CHERIFRAME_OFF_PCC 27 /* NB: Not register $c27! */
5467
5468/*
5469 * Offset of the capability cause register in struct cheri_kframe -- must
5470 * match the definition in cheri.h. Note that although this constant is sized
5471 * based on capabilities, in fact the cause register is 64-bit. We may want
5472 * to revisit this if we add more 64-bit values.
5473 */
5474#define CHERIFRAME_OFF_CAPCAUSE 28
5475
5476/*
5477 * Offsets of registers in struct cheri_kframe -- must match the definition in
5478 * cheri.h.
5479 */
5480#define CHERIKFRAME_OFF_C11 0
5481#define CHERIKFRAME_OFF_C12 1
5482
5483/*
5484 * List of CHERI capability cause code constants, which are used to
5485 * disambiguate various CP2 exceptions.
5486 *
5487 * XXXRW: I wonder if we really need different permissions for each exception-
5488 * handling capability.
5489 *
5490 * XXXRW: Curiously non-contiguous.
5491 *
5492 * XXXRW: KDC is listed as 0x1a in the spec, which collides with EPCC. Not
5493 * sure what is actually used.
5494 */
5495#define CHERI_EXCCODE_NONE 0x00
5496#define CHERI_EXCCODE_LENGTH 0x01
5497#define CHERI_EXCCODE_TAG 0x02
5498#define CHERI_EXCCODE_SEAL 0x03
5499#define CHERI_EXCCODE_TYPE 0x04
5500#define CHERI_EXCCODE_CALL 0x05
5501#define CHERI_EXCCODE_RETURN 0x06
5502#define CHERI_EXCCODE_UNDERFLOW 0x07
5503#define CHERI_EXCCODE_USER_PERM 0x08
5504#define CHERI_EXCCODE_TLBSTORE 0x09
5505#define CHERI_EXCCODE_CCALL_WRONGREGS 0x0a
5506#define _CHERI_EXCCODE_RESERVED0b 0x0b
5507#define _CHERI_EXCCODE_RESERVED0c 0x0c
5508#define _CHERI_EXCCODE_RESERVED0d 0x0d
5509#define _CHERI_EXCCODE_RESERVED0e 0x0e
5510#define _CHERI_EXCCODE_RESERVED0f 0x0f
5511#define CHERI_EXCCODE_GLOBAL 0x10
5512#define CHERI_EXCCODE_PERM_EXECUTE 0x11
5513#define CHERI_EXCCODE_PERM_LOAD 0x12
5514#define CHERI_EXCCODE_PERM_STORE 0x13
5515#define CHERI_EXCCODE_PERM_LOADCAP 0x14
5516#define CHERI_EXCCODE_PERM_STORECAP 0x15
5517#define CHERI_EXCCODE_STORE_LOCALCAP 0x16
5518#define CHERI_EXCCODE_PERM_SEAL 0x17
5519#define CHERI_EXCCODE_PERM_SETTYPE 0x18
5520#define _CHERI_EXCCODE_RESERVED19 0x19
5521#define CHERI_EXCCODE_ACCESS_EPCC 0x1a
5522#define CHERI_EXCCODE_ACCESS_KDC 0x1b /* XXXRW */
5523#define CHERI_EXCCODE_ACCESS_KCC 0x1c
5524#define CHERI_EXCCODE_ACCESS_KR1C 0x1d
5525#define CHERI_EXCCODE_ACCESS_KR2C 0x1e
5526#define _CHERI_EXCCODE_RESERVED1f 0x1f
5527
5528/*
5529 * User-defined CHERI exception codes are numbered 128...255.
5530 */
5531#define CHERI_EXCCODE_SW_BASE 0x80
5532#define CHERI_EXCCODE_SW_LOCALARG 0x80 /* Non-global CCall argument. */
5533#define CHERI_EXCCODE_SW_LOCALRET 0x81 /* Non-global CReturn value. */
5534#define CHERI_EXCCODE_SW_CCALLREGS 0x82 /* Incorrect CCall registers. */
5535
5536/*
5537 * How to turn the cause register into an exception code and register number.
5538 */
5539#define CHERI_CAPCAUSE_EXCCODE_MASK 0xff00
5540#define CHERI_CAPCAUSE_EXCCODE_SHIFT 8
5541#define CHERI_CAPCAUSE_REGNUM_MASK 0xff
5542
5543/*
5544 * Location of the CHERI CCall/CReturn software-path exception vector.
5545 */
5546#define CHERI_CCALL_EXC_VEC ((intptr_t)(int32_t)0x80000280)
5547
5548#endif /* _MIPS_INCLUDE_CHERIREG_H_ */
5549# 334 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
5550# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 2 3 4
5551#if 0 /* expanded by -frewrite-includes */
5552#include <sys/types.h>
5553#endif /* expanded by -frewrite-includes */
5554# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5555# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5556
5557/*
5558 * Canonical C-language representation of a capability for compilers that
5559 * don't support capabilities directly. The in-memory layout is sensitive to
5560 * the microarchitecture, and hence treated as opaque. Fields must be
5561 * accessed via the ISA.
5562 */
5563struct chericap {
5564 uint8_t c_data[CHERICAP_SIZE];
5565} __packed __aligned(CHERICAP_SIZE);
5566#ifdef _KERNEL
5567CTASSERT(sizeof(struct chericap) == CHERICAP_SIZE);
5568#endif
5569# 55 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5570
5571/*
5572 * Canonical C-language representation of a CHERI object capability -- code
5573 * and data capabilities in registers or memory.
5574 */
5575struct cheri_object {
5576#if !defined(_KERNEL) && __has_feature(capabilities)
5577 __capability void *co_codecap;
5578 __capability void *co_datacap;
5579#else
5580# 65 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5581 struct chericap co_codecap;
5582 struct chericap co_datacap;
5583#endif
5584# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5585};
5586
5587#if !defined(_KERNEL) && __has_feature(capabilities)
5588#define CHERI_OBJECT_INIT_NULL {NULL, NULL}
5589#define CHERI_OBJECT_ISNULL(co) \
5590 ((co).co_codecap == NULL && (co).co_datacap == NULL)
5591#endif
5592# 75 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5593
5594/*
5595 * Register frame to be preserved on context switching -- very similar to
5596 * struct mips_frame. As with mips_frame, the order of save/restore is very
5597 * important for both reasons of correctness and security.
5598 *
5599 * Must match the register offset definitions (CHERIFRAME_OFF_*) in
5600 * cherireg.h.
5601 */
5602struct cheri_frame {
5603 /* c0 has special properties for MIPS load/store instructions. */
5604#if !defined(_KERNEL) && __has_feature(capabilities)
5605 __capability void *cf_c0;
5606#else
5607# 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5608 struct chericap cf_c0;
5609#endif
5610# 91 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5611
5612 /*
5613 * General-purpose capabilities -- note, numbering is from v1.7 of the
5614 * CHERI ISA spec (ISAv2).
5615 */
5616#if !defined(_KERNEL) && __has_feature(capabilities)
5617 __capability void *cf_c1, *cf_c2, *cf_c3, *cf_c4;
5618 __capability void *cf_c5, *cf_c6, *cf_c7;
5619 __capability void *cf_c8, *cf_c9, *cf_c10, *cf_c11, *cf_c12;
5620 __capability void *cf_c13, *cf_c14, *cf_c15, *cf_c16, *cf_c17;
5621 __capability void *cf_c18, *cf_c19, *cf_c20, *cf_c21, *cf_c22;
5622 __capability void *cf_c23, *cf_rcc, *cf_c25, *cf_idc;
5623#else
5624# 104 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5625 struct chericap cf_c1, cf_c2, cf_c3, cf_c4;
5626 struct chericap cf_c5, cf_c6, cf_c7;
5627 struct chericap cf_c8, cf_c9, cf_c10, cf_c11, cf_c12;
5628 struct chericap cf_c13, cf_c14, cf_c15, cf_c16, cf_c17;
5629 struct chericap cf_c18, cf_c19, cf_c20, cf_c21, cf_c22;
5630 struct chericap cf_c23, cf_rcc, cf_c25, cf_idc;
5631#endif
5632# 111 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5633
5634 /*
5635 * Program counter capability -- extracted from exception frame EPCC.
5636 */
5637#if !defined(_KERNEL) && __has_feature(capabilities)
5638 __capability void *cf_pcc;
5639#else
5640# 118 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5641 struct chericap cf_pcc;
5642#endif
5643# 120 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5644
5645 /*
5646 * Padded out non-capability registers.
5647 *
5648 * XXXRW: The comment below on only updating for CP2 exceptions is
5649 * incorrect, but should be made correct.
5650 */
5651 register_t cf_capcause; /* Updated only on CP2 exceptions. */
5652 register_t _cf_pad0[1];
5653#if (defined(CPU_CHERI) && !defined(CPU_CHERI128)) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 256))
5654 register_t _cf_pad1[2];
5655#endif
5656# 132 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5657};
5658
5659#ifdef _KERNEL
5660/* 28 capability registers + capcause + padding. */
5661CTASSERT(sizeof(struct cheri_frame) == (29 * CHERICAP_SIZE));
5662#endif
5663# 138 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5664
5665#ifdef _KERNEL
5666/*
5667 * Data structure defining kernel per-thread caller-save state used in
5668 * voluntary context switches. This is morally equivalent to pcb_context[].
5669 *
5670 * XXXRW: For now, we define a 'micro-ABI' for the kernel, preserving and
5671 * restoring only a few capability registers used by overt inline assembly.
5672 * Once we use a CHERI-aware compiler for the kernel, this will need to be
5673 * expanded to include a full set of caller-save registers.
5674 */
5675struct cheri_kframe {
5676 struct chericap ckf_c11;
5677 struct chericap ckf_c12;
5678};
5679#endif
5680# 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5681
5682/*
5683 * Data structure describing CHERI's sigaltstack-like extensions to signal
5684 * delivery. In the event that a thread takes a signal when $pcc doesn't hold
5685 * CHERI_PERM_SYSCALL, we will need to install new $pcc, $c0, $c11, and $idc
5686 * state, and move execution to the per-thread alternative stack, whose
5687 * pointer should (presumably) be relative to the c0/c11 defined here.
5688 */
5689struct cheri_signal {
5690#if !defined(_KERNEL) && __has_feature(capabilities)
5691 __capability void *csig_pcc;
5692 __capability void *csig_c0;
5693 __capability void *csig_c11;
5694 __capability void *csig_idc;
5695 __capability void *csig_sigcode;
5696#else
5697# 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5698 struct chericap csig_pcc;
5699 struct chericap csig_c0;
5700 struct chericap csig_c11;
5701 struct chericap csig_idc;
5702 struct chericap csig_sigcode;
5703#endif
5704# 176 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5705};
5706
5707/*
5708 * Per-thread CHERI CCall/CReturn stack, which preserves the calling PC/PCC/
5709 * IDC across CCall so that CReturn can restore them.
5710 *
5711 * XXXRW: This is a very early experiment -- it's not clear if this idea will
5712 * persist in its current form, or at all. For more complex userspace
5713 * language, there's a reasonable expectation that it, rather than the kernel,
5714 * will want to manage the idea of a "trusted stack".
5715 *
5716 * XXXRW: This is currently part of the kernel-user ABI due to the
5717 * CHERI_GET_STACK and CHERI_SET_STACK sysarch() calls. In due course we need
5718 * to revise those APIs and differentiate the kernel-internal representation
5719 * from the public one.
5720 */
5721struct cheri_stack_frame {
5722 register_t _csf_pad0; /* Used to be MIPS program counter. */
5723 register_t _csf_pad1;
5724 register_t _csf_pad2;
5725 register_t _csf_pad3;
5726#if !defined(_KERNEL) && __has_feature(capabilities)
5727 __capability void *csf_pcc;
5728 __capability void *csf_idc;
5729#else
5730# 201 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5731 struct chericap csf_pcc; /* XXXRW: Store $pc in here? */
5732 struct chericap csf_idc;
5733#endif
5734# 204 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5735};
5736
5737#define CHERI_STACK_DEPTH 8 /* XXXRW: 8 is a nice round number. */
5738struct cheri_stack {
5739 register_t cs_tsp; /* Byte offset, not frame index. */
5740 register_t cs_tsize; /* Stack size, in bytes. */
5741 register_t _cs_pad0;
5742 register_t _cs_pad1;
5743 struct cheri_stack_frame cs_frames[CHERI_STACK_DEPTH];
5744} __aligned(CHERICAP_SIZE);
5745
5746#define CHERI_FRAME_SIZE sizeof(struct cheri_stack_frame)
5747#define CHERI_STACK_SIZE (CHERI_STACK_DEPTH * CHERI_FRAME_SIZE)
5748
5749/*
5750 * CHERI capability register manipulation macros.
5751 */
5752#define CHERI_CGETBASE(v, cb) do { \
5753 __asm__ __volatile__ ("cgetbase %0, $c%1" : "=r" (v) : \
5754 "i" (cb)); \
5755} while (0)
5756
5757#define CHERI_CGETLEN(v, cb) do { \
5758 __asm__ __volatile__ ("cgetlen %0, $c%1" : "=r" (v) : \
5759 "i" (cb)); \
5760} while (0)
5761
5762#define CHERI_CGETOFFSET(v, cb) do { \
5763 __asm__ __volatile__ ("cgetoffset %0, $c%1" : "=r" (v) : \
5764 "i" (cb)); \
5765} while (0)
5766
5767#define CHERI_CGETTAG(v, cb) do { \
5768 __asm__ __volatile__ ("cgettag %0, $c%1" : "=r" (v) : \
5769 "i" (cb)); \
5770} while (0)
5771
5772#define CHERI_CGETSEALED(v, cb) do { \
5773 __asm__ __volatile__ ("cgetsealed %0, $c%1" : "=r" (v) : \
5774 "i" (cb)); \
5775} while (0)
5776
5777#define CHERI_CGETPERM(v, cb) do { \
5778 __asm__ __volatile__ ("cgetperm %0, $c%1" : "=r" (v) : \
5779 "i" (cb)); \
5780} while (0)
5781
5782#define CHERI_CGETTYPE(v, cb) do { \
5783 __asm__ __volatile__ ("cgettype %0, $c%1" : "=r" (v) : \
5784 "i" (cb)); \
5785} while (0)
5786
5787#define CHERI_CGETCAUSE(v) do { \
5788 __asm__ __volatile__ ("cgetcause %0" : "=r" (v)); \
5789} while (0)
5790
5791#define CHERI_CTOPTR(v, cb, ct) do { \
5792 __asm__ __volatile__ ("ctoptr %0, $c%1, $c%2" : "=r" (v) : \
5793 "i" (cb), "i" (ct)); \
5794} while (0)
5795
5796/*
5797 * Note that despite effectively being a CMove, CGetDefault doesn't require a
5798 * memory clobber: if it's writing to $c0, it's a nop; otherwise, it's not
5799 * writing to $c0 so no clobber is needed.
5800 */
5801#define CHERI_CGETDEFAULT(cd) do { \
5802 __asm__ __volatile__ ("cgetdefault $c%0" : : "i" (cd)); \
5803} while (0)
5804
5805/*
5806 * Instructions that check capability values and could throw exceptions; no
5807 * capability-register value changes, so no clobbers required.
5808 */
5809#define CHERI_CCHECKPERM(cs, v) do { \
5810 __asm__ __volatile__ ("ccheckperm $c%0, %1" : : \
5811 "i" (cd), "r" (v)); \
5812} while (0)
5813
5814#define CHERI_CCHECKTYPE(cs, cb) do { \
5815 __asm__ __volatile__ ("cchecktype $c%0, $c%1" : : \
5816 "i" (cs), "i" (cb)); \
5817} while (0)
5818
5819/*
5820 * Routines that modify or replace values in capability registers that don't
5821 * affect memory access via the register. These do not require memory
5822 * clobbers.
5823 *
5824 * XXXRW: Are there now none of these?
5825 */
5826
5827/*
5828 * Instructions relating to capability invocation, return, sealing, and
5829 * unsealing. Memory clobbers are required for register manipulation when
5830 * targeting $c0. They are also required for both CCall and CReturn to ensure
5831 * that any memory write-back is done before invocation.
5832 *
5833 * XXXRW: Is the latter class of cases required?
5834 */
5835#define CHERI_CSEAL(cd, cs, ct) do { \
5836 if ((cd) == 0) \
5837 __asm__ __volatile__ ("cseal $c%0, $c%1, $c%2" : : \
5838 "i" (cd), "i" (cs), "i" (ct) : "memory"); \
5839 else \
5840 __asm__ __volatile__ ("cseal $c%0, $c%1, $c%2" : : \
5841 "i" (cd), "i" (cs), "i" (ct)); \
5842} while (0)
5843
5844#define CHERI_CUNSEAL(cd, cb, ct) do { \
5845 if ((cd) == 0) \
5846 __asm__ __volatile__ ("cunseal $c%0, $c%1, $c%2" : : \
5847 "i" (cd), "i" (cb), "i" (ct) : "memory"); \
5848 else \
5849 __asm__ __volatile__ ("cunseal $c%0, $c%1, $c%2" : : \
5850 "i" (cd), "i" (cb), "i" (ct)); \
5851} while (0)
5852
5853#define CHERI_CCALL(cs, cb) do { \
5854 __asm__ __volatile__ ("ccall $c%0, $c%1" : : \
5855 "i" (cs), "i" (cb) : "memory"); \
5856} while (0)
5857
5858#define CHERI_CRETURN() do { \
5859 __asm__ __volatile__ ("creturn" : : : "memory"); \
5860} while (0)
5861
5862/*
5863 * Capability store; while this doesn't muck with c0, it does require a memory
5864 * clobber.
5865 */
5866#define CHERI_CSC(cs, cb, regbase, offset) do { \
5867 __asm__ __volatile__ ("csc $c%0, %1, %2($c%3)" : : \
5868 "i" (cs), "r" (regbase), "i" (offset), "i" (cb) : \
5869 "memory"); \
5870} while (0)
5871
5872/*
5873 * Data stores; while these don't muck with c0, they do require memory
5874 * clobbers.
5875 */
5876#define CHERI_CSB(rs, rt, offset, cb) do { \
5877 __asm__ __volatile__ ("csb %0, %1, %2($c%3)" : : \
5878 "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5879} while (0)
5880
5881#define CHERI_CSH(rs, rt, offset, cb) do { \
5882 __asm__ __volatile__ ("csh %0, %1, %2($c%3)" : : \
5883 "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5884} while (0)
5885
5886#define CHERI_CSW(rs, rt, offset, cb) do { \
5887 __asm__ __volatile__ ("csw %0, %1, %2($c%3)" : : \
5888 "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5889} while (0)
5890
5891#define CHERI_CSD(rs, rt, offset, cb) do { \
5892 __asm__ __volatile__ ("csd %0, %1, %2($c%3)" : : \
5893 "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5894} while (0)
5895
5896/*
5897 * Data loads: while these don't much with c0, they do require memory
5898 * clobbers.
5899 */
5900#define CHERI_CLB(rd, rt, offset, cb) do { \
5901 __asm__ __volatile__ ("clb %0, %1, %2($c%3)" : \
5902 "=r" (rd) : "r" (rt), "i" (offset),"i" (cb) : "memory"); \
5903} while (0)
5904
5905#define CHERI_CLH(rd, rt, offset, cb) do { \
5906 __asm__ __volatile__ ("clh %0, %1, %2($c%3)" : \
5907 "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5908} while (0)
5909
5910#define CHERI_CLW(rd, rt, offset, cb) do { \
5911 __asm__ __volatile__ ("clw %0, %1, %2($c%3)" : \
5912 "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5913} while (0)
5914
5915#define CHERI_CLD(rd, rt, offset, cb) do { \
5916 __asm__ __volatile__ ("cld %0, %1, %2($c%3)" : \
5917 "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5918} while (0)
5919
5920#define CHERI_CLBU(rd, rt, offset, cb) do { \
5921 __asm__ __volatile__ ("clbu %0, %1, %2($c%3)" : \
5922 "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5923} while (0)
5924
5925#define CHERI_CLHU(rd, rt, offset, cb) do { \
5926 __asm__ __volatile__ ("clhu %0, %1, %2($c%3)" : \
5927 "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5928} while (0)
5929
5930#define CHERI_CLWU(rd, rt, offset, cb) do { \
5931 __asm__ __volatile__ ("clwu %0, %1, %2($c%3)" : \
5932 "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
5933} while (0)
5934
5935/*
5936 * Routines that modify or replace values in capability registers, and that if
5937 * if used on C0, require the compiler to write registers back to memory, and
5938 * reload afterwards, since we may effectively be changing the compiler-
5939 * visible address space. This is also necessary for permissions changes as
5940 * well, to ensure that write-back occurs before a possible loss of store
5941 * permission.
5942 */
5943#define CHERI_CGETPCC(v, cd) do { \
5944 if ((cd) == 0) \
5945 __asm__ __volatile__ ("cgetpcc %0, $c%1" : "=r" (v) : \
5946 "i" (cd) : "memory"); \
5947 else \
5948 __asm__ __volatile__ ("cgetpcc %0, $c%1" : "=r" (v) : \
5949 "i" (cd)); \
5950} while (0)
5951
5952#define CHERI_CINCBASE(cd, cb, v) do { \
5953 if ((cd) == 0) \
5954 __asm__ __volatile__ ("cincbase $c%0, $c%1, %2" : : \
5955 "i" (cd), "i" (cb), "r" (v) : "memory"); \
5956 else \
5957 __asm__ __volatile__ ("cincbase $c%0, $c%1, %2" : : \
5958 "i" (cd), "i" (cb), "r" (v)); \
5959} while (0)
5960
5961#define CHERI_CINCOFFSET(cd, cb, v) do { \
5962 if ((cd) == 0) \
5963 __asm__ __volatile__ ("cincoffset $c%0, $c%1, %2" : : \
5964 "i" (cd), "i" (cb), "r" (v) : "memory"); \
5965 else \
5966 __asm__ __volatile__ ("cincoffset $c%0, $c%1, %2" : : \
5967 "i" (cd), "i" (cb), "r" (v)); \
5968} while (0)
5969
5970#if (defined(CPU_CHERI) && !defined(CPU_CHERI128)) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 256))
5971#define CHERI_CMOVE(cd, cb) do { \
5972 if ((cd) == 0) \
5973 __asm__ __volatile__ ("cmove $c%0, $c%1" : : \
5974 "i" (cd), "i" (cb) : "memory"); \
5975 else \
5976 __asm__ __volatile__ ("cmove $c%0, $c%1" : : \
5977 "i" (cd), "i" (cb)); \
5978} while (0)
5979#else /* 128-bit CHERI */
5980# 449 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5981#define CHERI_CMOVE(cd, cb) CHERI_CINCOFFSET(cd, cb, 0)
5982#endif /* 128-bit CHERI */
5983# 451 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
5984
5985#define CHERI_CSETDEFAULT(cb) do { \
5986 __asm__ __volatile__ ("csetdefault %c%0" : : "i" (cb) : \
5987 "memory"); \
5988} while (0)
5989
5990#define CHERI_CSETLEN(cd, cb, v) do { \
5991 if ((cd) == 0) \
5992 __asm__ __volatile__ ("csetlen $c%0, $c%1, %2" : : \
5993 "i" (cd), "i" (cb), "r" (v) : "memory"); \
5994 else \
5995 __asm__ __volatile__ ("csetlen $c%0, $c%1, %2" : : \
5996 "i" (cd), "i" (cb), "r" (v)); \
5997} while (0)
5998
5999#define CHERI_CSETOFFSET(cd, cb, v) do { \
6000 if ((cd) == 0) \
6001 __asm__ __volatile__ ("csetoffset $c%0, $c%1, %2" : : \
6002 "i" (cd), "i" (cb), "r" (v) : "memory"); \
6003 else \
6004 __asm__ __volatile__ ("csetoffset $c%0, $c%1, %2" : : \
6005 "i" (cd), "i" (cb), "r" (v)); \
6006} while (0)
6007
6008#define CHERI_CCLEARTAG(cd, cb) do { \
6009 if ((cd) == 0) \
6010 __asm__ __volatile__ ("ccleartag $c%0, $c%1" : : \
6011 "i" (cd), "i" (cb) : "memory"); \
6012 else \
6013 __asm__ __volatile__ ("ccleartag $c%0, $c%1" : : \
6014 "i" (cd), "i" (cb)); \
6015} while (0)
6016
6017#define CHERI_CANDPERM(cd, cb, v) do { \
6018 if ((cd) == 0) \
6019 __asm__ __volatile__ ("candperm $c%0, $c%1, %2" : : \
6020 "i" (cd), "i" (cb), "r" (v) : "memory"); \
6021 else \
6022 __asm__ __volatile__ ("candperm $c%0, $c%1, %2" : : \
6023 "i" (cd), "i" (cb), "r" (v)); \
6024} while (0)
6025
6026#define CHERI_CSETBOUNDS(cd, cb, v) do { \
6027 if ((cd) == 0) \
6028 __asm__ __volatile__ ("csetbounds $c%0, $c%1, %2" : : \
6029 "i" (cd), "i" (cb), "r" (v) : "memory"); \
6030 else \
6031 __asm__ __volatile__ ("csetbounds $c%0, $c%1, %2" : : \
6032 "i" (cd), "i" (cb), "r" (v)); \
6033} while (0)
6034
6035#define CHERI_CFROMPTR(cd, cb, v) do { \
6036 if ((cd) == 0) \
6037 __asm__ __volatile__ ("cfromptr $c%0, $c%1, %2" : : \
6038 "i" (cd), "i" (cb), "r" (v) : "memory"); \
6039 else \
6040 __asm__ __volatile__ ("cfromptr $c%0, $c%1, %2" : : \
6041 "i" (cd), "i" (cb), "r" (v)); \
6042} while (0)
6043
6044#define CHERI_CLC(cd, cb, regbase, offset) do { \
6045 if ((cd) == 0) \
6046 __asm__ __volatile__ ("clc $c%0, %1, %2($c%3)" : : \
6047 "i" (cd), "r" (regbase), "i" (offset), "i" (cb) : \
6048 "memory"); \
6049 else \
6050 __asm__ __volatile__ ("clc $c%0, %1, %2($c%3)" : : \
6051 "i" (cd), "r" (regbase), "i" (offset), "i" (cb)); \
6052} while (0)
6053
6054static inline void
6055cheri_capability_load(u_int crn_to, struct chericap *cp)
6056{
6057
6058 CHERI_CLC(crn_to, CHERI_CR_KDC, cp, 0);
6059}
6060
6061static inline void
6062cheri_capability_store(u_int crn_from, struct chericap *cp)
6063{
6064
6065 CHERI_CSC(crn_from, CHERI_CR_KDC, cp, 0);
6066}
6067
6068/*
6069 * Extract a flattened but useful memory representation of a complete
6070 * capability register.
6071 */
6072#define CHERI_GETCAPREG(crn, c) do { \
6073 CHERI_CGETPERM((c).c_perms, (crn)); \
6074 CHERI_CGETSEALED((c).c_sealed, (crn)); \
6075 CHERI_CGETTYPE((c).c_otype, (crn)); \
6076 CHERI_CGETBASE((c).c_base, (crn)); \
6077 CHERI_CGETLEN((c).c_length, (crn)); \
6078} while (0)
6079
6080
6081/*
6082 * Routines for measuring time -- depends on a later MIPS userspace cycle
6083 * counter.
6084 */
6085static __inline uint32_t
6086cheri_get_cyclecount(void)
6087{
6088 uint64_t _time;
6089 __asm __volatile("rdhwr %0, $2" : "=r" (_time));
6090 return (_time & 0xffffffff);
6091}
6092
6093#ifdef _KERNEL
6094#define CHERI_CAP_PRINT(crn) do { \
6095 uintmax_t c_perms, c_otype, c_base, c_length, c_offset; \
6096 u_int ctag, c_sealed; \
6097 \
6098 CHERI_CGETTAG(ctag, (crn)); \
6099 CHERI_CGETSEALED(c_sealed, (crn)); \
6100 CHERI_CGETPERM(c_perms, (crn)); \
6101 CHERI_CGETTYPE(c_otype, (crn)); \
6102 CHERI_CGETBASE(c_base, (crn)); \
6103 CHERI_CGETLEN(c_length, (crn)); \
6104 CHERI_CGETOFFSET(c_offset, (crn)); \
6105 printf("v:%u s:%u p:%08jx b:%016jx l:%016jx o:%jx t:%jx\n", \
6106 ctag, c_sealed, c_perms, c_base, c_length, c_offset, \
6107 c_otype); \
6108} while (0)
6109
6110#define CHERI_REG_PRINT(crn, num) do { \
6111 printf("$c%02u: ", num); \
6112 CHERI_CAP_PRINT(crn); \
6113} while (0)
6114
6115#ifdef DDB
6116#define DB_CHERI_CAP_PRINT(crn) do { \
6117 uintmax_t c_perms, c_otype, c_base, c_length, c_offset; \
6118 u_int ctag, c_sealed; \
6119 \
6120 CHERI_CGETTAG(ctag, (crn)); \
6121 CHERI_CGETSEALED(c_sealed, (crn)); \
6122 CHERI_CGETPERM(c_perms, (crn)); \
6123 CHERI_CGETTYPE(c_otype, (crn)); \
6124 CHERI_CGETBASE(c_base, (crn)); \
6125 CHERI_CGETLEN(c_length, (crn)); \
6126 CHERI_CGETOFFSET(c_offset, (crn)); \
6127 db_printf("v:%u s:%u p:%08jx b:%016jx l:%016jx o:%jx t:%jx\n", \
6128 ctag, c_sealed, c_perms, c_base, c_length, c_offset, \
6129 c_otype); \
6130} while (0)
6131
6132#define DB_CHERI_REG_PRINT(crn, num) do { \
6133 db_printf("$c%02u: ", num); \
6134 DB_CHERI_CAP_PRINT(crn); \
6135} while (0)
6136#endif /* !_KERNEL */
6137# 604 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
6138
6139/*
6140 * APIs that act on C language representations of capabilities -- but not
6141 * capabilities themselves.
6142 */
6143void cheri_capability_copy(struct chericap *cp_to,
6144 struct chericap *cp_from);
6145void cheri_capability_set(struct chericap *cp, uint32_t uperms,
6146 void *otype, void *basep, size_t length, off_t off);
6147void cheri_capability_set_null(struct chericap *cp);
6148
6149/*
6150 * CHERI capability utility functions.
6151 */
6152void cheri_bcopy(void *src, void *dst, size_t len);
6153void *cheri_memcpy(void *dst, void *src, size_t len);
6154
6155/*
6156 * CHERI context management functions.
6157 */
6158
6159const char *cheri_exccode_string(uint8_t exccode);
6160void cheri_exec_setregs(struct thread *td);
6161void cheri_log_cheri_frame(struct cheri_frame *cheriframe);
6162void cheri_log_exception(struct trapframe *frame, int trap_type);
6163void cheri_log_exception_registers(struct trapframe *frame);
6164int cheri_syscall_authorize(struct thread *td, u_int code,
6165 int nargs, register_t *args);
6166int cheri_signal_sandboxed(struct thread *td);
6167void cheri_sendsig(struct thread *td);
6168
6169/*
6170 * Functions to set up and manipulate CHERI contexts and stacks.
6171 */
6172struct pcb;
6173struct sysarch_args;
6174void cheri_context_copy(struct pcb *dst, struct pcb *src);
6175void cheri_signal_copy(struct pcb *dst, struct pcb *src);
6176void cheri_stack_copy(struct pcb *dst, struct pcb *src);
6177void cheri_stack_init(struct pcb *pcb);
6178int cheri_stack_unwind(struct thread *td, struct trapframe *tf,
6179 int signum);
6180int cheri_sysarch_getstack(struct thread *td, struct sysarch_args *uap);
6181int cheri_sysarch_setstack(struct thread *td, struct sysarch_args *uap);
6182
6183/*
6184 * Global sysctl definitions.
6185 */
6186SYSCTL_DECL(_security_cheri);
6187SYSCTL_DECL(_security_cheri_stats);
6188extern u_int security_cheri_debugger_on_sandbox_signal;
6189extern u_int security_cheri_debugger_on_sandbox_syscall;
6190extern u_int security_cheri_debugger_on_sandbox_unwind;
6191extern u_int security_cheri_debugger_on_sigprot;
6192extern u_int security_cheri_sandboxed_signals;
6193extern u_int security_cheri_syscall_violations;
6194#endif /* !_KERNEL */
6195# 661 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
6196
6197#endif /* _MIPS_INCLUDE_CHERI_H_ */
6198# 663 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
6199# 43 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
6200#if 0 /* expanded by -frewrite-includes */
6201#include <machine/cheric.h>
6202#endif /* expanded by -frewrite-includes */
6203# 43 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
6204# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 1 3 4
6205/*-
6206 * Copyright (c) 2013-2015 Robert N. M. Watson
6207 * All rights reserved.
6208 *
6209 * This software was developed by SRI International and the University of
6210 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
6211 * ("CTSRD"), as part of the DARPA CRASH research programme.
6212 *
6213 * Redistribution and use in source and binary forms, with or without
6214 * modification, are permitted provided that the following conditions
6215 * are met:
6216 * 1. Redistributions of source code must retain the above copyright
6217 * notice, this list of conditions and the following disclaimer.
6218 * 2. Redistributions in binary form must reproduce the above copyright
6219 * notice, this list of conditions and the following disclaimer in the
6220 * documentation and/or other materials provided with the distribution.
6221 *
6222 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6223 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6224 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6225 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6226 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6227 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6228 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6229 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6230 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6231 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6232 * SUCH DAMAGE.
6233 */
6234
6235#ifndef _MIPS_INCLUDE_CHERIC_H_
6236#define _MIPS_INCLUDE_CHERIC_H_
6237
6238#if 0 /* expanded by -frewrite-includes */
6239#include <sys/cdefs.h>
6240#endif /* expanded by -frewrite-includes */
6241# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
6242# 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
6243
6244#if 0 /* expanded by -frewrite-includes */
6245#include <machine/cheri.h>
6246#endif /* expanded by -frewrite-includes */
6247# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
6248# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
6249
6250#if !defined(_KERNEL) && __has_feature(capabilities)
6251/*
6252 * Programmer-friendly macros for CHERI-aware C code -- requires use of
6253 * CHERI-aware Clang/LLVM, and full CP2 context switching, so not yet usable
6254 * in the kernel.
6255 */
6256#define cheri_getlen(x) __builtin_cheri_get_cap_length( \
6257 __DECONST(__capability void *, (x)))
6258#define cheri_getbase(x) __builtin_cheri_get_cap_base( \
6259 __DECONST(__capability void *, (x)))
6260#define cheri_getoffset(x) __builtin_cheri_cap_offset_get( \
6261 __DECONST(__capability void *, (x)))
6262#define cheri_getperm(x) __builtin_cheri_get_cap_perms( \
6263 __DECONST(__capability void *, (x)))
6264#define cheri_getsealed(x) __builtin_cheri_get_cap_sealed( \
6265 __DECONST(__capability void *, (x)))
6266#define cheri_gettag(x) __builtin_cheri_get_cap_tag( \
6267 __DECONST(__capability void *, (x)))
6268#define cheri_gettype(x) __builtin_cheri_get_cap_type( \
6269 __DECONST(__capability void *, (x)))
6270
6271#define cheri_andperm(x, y) __builtin_cheri_and_cap_perms( \
6272 __DECONST(__capability void *, (x)), (y))
6273#define cheri_cleartag(x) __builtin_cheri_clear_cap_tag( \
6274 __DECONST(__capability void *, (x)))
6275#define cheri_incbase(x, y) __builtin_cheri_inc_cap_base( \
6276 __DECONST(__capability void *, (x)), (y))
6277#define cheri_incoffset(x, y) __builtin_cheri_cap_offset_increment( \
6278 __DECONST(__capability void *, (x)), (y))
6279#define cheri_setlen(x, y) __builtin_cheri_set_cap_length( \
6280 __DECONST(__capability void *, (x)), (y))
6281#define cheri_setoffset(x, y) __builtin_cheri_cap_offset_set( \
6282 __DECONST(__capability void *, (x)), (y))
6283
6284#define cheri_seal(x, y) __builtin_cheri_seal_cap( \
6285 __DECONST(__capability void *, (x)), \
6286 __DECONST(__capability void *, (y)))
6287#define cheri_unseal(x, y) __builtin_cheri_unseal_cap( \
6288 __DECONST(__capability void *, (x)), \
6289 __DECONST(__capability void *, (y)))
6290
6291#define cheri_getcause() __builtin_cheri_get_cause()
6292#define cheri_setcause(x) __builtin_cheri_set_cause(x)
6293
6294#define cheri_ccheckperm(c, p) __builtin_cheri_check_perms( \
6295 __DECONST(__capability void *, (c)), (p))
6296#define cheri_cchecktype(c, t) __builtin_cheri_check_type( \
6297 __DECONST(__capability void *, (c)), (t))
6298
6299#define cheri_getdefault() __builtin_cheri_get_global_data_cap()
6300#define cheri_getidc() __builtin_cheri_get_invoke_data_cap()
6301#define cheri_getkr0c() __builtin_cheri_get_kernel_cap1()
6302#define cheri_getkr1c() __builtin_cheri_get_kernel_cap2()
6303#define cheri_getkcc() __builtin_cheri_get_kernel_code_cap()
6304#define cheri_getkdc() __builtin_cheri_get_kernel_data_cap()
6305#define cheri_getepcc() __builtin_cheri_get_exception_program_counter_cap()
6306#define cheri_getpcc() __builtin_cheri_get_program_counter_cap()
6307#define cheri_getstack() __builtin_memcap_stack_get()
6308
6309#define cheri_local(c) cheri_andperm((c), ~CHERI_PERM_GLOBAL)
6310
6311#define cheri_csetbounds(x, y) __builtin_memcap_bounds_set( \
6312 __DECONST(__capability void *, (x)), (y))
6313static __inline __capability void *
6314cheri_ptr(const void *ptr, size_t len)
6315{
6316 const __capability void *c;
6317
6318 /* Assume CFromPtr without base set, availability of CSetBounds. */
6319 c = (const __capability void *)ptr;
6320 return (cheri_csetbounds(c, len));
6321}
6322
6323static __inline __capability void *
6324cheri_ptrperm(const void *ptr, size_t len, register_t perm)
6325{
6326
6327 return (cheri_andperm(cheri_ptr(ptr, len), perm | CHERI_PERM_GLOBAL));
6328}
6329
6330static __inline __capability void *
6331cheri_ptrpermoff(const void *ptr, size_t len, register_t perm, off_t off)
6332{
6333
6334 return (cheri_setoffset(cheri_ptrperm(ptr, len, perm), off));
6335}
6336
6337/*
6338 * Construct a capability suitable to describe a type identified by 'ptr';
6339 * set it to zero-length with the offset equal to the base.
6340 */
6341static __inline __capability void *
6342cheri_maketype(const void *ptr, register_t perm)
6343{
6344
6345 return (cheri_ptrpermoff(ptr, 1, perm, 0));
6346}
6347
6348static __inline __capability void *
6349cheri_zerocap(void)
6350{
6351 return (__capability void*)0;
6352}
6353
6354#define cheri_getreg(x) ({ \
6355 __capability void *_cap; \
6356 __asm __volatile ("cmove %0, $c" #x : "=C" (_cap)); \
6357 _cap; \
6358})
6359
6360#define cheri_setreg(x, cap) do { \
6361 if ((x) == 0) \
6362 __asm __volatile ("cmove $c" #x ", %0" : : "C" (cap) : \
6363 "memory"); \
6364 else \
6365 __asm __volatile ("cmove $c" #x ", %0" : : "C" (cap)); \
6366} while (0)
6367#endif
6368# 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
6369
6370#define CHERI_PRINT_PTR(ptr) \
6371 printf("%s: " #ptr " b:%016jx l:%016zx o:%jx\n", __func__, \
6372 cheri_getbase((const __capability void *)(ptr)), \
6373 cheri_getlen((const __capability void *)(ptr)), \
6374 cheri_getoffset((const __capability void *)(ptr)))
6375
6376#endif /* _MIPS_INCLUDE_CHERIC_H_ */
6377# 164 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
6378# 44 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
6379#if 0 /* expanded by -frewrite-includes */
6380#include <machine/cherireg.h>
6381#endif /* expanded by -frewrite-includes */
6382# 44 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
6383# 45 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
6384#if 0 /* expanded by -frewrite-includes */
6385#include <machine/cpuregs.h>
6386#endif /* expanded by -frewrite-includes */
6387# 45 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
6388# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 1 3 4
6389/* $NetBSD: cpuregs.h,v 1.70 2006/05/15 02:26:54 simonb Exp $ */
6390
6391/*
6392 * Copyright (c) 1992, 1993
6393 * The Regents of the University of California. All rights reserved.
6394 *
6395 * This code is derived from software contributed to Berkeley by
6396 * Ralph Campbell and Rick Macklem.
6397 *
6398 * Redistribution and use in source and binary forms, with or without
6399 * modification, are permitted provided that the following conditions
6400 * are met:
6401 * 1. Redistributions of source code must retain the above copyright
6402 * notice, this list of conditions and the following disclaimer.
6403 * 2. Redistributions in binary form must reproduce the above copyright
6404 * notice, this list of conditions and the following disclaimer in the
6405 * documentation and/or other materials provided with the distribution.
6406 * 3. Neither the name of the University nor the names of its contributors
6407 * may be used to endorse or promote products derived from this software
6408 * without specific prior written permission.
6409 *
6410 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
6411 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6412 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6413 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
6414 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6415 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6416 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6417 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6418 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6419 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6420 * SUCH DAMAGE.
6421 *
6422 * @(#)machConst.h 8.1 (Berkeley) 6/10/93
6423 *
6424 * machConst.h --
6425 *
6426 * Machine dependent constants.
6427 *
6428 * Copyright (C) 1989 Digital Equipment Corporation.
6429 * Permission to use, copy, modify, and distribute this software and
6430 * its documentation for any purpose and without fee is hereby granted,
6431 * provided that the above copyright notice appears in all copies.
6432 * Digital Equipment Corporation makes no representations about the
6433 * suitability of this software for any purpose. It is provided "as is"
6434 * without express or implied warranty.
6435 *
6436 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machConst.h,
6437 * v 9.2 89/10/21 15:55:22 jhh Exp SPRITE (DECWRL)
6438 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAddrs.h,
6439 * v 1.2 89/08/15 18:28:21 rab Exp SPRITE (DECWRL)
6440 * from: Header: /sprite/src/kernel/vm/ds3100.md/RCS/vmPmaxConst.h,
6441 * v 9.1 89/09/18 17:33:00 shirriff Exp SPRITE (DECWRL)
6442 *
6443 * $FreeBSD$
6444 */
6445
6446#ifndef _MIPS_CPUREGS_H_
6447#define _MIPS_CPUREGS_H_
6448
6449/*
6450 * Address space.
6451 * 32-bit mips CPUS partition their 32-bit address space into four segments:
6452 *
6453 * kuseg 0x00000000 - 0x7fffffff User virtual mem, mapped
6454 * kseg0 0x80000000 - 0x9fffffff Physical memory, cached, unmapped
6455 * kseg1 0xa0000000 - 0xbfffffff Physical memory, uncached, unmapped
6456 * kseg2 0xc0000000 - 0xffffffff kernel-virtual, mapped
6457 *
6458 * Caching of mapped addresses is controlled by bits in the TLB entry.
6459 */
6460
6461#define MIPS_KSEG0_LARGEST_PHYS (0x20000000)
6462#define MIPS_KSEG0_PHYS_MASK (0x1fffffff)
6463#define MIPS_XKPHYS_LARGEST_PHYS (0x10000000000) /* 40 bit PA */
6464#define MIPS_XKPHYS_PHYS_MASK (0x0ffffffffff)
6465
6466#ifndef LOCORE
6467#define MIPS_KUSEG_START 0x00000000
6468#define MIPS_KSEG0_START ((intptr_t)(int32_t)0x80000000)
6469#define MIPS_KSEG0_END ((intptr_t)(int32_t)0x9fffffff)
6470#define MIPS_KSEG1_START ((intptr_t)(int32_t)0xa0000000)
6471#define MIPS_KSEG1_END ((intptr_t)(int32_t)0xbfffffff)
6472#define MIPS_KSSEG_START ((intptr_t)(int32_t)0xc0000000)
6473#define MIPS_KSSEG_END ((intptr_t)(int32_t)0xdfffffff)
6474#define MIPS_KSEG3_START ((intptr_t)(int32_t)0xe0000000)
6475#define MIPS_KSEG3_END ((intptr_t)(int32_t)0xffffffff)
6476#define MIPS_KSEG2_START MIPS_KSSEG_START
6477#define MIPS_KSEG2_END MIPS_KSSEG_END
6478#endif
6479# 91 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6480
6481#define MIPS_PHYS_TO_KSEG0(x) ((uintptr_t)(x) | MIPS_KSEG0_START)
6482#define MIPS_PHYS_TO_KSEG1(x) ((uintptr_t)(x) | MIPS_KSEG1_START)
6483#define MIPS_KSEG0_TO_PHYS(x) ((uintptr_t)(x) & MIPS_KSEG0_PHYS_MASK)
6484#define MIPS_KSEG1_TO_PHYS(x) ((uintptr_t)(x) & MIPS_KSEG0_PHYS_MASK)
6485
6486#define MIPS_IS_KSEG0_ADDR(x) \
6487 (((vm_offset_t)(x) >= MIPS_KSEG0_START) && \
6488 ((vm_offset_t)(x) <= MIPS_KSEG0_END))
6489#define MIPS_IS_KSEG1_ADDR(x) \
6490 (((vm_offset_t)(x) >= MIPS_KSEG1_START) && \
6491 ((vm_offset_t)(x) <= MIPS_KSEG1_END))
6492#define MIPS_IS_VALID_PTR(x) (MIPS_IS_KSEG0_ADDR(x) || \
6493 MIPS_IS_KSEG1_ADDR(x))
6494
6495/*
6496 * Cache Coherency Attributes:
6497 * UC: Uncached.
6498 * UA: Uncached accelerated.
6499 * C: Cacheable, coherency unspecified.
6500 * CNC: Cacheable non-coherent.
6501 * CC: Cacheable coherent.
6502 * CCE: Cacheable coherent, exclusive read.
6503 * CCEW: Cacheable coherent, exclusive write.
6504 * CCUOW: Cacheable coherent, update on write.
6505 *
6506 * Note that some bits vary in meaning across implementations (and that the
6507 * listing here is no doubt incomplete) and that the optimal cached mode varies
6508 * between implementations. 0x02 is required to be UC and 0x03 is required to
6509 * be a least C.
6510 *
6511 * We define the following logical bits:
6512 * UNCACHED:
6513 * The optimal uncached mode for the target CPU type. This must
6514 * be suitable for use in accessing memory-mapped devices.
6515 * CACHED: The optional cached mode for the target CPU type.
6516 */
6517
6518#define MIPS_CCA_UC 0x02 /* Uncached. */
6519#define MIPS_CCA_C 0x03 /* Cacheable, coherency unspecified. */
6520
6521#if defined(CPU_R4000) || defined(CPU_R10000)
6522#define MIPS_CCA_CNC 0x03
6523#define MIPS_CCA_CCE 0x04
6524#define MIPS_CCA_CCEW 0x05
6525
6526#ifdef CPU_R4000
6527#define MIPS_CCA_CCUOW 0x06
6528#endif
6529# 140 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6530
6531#ifdef CPU_R10000
6532#define MIPS_CCA_UA 0x07
6533#endif
6534# 144 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6535
6536#define MIPS_CCA_CACHED MIPS_CCA_CCEW
6537#endif /* defined(CPU_R4000) || defined(CPU_R10000) */
6538# 147 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6539
6540#if defined(CPU_SB1)
6541#define MIPS_CCA_CC 0x05 /* Cacheable Coherent. */
6542#endif
6543# 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6544
6545#if defined(CPU_MIPS74KC)
6546#define MIPS_CCA_UNCACHED 0x02
6547#define MIPS_CCA_CACHED 0x00
6548#endif
6549# 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6550
6551#ifndef MIPS_CCA_UNCACHED
6552#define MIPS_CCA_UNCACHED MIPS_CCA_UC
6553#endif
6554# 160 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6555
6556/*
6557 * If we don't know which cached mode to use and there is a cache coherent
6558 * mode, use it. If there is not a cache coherent mode, use the required
6559 * cacheable mode.
6560 */
6561#ifndef MIPS_CCA_CACHED
6562#ifdef MIPS_CCA_CC
6563#define MIPS_CCA_CACHED MIPS_CCA_CC
6564#else
6565# 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6566#define MIPS_CCA_CACHED MIPS_CCA_C
6567#endif
6568# 172 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6569#endif
6570# 173 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6571
6572#define MIPS_PHYS_TO_XKPHYS(cca,x) \
6573 ((0x2ULL << 62) | ((unsigned long long)(cca) << 59) | (x))
6574#define MIPS_PHYS_TO_XKPHYS_CACHED(x) \
6575 ((0x2ULL << 62) | ((unsigned long long)(MIPS_CCA_CACHED) << 59) | (x))
6576#define MIPS_PHYS_TO_XKPHYS_UNCACHED(x) \
6577 ((0x2ULL << 62) | ((unsigned long long)(MIPS_CCA_UNCACHED) << 59) | (x))
6578
6579#define MIPS_XKPHYS_TO_PHYS(x) ((uintptr_t)(x) & MIPS_XKPHYS_PHYS_MASK)
6580
6581#define MIPS_XKPHYS_START 0x8000000000000000
6582#define MIPS_XKPHYS_END 0xbfffffffffffffff
6583#define MIPS_XUSEG_START 0x0000000000000000
6584#define MIPS_XUSEG_END 0x0000010000000000
6585#define MIPS_XKSEG_START 0xc000000000000000
6586#define MIPS_XKSEG_END 0xc00000ff80000000
6587#define MIPS_XKSEG_COMPAT32_START 0xffffffff80000000
6588#define MIPS_XKSEG_COMPAT32_END 0xffffffffffffffff
6589#define MIPS_XKSEG_TO_COMPAT32(va) ((va) & 0xffffffff)
6590
6591#ifdef __mips_n64
6592#define MIPS_DIRECT_MAPPABLE(pa) 1
6593#define MIPS_PHYS_TO_DIRECT(pa) MIPS_PHYS_TO_XKPHYS_CACHED(pa)
6594#define MIPS_PHYS_TO_DIRECT_UNCACHED(pa) MIPS_PHYS_TO_XKPHYS_UNCACHED(pa)
6595#define MIPS_DIRECT_TO_PHYS(va) MIPS_XKPHYS_TO_PHYS(va)
6596#else
6597# 199 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6598#define MIPS_DIRECT_MAPPABLE(pa) ((pa) < MIPS_KSEG0_LARGEST_PHYS)
6599#define MIPS_PHYS_TO_DIRECT(pa) MIPS_PHYS_TO_KSEG0(pa)
6600#define MIPS_PHYS_TO_DIRECT_UNCACHED(pa) MIPS_PHYS_TO_KSEG1(pa)
6601#define MIPS_DIRECT_TO_PHYS(va) MIPS_KSEG0_TO_PHYS(va)
6602#endif
6603# 204 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6604
6605/* CPU dependent mtc0 hazard hook */
6606#if defined(CPU_CNMIPS) || defined(CPU_RMI)
6607#define COP0_SYNC
6608#elif defined(CPU_NLM)
6609# 209 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6610#define COP0_SYNC .word 0xc0 /* ehb */
6611#elif defined(CPU_SB1)
6612# 211 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6613#define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop
6614#elif defined(CPU_MIPS74KC)
6615# 213 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6616#define COP0_SYNC .word 0xc0 /* ehb */
6617#else
6618# 215 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6619/*
6620 * Pick a reasonable default based on the "typical" spacing described in the
6621 * "CP0 Hazards" chapter of MIPS Architecture Book Vol III.
6622 */
6623#define COP0_SYNC ssnop; ssnop; ssnop; ssnop; .word 0xc0;
6624#endif
6625# 221 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6626#define COP0_HAZARD_FPUENABLE nop; nop; nop; nop;
6627
6628/*
6629 * The bits in the cause register.
6630 *
6631 * Bits common to r3000 and r4000:
6632 *
6633 * MIPS_CR_BR_DELAY Exception happened in branch delay slot.
6634 * MIPS_CR_COP_ERR Coprocessor error.
6635 * MIPS_CR_IP Interrupt pending bits defined below.
6636 * (same meaning as in CAUSE register).
6637 * MIPS_CR_EXC_CODE The exception type (see exception codes below).
6638 *
6639 * Differences:
6640 * r3k has 4 bits of execption type, r4k has 5 bits.
6641 */
6642#define MIPS_CR_BR_DELAY 0x80000000
6643#define MIPS_CR_COP_ERR 0x30000000
6644#define MIPS_CR_EXC_CODE 0x0000007C /* five bits */
6645#define MIPS_CR_IP 0x0000FF00
6646#define MIPS_CR_EXC_CODE_SHIFT 2
6647#define MIPS_CR_COP_ERR_SHIFT 28
6648
6649/*
6650 * The bits in the status register. All bits are active when set to 1.
6651 *
6652 * R3000 status register fields:
6653 * MIPS_SR_COP_USABILITY Control the usability of the four coprocessors.
6654 * MIPS_SR_TS TLB shutdown.
6655 *
6656 * MIPS_SR_INT_IE Master (current) interrupt enable bit.
6657 *
6658 * Differences:
6659 * r3k has cache control is via frobbing SR register bits, whereas the
6660 * r4k cache control is via explicit instructions.
6661 * r3k has a 3-entry stack of kernel/user bits, whereas the
6662 * r4k has kernel/supervisor/user.
6663 */
6664#define MIPS_SR_COP_USABILITY 0xf0000000
6665#define MIPS_SR_COP_0_BIT 0x10000000
6666#define MIPS_SR_COP_1_BIT 0x20000000
6667#define MIPS_SR_COP_2_BIT 0x40000000
6668
6669 /* r4k and r3k differences, see below */
6670
6671#define MIPS_SR_MX 0x01000000 /* MIPS64 */
6672#define MIPS_SR_PX 0x00800000 /* MIPS64 */
6673#define MIPS_SR_BEV 0x00400000 /* Use boot exception vector */
6674#define MIPS_SR_TS 0x00200000
6675#define MIPS_SR_DE 0x00010000
6676
6677#define MIPS_SR_INT_IE 0x00000001
6678/*#define MIPS_SR_MBZ 0x0f8000c0*/ /* Never used, true for r3k */
6679#define MIPS_SR_INT_MASK 0x0000ff00
6680
6681/*
6682 * R4000 status register bit definitons,
6683 * where different from r2000/r3000.
6684 */
6685#define MIPS_SR_XX 0x80000000
6686#define MIPS_SR_RP 0x08000000
6687#define MIPS_SR_FR 0x04000000
6688#define MIPS_SR_RE 0x02000000
6689
6690#define MIPS_SR_DIAG_DL 0x01000000 /* QED 52xx */
6691#define MIPS_SR_DIAG_IL 0x00800000 /* QED 52xx */
6692#define MIPS_SR_SR 0x00100000
6693#define MIPS_SR_NMI 0x00080000 /* MIPS32/64 */
6694#define MIPS_SR_DIAG_CH 0x00040000
6695#define MIPS_SR_DIAG_CE 0x00020000
6696#define MIPS_SR_DIAG_PE 0x00010000
6697#define MIPS_SR_EIE 0x00010000 /* TX79/R5900 */
6698#define MIPS_SR_KX 0x00000080
6699#define MIPS_SR_SX 0x00000040
6700#define MIPS_SR_UX 0x00000020
6701#define MIPS_SR_KSU_MASK 0x00000018
6702#define MIPS_SR_KSU_USER 0x00000010
6703#define MIPS_SR_KSU_SUPER 0x00000008
6704#define MIPS_SR_KSU_KERNEL 0x00000000
6705#define MIPS_SR_ERL 0x00000004
6706#define MIPS_SR_EXL 0x00000002
6707
6708/*
6709 * The interrupt masks.
6710 * If a bit in the mask is 1 then the interrupt is enabled (or pending).
6711 */
6712#define MIPS_INT_MASK 0xff00
6713#define MIPS_INT_MASK_5 0x8000
6714#define MIPS_INT_MASK_4 0x4000
6715#define MIPS_INT_MASK_3 0x2000
6716#define MIPS_INT_MASK_2 0x1000
6717#define MIPS_INT_MASK_1 0x0800
6718#define MIPS_INT_MASK_0 0x0400
6719#define MIPS_HARD_INT_MASK 0xfc00
6720#define MIPS_SOFT_INT_MASK_1 0x0200
6721#define MIPS_SOFT_INT_MASK_0 0x0100
6722
6723/*
6724 * The bits in the MIPS3 config register.
6725 *
6726 * bit 0..5: R/W, Bit 6..31: R/O
6727 */
6728
6729/* kseg0 coherency algorithm - see MIPS3_TLB_ATTR values */
6730#define MIPS_CONFIG_K0_MASK 0x00000007
6731
6732/*
6733 * R/W Update on Store Conditional
6734 * 0: Store Conditional uses coherency algorithm specified by TLB
6735 * 1: Store Conditional uses cacheable coherent update on write
6736 */
6737#define MIPS_CONFIG_CU 0x00000008
6738
6739#define MIPS_CONFIG_DB 0x00000010 /* Primary D-cache line size */
6740#define MIPS_CONFIG_IB 0x00000020 /* Primary I-cache line size */
6741#define MIPS_CONFIG_CACHE_L1_LSIZE(config, bit) \
6742 (((config) & (bit)) ? 32 : 16)
6743
6744#define MIPS_CONFIG_DC_MASK 0x000001c0 /* Primary D-cache size */
6745#define MIPS_CONFIG_DC_SHIFT 6
6746#define MIPS_CONFIG_IC_MASK 0x00000e00 /* Primary I-cache size */
6747#define MIPS_CONFIG_IC_SHIFT 9
6748#define MIPS_CONFIG_C_DEFBASE 0x1000 /* default base 2^12 */
6749
6750/* Cache size mode indication: available only on Vr41xx CPUs */
6751#define MIPS_CONFIG_CS 0x00001000
6752#define MIPS_CONFIG_C_4100BASE 0x0400 /* base is 2^10 if CS=1 */
6753#define MIPS_CONFIG_CACHE_SIZE(config, mask, base, shift) \
6754 ((base) << (((config) & (mask)) >> (shift)))
6755
6756/* External cache enable: Controls L2 for R5000/Rm527x and L3 for Rm7000 */
6757#define MIPS_CONFIG_SE 0x00001000
6758
6759/* Block ordering: 0: sequential, 1: sub-block */
6760#define MIPS_CONFIG_EB 0x00002000
6761
6762/* ECC mode - 0: ECC mode, 1: parity mode */
6763#define MIPS_CONFIG_EM 0x00004000
6764
6765/* BigEndianMem - 0: kernel and memory are little endian, 1: big endian */
6766#define MIPS_CONFIG_BE 0x00008000
6767
6768/* Dirty Shared coherency state - 0: enabled, 1: disabled */
6769#define MIPS_CONFIG_SM 0x00010000
6770
6771/* Secondary Cache - 0: present, 1: not present */
6772#define MIPS_CONFIG_SC 0x00020000
6773
6774/* System Port width - 0: 64-bit, 1: 32-bit (QED RM523x), 2,3: reserved */
6775#define MIPS_CONFIG_EW_MASK 0x000c0000
6776#define MIPS_CONFIG_EW_SHIFT 18
6777
6778/* Secondary Cache port width - 0: 128-bit data path to S-cache, 1: reserved */
6779#define MIPS_CONFIG_SW 0x00100000
6780
6781/* Split Secondary Cache Mode - 0: I/D mixed, 1: I/D separated by SCAddr(17) */
6782#define MIPS_CONFIG_SS 0x00200000
6783
6784/* Secondary Cache line size */
6785#define MIPS_CONFIG_SB_MASK 0x00c00000
6786#define MIPS_CONFIG_SB_SHIFT 22
6787#define MIPS_CONFIG_CACHE_L2_LSIZE(config) \
6788 (0x10 << (((config) & MIPS_CONFIG_SB_MASK) >> MIPS_CONFIG_SB_SHIFT))
6789
6790/* Write back data rate */
6791#define MIPS_CONFIG_EP_MASK 0x0f000000
6792#define MIPS_CONFIG_EP_SHIFT 24
6793
6794/* System clock ratio - this value is CPU dependent */
6795#define MIPS_CONFIG_EC_MASK 0x70000000
6796#define MIPS_CONFIG_EC_SHIFT 28
6797
6798/* Master-Checker Mode - 1: enabled */
6799#define MIPS_CONFIG_CM 0x80000000
6800
6801/*
6802 * The bits in the MIPS4 config register.
6803 */
6804
6805/*
6806 * Location of exception vectors.
6807 *
6808 * Common vectors: reset and UTLB miss.
6809 */
6810#define MIPS_RESET_EXC_VEC ((intptr_t)(int32_t)0xBFC00000)
6811#define MIPS_UTLB_MISS_EXC_VEC ((intptr_t)(int32_t)0x80000000)
6812
6813/*
6814 * MIPS-III exception vectors
6815 */
6816#define MIPS_XTLB_MISS_EXC_VEC ((intptr_t)(int32_t)0x80000080)
6817#define MIPS_CACHE_ERR_EXC_VEC ((intptr_t)(int32_t)0x80000100)
6818#define MIPS_GEN_EXC_VEC ((intptr_t)(int32_t)0x80000180)
6819
6820/*
6821 * MIPS32/MIPS64 (and some MIPS3) dedicated interrupt vector.
6822 */
6823#define MIPS_INTR_EXC_VEC 0x80000200
6824
6825/*
6826 * Coprocessor 0 registers:
6827 *
6828 * v--- width for mips I,III,32,64
6829 * (3=32bit, 6=64bit, i=impl dep)
6830 * 0 MIPS_COP_0_TLB_INDEX 3333 TLB Index.
6831 * 1 MIPS_COP_0_TLB_RANDOM 3333 TLB Random.
6832 * 2 MIPS_COP_0_TLB_LO0 .636 r4k TLB entry low.
6833 * 3 MIPS_COP_0_TLB_LO1 .636 r4k TLB entry low, extended.
6834 * 4 MIPS_COP_0_TLB_CONTEXT 3636 TLB Context.
6835 * 4/2 MIPS_COP_0_USERLOCAL ..36 UserLocal.
6836 * 5 MIPS_COP_0_TLB_PG_MASK .333 TLB Page Mask register.
6837 * 6 MIPS_COP_0_TLB_WIRED .333 Wired TLB number.
6838 * 7 MIPS_COP_0_HWRENA ..33 rdHWR Enable.
6839 * 8 MIPS_COP_0_BAD_VADDR 3636 Bad virtual address.
6840 * 9 MIPS_COP_0_COUNT .333 Count register.
6841 * 10 MIPS_COP_0_TLB_HI 3636 TLB entry high.
6842 * 11 MIPS_COP_0_COMPARE .333 Compare (against Count).
6843 * 12 MIPS_COP_0_STATUS 3333 Status register.
6844 * 13 MIPS_COP_0_CAUSE 3333 Exception cause register.
6845 * 14 MIPS_COP_0_EXC_PC 3636 Exception PC.
6846 * 15 MIPS_COP_0_PRID 3333 Processor revision identifier.
6847 * 15/1 MIPS_COP_0_EBASE ..3? Exception Base.
6848 * 15/2 MIPS_COP_0_CDMM ..3? Common Device Memory Map.
6849 * 15/6 MIPS_COP_0_CINFO ...3 Core count/id (BERI).
6850 * 15/7 MIPS_COP_0_TINFO ...3 Thread count/id (BERI).
6851 * 16 MIPS_COP_0_CONFIG 3333 Configuration register.
6852 * 16/1 MIPS_COP_0_CONFIG1 ..33 Configuration register 1.
6853 * 16/2 MIPS_COP_0_CONFIG2 ..33 Configuration register 2.
6854 * 16/3 MIPS_COP_0_CONFIG3 ..33 Configuration register 3.
6855 * 16/4 MIPS_COP_0_CONFIG4 ..33 Configuration register 4.
6856 * 17 MIPS_COP_0_LLADDR .336 Load Linked Address.
6857 * 18 MIPS_COP_0_WATCH_LO .336 WatchLo register.
6858 * 19 MIPS_COP_0_WATCH_HI .333 WatchHi register.
6859 * 20 MIPS_COP_0_TLB_XCONTEXT .6.6 TLB XContext register.
6860 * 23 MIPS_COP_0_DEBUG .... Debug JTAG register.
6861 * 24 MIPS_COP_0_DEPC .... DEPC JTAG register.
6862 * 25 MIPS_COP_0_PERFCNT ..36 Performance Counter register.
6863 * 26 MIPS_COP_0_ECC .3ii ECC / Error Control register.
6864 * 27 MIPS_COP_0_CACHE_ERR .3ii Cache Error register.
6865 * 28/0 MIPS_COP_0_TAG_LO .3ii Cache TagLo register (instr).
6866 * 28/1 MIPS_COP_0_DATA_LO ..ii Cache DataLo register (instr).
6867 * 28/2 MIPS_COP_0_TAG_LO ..ii Cache TagLo register (data).
6868 * 28/3 MIPS_COP_0_DATA_LO ..ii Cache DataLo register (data).
6869 * 29/0 MIPS_COP_0_TAG_HI .3ii Cache TagHi register (instr).
6870 * 29/1 MIPS_COP_0_DATA_HI ..ii Cache DataHi register (instr).
6871 * 29/2 MIPS_COP_0_TAG_HI ..ii Cache TagHi register (data).
6872 * 29/3 MIPS_COP_0_DATA_HI ..ii Cache DataHi register (data).
6873 * 30 MIPS_COP_0_ERROR_PC .636 Error EPC register.
6874 * 31 MIPS_COP_0_DESAVE .... DESAVE JTAG register.
6875 */
6876
6877/* Deal with inclusion from an assembly file. */
6878#if defined(_LOCORE) || defined(LOCORE)
6879#define _(n) $n
6880#else
6881# 476 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6882#define _(n) n
6883#endif
6884# 478 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6885
6886
6887#define MIPS_COP_0_TLB_INDEX _(0)
6888#define MIPS_COP_0_TLB_RANDOM _(1)
6889 /* Name and meaning of TLB bits for $2 differ on r3k and r4k. */
6890
6891#define MIPS_COP_0_TLB_CONTEXT _(4)
6892 /* $5 and $6 new with MIPS-III */
6893#define MIPS_COP_0_BAD_VADDR _(8)
6894#define MIPS_COP_0_TLB_HI _(10)
6895#define MIPS_COP_0_STATUS _(12)
6896#define MIPS_COP_0_CAUSE _(13)
6897#define MIPS_COP_0_EXC_PC _(14)
6898#define MIPS_COP_0_PRID _(15)
6899
6900/* MIPS-III */
6901#define MIPS_COP_0_TLB_LO0 _(2)
6902#define MIPS_COP_0_TLB_LO1 _(3)
6903
6904#define MIPS_COP_0_TLB_PG_MASK _(5)
6905#define MIPS_COP_0_TLB_WIRED _(6)
6906
6907#define MIPS_COP_0_COUNT _(9)
6908#define MIPS_COP_0_COMPARE _(11)
6909
6910#define MIPS_COP_0_CONFIG _(16)
6911#define MIPS_COP_0_LLADDR _(17)
6912#define MIPS_COP_0_WATCH_LO _(18)
6913#define MIPS_COP_0_WATCH_HI _(19)
6914#define MIPS_COP_0_TLB_XCONTEXT _(20)
6915#define MIPS_COP_0_ECC _(26)
6916#define MIPS_COP_0_CACHE_ERR _(27)
6917#define MIPS_COP_0_TAG_LO _(28)
6918#define MIPS_COP_0_TAG_HI _(29)
6919#define MIPS_COP_0_ERROR_PC _(30)
6920
6921/* MIPS32/64 */
6922#define MIPS_COP_0_USERLOCAL _(4) /* sel 2 is userlevel register */
6923#define MIPS_COP_0_HWRENA _(7)
6924#define MIPS_COP_0_DEBUG _(23)
6925#define MIPS_COP_0_DEPC _(24)
6926#define MIPS_COP_0_PERFCNT _(25)
6927#define MIPS_COP_0_DATA_LO _(28)
6928#define MIPS_COP_0_DATA_HI _(29)
6929#define MIPS_COP_0_DESAVE _(31)
6930
6931/* CHERI */
6932#if defined(CPU_BERI) || defined(CPU_CHERI)
6933#define MIPS_COP_0_EXC_INS _(8) /* sel 1 encoding of instruction causing exception */
6934#endif
6935# 528 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
6936
6937/* MIPS32 Config register definitions */
6938#define MIPS_MMU_NONE 0x00 /* No MMU present */
6939#define MIPS_MMU_TLB 0x01 /* Standard TLB */
6940#define MIPS_MMU_BAT 0x02 /* Standard BAT */
6941#define MIPS_MMU_FIXED 0x03 /* Standard fixed mapping */
6942
6943/*
6944 * Config Register Fields
6945 * (See "MIPS Architecture for Programmers Volume III", MD00091, Table 9.39)
6946 */
6947#define MIPS_CONFIG0_M 0x80000000 /* Flag: Config1 is present. */
6948#define MIPS_CONFIG0_MT_MASK 0x00000380 /* bits 9..7 MMU Type */
6949#define MIPS_CONFIG0_MT_SHIFT 7
6950#define MIPS_CONFIG0_BE 0x00008000 /* data is big-endian */
6951#define MIPS_CONFIG0_VI 0x00000004 /* instruction cache is virtual */
6952
6953/*
6954 * Config1 Register Fields
6955 * (See "MIPS Architecture for Programmers Volume III", MD00091, Table 9-1)
6956 */
6957#define MIPS_CONFIG1_M 0x80000000 /* Flag: Config2 is present. */
6958#define MIPS_CONFIG1_TLBSZ_MASK 0x7E000000 /* bits 30..25 # tlb entries minus one */
6959#define MIPS_CONFIG1_TLBSZ_SHIFT 25
6960
6961#define MIPS_CONFIG1_IS_MASK 0x01C00000 /* bits 24..22 icache sets per way */
6962#define MIPS_CONFIG1_IS_SHIFT 22
6963#define MIPS_CONFIG1_IL_MASK 0x00380000 /* bits 21..19 icache line size */
6964#define MIPS_CONFIG1_IL_SHIFT 19
6965#define MIPS_CONFIG1_IA_MASK 0x00070000 /* bits 18..16 icache associativity */
6966#define MIPS_CONFIG1_IA_SHIFT 16
6967#define MIPS_CONFIG1_DS_MASK 0x0000E000 /* bits 15..13 dcache sets per way */
6968#define MIPS_CONFIG1_DS_SHIFT 13
6969#define MIPS_CONFIG1_DL_MASK 0x00001C00 /* bits 12..10 dcache line size */
6970#define MIPS_CONFIG1_DL_SHIFT 10
6971#define MIPS_CONFIG1_DA_MASK 0x00000380 /* bits 9.. 7 dcache associativity */
6972#define MIPS_CONFIG1_DA_SHIFT 7
6973#define MIPS_CONFIG1_LOWBITS 0x0000007F
6974#define MIPS_CONFIG1_C2 0x00000040 /* Coprocessor 2 implemented */
6975#define MIPS_CONFIG1_MD 0x00000020 /* MDMX ASE implemented (MIPS64) */
6976#define MIPS_CONFIG1_PC 0x00000010 /* Performance counters implemented */
6977#define MIPS_CONFIG1_WR 0x00000008 /* Watch registers implemented */
6978#define MIPS_CONFIG1_CA 0x00000004 /* MIPS16e ISA implemented */
6979#define MIPS_CONFIG1_EP 0x00000002 /* EJTAG implemented */
6980#define MIPS_CONFIG1_FP 0x00000001 /* FPU implemented */
6981
6982/*
6983 * Config2 Register Fields
6984 * (See "MIPS Architecture for Programmers Volume III", MD00091, Table 9.40)
6985 */
6986#define MIPS_CONFIG2_M 0x80000000 /* Flag: Config3 is present. */
6987#define MIPS_CONFIG2_SA_SHIFT 0 /* Secondary cache associativity */
6988#define MIPS_CONFIG2_SA_MASK 0xf
6989#define MIPS_CONFIG2_SL_SHIFT 4 /* Secondary cache line size */
6990#define MIPS_CONFIG2_SL_MASK 0xf
6991#define MIPS_CONFIG2_SS_SHIFT 8 /* Secondary cache sets per way */
6992#define MIPS_CONFIG2_SS_MASK 0xf
6993
6994/*
6995 * Config3 Register Fields
6996 * (See "MIPS Architecture for Programmers Volume III", MD00091, Table 9.41)
6997 */
6998#define MIPS_CONFIG3_M 0x80000000 /* Flag: Config4 is present */
6999#define MIPS_CONFIG3_ULR 0x00002000 /* UserLocal reg implemented */
7000
7001#define MIPS_CONFIG4_MMUSIZEEXT 0x000000FF /* bits 7.. 0 MMU Size Extension */
7002#define MIPS_CONFIG4_MMUEXTDEF 0x0000C000 /* bits 15.14 MMU Extension Definition */
7003#define MIPS_CONFIG4_MMUEXTDEF_MMUSIZEEXT 0x00004000 /* This values denotes CONFIG4 bits */
7004
7005/*
7006 * Values for the code field in a break instruction.
7007 */
7008#define MIPS_BREAK_INSTR 0x0000000d
7009#define MIPS_BREAK_VAL_MASK 0x03ff0000
7010#define MIPS_BREAK_VAL_SHIFT 16
7011#define MIPS_BREAK_KDB_VAL 512
7012#define MIPS_BREAK_SSTEP_VAL 513
7013#define MIPS_BREAK_BRKPT_VAL 514
7014#define MIPS_BREAK_SOVER_VAL 515
7015#define MIPS_BREAK_DDB_VAL 516
7016#define MIPS_BREAK_KDB (MIPS_BREAK_INSTR | \
7017 (MIPS_BREAK_KDB_VAL << MIPS_BREAK_VAL_SHIFT))
7018#define MIPS_BREAK_SSTEP (MIPS_BREAK_INSTR | \
7019 (MIPS_BREAK_SSTEP_VAL << MIPS_BREAK_VAL_SHIFT))
7020#define MIPS_BREAK_BRKPT (MIPS_BREAK_INSTR | \
7021 (MIPS_BREAK_BRKPT_VAL << MIPS_BREAK_VAL_SHIFT))
7022#define MIPS_BREAK_SOVER (MIPS_BREAK_INSTR | \
7023 (MIPS_BREAK_SOVER_VAL << MIPS_BREAK_VAL_SHIFT))
7024#define MIPS_BREAK_DDB (MIPS_BREAK_INSTR | \
7025 (MIPS_BREAK_DDB_VAL << MIPS_BREAK_VAL_SHIFT))
7026
7027/*
7028 * Mininum and maximum cache sizes.
7029 */
7030#define MIPS_MIN_CACHE_SIZE (16 * 1024)
7031#define MIPS_MAX_CACHE_SIZE (256 * 1024)
7032#define MIPS_MAX_PCACHE_SIZE (32 * 1024) /* max. primary cache size */
7033
7034/*
7035 * The floating point version and status registers.
7036 */
7037#define MIPS_FPU_ID $0
7038#define MIPS_FPU_CSR $31
7039
7040/*
7041 * The floating point coprocessor status register bits.
7042 */
7043#define MIPS_FPU_ROUNDING_BITS 0x00000003
7044#define MIPS_FPU_ROUND_RN 0x00000000
7045#define MIPS_FPU_ROUND_RZ 0x00000001
7046#define MIPS_FPU_ROUND_RP 0x00000002
7047#define MIPS_FPU_ROUND_RM 0x00000003
7048#define MIPS_FPU_STICKY_BITS 0x0000007c
7049#define MIPS_FPU_STICKY_INEXACT 0x00000004
7050#define MIPS_FPU_STICKY_UNDERFLOW 0x00000008
7051#define MIPS_FPU_STICKY_OVERFLOW 0x00000010
7052#define MIPS_FPU_STICKY_DIV0 0x00000020
7053#define MIPS_FPU_STICKY_INVALID 0x00000040
7054#define MIPS_FPU_ENABLE_BITS 0x00000f80
7055#define MIPS_FPU_ENABLE_INEXACT 0x00000080
7056#define MIPS_FPU_ENABLE_UNDERFLOW 0x00000100
7057#define MIPS_FPU_ENABLE_OVERFLOW 0x00000200
7058#define MIPS_FPU_ENABLE_DIV0 0x00000400
7059#define MIPS_FPU_ENABLE_INVALID 0x00000800
7060#define MIPS_FPU_EXCEPTION_BITS 0x0003f000
7061#define MIPS_FPU_EXCEPTION_INEXACT 0x00001000
7062#define MIPS_FPU_EXCEPTION_UNDERFLOW 0x00002000
7063#define MIPS_FPU_EXCEPTION_OVERFLOW 0x00004000
7064#define MIPS_FPU_EXCEPTION_DIV0 0x00008000
7065#define MIPS_FPU_EXCEPTION_INVALID 0x00010000
7066#define MIPS_FPU_EXCEPTION_UNIMPL 0x00020000
7067#define MIPS_FPU_COND_BIT 0x00800000
7068#define MIPS_FPU_FLUSH_BIT 0x01000000 /* r4k, MBZ on r3k */
7069#define MIPS_FPC_MBZ_BITS 0xfe7c0000
7070
7071
7072/*
7073 * Constants to determine if have a floating point instruction.
7074 */
7075#define MIPS_OPCODE_SHIFT 26
7076#define MIPS_OPCODE_C1 0x11
7077
7078/*
7079 * Bits defined for for the HWREna (CP0 register 7, select 0).
7080 */
7081#define MIPS_HWRENA_CPUNUM (1<<0) /* CPU number program is running on */
7082#define MIPS_HWRENA_SYNCI_STEP (1<<1) /* Address step sized used with SYNCI */
7083#define MIPS_HWRENA_CC (1<<2) /* Hi Res cycle counter */
7084#define MIPS_HWRENA_CCRES (1<<3) /* Cycle counter resolution */
7085#define MIPS_HWRENA_UL (1<<29) /* UserLocal Register */
7086#define MIPS_HWRENA_IMPL30 (1<<30) /* Implementation-dependent 30 */
7087#define MIPS_HWRENA_IMPL31 (1<<31) /* Implementation-dependent 31 */
7088
7089#endif /* _MIPS_CPUREGS_H_ */
7090# 682 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cpuregs.h" 3 4
7091# 46 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
7092
7093#if 0 /* expanded by -frewrite-includes */
7094#include <cheri/cheri_fd.h>
7095#endif /* expanded by -frewrite-includes */
7096# 47 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
7097# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri_fd.h" 1 3 4
7098/*-
7099 * Copyright (c) 2014-2015 Robert N. M. Watson
7100 * All rights reserved.
7101 *
7102 * This software was developed by SRI International and the University of
7103 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7104 * ("CTSRD"), as part of the DARPA CRASH research programme.
7105 *
7106 * Redistribution and use in source and binary forms, with or without
7107 * modification, are permitted provided that the following conditions
7108 * are met:
7109 * 1. Redistributions of source code must retain the above copyright
7110 * notice, this list of conditions and the following disclaimer.
7111 * 2. Redistributions in binary form must reproduce the above copyright
7112 * notice, this list of conditions and the following disclaimer in the
7113 * documentation and/or other materials provided with the distribution.
7114 *
7115 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7116 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7117 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7118 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7119 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7120 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7121 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7122 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7123 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7124 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7125 * SUCH DAMAGE.
7126 */
7127
7128#ifndef _CHERI_FD_H_
7129#define _CHERI_FD_H_
7130
7131extern __capability intptr_t *cheri_fd_vtable;
7132
7133extern struct cheri_object cheri_fd;
7134#ifdef CHERI_FD_INTERNAL
7135#define CHERI_FD_CCALL \
7136 __attribute__((cheri_ccallee)) \
7137 __attribute__((cheri_method_suffix("_c"))) \
7138 __attribute__((cheri_method_class(cheri_fd)))
7139#else
7140# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri_fd.h" 3 4
7141#define CHERI_FD_CCALL \
7142 __attribute__((cheri_ccall)) \
7143 __attribute__((cheri_method_suffix("_c"))) \
7144 __attribute__((cheri_method_class(cheri_fd)))
7145#endif
7146# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri_fd.h" 3 4
7147
7148
7149/*
7150 * Interfaces to create/revoke/destroy cheri_fd objects with ambient
7151 * authority.
7152 */
7153int cheri_fd_new(int fd, struct cheri_object *cop);
7154void cheri_fd_revoke(struct cheri_object co);
7155void cheri_fd_destroy(struct cheri_object co);
7156
7157/*
7158 * All methods return the following structure, which fits in register return
7159 * values for the calling convention. In practice, retval0 is what we think
7160 * of as the normal return value for each method; retval1 holds an errno value
7161 * if retval0 == -1. This is near-identical to the semantics of the kernel's
7162 * td_retval[0,1].
7163 */
7164struct cheri_fd_ret {
7165 register_t cfr_retval0; /* Actual return value. */
7166 register_t cfr_retval1; /* errno if cfr_retval0 == -1. */
7167};
7168
7169/*
7170 * Methods that can be invoked on cheri_fd objects regardless of ambient
7171 * authority.
7172 */
7173struct stat;
7174CHERI_FD_CCALL
7175struct cheri_fd_ret cheri_fd_fstat(__capability struct stat *sb_c);
7176CHERI_FD_CCALL
7177struct cheri_fd_ret cheri_fd_lseek(off_t offset, int whence);
7178CHERI_FD_CCALL
7179struct cheri_fd_ret cheri_fd_read(__capability void *buf_c,
7180 size_t nbytes);
7181CHERI_FD_CCALL
7182struct cheri_fd_ret cheri_fd_write(__capability const void *buf_c,
7183 size_t nbytes);
7184
7185#endif /* !_CHERI_FD_H_ */
7186# 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri_fd.h" 3 4
7187# 48 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
7188#if 0 /* expanded by -frewrite-includes */
7189#include <cheri/sandbox.h>
7190#endif /* expanded by -frewrite-includes */
7191# 48 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
7192# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/sandbox.h" 1 3 4
7193/*-
7194 * Copyright (c) 2012-2015 Robert N. M. Watson
7195 * Copyright (c) 2015 SRI International
7196 * All rights reserved.
7197 *
7198 * This software was developed by SRI International and the University of
7199 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7200 * ("CTSRD"), as part of the DARPA CRASH research programme.
7201 *
7202 * Redistribution and use in source and binary forms, with or without
7203 * modification, are permitted provided that the following conditions
7204 * are met:
7205 * 1. Redistributions of source code must retain the above copyright
7206 * notice, this list of conditions and the following disclaimer.
7207 * 2. Redistributions in binary form must reproduce the above copyright
7208 * notice, this list of conditions and the following disclaimer in the
7209 * documentation and/or other materials provided with the distribution.
7210 *
7211 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7212 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7213 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7214 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7215 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7216 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7217 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7218 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7219 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7220 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7221 * SUCH DAMAGE.
7222 */
7223
7224#ifndef _SANDBOX_H_
7225#define _SANDBOX_H_
7226
7227/*
7228 * This section defines the interface between 'inside' and 'outside' the
7229 * sandbox model.
7230 */
7231
7232/*
7233 * Per-sandbox meta-data structure mapped read-only within the sandbox at a
7234 * fixed address to allow sandboxed code to find its stack, heap, etc.
7235 *
7236 * NB: This data structure (and its base address) are part of the ABI between
7237 * libcheri and programs running in sandboxes. Only ever append to this,
7238 * don't modify the order, lengths, or interpretations of existing fields. If
7239 * this reaches a page in size, then allocation code in sandbox.c will need
7240 * updating. See also sandbox.c and sandboxasm.h.
7241 */
7242struct sandbox_metadata {
7243 register_t sbm_heapbase; /* Offset: 0 */
7244 register_t sbm_heaplen; /* Offset: 8 */
7245 uint64_t _sbm_reserved0; /* Offset: 16 */
7246 uint64_t _sbm_reserved1; /* Offset: 24 */
7247 struct cheri_object sbm_system_object; /* Offset: 32 */
7248#if __has_feature(capabilities)
7249 __capability intptr_t *sbm_vtable; /* Cap-offset: 2 */
7250 __capability void *sbm_stackcap; /* Cap-offset: 3 */
7251#else
7252# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/sandbox.h" 3 4
7253 struct chericap sbm_vtable;
7254 struct chericap sbm_stackcap;
7255#endif
7256# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/sandbox.h" 3 4
7257};
7258
7259/*
7260 * This section defines interfaces for setting up, invoking, resetting, and
7261 * destroying sandbox classes and objects.
7262 */
7263
7264extern int sb_verbose;
7265
7266struct sandbox_class;
7267int sandbox_class_new(const char *path, size_t maxmapsize,
7268 struct sandbox_class **sbcpp);
7269int sandbox_class_method_declare(struct sandbox_class *sbcp,
7270 u_int methodnum, const char *methodname);
7271void *sandbox_class_getbase(struct sandbox_class *sbcp);
7272size_t sandbox_class_getlength(struct sandbox_class *sbcp);
7273void sandbox_class_destroy(struct sandbox_class *sbcp);
7274
7275struct sandbox_object;
7276int sandbox_object_new(struct sandbox_class *sbcp, size_t heaplen,
7277 struct sandbox_object **sbopp);
7278int sandbox_object_new_flags(struct sandbox_class *sbcp, size_t heaplen,
7279 uint flags, struct sandbox_object **sbopp);
7280int sandbox_object_reset(struct sandbox_object *sbop);
7281void *sandbox_object_getbase(struct sandbox_object *sbop);
7282size_t sandbox_object_getlength(struct sandbox_object *sbop);
7283#if __has_feature(capabilities)
7284register_t sandbox_object_cinvoke(struct sandbox_object *sbop,
7285 register_t methodnum, register_t a1,
7286 register_t a2, register_t a3, register_t a4,
7287 register_t a5, register_t a6, register_t a7,
7288 __capability void *c3, __capability void *c4,
7289 __capability void *c5, __capability void *c6,
7290 __capability void *c7, __capability void *c8,
7291 __capability void *c9, __capability void *c10);
7292#endif
7293# 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/sandbox.h" 3 4
7294register_t sandbox_object_invoke(struct sandbox_object *sbop,
7295 register_t methodnum, register_t a1,
7296 register_t a2, register_t a3, register_t a4,
7297 register_t a5, register_t a6, register_t a7,
7298 struct chericap *c3p, struct chericap *c4p,
7299 struct chericap *c5p, struct chericap *c6p,
7300 struct chericap *c7p, struct chericap *c8p,
7301 struct chericap *c9p, struct chericap *c10p);
7302void sandbox_object_destroy(struct sandbox_object *sbop);
7303
7304/*
7305 * Flags for sandbox_object_new_flags():
7306 */
7307#define SANDBOX_OBJECT_FLAG_CONSOLE 0x00000001 /* printf(), etc. */
7308#define SANDBOX_OBJECT_FLAG_ALLOCFREE 0x00000002 /* calloc(), free(). */
7309#define SANDBOX_OBJECT_FLAG_USERFN 0x00000004 /* User callbacks. */
7310
7311/*
7312 * API to query the object-capability pair for the sandbox itself
7313 */
7314struct cheri_object sandbox_object_getobject(struct sandbox_object *sbop);
7315
7316/*
7317 * API to query system capabilities for use by sandboxes.
7318 */
7319struct cheri_object sandbox_object_getsystemobject(
7320 struct sandbox_object *sbop);
7321
7322#endif /* !_SANDBOX_H_ */
7323# 128 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/sandbox.h" 3 4
7324# 49 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
7325
7326#if 0 /* expanded by -frewrite-includes */
7327#include <cheritest-helper.h>
7328#endif /* expanded by -frewrite-includes */
7329# 50 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
7330# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 1 3 4
7331/*-
7332 * Copyright (c) 2013-2015 Robert N. M. Watson
7333 * Copyright (c) 2014-2015 SRI International
7334 * All rights reserved.
7335 *
7336 * This software was developed by SRI International and the University of
7337 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7338 * ("CTSRD"), as part of the DARPA CRASH research programme.
7339 *
7340 * Redistribution and use in source and binary forms, with or without
7341 * modification, are permitted provided that the following conditions
7342 * are met:
7343 * 1. Redistributions of source code must retain the above copyright
7344 * notice, this list of conditions and the following disclaimer.
7345 * 2. Redistributions in binary form must reproduce the above copyright
7346 * notice, this list of conditions and the following disclaimer in the
7347 * documentation and/or other materials provided with the distribution.
7348 *
7349 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7350 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7351 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7352 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7353 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7354 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7355 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7356 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7357 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7358 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7359 * SUCH DAMAGE.
7360 */
7361
7362#ifndef _LIBEXEC_CHERITEST_CHERITEST_HELPER_H_
7363#define _LIBEXEC_CHERITEST_CHERITEST_HELPER_H_
7364
7365#define CHERITEST_HELPER_CAP_FAULT_CP2_BOUND 1
7366#define CHERITEST_HELPER_CAP_FAULT_CP2_PERM_LOAD 2
7367#define CHERITEST_HELPER_CAP_FAULT_CP2_PERM_STORE 3
7368#define CHERITEST_HELPER_CAP_FAULT_CP2_TAG 4
7369#define CHERITEST_HELPER_CAP_FAULT_CP2_SEAL 5
7370
7371#define CHERITEST_HELPER_VM_FAULT_RFAULT 1
7372#define CHERITEST_HELPER_VM_FAULT_WFAULT 2
7373#define CHERITEST_HELPER_VM_FAULT_XFAULT 3
7374
7375/*
7376 * We use system-class extensions to allow cheritest-helper code to call back
7377 * into cheritest to exercise various cases (e.g., stack-related tests).
7378 * These are the corresponding method numbers.
7379 */
7380#define CHERITEST_USERFN_RETURNARG (CHERI_SYSTEM_USER_BASE)
7381#define CHERITEST_USERFN_GETSTACK (CHERI_SYSTEM_USER_BASE + 1)
7382#define CHERITEST_USERFN_SETSTACK (CHERI_SYSTEM_USER_BASE + 2)
7383
7384/*
7385 * Constants used to test BSS, .data, and constructor-based variable
7386 * initialisation in sandboxes.
7387 */
7388#define CHERITEST_VALUE_BSS 0x00 /* Of course. */
7389#define CHERITEST_VALUE_DATA 0xaa
7390#define CHERITEST_VALUE_INVALID 0xbb
7391#define CHERITEST_VALUE_CONSTRUCTOR 0xcc
7392
7393
7394#ifdef LIST_ONLY
7395#define CHERITEST_CCALL
7396#define CHERITEST_CCALL2
7397#define BEGIN_CAPABILITIES
7398#define END_CAPABILITIES
7399#else
7400# 70 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7401#if __has_feature(pointer_interpretation)
7402#define BEGIN_CAPABILITIES \
7403 _Pragma("pointer_interpretation push") \
7404 _Pragma("pointer_interpretation capability")
7405#define END_CAPABILITIES \
7406 _Pragma("pointer_interpretation pop")
7407#else
7408# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7409#error Compiler does not support capabilities.
7410#endif
7411# 79 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7412extern struct cheri_object cheritest;
7413#ifdef CHERITEST_INTERNAL
7414#define CHERITEST_CCALL \
7415 __attribute__((cheri_ccallee)) \
7416 __attribute__((cheri_method_class(cheritest)))
7417#else
7418# 85 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7419#define CHERITEST_CCALL \
7420 __attribute__((cheri_ccall)) \
7421 __attribute__((cheri_method_suffix("_cap"))) \
7422 __attribute__((cheri_method_class(cheritest)))
7423#endif
7424# 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7425extern struct cheri_object cheritest2;
7426#ifdef CHERITEST_INTERNAL
7427#define CHERITEST_CCALL2 \
7428 __attribute__((cheri_ccallee)) \
7429 __attribute__((cheri_method_class(cheritest2)))
7430#else
7431# 96 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7432#define CHERITEST_CCALL2 \
7433 __attribute__((cheri_ccall)) \
7434 __attribute__((cheri_method_suffix("_cap"))) \
7435 __attribute__((cheri_method_class(cheritest2)))
7436#endif
7437# 101 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7438#endif
7439# 102 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7440
7441struct cheri_object;
7442
7443BEGIN_CAPABILITIES
7444CHERITEST_CCALL int invoke_divzero(void);
7445CHERITEST_CCALL int invoke_cheri_system_helloworld(void);
7446CHERITEST_CCALL int invoke_cheri_system_puts(void);
7447CHERITEST_CCALL int invoke_cheri_system_putchar(void);
7448CHERITEST_CCALL int invoke_cheri_system_printf(void);
7449
7450CHERITEST_CCALL int invoke_abort(void);
7451CHERITEST_CCALL int invoke_md5(size_t len, char *data_input,
7452 char *data_output);
7453CHERITEST_CCALL int invoke_cap_fault(register_t op);
7454CHERITEST_CCALL int invoke_vm_fault(register_t op);
7455CHERITEST_CCALL int invoke_syscall(void);
7456CHERITEST_CCALL int invoke_fd_fstat_c(struct cheri_object fd_object);
7457CHERITEST_CCALL int invoke_fd_lseek_c(struct cheri_object fd_object);
7458CHERITEST_CCALL int invoke_fd_read_c(struct cheri_object fd_object,
7459 void *buf, size_t nbytes);
7460CHERITEST_CCALL int invoke_fd_write_c(struct cheri_object fd_object,
7461 char *arg, size_t nbytes);
7462CHERITEST_CCALL int invoke_malloc(void);
7463CHERITEST_CCALL int invoke_system_calloc(void);
7464CHERITEST_CCALL int invoke_clock_gettime(void);
7465CHERITEST_CCALL int invoke_libcheri_userfn(register_t arg, size_t len);
7466CHERITEST_CCALL int invoke_libcheri_userfn_setstack(register_t arg);
7467CHERITEST_CCALL int invoke_libcheri_save_capability_in_heap(
7468 void *data_input);
7469
7470CHERITEST_CCALL register_t invoke_get_var_bss(void);
7471CHERITEST_CCALL register_t invoke_get_var_data(void);
7472CHERITEST_CCALL register_t invoke_set_var_data(register_t v);
7473CHERITEST_CCALL register_t invoke_get_var_constructor(void);
7474struct zstream_proxy;
7475CHERITEST_CCALL register_t invoke_inflate(struct zstream_proxy *zspp);
7476CHERITEST_CCALL register_t invoke_spin(void);
7477
7478/* Test calling with a different default object */
7479CHERITEST_CCALL2 int call_invoke_md5(size_t len, char *data_input,
7480 char *data_output);
7481
7482CHERITEST_CCALL int sandbox_test_ptrdiff(void);
7483CHERITEST_CCALL int sandbox_test_varargs(void);
7484CHERITEST_CCALL int sandbox_test_va_copy(void);
7485END_CAPABILITIES
7486
7487#endif /* !_LIBEXEC_CHERITEST_CHERITEST_HELPER_H_ */
7488# 150 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheritest-helper.h" 3 4
7489# 51 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
7490#if 0 /* expanded by -frewrite-includes */
7491#include <err.h>
7492#endif /* expanded by -frewrite-includes */
7493# 51 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
7494# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/err.h" 1 3 4
7495/*-
7496 * Copyright (c) 1993
7497 * The Regents of the University of California. All rights reserved.
7498 *
7499 * Redistribution and use in source and binary forms, with or without
7500 * modification, are permitted provided that the following conditions
7501 * are met:
7502 * 1. Redistributions of source code must retain the above copyright
7503 * notice, this list of conditions and the following disclaimer.
7504 * 2. Redistributions in binary form must reproduce the above copyright
7505 * notice, this list of conditions and the following disclaimer in the
7506 * documentation and/or other materials provided with the distribution.
7507 * 3. Neither the name of the University nor the names of its contributors
7508 * may be used to endorse or promote products derived from this software
7509 * without specific prior written permission.
7510 *
7511 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
7512 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7513 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7514 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
7515 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7516 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7517 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7518 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7519 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7520 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7521 * SUCH DAMAGE.
7522 *
7523 * @(#)err.h 8.1 (Berkeley) 6/2/93
7524 * $FreeBSD$
7525 */
7526
7527#ifndef _ERR_H_
7528#define _ERR_H_
7529
7530/*
7531 * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two
7532 * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
7533 * of them here we may collide with the utility's includes. It's unreasonable
7534 * for utilities to have to include one of them to include err.h, so we get
7535 * __va_list from <sys/_types.h> and use it.
7536 */
7537#if 0 /* expanded by -frewrite-includes */
7538#include <sys/cdefs.h>
7539#endif /* expanded by -frewrite-includes */
7540# 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/err.h" 3 4
7541# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/err.h" 3 4
7542#if 0 /* expanded by -frewrite-includes */
7543#include <sys/_types.h>
7544#endif /* expanded by -frewrite-includes */
7545# 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/err.h" 3 4
7546# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/err.h" 3 4
7547
7548__BEGIN_DECLS
7549void err(int, const char *, ...) __dead2 __printf0like(2, 3);
7550void verr(int, const char *, __va_list) __dead2 __printf0like(2, 0);
7551void errc(int, int, const char *, ...) __dead2 __printf0like(3, 4);
7552void verrc(int, int, const char *, __va_list) __dead2
7553 __printf0like(3, 0);
7554void errx(int, const char *, ...) __dead2 __printf0like(2, 3);
7555void verrx(int, const char *, __va_list) __dead2 __printf0like(2, 0);
7556void warn(const char *, ...) __printf0like(1, 2);
7557void vwarn(const char *, __va_list) __printf0like(1, 0);
7558void warnc(int, const char *, ...) __printf0like(2, 3);
7559void vwarnc(int, const char *, __va_list) __printf0like(2, 0);
7560void warnx(const char *, ...) __printflike(1, 2);
7561void vwarnx(const char *, __va_list) __printflike(1, 0);
7562void err_set_file(void *);
7563void err_set_exit(void (*)(int));
7564__END_DECLS
7565
7566#endif /* !_ERR_H_ */
7567# 65 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/err.h" 3 4
7568# 52 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
7569#if 0 /* expanded by -frewrite-includes */
7570#include <fcntl.h>
7571#endif /* expanded by -frewrite-includes */
7572# 52 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
7573# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 1 3 4
7574/*-
7575 * Copyright (c) 1983, 1990, 1993
7576 * The Regents of the University of California. All rights reserved.
7577 * (c) UNIX System Laboratories, Inc.
7578 * All or some portions of this file are derived from material licensed
7579 * to the University of California by American Telephone and Telegraph
7580 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
7581 * the permission of UNIX System Laboratories, Inc.
7582 *
7583 * Redistribution and use in source and binary forms, with or without
7584 * modification, are permitted provided that the following conditions
7585 * are met:
7586 * 1. Redistributions of source code must retain the above copyright
7587 * notice, this list of conditions and the following disclaimer.
7588 * 2. Redistributions in binary form must reproduce the above copyright
7589 * notice, this list of conditions and the following disclaimer in the
7590 * documentation and/or other materials provided with the distribution.
7591 * 4. Neither the name of the University nor the names of its contributors
7592 * may be used to endorse or promote products derived from this software
7593 * without specific prior written permission.
7594 *
7595 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
7596 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7597 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7598 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
7599 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7600 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7601 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7602 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7603 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7604 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7605 * SUCH DAMAGE.
7606 *
7607 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
7608 * $FreeBSD$
7609 */
7610
7611#ifndef _SYS_FCNTL_H_
7612#define _SYS_FCNTL_H_
7613
7614/*
7615 * This file includes the definitions for open and fcntl
7616 * described by POSIX for <fcntl.h>; it also includes
7617 * related kernel definitions.
7618 */
7619
7620#if 0 /* expanded by -frewrite-includes */
7621#include <sys/cdefs.h>
7622#endif /* expanded by -frewrite-includes */
7623# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7624# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7625#if 0 /* expanded by -frewrite-includes */
7626#include <sys/_types.h>
7627#endif /* expanded by -frewrite-includes */
7628# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7629# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7630
7631#ifndef _MODE_T_DECLARED
7632typedef __mode_t mode_t;
7633#define _MODE_T_DECLARED
7634#endif
7635# 54 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7636
7637#ifndef _OFF_T_DECLARED
7638typedef __off_t off_t;
7639#define _OFF_T_DECLARED
7640#endif
7641# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7642
7643#ifndef _PID_T_DECLARED
7644typedef __pid_t pid_t;
7645#define _PID_T_DECLARED
7646#endif
7647# 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7648
7649/*
7650 * File status flags: these are used by open(2), fcntl(2).
7651 * They are also used (indirectly) in the kernel file structure f_flags,
7652 * which is a superset of the open/fcntl flags. Open flags and f_flags
7653 * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
7654 * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
7655 */
7656/* open-only flags */
7657#define O_RDONLY 0x0000 /* open for reading only */
7658#define O_WRONLY 0x0001 /* open for writing only */
7659#define O_RDWR 0x0002 /* open for reading and writing */
7660#define O_ACCMODE 0x0003 /* mask for above modes */
7661
7662/*
7663 * Kernel encoding of open mode; separate read and write bits that are
7664 * independently testable: 1 greater than the above.
7665 *
7666 * XXX
7667 * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
7668 * which was documented to use FREAD/FWRITE, continues to work.
7669 */
7670#if __BSD_VISIBLE
7671#define FREAD 0x0001
7672#define FWRITE 0x0002
7673#endif
7674# 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7675#define O_NONBLOCK 0x0004 /* no delay */
7676#define O_APPEND 0x0008 /* set append mode */
7677#if __BSD_VISIBLE
7678#define O_SHLOCK 0x0010 /* open with shared file lock */
7679#define O_EXLOCK 0x0020 /* open with exclusive file lock */
7680#define O_ASYNC 0x0040 /* signal pgrp when data ready */
7681#define O_FSYNC 0x0080 /* synchronous writes */
7682#endif
7683# 98 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7684#define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */
7685#if __POSIX_VISIBLE >= 200809
7686#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
7687#endif
7688# 102 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7689#define O_CREAT 0x0200 /* create if nonexistent */
7690#define O_TRUNC 0x0400 /* truncate to zero length */
7691#define O_EXCL 0x0800 /* error if already exists */
7692#ifdef _KERNEL
7693#define FHASLOCK 0x4000 /* descriptor holds advisory lock */
7694#endif
7695# 108 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7696
7697/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */
7698#define O_NOCTTY 0x8000 /* don't assign controlling terminal */
7699
7700#if __BSD_VISIBLE
7701/* Attempt to bypass buffer cache */
7702#define O_DIRECT 0x00010000
7703#endif
7704# 116 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7705
7706#if __POSIX_VISIBLE >= 200809
7707#define O_DIRECTORY 0x00020000 /* Fail if not directory */
7708#define O_EXEC 0x00040000 /* Open for execute only */
7709#endif
7710# 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7711#ifdef _KERNEL
7712#define FEXEC O_EXEC
7713#endif
7714# 124 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7715
7716#if __POSIX_VISIBLE >= 200809
7717/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */
7718#define O_TTY_INIT 0x00080000 /* Restore default termios attributes */
7719
7720#define O_CLOEXEC 0x00100000
7721#endif
7722# 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7723
7724#if __BSD_VISIBLE
7725#define O_VERIFY 0x00200000 /* open only after verification */
7726#endif
7727# 135 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7728
7729/*
7730 * XXX missing O_DSYNC, O_RSYNC.
7731 */
7732
7733#ifdef _KERNEL
7734/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
7735#define FFLAGS(oflags) ((oflags) & O_EXEC ? (oflags) : (oflags) + 1)
7736#define OFLAGS(fflags) ((fflags) & O_EXEC ? (fflags) : (fflags) - 1)
7737
7738/* bits to save after open */
7739#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT|FEXEC)
7740/* bits settable by fcntl(F_SETFL, ...) */
7741#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FRDAHEAD|O_DIRECT)
7742
7743#if defined(COMPAT_FREEBSD7) || defined(COMPAT_FREEBSD6) || \
7744 defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4)
7745/*
7746 * Set by shm_open(3) in older libc's to get automatic MAP_ASYNC
7747 * behavior for POSIX shared memory objects (which are otherwise
7748 * implemented as plain files).
7749 */
7750#define FPOSIXSHM O_NOFOLLOW
7751#undef FCNTLFLAGS
7752#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|FRDAHEAD| \
7753 O_DIRECT)
7754#endif
7755# 162 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7756#endif
7757# 163 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7758
7759/*
7760 * The O_* flags used to have only F* names, which were used in the kernel
7761 * and by fcntl. We retain the F* names for the kernel f_flag field
7762 * and for backward compatibility for fcntl. These flags are deprecated.
7763 */
7764#if __BSD_VISIBLE
7765#define FAPPEND O_APPEND /* kernel/compat */
7766#define FASYNC O_ASYNC /* kernel/compat */
7767#define FFSYNC O_FSYNC /* kernel */
7768#define FNONBLOCK O_NONBLOCK /* kernel */
7769#define FNDELAY O_NONBLOCK /* compat */
7770#define O_NDELAY O_NONBLOCK /* compat */
7771#endif
7772# 177 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7773
7774/*
7775 * We are out of bits in f_flag (which is a short). However,
7776 * the flag bits not set in FMASK are only meaningful in the
7777 * initial open syscall. Those bits can thus be given a
7778 * different meaning for fcntl(2).
7779 */
7780#if __BSD_VISIBLE
7781/* Read ahead */
7782#define FRDAHEAD O_CREAT
7783#endif
7784# 188 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7785
7786#if __POSIX_VISIBLE >= 200809
7787/*
7788 * Magic value that specify the use of the current working directory
7789 * to determine the target of relative file paths in the openat() and
7790 * similar syscalls.
7791 */
7792#define AT_FDCWD -100
7793
7794/*
7795 * Miscellaneous flags for the *at() syscalls.
7796 */
7797#define AT_EACCESS 0x100 /* Check access using effective user and group ID */
7798#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symbolic links */
7799#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic link */
7800#define AT_REMOVEDIR 0x800 /* Remove directory instead of file */
7801#endif
7802# 205 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7803
7804/*
7805 * Constants used for fcntl(2)
7806 */
7807
7808/* command values */
7809#define F_DUPFD 0 /* duplicate file descriptor */
7810#define F_GETFD 1 /* get file descriptor flags */
7811#define F_SETFD 2 /* set file descriptor flags */
7812#define F_GETFL 3 /* get file status flags */
7813#define F_SETFL 4 /* set file status flags */
7814#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
7815#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
7816#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
7817#endif
7818# 220 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7819#if __BSD_VISIBLE
7820#define F_OGETLK 7 /* get record locking information */
7821#define F_OSETLK 8 /* set record locking information */
7822#define F_OSETLKW 9 /* F_SETLK; wait if blocked */
7823#define F_DUP2FD 10 /* duplicate file descriptor to arg */
7824#endif
7825# 226 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7826#define F_GETLK 11 /* get record locking information */
7827#define F_SETLK 12 /* set record locking information */
7828#define F_SETLKW 13 /* F_SETLK; wait if blocked */
7829#if __BSD_VISIBLE
7830#define F_SETLK_REMOTE 14 /* debugging support for remote locks */
7831#define F_READAHEAD 15 /* read ahead */
7832#define F_RDAHEAD 16 /* Darwin compatible read ahead */
7833#endif
7834# 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7835#if __POSIX_VISIBLE >= 200809
7836#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
7837#endif
7838# 237 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7839#if __BSD_VISIBLE
7840#define F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */
7841#endif
7842# 240 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7843
7844/* file descriptor flags (F_GETFD, F_SETFD) */
7845#define FD_CLOEXEC 1 /* close-on-exec flag */
7846
7847/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
7848#define F_RDLCK 1 /* shared or read lock */
7849#define F_UNLCK 2 /* unlock */
7850#define F_WRLCK 3 /* exclusive or write lock */
7851#if __BSD_VISIBLE
7852#define F_UNLCKSYS 4 /* purge locks for a given system ID */
7853#define F_CANCEL 5 /* cancel an async lock request */
7854#endif
7855# 252 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7856#ifdef _KERNEL
7857#define F_WAIT 0x010 /* Wait until lock is granted */
7858#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */
7859#define F_POSIX 0x040 /* Use POSIX semantics for lock */
7860#define F_REMOTE 0x080 /* Lock owner is remote NFS client */
7861#define F_NOINTR 0x100 /* Ignore signals when waiting */
7862#endif
7863# 259 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7864
7865/*
7866 * Advisory file segment locking data type -
7867 * information passed to system by user
7868 */
7869struct flock {
7870 off_t l_start; /* starting offset */
7871 off_t l_len; /* len = 0 means until end of file */
7872 pid_t l_pid; /* lock owner */
7873 short l_type; /* lock type: read/write, etc. */
7874 short l_whence; /* type of l_start */
7875 int l_sysid; /* remote system id or zero for local */
7876};
7877
7878#if __BSD_VISIBLE
7879/*
7880 * Old advisory file segment locking data type,
7881 * before adding l_sysid.
7882 */
7883struct __oflock {
7884 off_t l_start; /* starting offset */
7885 off_t l_len; /* len = 0 means until end of file */
7886 pid_t l_pid; /* lock owner */
7887 short l_type; /* lock type: read/write, etc. */
7888 short l_whence; /* type of l_start */
7889};
7890#endif
7891# 286 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7892
7893#if __BSD_VISIBLE
7894/* lock operations for flock(2) */
7895#define LOCK_SH 0x01 /* shared file lock */
7896#define LOCK_EX 0x02 /* exclusive file lock */
7897#define LOCK_NB 0x04 /* don't block when locking */
7898#define LOCK_UN 0x08 /* unlock file */
7899#endif
7900# 294 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7901
7902#if __POSIX_VISIBLE >= 200112
7903/*
7904 * Advice to posix_fadvise
7905 */
7906#define POSIX_FADV_NORMAL 0 /* no special treatment */
7907#define POSIX_FADV_RANDOM 1 /* expect random page references */
7908#define POSIX_FADV_SEQUENTIAL 2 /* expect sequential page references */
7909#define POSIX_FADV_WILLNEED 3 /* will need these pages */
7910#define POSIX_FADV_DONTNEED 4 /* dont need these pages */
7911#define POSIX_FADV_NOREUSE 5 /* access data only once */
7912#endif
7913# 306 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7914
7915#ifndef _KERNEL
7916__BEGIN_DECLS
7917int open(const char *, int, ...);
7918int creat(const char *, mode_t);
7919int fcntl(int, int, ...);
7920#if __BSD_VISIBLE
7921int flock(int, int);
7922#endif
7923# 315 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7924#if __POSIX_VISIBLE >= 200809
7925int openat(int, const char *, int, ...);
7926#endif
7927# 318 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7928#if __POSIX_VISIBLE >= 200112
7929int posix_fadvise(int, off_t, off_t, int);
7930int posix_fallocate(int, off_t, off_t);
7931#endif
7932# 322 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7933__END_DECLS
7934#endif
7935# 324 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7936
7937#endif /* !_SYS_FCNTL_H_ */
7938# 326 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/fcntl.h" 3 4
7939# 53 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
7940#if 0 /* expanded by -frewrite-includes */
7941#include <inttypes.h>
7942#endif /* expanded by -frewrite-includes */
7943# 53 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
7944# 1 "/home/rnw24/git/llvm/Build/bin/../lib/clang/3.8.0/include/inttypes.h" 1 3 4
7945/*===---- inttypes.h - Standard header for integer printf macros ----------===*\
7946 *
7947 * Permission is hereby granted, free of charge, to any person obtaining a copy
7948 * of this software and associated documentation files (the "Software"), to deal
7949 * in the Software without restriction, including without limitation the rights
7950 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7951 * copies of the Software, and to permit persons to whom the Software is
7952 * furnished to do so, subject to the following conditions:
7953 *
7954 * The above copyright notice and this permission notice shall be included in
7955 * all copies or substantial portions of the Software.
7956 *
7957 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7958 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7959 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7960 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7961 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7962 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
7963 * THE SOFTWARE.
7964 *
7965\*===----------------------------------------------------------------------===*/
7966
7967#ifndef __CLANG_INTTYPES_H
7968#define __CLANG_INTTYPES_H
7969
7970#if 0 /* expanded by -frewrite-includes */
7971#include_next <inttypes.h>
7972#endif /* expanded by -frewrite-includes */
7973# 26 "/home/rnw24/git/llvm/Build/bin/../lib/clang/3.8.0/include/inttypes.h" 3 4
7974# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 1 3 4
7975/*-
7976 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
7977 * All rights reserved.
7978 *
7979 * Redistribution and use in source and binary forms, with or without
7980 * modification, are permitted provided that the following conditions
7981 * are met:
7982 * 1. Redistributions of source code must retain the above copyright
7983 * notice, this list of conditions and the following disclaimer.
7984 * 2. Redistributions in binary form must reproduce the above copyright
7985 * notice, this list of conditions and the following disclaimer in the
7986 * documentation and/or other materials provided with the distribution.
7987 *
7988 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7989 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7990 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7991 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
7992 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7993 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7994 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7995 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7996 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7997 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7998 * SUCH DAMAGE.
7999 *
8000 * $FreeBSD$
8001 */
8002
8003#ifndef _INTTYPES_H_
8004#define _INTTYPES_H_
8005
8006#if 0 /* expanded by -frewrite-includes */
8007#include <machine/_inttypes.h>
8008#endif /* expanded by -frewrite-includes */
8009# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8010# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_inttypes.h" 1 3 4
8011/*-
8012 * Copyright (c) 2001 The NetBSD Foundation, Inc.
8013 * All rights reserved.
8014 *
8015 * This code is derived from software contributed to The NetBSD Foundation
8016 * by Klaus Klein.
8017 *
8018 * Redistribution and use in source and binary forms, with or without
8019 * modification, are permitted provided that the following conditions
8020 * are met:
8021 * 1. Redistributions of source code must retain the above copyright
8022 * notice, this list of conditions and the following disclaimer.
8023 * 2. Redistributions in binary form must reproduce the above copyright
8024 * notice, this list of conditions and the following disclaimer in the
8025 * documentation and/or other materials provided with the distribution.
8026 *
8027 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
8028 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
8029 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8030 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
8031 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
8032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
8033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
8034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
8035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
8037 * POSSIBILITY OF SUCH DAMAGE.
8038 *
8039 * From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $
8040 * from: src/sys/i386/include/_inttypes.h,v 1.2 2002/06/30 05:48:02 mike
8041 * $FreeBSD$
8042 */
8043
8044#ifndef _MACHINE_INTTYPES_H_
8045#define _MACHINE_INTTYPES_H_
8046
8047/*
8048 * Macros for format specifiers.
8049 */
8050
8051#ifdef __mips_n64
8052#define __PRI64 "l"
8053#define __PRIptr "l"
8054#else
8055# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_inttypes.h" 3 4
8056#define __PRI64 "ll"
8057#define __PRIptr
8058#endif
8059# 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_inttypes.h" 3 4
8060
8061/* fprintf(3) macros for signed integers. */
8062
8063#define PRId8 "d" /* int8_t */
8064#define PRId16 "d" /* int16_t */
8065#define PRId32 "d" /* int32_t */
8066#define PRId64 __PRI64"d" /* int64_t */
8067#define PRIdLEAST8 "d" /* int_least8_t */
8068#define PRIdLEAST16 "d" /* int_least16_t */
8069#define PRIdLEAST32 "d" /* int_least32_t */
8070#define PRIdLEAST64 __PRI64"d" /* int_least64_t */
8071#define PRIdFAST8 "d" /* int_fast8_t */
8072#define PRIdFAST16 "d" /* int_fast16_t */
8073#define PRIdFAST32 "d" /* int_fast32_t */
8074#define PRIdFAST64 __PRI64"d" /* int_fast64_t */
8075#define PRIdMAX "jd" /* intmax_t */
8076#define PRIdPTR __PRIptr"d" /* intptr_t */
8077
8078#define PRIi8 "i" /* int8_t */
8079#define PRIi16 "i" /* int16_t */
8080#define PRIi32 "i" /* int32_t */
8081#define PRIi64 __PRI64"i" /* int64_t */
8082#define PRIiLEAST8 "i" /* int_least8_t */
8083#define PRIiLEAST16 "i" /* int_least16_t */
8084#define PRIiLEAST32 "i" /* int_least32_t */
8085#define PRIiLEAST64 __PRI64"i" /* int_least64_t */
8086#define PRIiFAST8 "i" /* int_fast8_t */
8087#define PRIiFAST16 "i" /* int_fast16_t */
8088#define PRIiFAST32 "i" /* int_fast32_t */
8089#define PRIiFAST64 __PRI64"i" /* int_fast64_t */
8090#define PRIiMAX "ji" /* intmax_t */
8091#define PRIiPTR __PRIptr"i" /* intptr_t */
8092
8093/* fprintf(3) macros for unsigned integers. */
8094
8095#define PRIo8 "o" /* uint8_t */
8096#define PRIo16 "o" /* uint16_t */
8097#define PRIo32 "o" /* uint32_t */
8098#define PRIo64 __PRI64"o" /* uint64_t */
8099#define PRIoLEAST8 "o" /* uint_least8_t */
8100#define PRIoLEAST16 "o" /* uint_least16_t */
8101#define PRIoLEAST32 "o" /* uint_least32_t */
8102#define PRIoLEAST64 __PRI64"o" /* uint_least64_t */
8103#define PRIoFAST8 "o" /* uint_fast8_t */
8104#define PRIoFAST16 "o" /* uint_fast16_t */
8105#define PRIoFAST32 "o" /* uint_fast32_t */
8106#define PRIoFAST64 __PRI64"o" /* uint_fast64_t */
8107#define PRIoMAX "jo" /* uintmax_t */
8108#define PRIoPTR __PRIptr"o" /* uintptr_t */
8109
8110#define PRIu8 "u" /* uint8_t */
8111#define PRIu16 "u" /* uint16_t */
8112#define PRIu32 "u" /* uint32_t */
8113#define PRIu64 __PRI64"u" /* uint64_t */
8114#define PRIuLEAST8 "u" /* uint_least8_t */
8115#define PRIuLEAST16 "u" /* uint_least16_t */
8116#define PRIuLEAST32 "u" /* uint_least32_t */
8117#define PRIuLEAST64 __PRI64"u" /* uint_least64_t */
8118#define PRIuFAST8 "u" /* uint_fast8_t */
8119#define PRIuFAST16 "u" /* uint_fast16_t */
8120#define PRIuFAST32 "u" /* uint_fast32_t */
8121#define PRIuFAST64 __PRI64"u" /* uint_fast64_t */
8122#define PRIuMAX "ju" /* uintmax_t */
8123#define PRIuPTR __PRIptr"u" /* uintptr_t */
8124
8125#define PRIx8 "x" /* uint8_t */
8126#define PRIx16 "x" /* uint16_t */
8127#define PRIx32 "x" /* uint32_t */
8128#define PRIx64 __PRI64"x" /* uint64_t */
8129#define PRIxLEAST8 "x" /* uint_least8_t */
8130#define PRIxLEAST16 "x" /* uint_least16_t */
8131#define PRIxLEAST32 "x" /* uint_least32_t */
8132#define PRIxLEAST64 __PRI64"x" /* uint_least64_t */
8133#define PRIxFAST8 "x" /* uint_fast8_t */
8134#define PRIxFAST16 "x" /* uint_fast16_t */
8135#define PRIxFAST32 "x" /* uint_fast32_t */
8136#define PRIxFAST64 __PRI64"x" /* uint_fast64_t */
8137#define PRIxMAX "jx" /* uintmax_t */
8138#define PRIxPTR __PRIptr"x" /* uintptr_t */
8139
8140#define PRIX8 "X" /* uint8_t */
8141#define PRIX16 "X" /* uint16_t */
8142#define PRIX32 "X" /* uint32_t */
8143#define PRIX64 __PRI64"X" /* uint64_t */
8144#define PRIXLEAST8 "X" /* uint_least8_t */
8145#define PRIXLEAST16 "X" /* uint_least16_t */
8146#define PRIXLEAST32 "X" /* uint_least32_t */
8147#define PRIXLEAST64 __PRI64"X" /* uint_least64_t */
8148#define PRIXFAST8 "X" /* uint_fast8_t */
8149#define PRIXFAST16 "X" /* uint_fast16_t */
8150#define PRIXFAST32 "X" /* uint_fast32_t */
8151#define PRIXFAST64 __PRI64"X" /* uint_fast64_t */
8152#define PRIXMAX "jX" /* uintmax_t */
8153#define PRIXPTR __PRIptr"X" /* uintptr_t */
8154
8155/* fscanf(3) macros for signed integers. */
8156
8157#define SCNd8 "hhd" /* int8_t */
8158#define SCNd16 "hd" /* int16_t */
8159#define SCNd32 "d" /* int32_t */
8160#define SCNd64 __PRI64"d" /* int64_t */
8161#define SCNdLEAST8 "hhd" /* int_least8_t */
8162#define SCNdLEAST16 "hd" /* int_least16_t */
8163#define SCNdLEAST32 "d" /* int_least32_t */
8164#define SCNdLEAST64 __PRI64"d" /* int_least64_t */
8165#define SCNdFAST8 "d" /* int_fast8_t */
8166#define SCNdFAST16 "d" /* int_fast16_t */
8167#define SCNdFAST32 "d" /* int_fast32_t */
8168#define SCNdFAST64 __PRI64"d" /* int_fast64_t */
8169#define SCNdMAX "jd" /* intmax_t */
8170#define SCNdPTR __PRIptr"d" /* intptr_t */
8171
8172#define SCNi8 "hhi" /* int8_t */
8173#define SCNi16 "hi" /* int16_t */
8174#define SCNi32 "i" /* int32_t */
8175#define SCNi64 __PRI64"i" /* int64_t */
8176#define SCNiLEAST8 "hhi" /* int_least8_t */
8177#define SCNiLEAST16 "hi" /* int_least16_t */
8178#define SCNiLEAST32 "i" /* int_least32_t */
8179#define SCNiLEAST64 __PRI64"i" /* int_least64_t */
8180#define SCNiFAST8 "i" /* int_fast8_t */
8181#define SCNiFAST16 "i" /* int_fast16_t */
8182#define SCNiFAST32 "i" /* int_fast32_t */
8183#define SCNiFAST64 __PRI64"i" /* int_fast64_t */
8184#define SCNiMAX "ji" /* intmax_t */
8185#define SCNiPTR __PRIptr"i" /* intptr_t */
8186
8187/* fscanf(3) macros for unsigned integers. */
8188
8189#define SCNo8 "hho" /* uint8_t */
8190#define SCNo16 "ho" /* uint16_t */
8191#define SCNo32 "o" /* uint32_t */
8192#define SCNo64 __PRI64"o" /* uint64_t */
8193#define SCNoLEAST8 "hho" /* uint_least8_t */
8194#define SCNoLEAST16 "ho" /* uint_least16_t */
8195#define SCNoLEAST32 "o" /* uint_least32_t */
8196#define SCNoLEAST64 __PRI64"o" /* uint_least64_t */
8197#define SCNoFAST8 "o" /* uint_fast8_t */
8198#define SCNoFAST16 "o" /* uint_fast16_t */
8199#define SCNoFAST32 "o" /* uint_fast32_t */
8200#define SCNoFAST64 __PRI64"o" /* uint_fast64_t */
8201#define SCNoMAX "jo" /* uintmax_t */
8202#define SCNoPTR __PRIptr"o" /* uintptr_t */
8203
8204#define SCNu8 "hhu" /* uint8_t */
8205#define SCNu16 "hu" /* uint16_t */
8206#define SCNu32 "u" /* uint32_t */
8207#define SCNu64 __PRI64"u" /* uint64_t */
8208#define SCNuLEAST8 "hhu" /* uint_least8_t */
8209#define SCNuLEAST16 "hu" /* uint_least16_t */
8210#define SCNuLEAST32 "u" /* uint_least32_t */
8211#define SCNuLEAST64 __PRI64"u" /* uint_least64_t */
8212#define SCNuFAST8 "u" /* uint_fast8_t */
8213#define SCNuFAST16 "u" /* uint_fast16_t */
8214#define SCNuFAST32 "u" /* uint_fast32_t */
8215#define SCNuFAST64 __PRI64"u" /* uint_fast64_t */
8216#define SCNuMAX "ju" /* uintmax_t */
8217#define SCNuPTR __PRIptr"u" /* uintptr_t */
8218
8219#define SCNx8 "hhx" /* uint8_t */
8220#define SCNx16 "hx" /* uint16_t */
8221#define SCNx32 "x" /* uint32_t */
8222#define SCNx64 __PRI64"x" /* uint64_t */
8223#define SCNxLEAST8 "hhx" /* uint_least8_t */
8224#define SCNxLEAST16 "hx" /* uint_least16_t */
8225#define SCNxLEAST32 "x" /* uint_least32_t */
8226#define SCNxLEAST64 __PRI64"x" /* uint_least64_t */
8227#define SCNxFAST8 "x" /* uint_fast8_t */
8228#define SCNxFAST16 "x" /* uint_fast16_t */
8229#define SCNxFAST32 "x" /* uint_fast32_t */
8230#define SCNxFAST64 __PRI64"x" /* uint_fast64_t */
8231#define SCNxMAX "jx" /* uintmax_t */
8232#define SCNxPTR __PRIptr"x" /* uintptr_t */
8233
8234#endif /* !_MACHINE_INTTYPES_H_ */
8235# 223 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_inttypes.h" 3 4
8236# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 2 3 4
8237#if 0 /* expanded by -frewrite-includes */
8238#include <sys/stdint.h>
8239#endif /* expanded by -frewrite-includes */
8240# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8241# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 1 3 4
8242/*-
8243 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
8244 * All rights reserved.
8245 *
8246 * Redistribution and use in source and binary forms, with or without
8247 * modification, are permitted provided that the following conditions
8248 * are met:
8249 * 1. Redistributions of source code must retain the above copyright
8250 * notice, this list of conditions and the following disclaimer.
8251 * 2. Redistributions in binary form must reproduce the above copyright
8252 * notice, this list of conditions and the following disclaimer in the
8253 * documentation and/or other materials provided with the distribution.
8254 *
8255 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
8256 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8257 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
8258 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
8259 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
8260 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
8261 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
8262 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
8263 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
8264 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
8265 * SUCH DAMAGE.
8266 *
8267 * $FreeBSD$
8268 */
8269
8270#ifndef _SYS_STDINT_H_
8271#define _SYS_STDINT_H_
8272
8273#if 0 /* expanded by -frewrite-includes */
8274#include <sys/cdefs.h>
8275#endif /* expanded by -frewrite-includes */
8276# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8277# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8278#if 0 /* expanded by -frewrite-includes */
8279#include <sys/_types.h>
8280#endif /* expanded by -frewrite-includes */
8281# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8282# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8283
8284#if 0 /* expanded by -frewrite-includes */
8285#include <machine/_stdint.h>
8286#endif /* expanded by -frewrite-includes */
8287# 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8288# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 1 3 4
8289/*-
8290 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
8291 * Copyright (c) 2001 The NetBSD Foundation, Inc.
8292 * All rights reserved.
8293 *
8294 * This code is derived from software contributed to The NetBSD Foundation
8295 * by Klaus Klein.
8296 *
8297 * Redistribution and use in source and binary forms, with or without
8298 * modification, are permitted provided that the following conditions
8299 * are met:
8300 * 1. Redistributions of source code must retain the above copyright
8301 * notice, this list of conditions and the following disclaimer.
8302 * 2. Redistributions in binary form must reproduce the above copyright
8303 * notice, this list of conditions and the following disclaimer in the
8304 * documentation and/or other materials provided with the distribution.
8305 * 3. All advertising materials mentioning features or use of this software
8306 * must display the following acknowledgement:
8307 * This product includes software developed by the NetBSD
8308 * Foundation, Inc. and its contributors.
8309 * 4. Neither the name of The NetBSD Foundation nor the names of its
8310 * contributors may be used to endorse or promote products derived
8311 * from this software without specific prior written permission.
8312 *
8313 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
8314 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
8315 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8316 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
8317 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
8318 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
8319 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
8320 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
8321 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8322 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
8323 * POSSIBILITY OF SUCH DAMAGE.
8324 *
8325 * from: src/sys/i386/include/_stdint.h,v 1.2 2004/05/18 16:04:57 stefanf
8326 * $FreeBSD$
8327 */
8328
8329#ifndef _MACHINE__STDINT_H_
8330#define _MACHINE__STDINT_H_
8331
8332#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
8333
8334#define INT8_C(c) (c)
8335#define INT16_C(c) (c)
8336#define INT32_C(c) (c)
8337
8338#define UINT8_C(c) (c)
8339#define UINT16_C(c) (c)
8340#define UINT32_C(c) (c ## U)
8341
8342#ifdef __mips_n64
8343#define INT64_C(c) (c ## L)
8344#define UINT64_C(c) (c ## UL)
8345#else
8346# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8347#define INT64_C(c) (c ## LL)
8348#define UINT64_C(c) (c ## ULL)
8349#endif
8350# 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8351
8352#define INTMAX_C(c) INT64_C(c)
8353#define UINTMAX_C(c) UINT64_C(c)
8354
8355#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
8356# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8357
8358#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
8359
8360#ifndef __INT64_C
8361#ifdef __mips_n64
8362#define __INT64_C(c) (c ## L)
8363#define __UINT64_C(c) (c ## UL)
8364#else
8365# 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8366#define __INT64_C(c) (c ## LL)
8367#define __UINT64_C(c) (c ## ULL)
8368#endif
8369# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8370#endif
8371# 78 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8372
8373/*
8374 * ISO/IEC 9899:1999
8375 * 7.18.2.1 Limits of exact-width integer types
8376 */
8377/* Minimum values of exact-width signed integer types. */
8378#define INT8_MIN (-0x7f-1)
8379#define INT16_MIN (-0x7fff-1)
8380#define INT32_MIN (-0x7fffffff-1)
8381#define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1)
8382
8383/* Maximum values of exact-width signed integer types. */
8384#define INT8_MAX 0x7f
8385#define INT16_MAX 0x7fff
8386#define INT32_MAX 0x7fffffff
8387#define INT64_MAX __INT64_C(0x7fffffffffffffff)
8388
8389/* Maximum values of exact-width unsigned integer types. */
8390#define UINT8_MAX 0xff
8391#define UINT16_MAX 0xffff
8392#define UINT32_MAX 0xffffffff
8393#define UINT64_MAX __UINT64_C(0xffffffffffffffff)
8394
8395/*
8396 * ISO/IEC 9899:1999
8397 * 7.18.2.2 Limits of minimum-width integer types
8398 */
8399/* Minimum values of minimum-width signed integer types. */
8400#define INT_LEAST8_MIN INT8_MIN
8401#define INT_LEAST16_MIN INT16_MIN
8402#define INT_LEAST32_MIN INT32_MIN
8403#define INT_LEAST64_MIN INT64_MIN
8404
8405/* Maximum values of minimum-width signed integer types. */
8406#define INT_LEAST8_MAX INT8_MAX
8407#define INT_LEAST16_MAX INT16_MAX
8408#define INT_LEAST32_MAX INT32_MAX
8409#define INT_LEAST64_MAX INT64_MAX
8410
8411/* Maximum values of minimum-width unsigned integer types. */
8412#define UINT_LEAST8_MAX UINT8_MAX
8413#define UINT_LEAST16_MAX UINT16_MAX
8414#define UINT_LEAST32_MAX UINT32_MAX
8415#define UINT_LEAST64_MAX UINT64_MAX
8416
8417/*
8418 * ISO/IEC 9899:1999
8419 * 7.18.2.3 Limits of fastest minimum-width integer types
8420 */
8421/* Minimum values of fastest minimum-width signed integer types. */
8422#define INT_FAST8_MIN INT32_MIN
8423#define INT_FAST16_MIN INT32_MIN
8424#define INT_FAST32_MIN INT32_MIN
8425#define INT_FAST64_MIN INT64_MIN
8426
8427/* Maximum values of fastest minimum-width signed integer types. */
8428#define INT_FAST8_MAX INT32_MAX
8429#define INT_FAST16_MAX INT32_MAX
8430#define INT_FAST32_MAX INT32_MAX
8431#define INT_FAST64_MAX INT64_MAX
8432
8433/* Maximum values of fastest minimum-width unsigned integer types. */
8434#define UINT_FAST8_MAX UINT32_MAX
8435#define UINT_FAST16_MAX UINT32_MAX
8436#define UINT_FAST32_MAX UINT32_MAX
8437#define UINT_FAST64_MAX UINT64_MAX
8438
8439/*
8440 * ISO/IEC 9899:1999
8441 * 7.18.2.4 Limits of integer types capable of holding object pointers
8442 */
8443#ifdef __mips_n64
8444#define INTPTR_MIN INT64_MIN
8445#define INTPTR_MAX INT64_MAX
8446#define UINTPTR_MAX UINT64_MAX
8447#else
8448# 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8449#define INTPTR_MIN INT32_MIN
8450#define INTPTR_MAX INT32_MAX
8451#define UINTPTR_MAX UINT32_MAX
8452#endif
8453# 158 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8454
8455/*
8456 * ISO/IEC 9899:1999
8457 * 7.18.2.5 Limits of greatest-width integer types
8458 */
8459#define INTMAX_MIN INT64_MIN
8460#define INTMAX_MAX INT64_MAX
8461#define UINTMAX_MAX UINT64_MAX
8462
8463/*
8464 * ISO/IEC 9899:1999
8465 * 7.18.3 Limits of other integer types
8466 */
8467#ifdef __mips_n64
8468/* Limits of ptrdiff_t. */
8469#define PTRDIFF_MIN INT64_MIN
8470#define PTRDIFF_MAX INT64_MAX
8471
8472/* Limit of size_t. */
8473#define SIZE_MAX UINT64_MAX
8474#else
8475# 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8476/* Limits of ptrdiff_t. */
8477#define PTRDIFF_MIN INT32_MIN
8478#define PTRDIFF_MAX INT32_MAX
8479
8480/* Limit of size_t. */
8481#define SIZE_MAX UINT32_MAX
8482#endif
8483# 186 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8484
8485/* Limits of sig_atomic_t. */
8486#define SIG_ATOMIC_MIN INT32_MIN
8487#define SIG_ATOMIC_MAX INT32_MAX
8488
8489/* Limits of wint_t. */
8490#define WINT_MIN INT32_MIN
8491#define WINT_MAX INT32_MAX
8492
8493#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
8494# 196 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8495
8496#endif /* !_MACHINE__STDINT_H_ */
8497# 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_stdint.h" 3 4
8498# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 2 3 4
8499#if 0 /* expanded by -frewrite-includes */
8500#include <sys/_stdint.h>
8501#endif /* expanded by -frewrite-includes */
8502# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8503# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8504
8505typedef __int_least8_t int_least8_t;
8506typedef __int_least16_t int_least16_t;
8507typedef __int_least32_t int_least32_t;
8508typedef __int_least64_t int_least64_t;
8509
8510typedef __uint_least8_t uint_least8_t;
8511typedef __uint_least16_t uint_least16_t;
8512typedef __uint_least32_t uint_least32_t;
8513typedef __uint_least64_t uint_least64_t;
8514
8515typedef __int_fast8_t int_fast8_t;
8516typedef __int_fast16_t int_fast16_t;
8517typedef __int_fast32_t int_fast32_t;
8518typedef __int_fast64_t int_fast64_t;
8519
8520typedef __uint_fast8_t uint_fast8_t;
8521typedef __uint_fast16_t uint_fast16_t;
8522typedef __uint_fast32_t uint_fast32_t;
8523typedef __uint_fast64_t uint_fast64_t;
8524
8525#ifndef _INTMAX_T_DECLARED
8526typedef __intmax_t intmax_t;
8527#define _INTMAX_T_DECLARED
8528#endif
8529# 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8530#ifndef _UINTMAX_T_DECLARED
8531typedef __uintmax_t uintmax_t;
8532#define _UINTMAX_T_DECLARED
8533#endif
8534# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8535
8536/* GNU and Darwin define this and people seem to think it's portable */
8537#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)
8538#define __WORDSIZE 64
8539#else
8540# 71 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8541#define __WORDSIZE 32
8542#endif
8543# 73 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8544
8545/* Limits of wchar_t. */
8546#define WCHAR_MIN __WCHAR_MIN
8547#define WCHAR_MAX __WCHAR_MAX
8548
8549#endif /* !_SYS_STDINT_H_ */
8550# 79 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stdint.h" 3 4
8551# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 2 3 4
8552
8553#ifndef __cplusplus
8554#ifndef _WCHAR_T_DECLARED
8555typedef ___wchar_t wchar_t;
8556#define _WCHAR_T_DECLARED
8557#endif
8558# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8559#endif
8560# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8561
8562typedef struct {
8563 intmax_t quot; /* Quotient. */
8564 intmax_t rem; /* Remainder. */
8565} imaxdiv_t;
8566
8567__BEGIN_DECLS
8568#ifdef _XLOCALE_H_
8569#if 0 /* expanded by -frewrite-includes */
8570#include <xlocale/_inttypes.h>
8571#endif /* expanded by -frewrite-includes */
8572# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8573# 50 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8574#endif
8575# 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8576intmax_t imaxabs(intmax_t) __pure2;
8577imaxdiv_t imaxdiv(intmax_t, intmax_t) __pure2;
8578
8579intmax_t strtoimax(const char * __restrict, char ** __restrict, int);
8580uintmax_t strtoumax(const char * __restrict, char ** __restrict, int);
8581intmax_t wcstoimax(const wchar_t * __restrict,
8582 wchar_t ** __restrict, int);
8583uintmax_t wcstoumax(const wchar_t * __restrict,
8584 wchar_t ** __restrict, int);
8585__END_DECLS
8586
8587#endif /* !_INTTYPES_H_ */
8588# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/inttypes.h" 3 4
8589# 27 "/home/rnw24/git/llvm/Build/bin/../lib/clang/3.8.0/include/inttypes.h" 2 3 4
8590
8591#if defined(_MSC_VER) && _MSC_VER < 1900
8592/* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x".
8593 * This triggers format warnings, so fix it up here. */
8594#undef PRId32
8595#undef PRIdLEAST32
8596#undef PRIdFAST32
8597#undef PRIi32
8598#undef PRIiLEAST32
8599#undef PRIiFAST32
8600#undef PRIo32
8601#undef PRIoLEAST32
8602#undef PRIoFAST32
8603#undef PRIu32
8604#undef PRIuLEAST32
8605#undef PRIuFAST32
8606#undef PRIx32
8607#undef PRIxLEAST32
8608#undef PRIxFAST32
8609#undef PRIX32
8610#undef PRIXLEAST32
8611#undef PRIXFAST32
8612
8613#undef SCNd32
8614#undef SCNdLEAST32
8615#undef SCNdFAST32
8616#undef SCNi32
8617#undef SCNiLEAST32
8618#undef SCNiFAST32
8619#undef SCNo32
8620#undef SCNoLEAST32
8621#undef SCNoFAST32
8622#undef SCNu32
8623#undef SCNuLEAST32
8624#undef SCNuFAST32
8625#undef SCNx32
8626#undef SCNxLEAST32
8627#undef SCNxFAST32
8628
8629#define PRId32 "d"
8630#define PRIdLEAST32 "d"
8631#define PRIdFAST32 "d"
8632#define PRIi32 "i"
8633#define PRIiLEAST32 "i"
8634#define PRIiFAST32 "i"
8635#define PRIo32 "o"
8636#define PRIoLEAST32 "o"
8637#define PRIoFAST32 "o"
8638#define PRIu32 "u"
8639#define PRIuLEAST32 "u"
8640#define PRIuFAST32 "u"
8641#define PRIx32 "x"
8642#define PRIxLEAST32 "x"
8643#define PRIxFAST32 "x"
8644#define PRIX32 "X"
8645#define PRIXLEAST32 "X"
8646#define PRIXFAST32 "X"
8647
8648#define SCNd32 "d"
8649#define SCNdLEAST32 "d"
8650#define SCNdFAST32 "d"
8651#define SCNi32 "i"
8652#define SCNiLEAST32 "i"
8653#define SCNiFAST32 "i"
8654#define SCNo32 "o"
8655#define SCNoLEAST32 "o"
8656#define SCNoFAST32 "o"
8657#define SCNu32 "u"
8658#define SCNuLEAST32 "u"
8659#define SCNuFAST32 "u"
8660#define SCNx32 "x"
8661#define SCNxLEAST32 "x"
8662#define SCNxFAST32 "x"
8663#endif
8664# 101 "/home/rnw24/git/llvm/Build/bin/../lib/clang/3.8.0/include/inttypes.h" 3 4
8665
8666#endif /* __CLANG_INTTYPES_H */
8667# 103 "/home/rnw24/git/llvm/Build/bin/../lib/clang/3.8.0/include/inttypes.h" 3 4
8668# 54 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
8669#if 0 /* expanded by -frewrite-includes */
8670#include <stdio.h>
8671#endif /* expanded by -frewrite-includes */
8672# 54 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
8673# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 1 3 4
8674/*-
8675 * Copyright (c) 1990, 1993
8676 * The Regents of the University of California. All rights reserved.
8677 *
8678 * This code is derived from software contributed to Berkeley by
8679 * Chris Torek.
8680 *
8681 * Redistribution and use in source and binary forms, with or without
8682 * modification, are permitted provided that the following conditions
8683 * are met:
8684 * 1. Redistributions of source code must retain the above copyright
8685 * notice, this list of conditions and the following disclaimer.
8686 * 2. Redistributions in binary form must reproduce the above copyright
8687 * notice, this list of conditions and the following disclaimer in the
8688 * documentation and/or other materials provided with the distribution.
8689 * 3. Neither the name of the University nor the names of its contributors
8690 * may be used to endorse or promote products derived from this software
8691 * without specific prior written permission.
8692 *
8693 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
8694 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8695 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
8696 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
8697 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
8698 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
8699 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
8700 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
8701 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
8702 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
8703 * SUCH DAMAGE.
8704 *
8705 * @(#)stdio.h 8.5 (Berkeley) 4/29/95
8706 * $FreeBSD$
8707 */
8708
8709#ifndef _STDIO_H_
8710#define _STDIO_H_
8711
8712#if 0 /* expanded by -frewrite-includes */
8713#include <sys/cdefs.h>
8714#endif /* expanded by -frewrite-includes */
8715# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8716# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8717#if 0 /* expanded by -frewrite-includes */
8718#include <sys/_null.h>
8719#endif /* expanded by -frewrite-includes */
8720# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8721# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8722#if 0 /* expanded by -frewrite-includes */
8723#include <sys/_types.h>
8724#endif /* expanded by -frewrite-includes */
8725# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8726# 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8727
8728typedef __off_t fpos_t;
8729
8730#ifndef _SIZE_T_DECLARED
8731typedef __size_t size_t;
8732#define _SIZE_T_DECLARED
8733#endif
8734# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8735
8736#if __POSIX_VISIBLE >= 200809
8737#ifndef _OFF_T_DECLARED
8738#define _OFF_T_DECLARED
8739typedef __off_t off_t;
8740#endif
8741# 55 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8742#ifndef _SSIZE_T_DECLARED
8743#define _SSIZE_T_DECLARED
8744typedef __ssize_t ssize_t;
8745#endif
8746# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8747#endif
8748# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8749
8750#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
8751#ifndef _VA_LIST_DECLARED
8752typedef __va_list va_list;
8753#define _VA_LIST_DECLARED
8754#endif
8755# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8756#endif
8757# 67 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8758
8759#define _FSTDIO /* Define for new stdio with functions. */
8760
8761/*
8762 * NB: to fit things in six character monocase externals, the stdio
8763 * code uses the prefix `__s' for stdio objects, typically followed
8764 * by a three-character attempt at a mnemonic.
8765 */
8766
8767/* stdio buffers */
8768struct __sbuf {
8769 unsigned char *_base;
8770 int _size;
8771};
8772
8773/*
8774 * stdio state variables.
8775 *
8776 * The following always hold:
8777 *
8778 * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
8779 * _lbfsize is -_bf._size, else _lbfsize is 0
8780 * if _flags&__SRD, _w is 0
8781 * if _flags&__SWR, _r is 0
8782 *
8783 * This ensures that the getc and putc macros (or inline functions) never
8784 * try to write or read from a file that is in `read' or `write' mode.
8785 * (Moreover, they can, and do, automatically switch from read mode to
8786 * write mode, and back, on "r+" and "w+" files.)
8787 *
8788 * _lbfsize is used only to make the inline line-buffered output stream
8789 * code as compact as possible.
8790 *
8791 * _ub, _up, and _ur are used when ungetc() pushes back more characters
8792 * than fit in the current _bf, or when ungetc() pushes back a character
8793 * that does not match the previous one in _bf. When this happens,
8794 * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
8795 * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
8796 *
8797 * Certain members of __sFILE are accessed directly via macros or
8798 * inline functions. To preserve ABI compat, these members must not
8799 * be disturbed. These members are marked below with (*).
8800 */
8801struct __sFILE {
8802 unsigned char *_p; /* (*) current position in (some) buffer */
8803 int _r; /* (*) read space left for getc() */
8804 int _w; /* (*) write space left for putc() */
8805 short _flags; /* (*) flags, below; this FILE is free if 0 */
8806 short _file; /* (*) fileno, if Unix descriptor, else -1 */
8807 struct __sbuf _bf; /* (*) the buffer (at least 1 byte, if !NULL) */
8808 int _lbfsize; /* (*) 0 or -_bf._size, for inline putc */
8809
8810 /* operations */
8811 void *_cookie; /* (*) cookie passed to io functions */
8812 int (*_close)(void *);
8813 int (*_read)(void *, char *, int);
8814 fpos_t (*_seek)(void *, fpos_t, int);
8815 int (*_write)(void *, const char *, int);
8816
8817 /* separate buffer for long sequences of ungetc() */
8818 struct __sbuf _ub; /* ungetc buffer */
8819 unsigned char *_up; /* saved _p when _p is doing ungetc data */
8820 int _ur; /* saved _r when _r is counting ungetc data */
8821
8822 /* tricks to meet minimum requirements even when malloc() fails */
8823 unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
8824 unsigned char _nbuf[1]; /* guarantee a getc() buffer */
8825
8826 /* separate buffer for fgetln() when line crosses buffer boundary */
8827 struct __sbuf _lb; /* buffer for fgetln() */
8828
8829 /* Unix stdio files get aligned to block boundaries on fseek() */
8830 int _blksize; /* stat.st_blksize (may be != _bf._size) */
8831 fpos_t _offset; /* current lseek offset */
8832
8833 struct pthread_mutex *_fl_mutex; /* used for MT-safety */
8834 struct pthread *_fl_owner; /* current owner */
8835 int _fl_count; /* recursive lock count */
8836 int _orientation; /* orientation for fwide() */
8837 __mbstate_t _mbstate; /* multibyte conversion state */
8838};
8839#ifndef _STDFILE_DECLARED
8840#define _STDFILE_DECLARED
8841typedef struct __sFILE FILE;
8842#endif
8843# 152 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8844#ifndef _STDSTREAM_DECLARED
8845__BEGIN_DECLS
8846extern FILE *__stdinp;
8847extern FILE *__stdoutp;
8848extern FILE *__stderrp;
8849__END_DECLS
8850#define _STDSTREAM_DECLARED
8851#endif
8852# 160 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8853
8854#define __SLBF 0x0001 /* line buffered */
8855#define __SNBF 0x0002 /* unbuffered */
8856#define __SRD 0x0004 /* OK to read */
8857#define __SWR 0x0008 /* OK to write */
8858 /* RD and WR are never simultaneously asserted */
8859#define __SRW 0x0010 /* open for reading & writing */
8860#define __SEOF 0x0020 /* found EOF */
8861#define __SERR 0x0040 /* found error */
8862#define __SMBF 0x0080 /* _bf._base is from malloc */
8863#define __SAPP 0x0100 /* fdopen()ed in append mode */
8864#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
8865#define __SOPT 0x0400 /* do fseek() optimization */
8866#define __SNPT 0x0800 /* do not do fseek() optimization */
8867#define __SOFF 0x1000 /* set iff _offset is in fact correct */
8868#define __SMOD 0x2000 /* true => fgetln modified _p text */
8869#define __SALC 0x4000 /* allocate string space dynamically */
8870#define __SIGN 0x8000 /* ignore this file in _fwalk */
8871
8872/*
8873 * The following three definitions are for ANSI C, which took them
8874 * from System V, which brilliantly took internal interface macros and
8875 * made them official arguments to setvbuf(), without renaming them.
8876 * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
8877 *
8878 * Although numbered as their counterparts above, the implementation
8879 * does not rely on this.
8880 */
8881#define _IOFBF 0 /* setvbuf should set fully buffered */
8882#define _IOLBF 1 /* setvbuf should set line buffered */
8883#define _IONBF 2 /* setvbuf should set unbuffered */
8884
8885#define BUFSIZ 1024 /* size of buffer used by setbuf */
8886#define EOF (-1)
8887
8888/*
8889 * FOPEN_MAX is a minimum maximum, and is the number of streams that
8890 * stdio can provide without attempting to allocate further resources
8891 * (which could fail). Do not use this for anything.
8892 */
8893 /* must be == _POSIX_STREAM_MAX <limits.h> */
8894#ifndef FOPEN_MAX
8895#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
8896#endif
8897# 204 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8898#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
8899
8900/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
8901#if __XSI_VISIBLE
8902#define P_tmpdir "/tmp/"
8903#endif
8904# 210 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8905#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
8906#define TMP_MAX 308915776
8907
8908#ifndef SEEK_SET
8909#define SEEK_SET 0 /* set file offset to offset */
8910#endif
8911# 216 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8912#ifndef SEEK_CUR
8913#define SEEK_CUR 1 /* set file offset to current plus offset */
8914#endif
8915# 219 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8916#ifndef SEEK_END
8917#define SEEK_END 2 /* set file offset to EOF plus offset */
8918#endif
8919# 222 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8920
8921#define stdin __stdinp
8922#define stdout __stdoutp
8923#define stderr __stderrp
8924
8925__BEGIN_DECLS
8926#ifdef _XLOCALE_H_
8927#if 0 /* expanded by -frewrite-includes */
8928#include <xlocale/_stdio.h>
8929#endif /* expanded by -frewrite-includes */
8930# 229 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8931# 230 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8932#endif
8933# 231 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8934/*
8935 * Functions defined in ANSI C standard.
8936 */
8937void clearerr(FILE *);
8938int fclose(FILE *);
8939int feof(FILE *);
8940int ferror(FILE *);
8941int fflush(FILE *);
8942int fgetc(FILE *);
8943int fgetpos(FILE * __restrict, fpos_t * __restrict);
8944char *fgets(char * __restrict, int, FILE * __restrict);
8945FILE *fopen(const char * __restrict, const char * __restrict);
8946int fprintf(FILE * __restrict, const char * __restrict, ...);
8947int fputc(int, FILE *);
8948int fputs(const char * __restrict, FILE * __restrict);
8949size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
8950FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict);
8951int fscanf(FILE * __restrict, const char * __restrict, ...);
8952int fseek(FILE *, long, int);
8953int fsetpos(FILE *, const fpos_t *);
8954long ftell(FILE *);
8955size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
8956int getc(FILE *);
8957int getchar(void);
8958char *gets(char *);
8959void perror(const char *);
8960int printf(const char * __restrict, ...);
8961int putc(int, FILE *);
8962int putchar(int);
8963int puts(const char *);
8964int remove(const char *);
8965int rename(const char *, const char *);
8966void rewind(FILE *);
8967int scanf(const char * __restrict, ...);
8968void setbuf(FILE * __restrict, char * __restrict);
8969int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
8970int sprintf(char * __restrict, const char * __restrict, ...);
8971int sscanf(const char * __restrict, const char * __restrict, ...);
8972FILE *tmpfile(void);
8973char *tmpnam(char *);
8974int ungetc(int, FILE *);
8975int vfprintf(FILE * __restrict, const char * __restrict,
8976 __va_list);
8977int vprintf(const char * __restrict, __va_list);
8978int vsprintf(char * __restrict, const char * __restrict,
8979 __va_list);
8980
8981#if __ISO_C_VISIBLE >= 1999
8982int snprintf(char * __restrict, size_t, const char * __restrict,
8983 ...) __printflike(3, 4);
8984int vfscanf(FILE * __restrict, const char * __restrict, __va_list)
8985 __scanflike(2, 0);
8986int vscanf(const char * __restrict, __va_list) __scanflike(1, 0);
8987int vsnprintf(char * __restrict, size_t, const char * __restrict,
8988 __va_list) __printflike(3, 0);
8989int vsscanf(const char * __restrict, const char * __restrict, __va_list)
8990 __scanflike(2, 0);
8991#endif
8992# 289 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
8993
8994/*
8995 * Functions defined in all versions of POSIX 1003.1.
8996 */
8997#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506)
8998#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */
8999#endif
9000# 296 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9001
9002#if __POSIX_VISIBLE
9003#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
9004
9005char *ctermid(char *);
9006FILE *fdopen(int, const char *);
9007int fileno(FILE *);
9008#endif /* __POSIX_VISIBLE */
9009# 304 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9010
9011#if __POSIX_VISIBLE >= 199209
9012int pclose(FILE *);
9013FILE *popen(const char *, const char *);
9014#endif
9015# 309 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9016
9017#if __POSIX_VISIBLE >= 199506
9018int ftrylockfile(FILE *);
9019void flockfile(FILE *);
9020void funlockfile(FILE *);
9021
9022/*
9023 * These are normally used through macros as defined below, but POSIX
9024 * requires functions as well.
9025 */
9026int getc_unlocked(FILE *);
9027int getchar_unlocked(void);
9028int putc_unlocked(int, FILE *);
9029int putchar_unlocked(int);
9030#endif
9031# 324 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9032#if __BSD_VISIBLE
9033void clearerr_unlocked(FILE *);
9034int feof_unlocked(FILE *);
9035int ferror_unlocked(FILE *);
9036int fileno_unlocked(FILE *);
9037#endif
9038# 330 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9039
9040#if __POSIX_VISIBLE >= 200112
9041int fseeko(FILE *, __off_t, int);
9042__off_t ftello(FILE *);
9043#endif
9044# 335 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9045
9046#if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600
9047int getw(FILE *);
9048int putw(int, FILE *);
9049#endif /* BSD or X/Open before issue 6 */
9050# 340 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9051
9052#if __XSI_VISIBLE
9053char *tempnam(const char *, const char *);
9054#endif
9055# 344 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9056
9057#if __POSIX_VISIBLE >= 200809
9058FILE *fmemopen(void * __restrict, size_t, const char * __restrict);
9059ssize_t getdelim(char ** __restrict, size_t * __restrict, int,
9060 FILE * __restrict);
9061FILE *open_memstream(char **, size_t *);
9062int renameat(int, const char *, int, const char *);
9063int vdprintf(int, const char * __restrict, __va_list);
9064
9065/*
9066 * Every programmer and his dog wrote functions called getline() and dprintf()
9067 * before POSIX.1-2008 came along and decided to usurp the names, so we
9068 * don't prototype them by default unless one of the following is true:
9069 * a) the app has requested them specifically by defining _WITH_GETLINE or
9070 * _WITH_DPRINTF, respectively
9071 * b) the app has requested a POSIX.1-2008 environment via _POSIX_C_SOURCE
9072 * c) the app defines a GNUism such as _BSD_SOURCE or _GNU_SOURCE
9073 */
9074#ifndef _WITH_GETLINE
9075#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
9076#define _WITH_GETLINE
9077#elif defined(_POSIX_C_SOURCE)
9078# 366 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9079#if _POSIX_C_SOURCE >= 200809
9080#define _WITH_GETLINE
9081#endif
9082# 369 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9083#endif
9084# 370 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9085#endif
9086# 371 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9087
9088#ifdef _WITH_GETLINE
9089ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
9090#endif
9091# 375 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9092
9093#ifndef _WITH_DPRINTF
9094#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
9095#define _WITH_DPRINTF
9096#elif defined(_POSIX_C_SOURCE)
9097# 380 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9098#if _POSIX_C_SOURCE >= 200809
9099#define _WITH_DPRINTF
9100#endif
9101# 383 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9102#endif
9103# 384 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9104#endif
9105# 385 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9106
9107#ifdef _WITH_DPRINTF
9108int (dprintf)(int, const char * __restrict, ...);
9109#endif
9110# 389 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9111
9112#endif /* __POSIX_VISIBLE >= 200809 */
9113# 391 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9114
9115/*
9116 * Routines that are purely local.
9117 */
9118#if __BSD_VISIBLE
9119int asprintf(char **, const char *, ...) __printflike(2, 3);
9120char *ctermid_r(char *);
9121void fcloseall(void);
9122int fdclose(FILE *, int *);
9123char *fgetln(FILE *, size_t *);
9124const char *fmtcheck(const char *, const char *) __format_arg(2);
9125int fpurge(FILE *);
9126void setbuffer(FILE *, char *, int);
9127int setlinebuf(FILE *);
9128int vasprintf(char **, const char *, __va_list)
9129 __printflike(2, 0);
9130
9131/*
9132 * The system error table contains messages for the first sys_nerr
9133 * positive errno values. Use strerror() or strerror_r() from <string.h>
9134 * instead.
9135 */
9136extern const int sys_nerr;
9137extern const char * const sys_errlist[];
9138
9139/*
9140 * Stdio function-access interface.
9141 */
9142FILE *funopen(const void *,
9143 int (*)(void *, char *, int),
9144 int (*)(void *, const char *, int),
9145 fpos_t (*)(void *, fpos_t, int),
9146 int (*)(void *));
9147#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
9148#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
9149
9150/*
9151 * Portability hacks. See <sys/types.h>.
9152 */
9153#ifndef _FTRUNCATE_DECLARED
9154#define _FTRUNCATE_DECLARED
9155int ftruncate(int, __off_t);
9156#endif
9157# 434 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9158#ifndef _LSEEK_DECLARED
9159#define _LSEEK_DECLARED
9160__off_t lseek(int, __off_t, int);
9161#endif
9162# 438 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9163#ifndef _MMAP_DECLARED
9164#define _MMAP_DECLARED
9165void *mmap(void *, size_t, int, int, int, __off_t);
9166#endif
9167# 442 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9168#ifndef _TRUNCATE_DECLARED
9169#define _TRUNCATE_DECLARED
9170int truncate(const char *, __off_t);
9171#endif
9172# 446 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9173#endif /* __BSD_VISIBLE */
9174# 447 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9175
9176/*
9177 * Functions internal to the implementation.
9178 */
9179int __srget(FILE *);
9180int __swbuf(int, FILE *);
9181
9182/*
9183 * The __sfoo macros are here so that we can
9184 * define function versions in the C library.
9185 */
9186#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
9187#if defined(__GNUC__) && defined(__STDC__)
9188static __inline int __sputc(int _c, FILE *_p) {
9189 if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
9190 return (*_p->_p++ = _c);
9191 else
9192 return (__swbuf(_c, _p));
9193}
9194#else
9195# 467 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9196/*
9197 * This has been tuned to generate reasonable code on the vax using pcc.
9198 */
9199#define __sputc(c, p) \
9200 (--(p)->_w < 0 ? \
9201 (p)->_w >= (p)->_lbfsize ? \
9202 (*(p)->_p = (c)), *(p)->_p != '\n' ? \
9203 (int)*(p)->_p++ : \
9204 __swbuf('\n', p) : \
9205 __swbuf((int)(c), p) : \
9206 (*(p)->_p = (c), (int)*(p)->_p++))
9207#endif
9208# 479 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9209
9210extern int __isthreaded;
9211
9212#ifndef __cplusplus
9213
9214#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
9215#define __sferror(p) (((p)->_flags & __SERR) != 0)
9216#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
9217#define __sfileno(p) ((p)->_file)
9218
9219
9220#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
9221#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
9222#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
9223
9224#if __POSIX_VISIBLE
9225#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
9226#endif
9227# 497 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9228
9229#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
9230#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
9231
9232#define getchar() getc(stdin)
9233#define putchar(x) putc(x, stdout)
9234
9235#if __BSD_VISIBLE
9236/*
9237 * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
9238 * B.8.2.7 for the rationale behind the *_unlocked() macros.
9239 */
9240#define feof_unlocked(p) __sfeof(p)
9241#define ferror_unlocked(p) __sferror(p)
9242#define clearerr_unlocked(p) __sclearerr(p)
9243#define fileno_unlocked(p) __sfileno(p)
9244#endif
9245# 514 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9246#if __POSIX_VISIBLE >= 199506
9247#define getc_unlocked(fp) __sgetc(fp)
9248#define putc_unlocked(x, fp) __sputc(x, fp)
9249
9250#define getchar_unlocked() getc_unlocked(stdin)
9251#define putchar_unlocked(x) putc_unlocked(x, stdout)
9252#endif
9253# 521 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9254#endif /* __cplusplus */
9255# 522 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9256
9257__END_DECLS
9258#endif /* !_STDIO_H_ */
9259# 525 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdio.h" 3 4
9260# 55 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
9261#if 0 /* expanded by -frewrite-includes */
9262#include <stdlib.h>
9263#endif /* expanded by -frewrite-includes */
9264# 55 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
9265# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 1 3 4
9266/*-
9267 * Copyright (c) 1990, 1993
9268 * The Regents of the University of California. All rights reserved.
9269 *
9270 * Redistribution and use in source and binary forms, with or without
9271 * modification, are permitted provided that the following conditions
9272 * are met:
9273 * 1. Redistributions of source code must retain the above copyright
9274 * notice, this list of conditions and the following disclaimer.
9275 * 2. Redistributions in binary form must reproduce the above copyright
9276 * notice, this list of conditions and the following disclaimer in the
9277 * documentation and/or other materials provided with the distribution.
9278 * 3. Neither the name of the University nor the names of its contributors
9279 * may be used to endorse or promote products derived from this software
9280 * without specific prior written permission.
9281 *
9282 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
9283 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9284 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9285 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
9286 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9287 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9288 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9289 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9290 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9291 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9292 * SUCH DAMAGE.
9293 *
9294 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
9295 * $FreeBSD$
9296 */
9297
9298#ifndef _STDLIB_H_
9299#define _STDLIB_H_
9300
9301#if 0 /* expanded by -frewrite-includes */
9302#include <sys/cdefs.h>
9303#endif /* expanded by -frewrite-includes */
9304# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9305# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9306#if 0 /* expanded by -frewrite-includes */
9307#include <sys/_null.h>
9308#endif /* expanded by -frewrite-includes */
9309# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9310# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9311#if 0 /* expanded by -frewrite-includes */
9312#include <sys/_types.h>
9313#endif /* expanded by -frewrite-includes */
9314# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9315# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9316
9317#if __BSD_VISIBLE
9318#ifndef _RUNE_T_DECLARED
9319typedef __rune_t rune_t;
9320#define _RUNE_T_DECLARED
9321#endif
9322# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9323#endif
9324# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9325
9326#ifndef _SIZE_T_DECLARED
9327typedef __size_t size_t;
9328#define _SIZE_T_DECLARED
9329#endif
9330# 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9331
9332#ifndef __cplusplus
9333#ifndef _WCHAR_T_DECLARED
9334typedef ___wchar_t wchar_t;
9335#define _WCHAR_T_DECLARED
9336#endif
9337# 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9338#endif
9339# 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9340
9341typedef struct {
9342 int quot; /* quotient */
9343 int rem; /* remainder */
9344} div_t;
9345
9346typedef struct {
9347 long quot;
9348 long rem;
9349} ldiv_t;
9350
9351#define EXIT_FAILURE 1
9352#define EXIT_SUCCESS 0
9353
9354#define RAND_MAX 0x7ffffffd
9355
9356__BEGIN_DECLS
9357#ifdef _XLOCALE_H_
9358#if 0 /* expanded by -frewrite-includes */
9359#include <xlocale/_stdlib.h>
9360#endif /* expanded by -frewrite-includes */
9361# 76 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9362# 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9363#endif
9364# 78 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9365extern int __mb_cur_max;
9366extern int ___mb_cur_max(void);
9367#define MB_CUR_MAX (___mb_cur_max())
9368
9369_Noreturn void abort(void);
9370int abs(int) __pure2;
9371int atexit(void (*)(void));
9372double atof(const char *);
9373int atoi(const char *);
9374long atol(const char *);
9375void *bsearch(const void *, const void *, size_t,
9376 size_t, int (*)(const void *, const void *));
9377void *calloc(size_t, size_t) __malloc_like __result_use_check
9378 __alloc_size(1) __alloc_size(2);
9379div_t div(int, int) __pure2;
9380_Noreturn void exit(int);
9381void free(void *);
9382char *getenv(const char *);
9383long labs(long) __pure2;
9384ldiv_t ldiv(long, long) __pure2;
9385void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
9386int mblen(const char *, size_t);
9387size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
9388int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
9389void qsort(void *, size_t, size_t,
9390 int (*)(const void *, const void *));
9391int rand(void);
9392void *realloc(void *, size_t) __result_use_check __alloc_size(2);
9393void srand(unsigned);
9394double strtod(const char * __restrict, char ** __restrict);
9395float strtof(const char * __restrict, char ** __restrict);
9396long strtol(const char * __restrict, char ** __restrict, int);
9397long double
9398 strtold(const char * __restrict, char ** __restrict);
9399unsigned long
9400 strtoul(const char * __restrict, char ** __restrict, int);
9401int system(const char *);
9402int wctomb(char *, wchar_t);
9403size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
9404
9405/*
9406 * Functions added in C99 which we make conditionally available in the
9407 * BSD^C89 namespace if the compiler supports `long long'.
9408 * The #if test is more complicated than it ought to be because
9409 * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
9410 * is not supported in the compilation environment (which therefore means
9411 * that it can't really be ISO C99).
9412 *
9413 * (The only other extension made by C99 in thie header is _Exit().)
9414 */
9415#if __ISO_C_VISIBLE >= 1999
9416#ifdef __LONG_LONG_SUPPORTED
9417/* LONGLONG */
9418typedef struct {
9419 long long quot;
9420 long long rem;
9421} lldiv_t;
9422
9423/* LONGLONG */
9424long long
9425 atoll(const char *);
9426/* LONGLONG */
9427long long
9428 llabs(long long) __pure2;
9429/* LONGLONG */
9430lldiv_t lldiv(long long, long long) __pure2;
9431/* LONGLONG */
9432long long
9433 strtoll(const char * __restrict, char ** __restrict, int);
9434/* LONGLONG */
9435unsigned long long
9436 strtoull(const char * __restrict, char ** __restrict, int);
9437#endif /* __LONG_LONG_SUPPORTED */
9438# 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9439
9440_Noreturn void _Exit(int);
9441#endif /* __ISO_C_VISIBLE >= 1999 */
9442# 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9443
9444/*
9445 * If we're in a mode greater than C99, expose C11 functions.
9446 */
9447#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
9448void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
9449 __alloc_size(2);
9450int at_quick_exit(void (*)(void));
9451_Noreturn void
9452 quick_exit(int);
9453#endif /* __ISO_C_VISIBLE >= 2011 */
9454# 165 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9455/*
9456 * Extensions made by POSIX relative to C.
9457 */
9458#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
9459char *realpath(const char * __restrict, char * __restrict);
9460#endif
9461# 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9462#if __POSIX_VISIBLE >= 199506
9463int rand_r(unsigned *); /* (TSF) */
9464#endif
9465# 174 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9466#if __POSIX_VISIBLE >= 200112
9467int posix_memalign(void **, size_t, size_t) __nonnull(1) __alloc_align(2)
9468 __alloc_size(3); /* (ADV) */
9469int setenv(const char *, const char *, int);
9470int unsetenv(const char *);
9471#endif
9472# 180 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9473
9474#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
9475int getsubopt(char **, char *const *, char **);
9476#ifndef _MKDTEMP_DECLARED
9477char *mkdtemp(char *);
9478#define _MKDTEMP_DECLARED
9479#endif
9480# 187 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9481#ifndef _MKSTEMP_DECLARED
9482int mkstemp(char *);
9483#define _MKSTEMP_DECLARED
9484#endif
9485# 191 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9486#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
9487# 192 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9488
9489/*
9490 * The only changes to the XSI namespace in revision 6 were the deletion
9491 * of the ttyslot() and valloc() functions, which FreeBSD never declared
9492 * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
9493 * FreeBSD also does not have, and mktemp(), are to be deleted.
9494 */
9495#if __XSI_VISIBLE
9496/* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
9497long a64l(const char *);
9498double drand48(void);
9499/* char *ecvt(double, int, int * __restrict, int * __restrict); */
9500double erand48(unsigned short[3]);
9501/* char *fcvt(double, int, int * __restrict, int * __restrict); */
9502/* char *gcvt(double, int, int * __restrict, int * __restrict); */
9503int grantpt(int);
9504char *initstate(unsigned long /* XSI requires u_int */, char *, long);
9505long jrand48(unsigned short[3]);
9506char *l64a(long);
9507void lcong48(unsigned short[7]);
9508long lrand48(void);
9509#if !defined(_MKTEMP_DECLARED) && (__BSD_VISIBLE || __XSI_VISIBLE <= 600)
9510char *mktemp(char *);
9511#define _MKTEMP_DECLARED
9512#endif
9513# 217 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9514long mrand48(void);
9515long nrand48(unsigned short[3]);
9516int posix_openpt(int);
9517char *ptsname(int);
9518int putenv(char *);
9519long random(void);
9520unsigned short
9521 *seed48(unsigned short[3]);
9522#ifndef _SETKEY_DECLARED
9523int setkey(const char *);
9524#define _SETKEY_DECLARED
9525#endif
9526# 229 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9527char *setstate(/* const */ char *);
9528void srand48(long);
9529void srandom(unsigned long);
9530int unlockpt(int);
9531#endif /* __XSI_VISIBLE */
9532# 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9533
9534#if __BSD_VISIBLE
9535extern const char *malloc_conf;
9536extern void (*malloc_message)(void *, const char *);
9537
9538/*
9539 * The alloca() function can't be implemented in C, and on some
9540 * platforms it can't be implemented at all as a callable function.
9541 * The GNU C compiler provides a built-in alloca() which we can use;
9542 * in all other cases, provide a prototype, mainly to pacify various
9543 * incarnations of lint. On platforms where alloca() is not in libc,
9544 * programs which use it will fail to link when compiled with non-GNU
9545 * compilers.
9546 */
9547#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
9548#undef alloca /* some GNU bits try to get cute and define this on their own */
9549#define alloca(sz) __builtin_alloca(sz)
9550#elif defined(lint)
9551# 252 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9552void *alloca(size_t);
9553#endif
9554# 254 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9555
9556void abort2(const char *, int, void **) __dead2;
9557__uint32_t
9558 arc4random(void);
9559void arc4random_addrandom(unsigned char *, int);
9560void arc4random_buf(void *, size_t);
9561void arc4random_stir(void);
9562__uint32_t
9563 arc4random_uniform(__uint32_t);
9564#ifdef __BLOCKS__
9565int atexit_b(void (^)(void));
9566void *bsearch_b(const void *, const void *, size_t,
9567 size_t, int (^)(const void *, const void *));
9568#endif
9569# 268 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9570char *getbsize(int *, long *);
9571 /* getcap(3) functions */
9572char *cgetcap(char *, const char *, int);
9573int cgetclose(void);
9574int cgetent(char **, char **, const char *);
9575int cgetfirst(char **, char **);
9576int cgetmatch(const char *, const char *);
9577int cgetnext(char **, char **);
9578int cgetnum(char *, const char *, long *);
9579int cgetset(const char *);
9580int cgetstr(char *, const char *, char **);
9581int cgetustr(char *, const char *, char **);
9582
9583int daemon(int, int);
9584char *devname(__dev_t, __mode_t);
9585char *devname_r(__dev_t, __mode_t, char *, int);
9586char *fdevname(int);
9587char *fdevname_r(int, char *, int);
9588int getloadavg(double [], int);
9589const char *
9590 getprogname(void);
9591
9592int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
9593#ifdef __BLOCKS__
9594int heapsort_b(void *, size_t, size_t, int (^)(const void *, const void *));
9595void qsort_b(void *, size_t, size_t,
9596 int (^)(const void *, const void *));
9597#endif
9598# 296 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9599int l64a_r(long, char *, int);
9600int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
9601#ifdef __BLOCKS__
9602int mergesort_b(void *, size_t, size_t, int (^)(const void *, const void *));
9603#endif
9604# 301 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9605int mkostemp(char *, int);
9606int mkostemps(char *, int, int);
9607void qsort_r(void *, size_t, size_t, void *,
9608 int (*)(void *, const void *, const void *));
9609int radixsort(const unsigned char **, int, const unsigned char *,
9610 unsigned);
9611void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
9612 __alloc_size(3);
9613void *reallocf(void *, size_t) __alloc_size(2);
9614int rpmatch(const char *);
9615void setprogname(const char *);
9616int sradixsort(const unsigned char **, int, const unsigned char *,
9617 unsigned);
9618void sranddev(void);
9619void srandomdev(void);
9620long long
9621 strtonum(const char *, long long, long long, const char **);
9622
9623/* Deprecated interfaces, to be removed in FreeBSD 6.0. */
9624__int64_t
9625 strtoq(const char *, char **, int);
9626__uint64_t
9627 strtouq(const char *, char **, int);
9628
9629#if __has_feature(capabilities)
9630long strtol_c(__capability const char * __restrict,
9631 __capability char ** __restrict, int);
9632long double
9633 strtold_c(__capability const char * __restrict,
9634 __capability char ** __restrict);
9635#endif
9636# 332 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9637
9638extern char *suboptarg; /* getsubopt(3) external variable */
9639#endif /* __BSD_VISIBLE */
9640# 335 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9641__END_DECLS
9642
9643#endif /* !_STDLIB_H_ */
9644# 338 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/stdlib.h" 3 4
9645# 56 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
9646#if 0 /* expanded by -frewrite-includes */
9647#include <string.h>
9648#endif /* expanded by -frewrite-includes */
9649# 56 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
9650# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 1 3 4
9651/*-
9652 * Copyright (c) 1990, 1993
9653 * The Regents of the University of California. All rights reserved.
9654 *
9655 * Redistribution and use in source and binary forms, with or without
9656 * modification, are permitted provided that the following conditions
9657 * are met:
9658 * 1. Redistributions of source code must retain the above copyright
9659 * notice, this list of conditions and the following disclaimer.
9660 * 2. Redistributions in binary form must reproduce the above copyright
9661 * notice, this list of conditions and the following disclaimer in the
9662 * documentation and/or other materials provided with the distribution.
9663 * 3. Neither the name of the University nor the names of its contributors
9664 * may be used to endorse or promote products derived from this software
9665 * without specific prior written permission.
9666 *
9667 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
9668 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9669 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9670 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
9671 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9672 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9673 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9674 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9675 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9676 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9677 * SUCH DAMAGE.
9678 *
9679 * @(#)string.h 8.1 (Berkeley) 6/2/93
9680 * $FreeBSD$
9681 */
9682
9683#ifndef _STRING_H_
9684#define _STRING_H_
9685
9686#if 0 /* expanded by -frewrite-includes */
9687#include <sys/cdefs.h>
9688#endif /* expanded by -frewrite-includes */
9689# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9690# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9691#if 0 /* expanded by -frewrite-includes */
9692#include <sys/_null.h>
9693#endif /* expanded by -frewrite-includes */
9694# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9695# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9696#if 0 /* expanded by -frewrite-includes */
9697#include <sys/_types.h>
9698#endif /* expanded by -frewrite-includes */
9699# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9700# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9701
9702/*
9703 * Prototype functions which were historically defined in <string.h>, but
9704 * are required by POSIX to be prototyped in <strings.h>.
9705 */
9706#if __BSD_VISIBLE
9707#if 0 /* expanded by -frewrite-includes */
9708#include <strings.h>
9709#endif /* expanded by -frewrite-includes */
9710# 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9711# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 1 3 4
9712/*-
9713 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
9714 * All rights reserved.
9715 *
9716 * Redistribution and use in source and binary forms, with or without
9717 * modification, are permitted provided that the following conditions
9718 * are met:
9719 * 1. Redistributions of source code must retain the above copyright
9720 * notice, this list of conditions and the following disclaimer.
9721 * 2. Redistributions in binary form must reproduce the above copyright
9722 * notice, this list of conditions and the following disclaimer in the
9723 * documentation and/or other materials provided with the distribution.
9724 *
9725 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
9726 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9727 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9728 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
9729 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9730 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9731 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9732 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9733 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9734 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9735 * SUCH DAMAGE.
9736 *
9737 * $FreeBSD$
9738 */
9739
9740#ifndef _STRINGS_H_
9741#define _STRINGS_H_
9742
9743#if 0 /* expanded by -frewrite-includes */
9744#include <sys/cdefs.h>
9745#endif /* expanded by -frewrite-includes */
9746# 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9747# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9748#if 0 /* expanded by -frewrite-includes */
9749#include <sys/_types.h>
9750#endif /* expanded by -frewrite-includes */
9751# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9752# 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9753
9754#ifndef _SIZE_T_DECLARED
9755typedef __size_t size_t;
9756#define _SIZE_T_DECLARED
9757#endif
9758# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9759
9760__BEGIN_DECLS
9761#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
9762int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
9763void bcopy(const void *, void *, size_t); /* LEGACY */
9764void bzero(void *, size_t); /* LEGACY */
9765#endif
9766# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9767#if __BSD_VISIBLE
9768void explicit_bzero(void *, size_t);
9769#endif
9770# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9771#if __XSI_VISIBLE
9772int ffs(int) __pure2;
9773#endif
9774# 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9775#if __BSD_VISIBLE
9776int ffsl(long) __pure2;
9777int ffsll(long long) __pure2;
9778int fls(int) __pure2;
9779int flsl(long) __pure2;
9780int flsll(long long) __pure2;
9781#endif
9782# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9783#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
9784char *index(const char *, int) __pure; /* LEGACY */
9785char *rindex(const char *, int) __pure; /* LEGACY */
9786#endif
9787# 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9788int strcasecmp(const char *, const char *) __pure;
9789int strncasecmp(const char *, const char *, size_t) __pure;
9790
9791#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
9792#if 0 /* expanded by -frewrite-includes */
9793#include <xlocale/_strings.h>
9794#endif /* expanded by -frewrite-includes */
9795# 67 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9796# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_strings.h" 1 3 4
9797/*-
9798 * Copyright (c) 2011, 2012 The FreeBSD Foundation
9799 * All rights reserved.
9800 *
9801 * Redistribution and use in source and binary forms, with or without
9802 * modification, are permitted provided that the following conditions
9803 * are met:
9804 * 1. Redistributions of source code must retain the above copyright
9805 * notice, this list of conditions and the following disclaimer.
9806 * 2. Redistributions in binary form must reproduce the above copyright
9807 * notice, this list of conditions and the following disclaimer in the
9808 * documentation and/or other materials provided with the distribution.
9809 *
9810 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
9811 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9812 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9813 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
9814 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9815 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
9816 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
9817 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
9818 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
9819 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9820 * SUCH DAMAGE.
9821 *
9822 * $FreeBSD$
9823 */
9824
9825#ifndef _LOCALE_T_DEFINED
9826#define _LOCALE_T_DEFINED
9827typedef struct _xlocale *locale_t;
9828#endif
9829# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_strings.h" 3 4
9830
9831/*
9832 * This file is included from both strings.h and xlocale.h. We need to expose
9833 * the declarations unconditionally if we are included from xlocale.h, but only
9834 * if we are in POSIX2008 mode if included from string.h.
9835 */
9836
9837#ifndef _XLOCALE_STRINGS1_H
9838#define _XLOCALE_STRINGS1_H
9839
9840/*
9841 * POSIX2008 functions
9842 */
9843int strcasecmp_l(const char *, const char *, locale_t);
9844int strncasecmp_l(const char *, const char *, size_t, locale_t);
9845#endif /* _XLOCALE_STRINGS1_H */
9846# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_strings.h" 3 4
9847# 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 2 3 4
9848#endif
9849# 69 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9850__END_DECLS
9851
9852#endif /* _STRINGS_H_ */
9853# 72 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/strings.h" 3 4
9854# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 2 3 4
9855#endif
9856# 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9857
9858#ifndef _SIZE_T_DECLARED
9859typedef __size_t size_t;
9860#define _SIZE_T_DECLARED
9861#endif
9862# 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9863
9864__BEGIN_DECLS
9865#if __XSI_VISIBLE >= 600
9866void *memccpy(void * __restrict, const void * __restrict, int, size_t);
9867#endif
9868# 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9869void *memchr(const void *, int, size_t) __pure;
9870#if __BSD_VISIBLE
9871void *memrchr(const void *, int, size_t) __pure;
9872#endif
9873# 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9874int memcmp(const void *, const void *, size_t) __pure;
9875void *memcpy(void * __restrict, const void * __restrict, size_t);
9876#if __BSD_VISIBLE
9877void *memmem(const void *, size_t, const void *, size_t) __pure;
9878#endif
9879# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9880void *memmove(void *, const void *, size_t);
9881void *memset(void *, int, size_t);
9882#if __POSIX_VISIBLE >= 200809
9883char *stpcpy(char * __restrict, const char * __restrict);
9884char *stpncpy(char * __restrict, const char * __restrict, size_t);
9885#endif
9886# 72 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9887#if __BSD_VISIBLE
9888char *strcasestr(const char *, const char *) __pure;
9889#endif
9890# 75 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9891char *strcat(char * __restrict, const char * __restrict);
9892char *strchr(const char *, int) __pure;
9893#if __BSD_VISIBLE
9894char *strchrnul(const char*, int) __pure;
9895#endif
9896# 80 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9897int strcmp(const char *, const char *) __pure;
9898int strcoll(const char *, const char *);
9899char *strcpy(char * __restrict, const char * __restrict);
9900size_t strcspn(const char *, const char *) __pure;
9901#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
9902char *strdup(const char *) __malloc_like;
9903#endif
9904# 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9905char *strerror(int);
9906#if __POSIX_VISIBLE >= 200112
9907int strerror_r(int, char *, size_t);
9908#endif
9909# 91 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9910#if __BSD_VISIBLE
9911size_t strlcat(char * __restrict, const char * __restrict, size_t);
9912size_t strlcpy(char * __restrict, const char * __restrict, size_t);
9913#endif
9914# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9915size_t strlen(const char *) __pure;
9916#if __BSD_VISIBLE
9917void strmode(int, char *);
9918#endif
9919# 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9920char *strncat(char * __restrict, const char * __restrict, size_t);
9921int strncmp(const char *, const char *, size_t) __pure;
9922char *strncpy(char * __restrict, const char * __restrict, size_t);
9923#if __POSIX_VISIBLE >= 200809
9924char *strndup(const char *, size_t) __malloc_like;
9925size_t strnlen(const char *, size_t) __pure;
9926#endif
9927# 106 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9928#if __BSD_VISIBLE
9929char *strnstr(const char *, const char *, size_t) __pure;
9930#endif
9931# 109 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9932char *strpbrk(const char *, const char *) __pure;
9933char *strrchr(const char *, int) __pure;
9934#if __BSD_VISIBLE
9935char *strsep(char **, const char *);
9936#endif
9937# 114 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9938#if __POSIX_VISIBLE >= 200809
9939char *strsignal(int);
9940#endif
9941# 117 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9942size_t strspn(const char *, const char *) __pure;
9943char *strstr(const char *, const char *) __pure;
9944char *strtok(char * __restrict, const char * __restrict);
9945#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
9946char *strtok_r(char *, const char *, char **);
9947#endif
9948# 123 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9949size_t strxfrm(char * __restrict, const char * __restrict, size_t);
9950#if __BSD_VISIBLE
9951
9952#ifndef _SWAB_DECLARED
9953#define _SWAB_DECLARED
9954
9955#ifndef _SSIZE_T_DECLARED
9956typedef __ssize_t ssize_t;
9957#define _SSIZE_T_DECLARED
9958#endif /* _SIZE_T_DECLARED */
9959# 133 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9960
9961void swab(const void * __restrict, void * __restrict, ssize_t);
9962#endif /* _SWAB_DECLARED */
9963# 136 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
9964
9965#if __has_feature(capabilities)
9966__capability const void *
9967 memchr_c_const(__capability const void *, int, size_t) __pure;
9968__capability void
9969 *memchr_c(__capability const void *, int, size_t) __pure;
9970int memcmp_c(__capability const void *, __capability const void *, size_t)
9971 __pure;
9972__capability void
9973 *memcpy_c(__capability void * __restrict,
9974 __capability const void * __restrict, size_t);
9975void *memcpy_c_fromcap(void * __restrict,
9976 __capability const void * __restrict, size_t);
9977__capability void
9978 *memcpy_c_tocap(__capability void * __restrict,
9979 const void * __restrict, size_t);
9980__capability void
9981 *memmove_c(__capability void * __restrict,
9982 __capability const void * __restrict, size_t);
9983__capability void
9984 *memset_c(__capability void *, int, size_t);
9985
9986__capability char
9987 *strchr_c(__capability const char *, int) __pure;
9988int strcmp_c(__capability const char *,
9989 __capability const char *s2) __pure;
9990__capability char
9991 *strcpy_c(__capability char * __restrict,
9992 __capability const char * __restrict);
9993int strncmp_c(__capability const char *, __capability const char *,
9994 size_t) __pure;
9995__capability char
9996*strncpy_c(__capability char * __restrict, __capability const char * __restrict,
9997 size_t);
9998char *strncpy_c_fromcap(char * __restrict,
9999 __capability const char * __restrict, size_t);
10000__capability char
10001 *strncpy_c_tocap(__capability char * __restrict,
10002 const char * __restrict, size_t);
10003size_t strnlen_c(__capability const char *, size_t) __pure;
10004#endif
10005# 177 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
10006
10007#endif /* __BSD_VISIBLE */
10008# 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
10009
10010#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
10011#if 0 /* expanded by -frewrite-includes */
10012#include <xlocale/_string.h>
10013#endif /* expanded by -frewrite-includes */
10014# 181 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
10015# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_string.h" 1 3 4
10016/*-
10017 * Copyright (c) 2011, 2012 The FreeBSD Foundation
10018 * All rights reserved.
10019 *
10020 * Redistribution and use in source and binary forms, with or without
10021 * modification, are permitted provided that the following conditions
10022 * are met:
10023 * 1. Redistributions of source code must retain the above copyright
10024 * notice, this list of conditions and the following disclaimer.
10025 * 2. Redistributions in binary form must reproduce the above copyright
10026 * notice, this list of conditions and the following disclaimer in the
10027 * documentation and/or other materials provided with the distribution.
10028 *
10029 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
10030 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
10031 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
10032 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10033 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10034 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
10035 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
10036 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
10037 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
10038 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
10039 * SUCH DAMAGE.
10040 *
10041 * $FreeBSD$
10042 */
10043
10044#ifndef _LOCALE_T_DEFINED
10045#define _LOCALE_T_DEFINED
10046typedef struct _xlocale *locale_t;
10047#endif
10048# 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_string.h" 3 4
10049
10050/*
10051 * This file is included from both string.h and xlocale.h. We need to expose
10052 * the declarations unconditionally if we are included from xlocale.h, but only
10053 * if we are in POSIX2008 mode if included from string.h.
10054 */
10055
10056#ifndef _XLOCALE_STRING1_H
10057#define _XLOCALE_STRING1_H
10058
10059/*
10060 * POSIX2008 functions
10061 */
10062int strcoll_l(const char *, const char *, locale_t);
10063size_t strxfrm_l(char *, const char *, size_t, locale_t);
10064#endif /* _XLOCALE_STRING1_H */
10065# 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_string.h" 3 4
10066
10067/*
10068 * xlocale extensions
10069 */
10070#ifdef _XLOCALE_H_
10071#ifndef _XLOCALE_STRING2_H
10072#define _XLOCALE_STRING2_H
10073char *strcasestr_l(const char *, const char *, locale_t);
10074
10075#endif /* _XLOCALE_STRING2_H */
10076# 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_string.h" 3 4
10077#endif /* _XLOCALE_H_ */
10078# 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_string.h" 3 4
10079# 182 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 2 3 4
10080#endif
10081# 183 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
10082__END_DECLS
10083
10084#endif /* _STRING_H_ */
10085# 186 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/string.h" 3 4
10086# 57 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
10087#if 0 /* expanded by -frewrite-includes */
10088#include <sysexits.h>
10089#endif /* expanded by -frewrite-includes */
10090# 57 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
10091# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sysexits.h" 1 3 4
10092/*
10093 * Copyright (c) 1987, 1993
10094 * The Regents of the University of California. All rights reserved.
10095 *
10096 * Redistribution and use in source and binary forms, with or without
10097 * modification, are permitted provided that the following conditions
10098 * are met:
10099 * 1. Redistributions of source code must retain the above copyright
10100 * notice, this list of conditions and the following disclaimer.
10101 * 2. Redistributions in binary form must reproduce the above copyright
10102 * notice, this list of conditions and the following disclaimer in the
10103 * documentation and/or other materials provided with the distribution.
10104 * 3. Neither the name of the University nor the names of its contributors
10105 * may be used to endorse or promote products derived from this software
10106 * without specific prior written permission.
10107 *
10108 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
10109 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
10110 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
10111 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
10112 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10113 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
10114 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
10115 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
10116 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
10117 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
10118 * SUCH DAMAGE.
10119 *
10120 * @(#)sysexits.h 8.1 (Berkeley) 6/2/93
10121 *
10122 * $FreeBSD$
10123 */
10124
10125#ifndef _SYSEXITS_H_
10126#define _SYSEXITS_H_
10127
10128/*
10129 * SYSEXITS.H -- Exit status codes for system programs.
10130 *
10131 * This include file attempts to categorize possible error
10132 * exit statuses for system programs, notably delivermail
10133 * and the Berkeley network.
10134 *
10135 * Error numbers begin at EX__BASE to reduce the possibility of
10136 * clashing with other exit statuses that random programs may
10137 * already return. The meaning of the codes is approximately
10138 * as follows:
10139 *
10140 * EX_USAGE -- The command was used incorrectly, e.g., with
10141 * the wrong number of arguments, a bad flag, a bad
10142 * syntax in a parameter, or whatever.
10143 * EX_DATAERR -- The input data was incorrect in some way.
10144 * This should only be used for user's data & not
10145 * system files.
10146 * EX_NOINPUT -- An input file (not a system file) did not
10147 * exist or was not readable. This could also include
10148 * errors like "No message" to a mailer (if it cared
10149 * to catch it).
10150 * EX_NOUSER -- The user specified did not exist. This might
10151 * be used for mail addresses or remote logins.
10152 * EX_NOHOST -- The host specified did not exist. This is used
10153 * in mail addresses or network requests.
10154 * EX_UNAVAILABLE -- A service is unavailable. This can occur
10155 * if a support program or file does not exist. This
10156 * can also be used as a catchall message when something
10157 * you wanted to do doesn't work, but you don't know
10158 * why.
10159 * EX_SOFTWARE -- An internal software error has been detected.
10160 * This should be limited to non-operating system related
10161 * errors as possible.
10162 * EX_OSERR -- An operating system error has been detected.
10163 * This is intended to be used for such things as "cannot
10164 * fork", "cannot create pipe", or the like. It includes
10165 * things like getuid returning a user that does not
10166 * exist in the passwd file.
10167 * EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
10168 * etc.) does not exist, cannot be opened, or has some
10169 * sort of error (e.g., syntax error).
10170 * EX_CANTCREAT -- A (user specified) output file cannot be
10171 * created.
10172 * EX_IOERR -- An error occurred while doing I/O on some file.
10173 * EX_TEMPFAIL -- temporary failure, indicating something that
10174 * is not really an error. In sendmail, this means
10175 * that a mailer (e.g.) could not create a connection,
10176 * and the request should be reattempted later.
10177 * EX_PROTOCOL -- the remote system returned something that
10178 * was "not possible" during a protocol exchange.
10179 * EX_NOPERM -- You did not have sufficient permission to
10180 * perform the operation. This is not intended for
10181 * file system problems, which should use NOINPUT or
10182 * CANTCREAT, but rather for higher level permissions.
10183 */
10184
10185#define EX_OK 0 /* successful termination */
10186
10187#define EX__BASE 64 /* base value for error messages */
10188
10189#define EX_USAGE 64 /* command line usage error */
10190#define EX_DATAERR 65 /* data format error */
10191#define EX_NOINPUT 66 /* cannot open input */
10192#define EX_NOUSER 67 /* addressee unknown */
10193#define EX_NOHOST 68 /* host name unknown */
10194#define EX_UNAVAILABLE 69 /* service unavailable */
10195#define EX_SOFTWARE 70 /* internal software error */
10196#define EX_OSERR 71 /* system error (e.g., can't fork) */
10197#define EX_OSFILE 72 /* critical OS file missing */
10198#define EX_CANTCREAT 73 /* can't create (user) output file */
10199#define EX_IOERR 74 /* input/output error */
10200#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
10201#define EX_PROTOCOL 76 /* remote error in protocol */
10202#define EX_NOPERM 77 /* permission denied */
10203#define EX_CONFIG 78 /* configuration error */
10204
10205#define EX__MAX 78 /* maximum listed value */
10206
10207#endif /* !_SYSEXITS_H_ */
10208# 117 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sysexits.h" 3 4
10209# 58 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
10210#if 0 /* expanded by -frewrite-includes */
10211#include <unistd.h>
10212#endif /* expanded by -frewrite-includes */
10213# 58 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
10214# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 1 3 4
10215/*-
10216 * Copyright (c) 1991, 1993, 1994
10217 * The Regents of the University of California. All rights reserved.
10218 *
10219 * Redistribution and use in source and binary forms, with or without
10220 * modification, are permitted provided that the following conditions
10221 * are met:
10222 * 1. Redistributions of source code must retain the above copyright
10223 * notice, this list of conditions and the following disclaimer.
10224 * 2. Redistributions in binary form must reproduce the above copyright
10225 * notice, this list of conditions and the following disclaimer in the
10226 * documentation and/or other materials provided with the distribution.
10227 * 3. Neither the name of the University nor the names of its contributors
10228 * may be used to endorse or promote products derived from this software
10229 * without specific prior written permission.
10230 *
10231 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
10232 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
10233 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
10234 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
10235 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10236 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
10237 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
10238 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
10239 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
10240 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
10241 * SUCH DAMAGE.
10242 *
10243 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
10244 * $FreeBSD$
10245 */
10246
10247#ifndef _UNISTD_H_
10248#define _UNISTD_H_
10249
10250#if 0 /* expanded by -frewrite-includes */
10251#include <sys/cdefs.h>
10252#endif /* expanded by -frewrite-includes */
10253# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10254# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10255#if 0 /* expanded by -frewrite-includes */
10256#include <sys/types.h> /* XXX adds too much pollution. */
10257#endif /* expanded by -frewrite-includes */
10258# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10259# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10260#if 0 /* expanded by -frewrite-includes */
10261#include <sys/unistd.h>
10262#endif /* expanded by -frewrite-includes */
10263# 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10264# 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 1 3 4
10265/*-
10266 * Copyright (c) 1989, 1993
10267 * The Regents of the University of California. All rights reserved.
10268 *
10269 * Redistribution and use in source and binary forms, with or without
10270 * modification, are permitted provided that the following conditions
10271 * are met:
10272 * 1. Redistributions of source code must retain the above copyright
10273 * notice, this list of conditions and the following disclaimer.
10274 * 2. Redistributions in binary form must reproduce the above copyright
10275 * notice, this list of conditions and the following disclaimer in the
10276 * documentation and/or other materials provided with the distribution.
10277 * 4. Neither the name of the University nor the names of its contributors
10278 * may be used to endorse or promote products derived from this software
10279 * without specific prior written permission.
10280 *
10281 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
10282 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
10283 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
10284 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
10285 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10286 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
10287 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
10288 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
10289 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
10290 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
10291 * SUCH DAMAGE.
10292 *
10293 * @(#)unistd.h 8.2 (Berkeley) 1/7/94
10294 * $FreeBSD$
10295 */
10296
10297#ifndef _SYS_UNISTD_H_
10298#define _SYS_UNISTD_H_
10299
10300#if 0 /* expanded by -frewrite-includes */
10301#include <sys/cdefs.h>
10302#endif /* expanded by -frewrite-includes */
10303# 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10304# 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10305
10306/*
10307 * POSIX options and option groups we unconditionally do or don't
10308 * implement. Those options which are implemented (or not) entirely
10309 * in user mode are defined in <unistd.h>. Please keep this list in
10310 * alphabetical order.
10311 *
10312 * Anything which is defined as zero below **must** have an
10313 * implementation for the corresponding sysconf() which is able to
10314 * determine conclusively whether or not the feature is supported.
10315 * Anything which is defined as other than -1 below **must** have
10316 * complete headers, types, and function declarations as specified by
10317 * the POSIX standard; however, if the relevant sysconf() function
10318 * returns -1, the functions may be stubbed out.
10319 */
10320#define _POSIX_ADVISORY_INFO 200112L
10321#define _POSIX_ASYNCHRONOUS_IO 0
10322#define _POSIX_CHOWN_RESTRICTED 1
10323#define _POSIX_CLOCK_SELECTION (-1)
10324#define _POSIX_CPUTIME 200112L
10325#define _POSIX_FSYNC 200112L
10326#define _POSIX_IPV6 0
10327#define _POSIX_JOB_CONTROL 1
10328#define _POSIX_MAPPED_FILES 200112L
10329#define _POSIX_MEMLOCK (-1)
10330#define _POSIX_MEMLOCK_RANGE 200112L
10331#define _POSIX_MEMORY_PROTECTION 200112L
10332#define _POSIX_MESSAGE_PASSING 200112L
10333#define _POSIX_MONOTONIC_CLOCK 200112L
10334#define _POSIX_NO_TRUNC 1
10335#define _POSIX_PRIORITIZED_IO (-1)
10336#define _POSIX_PRIORITY_SCHEDULING 200112L
10337#define _POSIX_RAW_SOCKETS 200112L
10338#define _POSIX_REALTIME_SIGNALS 200112L
10339#define _POSIX_SEMAPHORES 200112L
10340#define _POSIX_SHARED_MEMORY_OBJECTS 200112L
10341#define _POSIX_SPORADIC_SERVER (-1)
10342#define _POSIX_SYNCHRONIZED_IO (-1)
10343#define _POSIX_TIMEOUTS 200112L
10344#define _POSIX_TIMERS 200112L
10345#define _POSIX_TYPED_MEMORY_OBJECTS (-1)
10346#define _POSIX_VDISABLE 0xff
10347
10348#if __XSI_VISIBLE
10349#define _XOPEN_SHM 1
10350#define _XOPEN_STREAMS (-1)
10351#endif
10352# 84 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10353
10354/*
10355 * Although we have saved user/group IDs, we do not use them in setuid
10356 * as described in POSIX 1003.1, because the feature does not work for
10357 * root. We use the saved IDs in seteuid/setegid, which are not currently
10358 * part of the POSIX 1003.1 specification. XXX revisit for 1003.1-2001
10359 * as this is now mandatory.
10360 */
10361#ifdef _NOT_AVAILABLE
10362#define _POSIX_SAVED_IDS 1 /* saved set-user-ID and set-group-ID */
10363#endif
10364# 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10365
10366/* Define the POSIX.1 version we target for compliance. */
10367#define _POSIX_VERSION 200112L
10368
10369/* access function */
10370#define F_OK 0 /* test for existence of file */
10371#define X_OK 0x01 /* test for execute or search permission */
10372#define W_OK 0x02 /* test for write permission */
10373#define R_OK 0x04 /* test for read permission */
10374
10375/* whence values for lseek(2) */
10376#ifndef SEEK_SET
10377#define SEEK_SET 0 /* set file offset to offset */
10378#define SEEK_CUR 1 /* set file offset to current plus offset */
10379#define SEEK_END 2 /* set file offset to EOF plus offset */
10380#endif
10381# 111 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10382#if __BSD_VISIBLE
10383#define SEEK_DATA 3 /* set file offset to next data past offset */
10384#define SEEK_HOLE 4 /* set file offset to next hole past offset */
10385#endif
10386# 115 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10387
10388#ifndef _POSIX_SOURCE
10389/* whence values for lseek(2); renamed by POSIX 1003.1 */
10390#define L_SET SEEK_SET
10391#define L_INCR SEEK_CUR
10392#define L_XTND SEEK_END
10393#endif
10394# 122 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10395
10396/* configurable pathname variables */
10397#define _PC_LINK_MAX 1
10398#define _PC_MAX_CANON 2
10399#define _PC_MAX_INPUT 3
10400#define _PC_NAME_MAX 4
10401#define _PC_PATH_MAX 5
10402#define _PC_PIPE_BUF 6
10403#define _PC_CHOWN_RESTRICTED 7
10404#define _PC_NO_TRUNC 8
10405#define _PC_VDISABLE 9
10406
10407#if __POSIX_VISIBLE >= 199309
10408#define _PC_ASYNC_IO 53
10409#define _PC_PRIO_IO 54
10410#define _PC_SYNC_IO 55
10411#endif
10412# 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10413
10414#if __POSIX_VISIBLE >= 200112
10415#define _PC_ALLOC_SIZE_MIN 10
10416#define _PC_FILESIZEBITS 12
10417#define _PC_REC_INCR_XFER_SIZE 14
10418#define _PC_REC_MAX_XFER_SIZE 15
10419#define _PC_REC_MIN_XFER_SIZE 16
10420#define _PC_REC_XFER_ALIGN 17
10421#define _PC_SYMLINK_MAX 18
10422#endif
10423# 149 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10424
10425#if __BSD_VISIBLE
10426#define _PC_ACL_EXTENDED 59
10427#define _PC_ACL_PATH_MAX 60
10428#define _PC_CAP_PRESENT 61
10429#define _PC_INF_PRESENT 62
10430#define _PC_MAC_PRESENT 63
10431#define _PC_ACL_NFS4 64
10432#endif
10433# 158 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10434
10435/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
10436#define _PC_MIN_HOLE_SIZE 21
10437
10438#if __BSD_VISIBLE
10439/*
10440 * rfork() options.
10441 *
10442 * XXX currently, some operations without RFPROC set are not supported.
10443 */
10444#define RFNAMEG (1<<0) /* UNIMPL new plan9 `name space' */
10445#define RFENVG (1<<1) /* UNIMPL copy plan9 `env space' */
10446#define RFFDG (1<<2) /* copy fd table */
10447#define RFNOTEG (1<<3) /* UNIMPL create new plan9 `note group' */
10448#define RFPROC (1<<4) /* change child (else changes curproc) */
10449#define RFMEM (1<<5) /* share `address space' */
10450#define RFNOWAIT (1<<6) /* give child to init */
10451#define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */
10452#define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */
10453#define RFCFDG (1<<12) /* close all fds, zero fd table */
10454#define RFTHREAD (1<<13) /* enable kernel thread support */
10455#define RFSIGSHARE (1<<14) /* share signal handlers */
10456#define RFLINUXTHPN (1<<16) /* do linux clone exit parent notification */
10457#define RFSTOPPED (1<<17) /* leave child in a stopped state */
10458#define RFHIGHPID (1<<18) /* use a pid higher than 10 (idleproc) */
10459#define RFTSIGZMB (1<<19) /* select signal for exit parent notification */
10460#define RFTSIGSHIFT 20 /* selected signal number is in bits 20-27 */
10461#define RFTSIGMASK 0xFF
10462#define RFTSIGNUM(flags) (((flags) >> RFTSIGSHIFT) & RFTSIGMASK)
10463#define RFTSIGFLAGS(signum) ((signum) << RFTSIGSHIFT)
10464#define RFPROCDESC (1<<28) /* return a process descriptor */
10465#define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */
10466#define RFFLAGS (RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \
10467 RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \
10468 RFPROCDESC | RFPPWAIT)
10469#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPPWAIT | RFPROCDESC)
10470
10471#endif /* __BSD_VISIBLE */
10472# 196 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10473
10474#endif /* !_SYS_UNISTD_H_ */
10475# 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/unistd.h" 3 4
10476# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 2 3 4
10477#if 0 /* expanded by -frewrite-includes */
10478#include <sys/_null.h>
10479#endif /* expanded by -frewrite-includes */
10480# 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10481# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10482#if 0 /* expanded by -frewrite-includes */
10483#include <sys/_types.h>
10484#endif /* expanded by -frewrite-includes */
10485# 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10486# 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10487
10488#ifndef _GID_T_DECLARED
10489typedef __gid_t gid_t;
10490#define _GID_T_DECLARED
10491#endif
10492# 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10493
10494#ifndef _OFF_T_DECLARED
10495typedef __off_t off_t;
10496#define _OFF_T_DECLARED
10497#endif
10498# 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10499
10500#ifndef _PID_T_DECLARED
10501typedef __pid_t pid_t;
10502#define _PID_T_DECLARED
10503#endif
10504# 56 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10505
10506#ifndef _SIZE_T_DECLARED
10507typedef __size_t size_t;
10508#define _SIZE_T_DECLARED
10509#endif
10510# 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10511
10512#ifndef _SSIZE_T_DECLARED
10513typedef __ssize_t ssize_t;
10514#define _SSIZE_T_DECLARED
10515#endif
10516# 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10517
10518#ifndef _UID_T_DECLARED
10519typedef __uid_t uid_t;
10520#define _UID_T_DECLARED
10521#endif
10522# 71 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10523
10524#ifndef _USECONDS_T_DECLARED
10525typedef __useconds_t useconds_t;
10526#define _USECONDS_T_DECLARED
10527#endif
10528# 76 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10529
10530#define STDIN_FILENO 0 /* standard input file descriptor */
10531#define STDOUT_FILENO 1 /* standard output file descriptor */
10532#define STDERR_FILENO 2 /* standard error file descriptor */
10533
10534#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
10535#define F_ULOCK 0 /* unlock locked section */
10536#define F_LOCK 1 /* lock a section for exclusive use */
10537#define F_TLOCK 2 /* test and lock a section for exclusive use */
10538#define F_TEST 3 /* test a section for locks by other procs */
10539#endif
10540# 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10541
10542/*
10543 * POSIX options and option groups we unconditionally do or don't
10544 * implement. This list includes those options which are exclusively
10545 * implemented (or not) in user mode. Please keep this list in
10546 * alphabetical order.
10547 *
10548 * Anything which is defined as zero below **must** have an
10549 * implementation for the corresponding sysconf() which is able to
10550 * determine conclusively whether or not the feature is supported.
10551 * Anything which is defined as other than -1 below **must** have
10552 * complete headers, types, and function declarations as specified by
10553 * the POSIX standard; however, if the relevant sysconf() function
10554 * returns -1, the functions may be stubbed out.
10555 */
10556#define _POSIX_BARRIERS 200112L
10557#define _POSIX_CPUTIME 200112L
10558#define _POSIX_READER_WRITER_LOCKS 200112L
10559#define _POSIX_REGEXP 1
10560#define _POSIX_SHELL 1
10561#define _POSIX_SPAWN 200112L
10562#define _POSIX_SPIN_LOCKS 200112L
10563#define _POSIX_THREAD_ATTR_STACKADDR 200112L
10564#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
10565#define _POSIX_THREAD_CPUTIME 200112L
10566#define _POSIX_THREAD_PRIO_INHERIT 200112L
10567#define _POSIX_THREAD_PRIO_PROTECT 200112L
10568#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L
10569#define _POSIX_THREAD_PROCESS_SHARED -1
10570#define _POSIX_THREAD_SAFE_FUNCTIONS -1
10571#define _POSIX_THREAD_SPORADIC_SERVER -1
10572#define _POSIX_THREADS 200112L
10573#define _POSIX_TRACE -1
10574#define _POSIX_TRACE_EVENT_FILTER -1
10575#define _POSIX_TRACE_INHERIT -1
10576#define _POSIX_TRACE_LOG -1
10577#define _POSIX2_C_BIND 200112L /* mandatory */
10578#define _POSIX2_C_DEV -1 /* need c99 utility */
10579#define _POSIX2_CHAR_TERM 1
10580#define _POSIX2_FORT_DEV -1 /* need fort77 utility */
10581#define _POSIX2_FORT_RUN 200112L
10582#define _POSIX2_LOCALEDEF -1
10583#define _POSIX2_PBS -1
10584#define _POSIX2_PBS_ACCOUNTING -1
10585#define _POSIX2_PBS_CHECKPOINT -1
10586#define _POSIX2_PBS_LOCATE -1
10587#define _POSIX2_PBS_MESSAGE -1
10588#define _POSIX2_PBS_TRACK -1
10589#define _POSIX2_SW_DEV -1 /* XXX ??? */
10590#define _POSIX2_UPE 200112L
10591#define _V6_ILP32_OFF32 -1
10592#define _V6_ILP32_OFFBIG 0
10593#define _V6_LP64_OFF64 0
10594#define _V6_LPBIG_OFFBIG -1
10595
10596#if __XSI_VISIBLE
10597#define _XOPEN_CRYPT -1 /* XXX ??? */
10598#define _XOPEN_ENH_I18N -1 /* mandatory in XSI */
10599#define _XOPEN_LEGACY -1
10600#define _XOPEN_REALTIME -1
10601#define _XOPEN_REALTIME_THREADS -1
10602#define _XOPEN_UNIX -1
10603#endif
10604# 150 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10605
10606/* Define the POSIX.2 version we target for compliance. */
10607#define _POSIX2_VERSION 199212L
10608
10609/*
10610 * POSIX-style system configuration variable accessors (for the
10611 * sysconf function). The kernel does not directly implement the
10612 * sysconf() interface; rather, a C library stub translates references
10613 * to sysconf() into calls to sysctl() using a giant switch statement.
10614 * Those that are marked `user' are implemented entirely in the C
10615 * library and never query the kernel. pathconf() is implemented
10616 * directly by the kernel so those are not defined here.
10617 */
10618#define _SC_ARG_MAX 1
10619#define _SC_CHILD_MAX 2
10620#define _SC_CLK_TCK 3
10621#define _SC_NGROUPS_MAX 4
10622#define _SC_OPEN_MAX 5
10623#define _SC_JOB_CONTROL 6
10624#define _SC_SAVED_IDS 7
10625#define _SC_VERSION 8
10626#define _SC_BC_BASE_MAX 9 /* user */
10627#define _SC_BC_DIM_MAX 10 /* user */
10628#define _SC_BC_SCALE_MAX 11 /* user */
10629#define _SC_BC_STRING_MAX 12 /* user */
10630#define _SC_COLL_WEIGHTS_MAX 13 /* user */
10631#define _SC_EXPR_NEST_MAX 14 /* user */
10632#define _SC_LINE_MAX 15 /* user */
10633#define _SC_RE_DUP_MAX 16 /* user */
10634#define _SC_2_VERSION 17 /* user */
10635#define _SC_2_C_BIND 18 /* user */
10636#define _SC_2_C_DEV 19 /* user */
10637#define _SC_2_CHAR_TERM 20 /* user */
10638#define _SC_2_FORT_DEV 21 /* user */
10639#define _SC_2_FORT_RUN 22 /* user */
10640#define _SC_2_LOCALEDEF 23 /* user */
10641#define _SC_2_SW_DEV 24 /* user */
10642#define _SC_2_UPE 25 /* user */
10643#define _SC_STREAM_MAX 26 /* user */
10644#define _SC_TZNAME_MAX 27 /* user */
10645
10646#if __POSIX_VISIBLE >= 199309
10647#define _SC_ASYNCHRONOUS_IO 28
10648#define _SC_MAPPED_FILES 29
10649#define _SC_MEMLOCK 30
10650#define _SC_MEMLOCK_RANGE 31
10651#define _SC_MEMORY_PROTECTION 32
10652#define _SC_MESSAGE_PASSING 33
10653#define _SC_PRIORITIZED_IO 34
10654#define _SC_PRIORITY_SCHEDULING 35
10655#define _SC_REALTIME_SIGNALS 36
10656#define _SC_SEMAPHORES 37
10657#define _SC_FSYNC 38
10658#define _SC_SHARED_MEMORY_OBJECTS 39
10659#define _SC_SYNCHRONIZED_IO 40
10660#define _SC_TIMERS 41
10661#define _SC_AIO_LISTIO_MAX 42
10662#define _SC_AIO_MAX 43
10663#define _SC_AIO_PRIO_DELTA_MAX 44
10664#define _SC_DELAYTIMER_MAX 45
10665#define _SC_MQ_OPEN_MAX 46
10666#define _SC_PAGESIZE 47
10667#define _SC_RTSIG_MAX 48
10668#define _SC_SEM_NSEMS_MAX 49
10669#define _SC_SEM_VALUE_MAX 50
10670#define _SC_SIGQUEUE_MAX 51
10671#define _SC_TIMER_MAX 52
10672#endif
10673# 218 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10674
10675#if __POSIX_VISIBLE >= 200112
10676#define _SC_2_PBS 59 /* user */
10677#define _SC_2_PBS_ACCOUNTING 60 /* user */
10678#define _SC_2_PBS_CHECKPOINT 61 /* user */
10679#define _SC_2_PBS_LOCATE 62 /* user */
10680#define _SC_2_PBS_MESSAGE 63 /* user */
10681#define _SC_2_PBS_TRACK 64 /* user */
10682#define _SC_ADVISORY_INFO 65
10683#define _SC_BARRIERS 66 /* user */
10684#define _SC_CLOCK_SELECTION 67
10685#define _SC_CPUTIME 68
10686#define _SC_FILE_LOCKING 69
10687#define _SC_GETGR_R_SIZE_MAX 70 /* user */
10688#define _SC_GETPW_R_SIZE_MAX 71 /* user */
10689#define _SC_HOST_NAME_MAX 72
10690#define _SC_LOGIN_NAME_MAX 73
10691#define _SC_MONOTONIC_CLOCK 74
10692#define _SC_MQ_PRIO_MAX 75
10693#define _SC_READER_WRITER_LOCKS 76 /* user */
10694#define _SC_REGEXP 77 /* user */
10695#define _SC_SHELL 78 /* user */
10696#define _SC_SPAWN 79 /* user */
10697#define _SC_SPIN_LOCKS 80 /* user */
10698#define _SC_SPORADIC_SERVER 81
10699#define _SC_THREAD_ATTR_STACKADDR 82 /* user */
10700#define _SC_THREAD_ATTR_STACKSIZE 83 /* user */
10701#define _SC_THREAD_CPUTIME 84 /* user */
10702#define _SC_THREAD_DESTRUCTOR_ITERATIONS 85 /* user */
10703#define _SC_THREAD_KEYS_MAX 86 /* user */
10704#define _SC_THREAD_PRIO_INHERIT 87 /* user */
10705#define _SC_THREAD_PRIO_PROTECT 88 /* user */
10706#define _SC_THREAD_PRIORITY_SCHEDULING 89 /* user */
10707#define _SC_THREAD_PROCESS_SHARED 90 /* user */
10708#define _SC_THREAD_SAFE_FUNCTIONS 91 /* user */
10709#define _SC_THREAD_SPORADIC_SERVER 92 /* user */
10710#define _SC_THREAD_STACK_MIN 93 /* user */
10711#define _SC_THREAD_THREADS_MAX 94 /* user */
10712#define _SC_TIMEOUTS 95 /* user */
10713#define _SC_THREADS 96 /* user */
10714#define _SC_TRACE 97 /* user */
10715#define _SC_TRACE_EVENT_FILTER 98 /* user */
10716#define _SC_TRACE_INHERIT 99 /* user */
10717#define _SC_TRACE_LOG 100 /* user */
10718#define _SC_TTY_NAME_MAX 101 /* user */
10719#define _SC_TYPED_MEMORY_OBJECTS 102
10720#define _SC_V6_ILP32_OFF32 103 /* user */
10721#define _SC_V6_ILP32_OFFBIG 104 /* user */
10722#define _SC_V6_LP64_OFF64 105 /* user */
10723#define _SC_V6_LPBIG_OFFBIG 106 /* user */
10724#define _SC_IPV6 118
10725#define _SC_RAW_SOCKETS 119
10726#define _SC_SYMLOOP_MAX 120
10727#endif
10728# 272 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10729
10730#if __XSI_VISIBLE
10731#define _SC_ATEXIT_MAX 107 /* user */
10732#define _SC_IOV_MAX 56
10733#define _SC_PAGE_SIZE _SC_PAGESIZE
10734#define _SC_XOPEN_CRYPT 108 /* user */
10735#define _SC_XOPEN_ENH_I18N 109 /* user */
10736#define _SC_XOPEN_LEGACY 110 /* user */
10737#define _SC_XOPEN_REALTIME 111
10738#define _SC_XOPEN_REALTIME_THREADS 112
10739#define _SC_XOPEN_SHM 113
10740#define _SC_XOPEN_STREAMS 114
10741#define _SC_XOPEN_UNIX 115
10742#define _SC_XOPEN_VERSION 116
10743#define _SC_XOPEN_XCU_VERSION 117 /* user */
10744#endif
10745# 288 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10746
10747#if __BSD_VISIBLE
10748#define _SC_NPROCESSORS_CONF 57
10749#define _SC_NPROCESSORS_ONLN 58
10750#define _SC_CPUSET_SIZE 122
10751#endif
10752# 294 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10753
10754/* Extensions found in Solaris and Linux. */
10755#define _SC_PHYS_PAGES 121
10756
10757/* Keys for the confstr(3) function. */
10758#if __POSIX_VISIBLE >= 199209
10759#define _CS_PATH 1 /* default value of PATH */
10760#endif
10761# 302 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10762
10763#if __POSIX_VISIBLE >= 200112
10764#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 2
10765#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 3
10766#define _CS_POSIX_V6_ILP32_OFF32_LIBS 4
10767#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 5
10768#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 6
10769#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 7
10770#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 8
10771#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 9
10772#define _CS_POSIX_V6_LP64_OFF64_LIBS 10
10773#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 11
10774#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 12
10775#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 13
10776#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 14
10777#endif
10778# 318 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10779
10780__BEGIN_DECLS
10781/* 1003.1-1990 */
10782void _exit(int) __dead2;
10783int access(const char *, int);
10784unsigned int alarm(unsigned int);
10785int chdir(const char *);
10786int chown(const char *, uid_t, gid_t);
10787int close(int);
10788void closefrom(int);
10789int dup(int);
10790int dup2(int, int);
10791int execl(const char *, const char *, ...) __sentinel;
10792int execle(const char *, const char *, ...);
10793int execlp(const char *, const char *, ...) __sentinel;
10794int execv(const char *, char * const *);
10795int execve(const char *, char * const *, char * const *);
10796int execvp(const char *, char * const *);
10797pid_t fork(void);
10798long fpathconf(int, int);
10799char *getcwd(char *, size_t);
10800gid_t getegid(void);
10801uid_t geteuid(void);
10802gid_t getgid(void);
10803int getgroups(int, gid_t []);
10804char *getlogin(void);
10805pid_t getpgrp(void);
10806pid_t getpid(void);
10807pid_t getppid(void);
10808uid_t getuid(void);
10809int isatty(int);
10810int link(const char *, const char *);
10811#ifndef _LSEEK_DECLARED
10812#define _LSEEK_DECLARED
10813off_t lseek(int, off_t, int);
10814#endif
10815# 354 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10816long pathconf(const char *, int);
10817int pause(void);
10818int pipe(int *);
10819ssize_t read(int, void *, size_t);
10820int rmdir(const char *);
10821int setgid(gid_t);
10822int setpgid(pid_t, pid_t);
10823pid_t setsid(void);
10824int setuid(uid_t);
10825unsigned int sleep(unsigned int);
10826long sysconf(int);
10827pid_t tcgetpgrp(int);
10828int tcsetpgrp(int, pid_t);
10829char *ttyname(int);
10830int ttyname_r(int, char *, size_t);
10831int unlink(const char *);
10832ssize_t write(int, const void *, size_t);
10833
10834/* 1003.2-1992 */
10835#if __POSIX_VISIBLE >= 199209 || __XSI_VISIBLE
10836size_t confstr(int, char *, size_t);
10837#ifndef _GETOPT_DECLARED
10838#define _GETOPT_DECLARED
10839int getopt(int, char * const [], const char *);
10840
10841extern char *optarg; /* getopt(3) external variables */
10842extern int optind, opterr, optopt;
10843#endif /* _GETOPT_DECLARED */
10844# 382 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10845#endif
10846# 383 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10847
10848/* ISO/IEC 9945-1: 1996 */
10849#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
10850int fsync(int);
10851
10852/*
10853 * ftruncate() was in the POSIX Realtime Extension (it's used for shared
10854 * memory), but truncate() was not.
10855 */
10856#ifndef _FTRUNCATE_DECLARED
10857#define _FTRUNCATE_DECLARED
10858int ftruncate(int, off_t);
10859#endif
10860# 396 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10861#endif
10862# 397 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10863
10864#if __POSIX_VISIBLE >= 199506
10865int getlogin_r(char *, int);
10866#endif
10867# 401 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10868
10869/* 1003.1-2001 */
10870#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
10871int fchown(int, uid_t, gid_t);
10872ssize_t readlink(const char * __restrict, char * __restrict, size_t);
10873#endif
10874# 407 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10875#if __POSIX_VISIBLE >= 200112
10876int gethostname(char *, size_t);
10877int setegid(gid_t);
10878int seteuid(uid_t);
10879#endif
10880# 412 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10881
10882/* 1003.1-2008 */
10883#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
10884int getsid(pid_t _pid);
10885int fchdir(int);
10886int getpgid(pid_t _pid);
10887int lchown(const char *, uid_t, gid_t);
10888ssize_t pread(int, void *, size_t, off_t);
10889ssize_t pwrite(int, const void *, size_t, off_t);
10890
10891/* See comment at ftruncate() above. */
10892#ifndef _TRUNCATE_DECLARED
10893#define _TRUNCATE_DECLARED
10894int truncate(const char *, off_t);
10895#endif
10896# 427 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10897#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
10898# 428 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10899
10900#if __POSIX_VISIBLE >= 200809
10901int faccessat(int, const char *, int, int);
10902int fchownat(int, const char *, uid_t, gid_t, int);
10903int fexecve(int, char *const [], char *const []);
10904int linkat(int, const char *, int, const char *, int);
10905ssize_t readlinkat(int, const char * __restrict, char * __restrict, size_t);
10906int symlinkat(const char *, int, const char *);
10907int unlinkat(int, const char *, int);
10908#endif /* __POSIX_VISIBLE >= 200809 */
10909# 438 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10910
10911/*
10912 * symlink() was originally in POSIX.1a, which was withdrawn after
10913 * being overtaken by events (1003.1-2001). It was in XPG4.2, and of
10914 * course has been in BSD since 4.2.
10915 */
10916#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402
10917int symlink(const char * __restrict, const char * __restrict);
10918#endif
10919# 447 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10920
10921/* X/Open System Interfaces */
10922#if __XSI_VISIBLE
10923char *crypt(const char *, const char *);
10924/* char *ctermid(char *); */ /* XXX ??? */
10925int encrypt(char *, int);
10926long gethostid(void);
10927int lockf(int, int, off_t);
10928int nice(int);
10929int setregid(gid_t, gid_t);
10930int setreuid(uid_t, uid_t);
10931
10932#ifndef _SWAB_DECLARED
10933#define _SWAB_DECLARED
10934void swab(const void * __restrict, void * __restrict, ssize_t);
10935#endif /* _SWAB_DECLARED */
10936# 463 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10937
10938void sync(void);
10939
10940#endif /* __XSI_VISIBLE */
10941# 467 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10942
10943#if (__XSI_VISIBLE && __XSI_VISIBLE <= 500) || __BSD_VISIBLE
10944int brk(const void *);
10945int chroot(const char *);
10946int getdtablesize(void);
10947int getpagesize(void) __pure2;
10948char *getpass(const char *);
10949void *sbrk(intptr_t);
10950#endif
10951# 476 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10952
10953#if (__XSI_VISIBLE && __XSI_VISIBLE <= 600) || __BSD_VISIBLE
10954char *getwd(char *); /* obsoleted by getcwd() */
10955useconds_t
10956 ualarm(useconds_t, useconds_t);
10957int usleep(useconds_t);
10958pid_t vfork(void) __returns_twice;
10959#endif
10960# 484 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10961
10962#if __BSD_VISIBLE
10963struct timeval; /* select(2) */
10964int acct(const char *);
10965int async_daemon(void);
10966int check_utility_compat(const char *);
10967const char *
10968 crypt_get_format(void);
10969int crypt_set_format(const char *);
10970int des_cipher(const char *, char *, long, int);
10971int des_setkey(const char *key);
10972int dup3(int, int, int);
10973int eaccess(const char *, int);
10974void endusershell(void);
10975int exect(const char *, char * const *, char * const *);
10976int execvP(const char *, const char *, char * const *);
10977int feature_present(const char *);
10978char *fflagstostr(u_long);
10979int getdomainname(char *, int);
10980int getgrouplist(const char *, gid_t, gid_t *, int *);
10981int getloginclass(char *, size_t);
10982mode_t getmode(const void *, mode_t);
10983int getosreldate(void);
10984int getpeereid(int, uid_t *, gid_t *);
10985int getresgid(gid_t *, gid_t *, gid_t *);
10986int getresuid(uid_t *, uid_t *, uid_t *);
10987char *getusershell(void);
10988int initgroups(const char *, gid_t);
10989int iruserok(unsigned long, int, const char *, const char *);
10990int iruserok_sa(const void *, int, int, const char *, const char *);
10991int issetugid(void);
10992void __FreeBSD_libc_enter_restricted_mode(void);
10993long lpathconf(const char *, int);
10994#ifndef _MKDTEMP_DECLARED
10995char *mkdtemp(char *);
10996#define _MKDTEMP_DECLARED
10997#endif
10998# 521 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
10999#ifndef _MKNOD_DECLARED
11000int mknod(const char *, mode_t, dev_t);
11001#define _MKNOD_DECLARED
11002#endif
11003# 525 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11004#ifndef _MKSTEMP_DECLARED
11005int mkstemp(char *);
11006#define _MKSTEMP_DECLARED
11007#endif
11008# 529 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11009int mkstemps(char *, int);
11010#ifndef _MKTEMP_DECLARED
11011char *mktemp(char *);
11012#define _MKTEMP_DECLARED
11013#endif
11014# 534 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11015int nfssvc(int, void *);
11016int nlm_syscall(int, int, int, char **);
11017int pipe2(int *, int);
11018int profil(char *, size_t, vm_offset_t, int);
11019int rcmd(char **, int, const char *, const char *, const char *, int *);
11020int rcmd_af(char **, int, const char *,
11021 const char *, const char *, int *, int);
11022int rcmdsh(char **, int, const char *,
11023 const char *, const char *, const char *);
11024char *re_comp(const char *);
11025int re_exec(const char *);
11026int reboot(int);
11027int revoke(const char *);
11028pid_t rfork(int);
11029pid_t rfork_thread(int, void *, int (*)(void *), void *);
11030int rresvport(int *);
11031int rresvport_af(int *, int);
11032int ruserok(const char *, int, const char *, const char *);
11033#if __BSD_VISIBLE
11034#ifndef _SELECT_DECLARED
11035#define _SELECT_DECLARED
11036int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
11037#endif
11038# 557 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11039#endif
11040# 558 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11041int setdomainname(const char *, int);
11042int setgroups(int, const gid_t *);
11043void sethostid(long);
11044int sethostname(const char *, int);
11045#ifndef _SETKEY_DECLARED
11046int setkey(const char *);
11047#define _SETKEY_DECLARED
11048#endif
11049# 566 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11050int setlogin(const char *);
11051int setloginclass(const char *);
11052void *setmode(const char *);
11053int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */
11054void setproctitle(const char *_fmt, ...) __printf0like(1, 2);
11055int setresgid(gid_t, gid_t, gid_t);
11056int setresuid(uid_t, uid_t, uid_t);
11057int setrgid(gid_t);
11058int setruid(uid_t);
11059void setusershell(void);
11060int strtofflags(char **, u_long *, u_long *);
11061int swapon(const char *);
11062int swapoff(const char *);
11063int syscall(int, ...);
11064off_t __syscall(quad_t, ...);
11065int undelete(const char *);
11066int unwhiteout(const char *);
11067void *valloc(size_t); /* obsoleted by malloc() */
11068
11069#ifndef _OPTRESET_DECLARED
11070#define _OPTRESET_DECLARED
11071extern int optreset; /* getopt(3) external variable */
11072#endif
11073# 589 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11074
11075#if __has_feature(capabilities)
11076ssize_t write_c(int, __capability const void *, size_t);
11077#endif
11078# 593 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11079#endif /* __BSD_VISIBLE */
11080# 594 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11081__END_DECLS
11082
11083#endif /* !_UNISTD_H_ */
11084# 597 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/unistd.h" 3 4
11085# 59 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
11086
11087#if 0 /* expanded by -frewrite-includes */
11088#include "cheritest.h"
11089#endif /* expanded by -frewrite-includes */
11090# 60 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c"
11091# 1 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest.h" 1
11092/*-
11093 * Copyright (c) 2012-2015 Robert N. M. Watson
11094 * Copyright (c) 2014 SRI International
11095 * All rights reserved.
11096 *
11097 * This software was developed by SRI International and the University of
11098 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
11099 * ("CTSRD"), as part of the DARPA CRASH research programme.
11100 *
11101 * Redistribution and use in source and binary forms, with or without
11102 * modification, are permitted provided that the following conditions
11103 * are met:
11104 * 1. Redistributions of source code must retain the above copyright
11105 * notice, this list of conditions and the following disclaimer.
11106 * 2. Redistributions in binary form must reproduce the above copyright
11107 * notice, this list of conditions and the following disclaimer in the
11108 * documentation and/or other materials provided with the distribution.
11109 *
11110 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
11111 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
11112 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
11113 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
11114 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11115 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
11116 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
11117 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
11118 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
11119 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
11120 * SUCH DAMAGE.
11121 */
11122
11123#ifndef _CHERITEST_H_
11124#define _CHERITEST_H_
11125
11126#define CHERI_CAP_PRINT(cap) do { \
11127 printf("tag %ju s %ju perms %08jx type %016jx\n", \
11128 (uintmax_t)cheri_gettag(cap), \
11129 (uintmax_t)cheri_getsealed(cap), \
11130 (uintmax_t)cheri_getperm(cap), \
11131 (uintmax_t)cheri_gettype(cap)); \
11132 printf("\tbase %016jx length %016jx\n", \
11133 (uintmax_t)cheri_getbase(cap), \
11134 (uintmax_t)cheri_getlen(cap)); \
11135} while (0)
11136
11137#define CHERI_CAPREG_PRINT(crn) do { \
11138 __capability void *cap; \
11139 if (crn == 0) \
11140 cap = cheri_getdefault(); \
11141 else \
11142 cap = cheri_getreg(crn); \
11143 printf("C%u ", crn); \
11144 CHERI_CAP_PRINT(cap); \
11145} while (0)
11146
11147#define CHERI_PCC_PRINT() do { \
11148 __capability void *cap; \
11149 cap = cheri_getpcc(); \
11150 printf("PCC "); \
11151 CHERI_CAP_PRINT(cap); \
11152} while (0)
11153
11154/*
11155 * Shared memory interface between tests and the test controller process.
11156 */
11157#define TESTRESULT_STR_LEN 1024
11158struct cheritest_child_state {
11159 /* Fields filled in by the child signal handler. */
11160 int ccs_signum;
11161 register_t ccs_mips_cause;
11162 register_t ccs_cp2_cause;
11163
11164 /* Fields filled in by the test itself. */
11165 int ccs_testresult;
11166 char ccs_testresult_str[TESTRESULT_STR_LEN];
11167};
11168extern struct cheritest_child_state *ccsp;
11169
11170/*
11171 * If the test runs to completion, it must set ccs_testresult to SUCCESS or
11172 * FAILURE. If the latter, it should also fill ccs_testresult_str with a
11173 * suitable message to display to the user.
11174 */
11175#define TESTRESULT_UNKNOWN 0 /* Default initialisation. */
11176#define TESTRESULT_SUCCESS 1 /* Test declares success. */
11177#define TESTRESULT_FAILURE 2 /* Test declares failure. */
11178
11179/*
11180 * Description structure for each test -- passed to the test in case it needs
11181 * access to configuration state, such as strings passed to/from stdio.
11182 */
11183#define CT_FLAG_SIGNAL 0x00000001 /* Should fault; checks signum. */
11184#define CT_FLAG_MIPS_EXCCODE 0x00000002 /* Check MIPS exception code. */
11185#define CT_FLAG_CP2_EXCCODE 0x00000004 /* Check CP2 exception code. */
11186#define CT_FLAG_STDOUT_STRING 0x00000008 /* Check stdout for a string. */
11187#define CT_FLAG_STDIN_STRING 0x00000010 /* Provide strong on stdin. */
11188#define CT_FLAG_STDOUT_IGNORE 0x00000020 /* Standard output produced,
11189 but not checkable */
11190#define CT_FLAG_SLOW 0x00000040 /* Test is expected to take a
11191 long time to run */
11192#define CT_FLAG_SIGNAL_UNWIND 0x00000080 /* Should fault and unwind
11193 trusted stack; checks signum
11194 and result. */
11195
11196#define CHERITEST_SANDBOX_UNWOUND 0x123456789ULL
11197
11198struct cheri_test {
11199 const char *ct_name;
11200 const char *ct_desc;
11201 int ct_arg; /* 0: ct_func; otherwise ct_func_arg. */
11202 void (*ct_func)(const struct cheri_test *);
11203 void (*ct_func_arg)(const struct cheri_test *, int);
11204 const char * (*ct_check_xfail)(const char *);
11205 u_int ct_flags;
11206 int ct_signum;
11207 register_t ct_mips_exccode;
11208 register_t ct_cp2_exccode;
11209 const char *ct_stdin_string;
11210 const char *ct_stdout_string;
11211 const char *ct_xfail_reason;
11212};
11213
11214/*
11215 * Useful APIs for tests. These terminate the process returning either
11216 * success or failure with a test-defined, human-readable string describing
11217 * the error.
11218 *
11219 * XXXRW: It would be nice to also offer a cheritest_failure_err().
11220 */
11221void cheritest_failure_err(const char *msg, ...) __dead2;
11222void cheritest_failure_errx(const char *msg, ...) __dead2;
11223void cheritest_success(void) __dead2;
11224
11225/* cheritest_bounds.c */
11226void test_bounds_stack_static_uint8(const struct cheri_test *ctp);
11227void test_bounds_stack_static_uint16(const struct cheri_test *ctp);
11228void test_bounds_stack_static_uint32(const struct cheri_test *ctp);
11229void test_bounds_stack_static_uint64(const struct cheri_test *ctp);
11230void test_bounds_stack_static_cap(const struct cheri_test *ctp);
11231void test_bounds_stack_static_16(const struct cheri_test *ctp);
11232void test_bounds_stack_static_32(const struct cheri_test *ctp);
11233void test_bounds_stack_static_64(const struct cheri_test *ctp);
11234void test_bounds_stack_static_128(const struct cheri_test *ctp);
11235void test_bounds_stack_static_256(const struct cheri_test *ctp);
11236void test_bounds_stack_static_512(const struct cheri_test *ctp);
11237void test_bounds_stack_static_1024(const struct cheri_test *ctp);
11238void test_bounds_stack_static_2048(const struct cheri_test *ctp);
11239void test_bounds_stack_static_4096(const struct cheri_test *ctp);
11240void test_bounds_stack_static_8192(const struct cheri_test *ctp);
11241void test_bounds_stack_static_16384(const struct cheri_test *ctp);
11242void test_bounds_stack_static_32768(const struct cheri_test *ctp);
11243void test_bounds_stack_static_65536(const struct cheri_test *ctp);
11244void test_bounds_stack_static_131072(const struct cheri_test *ctp);
11245void test_bounds_stack_static_262144(const struct cheri_test *ctp);
11246void test_bounds_stack_static_524288(const struct cheri_test *ctp);
11247void test_bounds_stack_static_1048576(const struct cheri_test *ctp);
11248void test_bounds_stack_dynamic_uint8(const struct cheri_test *ctp);
11249void test_bounds_stack_dynamic_uint16(const struct cheri_test *ctp);
11250void test_bounds_stack_dynamic_uint32(const struct cheri_test *ctp);
11251void test_bounds_stack_dynamic_uint64(const struct cheri_test *ctp);
11252void test_bounds_stack_dynamic_cap(const struct cheri_test *ctp);
11253void test_bounds_stack_dynamic_16(const struct cheri_test *ctp);
11254void test_bounds_stack_dynamic_32(const struct cheri_test *ctp);
11255void test_bounds_stack_dynamic_64(const struct cheri_test *ctp);
11256void test_bounds_stack_dynamic_128(const struct cheri_test *ctp);
11257void test_bounds_stack_dynamic_256(const struct cheri_test *ctp);
11258void test_bounds_stack_dynamic_512(const struct cheri_test *ctp);
11259void test_bounds_stack_dynamic_1024(const struct cheri_test *ctp);
11260void test_bounds_stack_dynamic_2048(const struct cheri_test *ctp);
11261void test_bounds_stack_dynamic_4096(const struct cheri_test *ctp);
11262void test_bounds_stack_dynamic_8192(const struct cheri_test *ctp);
11263void test_bounds_stack_dynamic_16384(const struct cheri_test *ctp);
11264void test_bounds_stack_dynamic_32768(const struct cheri_test *ctp);
11265void test_bounds_stack_dynamic_65536(const struct cheri_test *ctp);
11266void test_bounds_stack_dynamic_131072(const struct cheri_test *ctp);
11267void test_bounds_stack_dynamic_262144(const struct cheri_test *ctp);
11268void test_bounds_stack_dynamic_524288(const struct cheri_test *ctp);
11269void test_bounds_stack_dynamic_1048576(const struct cheri_test *ctp);
11270
11271/* cheritest_ccall.c */
11272void cheritest_ccall_setup(void);
11273void test_nofault_ccall_creturn(const struct cheri_test *ctp);
11274void test_nofault_ccall_nop_creturn(const struct cheri_test *ctp);
11275void test_nofault_ccall_dli_creturn(const struct cheri_test *ctp);
11276void test_fault_creturn(const struct cheri_test *ctp);
11277void test_fault_ccall_code_untagged(const struct cheri_test *ctp);
11278void test_fault_ccall_data_untagged(const struct cheri_test *ctp);
11279void test_fault_ccall_code_unsealed(const struct cheri_test *ctp);
11280void test_fault_ccall_data_unsealed(const struct cheri_test *ctp);
11281void test_fault_ccall_typemismatch(const struct cheri_test *ctp);
11282void test_fault_ccall_code_noexecute(const struct cheri_test *ctp);
11283void test_fault_ccall_data_execute(const struct cheri_test *ctp);
11284
11285/* cheritest_fault.c */
11286void test_fault_bounds(const struct cheri_test *ctp);
11287void test_fault_cgetcause(const struct cheri_test *ctp);
11288void test_nofault_cfromptr(const struct cheri_test *ctp);
11289void test_fault_perm_load(const struct cheri_test *ctp);
11290void test_nofault_perm_load(const struct cheri_test *ctp);
11291void test_fault_perm_store(const struct cheri_test *ctp);
11292void test_nofault_perm_store(const struct cheri_test *ctp);
11293void test_fault_tag(const struct cheri_test *ctp);
11294void test_fault_ccheck_user_fail(const struct cheri_test *ctp);
11295void test_fault_read_kr1c(const struct cheri_test *ctp);
11296void test_fault_read_kr2c(const struct cheri_test *ctp);
11297void test_fault_read_kcc(const struct cheri_test *ctp);
11298void test_fault_read_kdc(const struct cheri_test *ctp);
11299void test_fault_read_epcc(const struct cheri_test *ctp);
11300void test_nofault_ccheck_user_pass(const struct cheri_test *ctp);
11301
11302void test_sandbox_cp2_bound_catch(const struct cheri_test *ctp);
11303void test_sandbox_cp2_bound_nocatch(const struct cheri_test *ctp);
11304void test_sandbox_cp2_perm_load_catch(const struct cheri_test *ctp);
11305void test_sandbox_cp2_perm_load_nocatch(const struct cheri_test *ctp);
11306void test_sandbox_cp2_perm_store_catch(const struct cheri_test *ctp);
11307void test_sandbox_cp2_perm_store_nocatch(const struct cheri_test *ctp);
11308void test_sandbox_cp2_tag_catch(const struct cheri_test *ctp);
11309void test_sandbox_cp2_tag_nocatch(const struct cheri_test *ctp);
11310void test_sandbox_cp2_seal_catch(const struct cheri_test *ctp);
11311void test_sandbox_cp2_seal_nocatch(const struct cheri_test *ctp);
11312void test_sandbox_divzero_catch(const struct cheri_test *ctp);
11313void test_sandbox_divzero_nocatch(const struct cheri_test *ctp);
11314void test_sandbox_vm_rfault_catch(const struct cheri_test *ctp);
11315void test_sandbox_vm_rfault_nocatch(const struct cheri_test *ctp);
11316void test_sandbox_vm_wfault_catch(const struct cheri_test *ctp);
11317void test_sandbox_vm_wfault_nocatch(const struct cheri_test *ctp);
11318void test_sandbox_vm_xfault_catch(const struct cheri_test *ctp);
11319void test_sandbox_vm_xfault_nocatch(const struct cheri_test *ctp);
11320
11321/* cheritest_fd.c */
11322#define CHERITEST_FD_READ_STR "read123"
11323#define CHERITEST_FD_WRITE_STR "write123"
11324
11325extern int zero_fd;
11326extern struct cheri_object stdin_fd_object;
11327extern struct cheri_object stdout_fd_object;
11328extern struct cheri_object zero_fd_object;
11329
11330void test_sandbox_fd_fstat(const struct cheri_test *ctp);
11331void test_sandbox_fd_lseek(const struct cheri_test *ctp);
11332void test_sandbox_fd_read(const struct cheri_test *ctp);
11333void test_sandbox_fd_read_revoke(const struct cheri_test *ctp);
11334void test_sandbox_fd_write(const struct cheri_test *ctp);
11335void test_sandbox_fd_write_revoke(const struct cheri_test *ctp);
11336
11337/* cheritest_inflate.c */
11338void test_sandbox_inflate_zeros(const struct cheri_test *ctp);
11339
11340/* cheritest_libcheri.c */
11341extern struct sandbox_class *cheritest_classp;
11342extern struct sandbox_object *cheritest_objectp;
11343
11344void test_sandbox_abort(const struct cheri_test *ctp);
11345void test_sandbox_cs_calloc(const struct cheri_test *ctp);
11346void test_sandbox_cs_clock_gettime(const struct cheri_test *ctp);
11347void test_sandbox_cs_helloworld(const struct cheri_test *ctp);
11348void test_sandbox_cs_putchar(const struct cheri_test *ctp);
11349void test_sandbox_cs_puts(const struct cheri_test *ctp);
11350void test_sandbox_malloc(const struct cheri_test *ctp);
11351void test_sandbox_md5_ccall(const struct cheri_test *ctp, int class2);
11352void test_sandbox_printf(const struct cheri_test *ctp);
11353void test_sandbox_ptrdiff(const struct cheri_test *ctp);
11354void test_sandbox_varargs(const struct cheri_test *ctp);
11355void test_sandbox_va_copy(const struct cheri_test *ctp);
11356void test_sandbox_spin(const struct cheri_test *ctp);
11357void test_sandbox_userfn(const struct cheri_test *ctp);
11358void test_2sandbox_newdestroy(const struct cheri_test *ctp);
11359int cheritest_libcheri_setup(void);
11360void cheritest_libcheri_destroy(void);
11361
11362/* cheritest_stack.c */
11363register_t cheritest_libcheri_userfn_getstack(void);
11364register_t cheritest_libcheri_userfn_setstack(register_t arg);
11365void test_sandbox_getstack(const struct cheri_test *ctp);
11366void test_sandbox_setstack(const struct cheri_test *ctp);
11367void test_sandbox_setstack_nop(const struct cheri_test *ctp);
11368
11369/* cheritest_string.c */
11370void test_string_memcpy(const struct cheri_test *ctp);
11371void test_string_memcpy_c(const struct cheri_test *ctp);
11372void test_string_memmove(const struct cheri_test *ctp);
11373void test_string_memmove_c(const struct cheri_test *ctp);
11374
11375/* cheritest_syscall.c */
11376void test_sandbox_syscall(const struct cheri_test *ctp);
11377
11378/* cheritest_registers.c */
11379void test_initregs_default(const struct cheri_test *ctp);
11380void test_initregs_stack(const struct cheri_test *ctp);
11381void test_initregs_idc(const struct cheri_test *ctp);
11382void test_initregs_pcc(const struct cheri_test *ctp);
11383void test_copyregs(const struct cheri_test *ctp);
11384void test_listregs(const struct cheri_test *ctp);
11385
11386/* cheritest_var.c */
11387void test_sandbox_save_global(const struct cheri_test *ctp);
11388void test_sandbox_save_local(const struct cheri_test *ctp);
11389void test_sandbox_var_bss(const struct cheri_test *ctp);
11390void test_sandbox_var_data(const struct cheri_test *ctp);
11391void test_sandbox_var_data_getset(const struct cheri_test *ctp);
11392void test_2sandbox_var_data_getset(const struct cheri_test *ctp);
11393void test_sandbox_var_constructor(const struct cheri_test *ctp);
11394
11395/* cheritest_vm.c */
11396void cheritest_vm_tag_mmap_anon(const struct cheri_test *ctp __unused);
11397void cheritest_vm_tag_shm_open_anon_shared(const struct cheri_test *ctp
11398 __unused);
11399void cheritest_vm_tag_shm_open_anon_private(const struct cheri_test *ctp
11400 __unused);
11401void cheritest_vm_tag_dev_zero_shared(const struct cheri_test *ctp
11402 __unused);
11403void cheritest_vm_tag_dev_zero_private(const struct cheri_test *ctp
11404 __unused);
11405void cheritest_vm_notag_tmpfile_shared(const struct cheri_test *ctp __unused);
11406void cheritest_vm_tag_tmpfile_private(const struct cheri_test *ctp __unused);
11407void cheritest_vm_tag_tmpfile_private_prefault(const struct cheri_test *ctp
11408 __unused);
11409void cheritest_vm_cow_read(const struct cheri_test *ctp);
11410void cheritest_vm_cow_write(const struct cheri_test *ctp);
11411const char *xfail_need_writable_tmp(const char *name);
11412
11413/* cheritest_vm_swap.c */
11414void cheritest_vm_swap(const struct cheri_test *ctp __unused);
11415const char *xfail_swap_required(const char *name);
11416
11417#endif /* !_CHERITEST_H_ */
11418# 327 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest.h"
11419# 61 "/home/rnw24/git/cheribsd/bin/cheritest/cheritest_registers.c" 2
11420
11421void
11422test_copyregs(const struct cheri_test *ctp __unused)
11423{
11424
11425 CHERI_CGETDEFAULT(2);
11426 CHERI_CGETDEFAULT(3);
11427 CHERI_CGETDEFAULT(4);
11428 CHERI_CGETDEFAULT(5);
11429 CHERI_CGETDEFAULT(6);
11430 CHERI_CGETDEFAULT(7);
11431 cheritest_success();
11432}
11433
11434void
11435test_listregs(const struct cheri_test *ctp __unused)
11436{
11437
11438 /*
11439 * Because of the assembly generated by CP2_CR_GET(), can't use a loop
11440 * -- register numbers must be available at compile-time.
11441 */
11442 printf("CP2 registers:\n");
11443 CHERI_CAPREG_PRINT(0);
11444 CHERI_CAPREG_PRINT(1);
11445 CHERI_CAPREG_PRINT(2);
11446 CHERI_CAPREG_PRINT(3);
11447 CHERI_CAPREG_PRINT(4);
11448 CHERI_CAPREG_PRINT(5);
11449 CHERI_CAPREG_PRINT(6);
11450 CHERI_CAPREG_PRINT(7);
11451 CHERI_CAPREG_PRINT(8);
11452 CHERI_CAPREG_PRINT(9);
11453 CHERI_CAPREG_PRINT(10);
11454 CHERI_CAPREG_PRINT(11);
11455 CHERI_CAPREG_PRINT(12);
11456 CHERI_CAPREG_PRINT(13);
11457 CHERI_CAPREG_PRINT(14);
11458 CHERI_CAPREG_PRINT(15);
11459 CHERI_CAPREG_PRINT(16);
11460 CHERI_CAPREG_PRINT(17);
11461 CHERI_CAPREG_PRINT(18);
11462 CHERI_CAPREG_PRINT(19);
11463 CHERI_CAPREG_PRINT(20);
11464 CHERI_CAPREG_PRINT(21);
11465 CHERI_CAPREG_PRINT(22);
11466 CHERI_CAPREG_PRINT(23);
11467 CHERI_CAPREG_PRINT(24);
11468 CHERI_CAPREG_PRINT(25);
11469 CHERI_CAPREG_PRINT(26);
11470 CHERI_PCC_PRINT();
11471 cheritest_success();
11472}
11473
11474/*
11475 * These tests assume that the compiler and run-time libraries won't muck with
11476 * the global registers in question -- which is true at the time of writing.
11477 *
11478 * However, in the future, it could be that they are modified -- e.g., to
11479 * differentiate memory capabilities from class-type capabilities. In that
11480 * case, these tests would need to check the original capability values saved
11481 * during process startup -- and also the new expected values.
11482 */
11483static void
11484check_initreg_code(__capability void *c)
11485{
11486 register_t v;
11487
11488 /* Base. */
11489 v = cheri_getbase(c);
11490 if (v != CHERI_CAP_USER_CODE_BASE)
11491 cheritest_failure_errx("base %jx (expected %jx)", v,
11492 CHERI_CAP_USER_CODE_BASE);
11493
11494 /* Length. */
11495 v = cheri_getlen(c);
11496 if (v != CHERI_CAP_USER_CODE_LENGTH)
11497 cheritest_failure_errx("length 0x%jx (expected 0x%jx)", v,
11498 CHERI_CAP_USER_CODE_LENGTH);
11499
11500 /* Offset. */
11501 v = cheri_getoffset(c);
11502 if (v != CHERI_CAP_USER_CODE_OFFSET)
11503 cheritest_failure_errx("offset %jx (expected %jx)", v,
11504 CHERI_CAP_USER_CODE_OFFSET);
11505 /* Type. */
11506 v = cheri_gettype(c);
11507 if (v != CHERI_CAP_USER_CODE_OTYPE)
11508 cheritest_failure_errx("otype %jx (expected %jx)", v,
11509 CHERI_CAP_USER_CODE_OTYPE);
11510
11511 /* Permissions. */
11512 v = cheri_getperm(c);
11513 if (v != CHERI_CAP_USER_CODE_PERMS)
11514 cheritest_failure_errx("perms %jx (expected %jx)", v,
11515 CHERI_CAP_USER_CODE_PERMS);
11516
11517 /* Sealed bit. */
11518 v = cheri_getsealed(c);
11519 if (v != 0)
11520 cheritest_failure_errx("sealed %jx (expected 0)", v);
11521
11522 /* Tag bit. */
11523 v = cheri_gettag(c);
11524 if (v != 1)
11525 cheritest_failure_errx("tag %jx (expected 1)", v);
11526 cheritest_success();
11527}
11528
11529static void
11530check_initreg_data(__capability void *c)
11531{
11532 register_t v;
11533
11534 /* Base. */
11535 v = cheri_getbase(c);
11536 if (v != CHERI_CAP_USER_DATA_BASE)
11537 cheritest_failure_errx("base %jx (expected %jx)", v,
11538 CHERI_CAP_USER_DATA_BASE);
11539
11540 /* Length. */
11541 v = cheri_getlen(c);
11542 if (v != CHERI_CAP_USER_DATA_LENGTH)
11543 cheritest_failure_errx("length 0x%jx (expected 0x%jx)", v,
11544 CHERI_CAP_USER_DATA_LENGTH);
11545
11546 /* Offset. */
11547 v = cheri_getoffset(c);
11548 if (v != CHERI_CAP_USER_DATA_OFFSET)
11549 cheritest_failure_errx("offset %jx (expected %jx)", v,
11550 CHERI_CAP_USER_DATA_OFFSET);
11551 /* Type. */
11552 v = cheri_gettype(c);
11553 if (v != CHERI_CAP_USER_DATA_OTYPE)
11554 cheritest_failure_errx("otype %jx (expected %jx)", v,
11555 CHERI_CAP_USER_DATA_OTYPE);
11556
11557 /* Permissions. */
11558 v = cheri_getperm(c);
11559 if (v != CHERI_CAP_USER_DATA_PERMS)
11560 cheritest_failure_errx("perms %jx (expected %jx)", v,
11561 CHERI_CAP_USER_DATA_PERMS);
11562
11563 /* Sealed bit. */
11564 v = cheri_getsealed(c);
11565 if (v != 0)
11566 cheritest_failure_errx("sealed %jx (expected 0)", v);
11567
11568 /* Tag bit. */
11569 v = cheri_gettag(c);
11570 if (v != 1)
11571 cheritest_failure_errx("tag %jx (expected 1)", v);
11572 cheritest_success();
11573}
11574
11575void
11576test_initregs_default(const struct cheri_test *ctp __unused)
11577{
11578
11579 check_initreg_data(cheri_getdefault());
11580}
11581
11582void
11583test_initregs_stack(const struct cheri_test *ctp __unused)
11584{
11585
11586 check_initreg_data(cheri_getstack());
11587}
11588
11589void
11590test_initregs_idc(const struct cheri_test *ctp __unused)
11591{
11592
11593 check_initreg_code(cheri_getidc());
11594}
11595
11596void
11597test_initregs_pcc(const struct cheri_test *ctp __unused)
11598{
11599 __capability void *c;
11600
11601 /* $pcc includes $pc, so clear that for the purposes of the check. */
11602 c = cheri_getpcc();
11603 c = cheri_setoffset(c, 0);
11604 check_initreg_code(c);
11605}