Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 242.59 KB | None | 0 0
  1. # 1 "<built-in>"
  2. # 1 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  3. /*-
  4. * Copyright (c) 2017 Robert N. M. Watson
  5. * All rights reserved.
  6. *
  7. * This software was developed by SRI International and the University of
  8. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  9. * ("CTSRD"), as part of the DARPA CRASH research programme.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. */
  32.  
  33. #if 0 /* expanded by -frewrite-includes */
  34. #include <sys/types.h>
  35. #endif /* expanded by -frewrite-includes */
  36. # 31 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  37. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 1 3 4
  38. /*-
  39. * Copyright (c) 1982, 1986, 1991, 1993, 1994
  40. * The Regents of the University of California. All rights reserved.
  41. * (c) UNIX System Laboratories, Inc.
  42. * All or some portions of this file are derived from material licensed
  43. * to the University of California by American Telephone and Telegraph
  44. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  45. * the permission of UNIX System Laboratories, Inc.
  46. *
  47. * Redistribution and use in source and binary forms, with or without
  48. * modification, are permitted provided that the following conditions
  49. * are met:
  50. * 1. Redistributions of source code must retain the above copyright
  51. * notice, this list of conditions and the following disclaimer.
  52. * 2. Redistributions in binary form must reproduce the above copyright
  53. * notice, this list of conditions and the following disclaimer in the
  54. * documentation and/or other materials provided with the distribution.
  55. * 3. Neither the name of the University nor the names of its contributors
  56. * may be used to endorse or promote products derived from this software
  57. * without specific prior written permission.
  58. *
  59. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  60. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  61. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  62. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  63. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  64. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  65. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  66. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  67. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  68. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  69. * SUCH DAMAGE.
  70. *
  71. * @(#)types.h 8.6 (Berkeley) 2/19/95
  72. * $FreeBSD$
  73. */
  74.  
  75. #ifndef _SYS_TYPES_H_
  76. #define _SYS_TYPES_H_
  77.  
  78. #if 0 /* expanded by -frewrite-includes */
  79. #include <sys/cdefs.h>
  80. #endif /* expanded by -frewrite-includes */
  81. # 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  82. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 1 3 4
  83. /*-
  84. * Copyright (c) 1991, 1993
  85. * The Regents of the University of California. All rights reserved.
  86. *
  87. * This code is derived from software contributed to Berkeley by
  88. * Berkeley Software Design, Inc.
  89. *
  90. * Redistribution and use in source and binary forms, with or without
  91. * modification, are permitted provided that the following conditions
  92. * are met:
  93. * 1. Redistributions of source code must retain the above copyright
  94. * notice, this list of conditions and the following disclaimer.
  95. * 2. Redistributions in binary form must reproduce the above copyright
  96. * notice, this list of conditions and the following disclaimer in the
  97. * documentation and/or other materials provided with the distribution.
  98. * 3. Neither the name of the University nor the names of its contributors
  99. * may be used to endorse or promote products derived from this software
  100. * without specific prior written permission.
  101. *
  102. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  103. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  104. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  105. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  106. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  107. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  108. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  109. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  110. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  111. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  112. * SUCH DAMAGE.
  113. *
  114. * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
  115. * $FreeBSD$
  116. */
  117.  
  118. #ifndef _SYS_CDEFS_H_
  119. #define _SYS_CDEFS_H_
  120.  
  121. /*
  122. * Testing against Clang-specific extensions.
  123. */
  124. #ifndef __has_attribute
  125. #define __has_attribute(x) 0
  126. #endif
  127. # 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  128. #ifndef __has_extension
  129. #define __has_extension __has_feature
  130. #endif
  131. # 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  132. #ifndef __has_feature
  133. #define __has_feature(x) 0
  134. #endif
  135. # 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  136. #ifndef __has_include
  137. #define __has_include(x) 0
  138. #endif
  139. # 54 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  140. #ifndef __has_builtin
  141. #define __has_builtin(x) 0
  142. #endif
  143. # 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  144.  
  145. #if defined(__cplusplus)
  146. #define __BEGIN_DECLS extern "C" {
  147. #define __END_DECLS }
  148. #else
  149. # 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  150. #define __BEGIN_DECLS
  151. #define __END_DECLS
  152. #endif
  153. # 65 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  154.  
  155. /*
  156. * This code has been put in place to help reduce the addition of
  157. * compiler specific defines in FreeBSD code. It helps to aid in
  158. * having a compiler-agnostic source tree.
  159. */
  160.  
  161. #if defined(__GNUC__) || defined(__INTEL_COMPILER)
  162.  
  163. #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
  164. #define __GNUCLIKE_ASM 3
  165. #define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
  166. #else
  167. # 78 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  168. #define __GNUCLIKE_ASM 2
  169. #endif
  170. # 80 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  171. #define __GNUCLIKE___TYPEOF 1
  172. #define __GNUCLIKE___OFFSETOF 1
  173. #define __GNUCLIKE___SECTION 1
  174.  
  175. #ifndef __INTEL_COMPILER
  176. #define __GNUCLIKE_CTOR_SECTION_HANDLING 1
  177. #endif
  178. # 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  179.  
  180. #define __GNUCLIKE_BUILTIN_CONSTANT_P 1
  181. #if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
  182. __INTEL_COMPILER < 800
  183. #undef __GNUCLIKE_BUILTIN_CONSTANT_P
  184. #endif
  185. # 93 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  186.  
  187. #if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
  188. #define __GNUCLIKE_BUILTIN_VARARGS 1
  189. #define __GNUCLIKE_BUILTIN_STDARG 1
  190. #define __GNUCLIKE_BUILTIN_VAALIST 1
  191. #endif
  192. # 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  193.  
  194. #if defined(__GNUC__)
  195. #define __GNUC_VA_LIST_COMPATIBILITY 1
  196. #endif
  197. # 103 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  198.  
  199. /*
  200. * Compiler memory barriers, specific to gcc and clang.
  201. */
  202. #if defined(__GNUC__)
  203. #define __compiler_membar() __asm __volatile(" " : : : "memory")
  204. #endif
  205. # 110 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  206.  
  207. #ifndef __INTEL_COMPILER
  208. #define __GNUCLIKE_BUILTIN_NEXT_ARG 1
  209. #define __GNUCLIKE_MATH_BUILTIN_RELOPS
  210. #endif
  211. # 115 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  212.  
  213. #define __GNUCLIKE_BUILTIN_MEMCPY 1
  214.  
  215. /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
  216. #define __CC_SUPPORTS_INLINE 1
  217. #define __CC_SUPPORTS___INLINE 1
  218. #define __CC_SUPPORTS___INLINE__ 1
  219.  
  220. #define __CC_SUPPORTS___FUNC__ 1
  221. #define __CC_SUPPORTS_WARNING 1
  222.  
  223. #define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
  224.  
  225. #define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
  226.  
  227. #endif /* __GNUC__ || __INTEL_COMPILER */
  228. # 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  229.  
  230. /*
  231. * Macro to test if we're using a specific version of gcc or later.
  232. */
  233. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  234. #define __GNUC_PREREQ__(ma, mi) \
  235. (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
  236. #else
  237. # 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  238. #define __GNUC_PREREQ__(ma, mi) 0
  239. #endif
  240. # 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  241.  
  242. /*
  243. * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
  244. * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
  245. * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
  246. * mode -- there must be no spaces between its arguments, and for nested
  247. * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
  248. * concatenate double-quoted strings produced by the __STRING macro, but
  249. * this only works with ANSI C.
  250. *
  251. * __XSTRING is like __STRING, but it expands any macros in its argument
  252. * first. It is only available with ANSI C.
  253. */
  254. #if defined(__STDC__) || defined(__cplusplus)
  255. #define __P(protos) protos /* full-blown ANSI C */
  256. #define __CONCAT1(x,y) x ## y
  257. #define __CONCAT(x,y) __CONCAT1(x,y)
  258. #define __STRING(x) #x /* stringify without expanding x */
  259. #define __XSTRING(x) __STRING(x) /* expand x, then stringify */
  260.  
  261. #define __const const /* define reserved names to standard */
  262. #define __signed signed
  263. #define __volatile volatile
  264. #if defined(__cplusplus)
  265. #define __inline inline /* convert to C++ keyword */
  266. #else
  267. # 167 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  268. #if !(defined(__CC_SUPPORTS___INLINE))
  269. #define __inline /* delete GCC keyword */
  270. #endif /* ! __CC_SUPPORTS___INLINE */
  271. # 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  272. #endif /* !__cplusplus */
  273. # 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  274.  
  275. #else /* !(__STDC__ || __cplusplus) */
  276. # 173 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  277. #define __P(protos) () /* traditional C preprocessor */
  278. #define __CONCAT(x,y) x/**/y
  279. #define __STRING(x) "x"
  280.  
  281. #if !defined(__CC_SUPPORTS___INLINE)
  282. #define __const /* delete pseudo-ANSI C keywords */
  283. #define __inline
  284. #define __signed
  285. #define __volatile
  286. /*
  287. * In non-ANSI C environments, new programs will want ANSI-only C keywords
  288. * deleted from the program and old programs will want them left alone.
  289. * When using a compiler other than gcc, programs using the ANSI C keywords
  290. * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
  291. * When using "gcc -traditional", we assume that this is the intent; if
  292. * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
  293. */
  294. #ifndef NO_ANSI_KEYWORDS
  295. #define const /* delete ANSI C keywords */
  296. #define inline
  297. #define signed
  298. #define volatile
  299. #endif /* !NO_ANSI_KEYWORDS */
  300. # 196 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  301. #endif /* !__CC_SUPPORTS___INLINE */
  302. # 197 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  303. #endif /* !(__STDC__ || __cplusplus) */
  304. # 198 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  305.  
  306. /*
  307. * Compiler-dependent macros to help declare dead (non-returning) and
  308. * pure (no side effects) functions, and unused variables. They are
  309. * null except for versions of gcc that are known to support the features
  310. * properly (old versions of gcc-2 supported the dead and pure features
  311. * in a different (wrong) way). If we do not provide an implementation
  312. * for a given compiler, let the compile fail if it is told to use
  313. * a feature that we cannot live without.
  314. */
  315. #ifdef lint
  316. #define __dead2
  317. #define __pure2
  318. #define __unused
  319. #define __packed
  320. #define __aligned(x)
  321. #define __alloc_align(x)
  322. #define __alloc_size(x)
  323. #define __section(x)
  324. #define __weak_symbol
  325. #else
  326. # 219 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  327. #define __weak_symbol __attribute__((__weak__))
  328. #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
  329. #define __dead2
  330. #define __pure2
  331. #define __unused
  332. #endif
  333. # 225 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  334. #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
  335. #define __dead2 __attribute__((__noreturn__))
  336. #define __pure2 __attribute__((__const__))
  337. #define __unused
  338. /* XXX Find out what to do for __packed, __aligned and __section */
  339. #endif
  340. # 231 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  341. #if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
  342. #define __dead2 __attribute__((__noreturn__))
  343. #define __pure2 __attribute__((__const__))
  344. #define __unused __attribute__((__unused__))
  345. #define __used __attribute__((__used__))
  346. #define __packed __attribute__((__packed__))
  347. #define __aligned(x) __attribute__((__aligned__(x)))
  348. #define __section(x) __attribute__((__section__(x)))
  349. #endif
  350. # 240 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  351. #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
  352. #define __alloc_size(x) __attribute__((__alloc_size__(x)))
  353. #else
  354. # 243 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  355. #define __alloc_size(x)
  356. #endif
  357. # 245 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  358. #if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
  359. #define __alloc_align(x) __attribute__((__alloc_align__(x)))
  360. #else
  361. # 248 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  362. #define __alloc_align(x)
  363. #endif
  364. # 250 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  365. #endif /* lint */
  366. # 251 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  367.  
  368. #if !__GNUC_PREREQ__(2, 95)
  369. #define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
  370. #endif
  371. # 255 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  372.  
  373. /*
  374. * Keywords added in C11.
  375. */
  376.  
  377. #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
  378.  
  379. #if !__has_extension(c_alignas)
  380. #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
  381. __has_extension(cxx_alignas)
  382. #define _Alignas(x) alignas(x)
  383. #else
  384. # 267 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  385. /* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
  386. #define _Alignas(x) __aligned(x)
  387. #endif
  388. # 270 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  389. #endif
  390. # 271 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  391.  
  392. #if defined(__cplusplus) && __cplusplus >= 201103L
  393. #define _Alignof(x) alignof(x)
  394. #else
  395. # 275 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  396. #define _Alignof(x) __alignof(x)
  397. #endif
  398. # 277 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  399.  
  400. #if !defined(__cplusplus) && !__has_extension(c_atomic) && \
  401. !__has_extension(cxx_atomic)
  402. /*
  403. * No native support for _Atomic(). Place object in structure to prevent
  404. * most forms of direct non-atomic access.
  405. */
  406. #define _Atomic(T) struct { T volatile __val; }
  407. #endif
  408. # 286 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  409.  
  410. #if defined(__cplusplus) && __cplusplus >= 201103L
  411. #define _Noreturn [[noreturn]]
  412. #else
  413. # 290 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  414. #define _Noreturn __dead2
  415. #endif
  416. # 292 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  417.  
  418. #if !__has_extension(c_static_assert)
  419. #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
  420. __has_extension(cxx_static_assert)
  421. #define _Static_assert(x, y) static_assert(x, y)
  422. #elif __GNUC_PREREQ__(4,6)
  423. # 298 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  424. /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
  425. #elif defined(__COUNTER__)
  426. # 300 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  427. #define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
  428. #define __Static_assert(x, y) ___Static_assert(x, y)
  429. #define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \
  430. __unused
  431. #else
  432. # 305 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  433. #define _Static_assert(x, y) struct __hack
  434. #endif
  435. # 307 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  436. #endif
  437. # 308 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  438.  
  439. #if !__has_extension(c_thread_local)
  440. /*
  441. * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
  442. * without actually supporting the thread_local keyword. Don't check for
  443. * the presence of C++11 when defining _Thread_local.
  444. */
  445. #if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
  446. __has_extension(cxx_thread_local)
  447. #define _Thread_local thread_local
  448. #else
  449. # 319 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  450. #define _Thread_local __thread
  451. #endif
  452. # 321 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  453. #endif
  454. # 322 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  455.  
  456. #endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
  457. # 324 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  458.  
  459. /*
  460. * Emulation of C11 _Generic(). Unlike the previously defined C11
  461. * keywords, it is not possible to implement this using exactly the same
  462. * syntax. Therefore implement something similar under the name
  463. * __generic(). Unlike _Generic(), this macro can only distinguish
  464. * between a single type, so it requires nested invocations to
  465. * distinguish multiple cases.
  466. */
  467.  
  468. #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
  469. __has_extension(c_generic_selections)
  470. #define __generic(expr, t, yes, no) \
  471. _Generic(expr, t: yes, default: no)
  472. #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
  473. # 339 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  474. #define __generic(expr, t, yes, no) \
  475. __builtin_choose_expr( \
  476. __builtin_types_compatible_p(__typeof(expr), t), yes, no)
  477. #endif
  478. # 343 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  479.  
  480. /*
  481. * C99 Static array indices in function parameter declarations. Syntax such as:
  482. * void bar(int myArray[static 10]);
  483. * is allowed in C99 but not in C++. Define __min_size appropriately so
  484. * headers using it can be compiled in either language. Use like this:
  485. * void bar(int myArray[__min_size(10)]);
  486. */
  487. #if !defined(__cplusplus) && \
  488. (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
  489. (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
  490. #define __min_size(x) static (x)
  491. #else
  492. # 356 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  493. #define __min_size(x) (x)
  494. #endif
  495. # 358 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  496.  
  497. #if __GNUC_PREREQ__(2, 96)
  498. #define __malloc_like __attribute__((__malloc__))
  499. #define __pure __attribute__((__pure__))
  500. #else
  501. # 363 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  502. #define __malloc_like
  503. #define __pure
  504. #endif
  505. # 366 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  506.  
  507. #if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
  508. #define __always_inline __attribute__((__always_inline__))
  509. #else
  510. # 370 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  511. #define __always_inline
  512. #endif
  513. # 372 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  514.  
  515. #if __GNUC_PREREQ__(3, 1)
  516. #define __noinline __attribute__ ((__noinline__))
  517. #else
  518. # 376 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  519. #define __noinline
  520. #endif
  521. # 378 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  522.  
  523. #if __GNUC_PREREQ__(3, 4)
  524. #define __fastcall __attribute__((__fastcall__))
  525. #define __result_use_check __attribute__((__warn_unused_result__))
  526. #else
  527. # 383 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  528. #define __fastcall
  529. #define __result_use_check
  530. #endif
  531. # 386 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  532.  
  533. #if __GNUC_PREREQ__(4, 1)
  534. #define __returns_twice __attribute__((__returns_twice__))
  535. #else
  536. # 390 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  537. #define __returns_twice
  538. #endif
  539. # 392 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  540.  
  541. #if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
  542. #define __unreachable() __builtin_unreachable()
  543. #else
  544. # 396 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  545. #define __unreachable() ((void)0)
  546. #endif
  547. # 398 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  548.  
  549. /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
  550. #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
  551. #define __func__ NULL
  552. #endif
  553. # 403 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  554.  
  555. #if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
  556. #define __LONG_LONG_SUPPORTED
  557. #endif
  558. # 407 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  559.  
  560. /* C++11 exposes a load of C99 stuff */
  561. #if defined(__cplusplus) && __cplusplus >= 201103L
  562. #define __LONG_LONG_SUPPORTED
  563. #ifndef __STDC_LIMIT_MACROS
  564. #define __STDC_LIMIT_MACROS
  565. #endif
  566. # 414 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  567. #ifndef __STDC_CONSTANT_MACROS
  568. #define __STDC_CONSTANT_MACROS
  569. #endif
  570. # 417 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  571. #endif
  572. # 418 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  573.  
  574. /*
  575. * GCC 2.95 provides `__restrict' as an extension to C90 to support the
  576. * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
  577. * a way to define the `restrict' type qualifier without disturbing older
  578. * software that is unaware of C99 keywords.
  579. */
  580. #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
  581. #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
  582. #define __restrict
  583. #else
  584. # 429 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  585. #define __restrict restrict
  586. #endif
  587. # 431 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  588. #endif
  589. # 432 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  590.  
  591. /*
  592. * GNU C version 2.96 adds explicit branch prediction so that
  593. * the CPU back-end can hint the processor and also so that
  594. * code blocks can be reordered such that the predicted path
  595. * sees a more linear flow, thus improving cache behavior, etc.
  596. *
  597. * The following two macros provide us with a way to utilize this
  598. * compiler feature. Use __predict_true() if you expect the expression
  599. * to evaluate to true, and __predict_false() if you expect the
  600. * expression to evaluate to false.
  601. *
  602. * A few notes about usage:
  603. *
  604. * * Generally, __predict_false() error condition checks (unless
  605. * you have some _strong_ reason to do otherwise, in which case
  606. * document it), and/or __predict_true() `no-error' condition
  607. * checks, assuming you want to optimize for the no-error case.
  608. *
  609. * * Other than that, if you don't know the likelihood of a test
  610. * succeeding from empirical or other `hard' evidence, don't
  611. * make predictions.
  612. *
  613. * * These are meant to be used in places that are run `a lot'.
  614. * It is wasteful to make predictions in code that is run
  615. * seldomly (e.g. at subsystem initialization time) as the
  616. * basic block reordering that this affects can often generate
  617. * larger code.
  618. */
  619. #if __GNUC_PREREQ__(2, 96)
  620. #define __predict_true(exp) __builtin_expect((exp), 1)
  621. #define __predict_false(exp) __builtin_expect((exp), 0)
  622. #else
  623. # 465 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  624. #define __predict_true(exp) (exp)
  625. #define __predict_false(exp) (exp)
  626. #endif
  627. # 468 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  628.  
  629. #if __GNUC_PREREQ__(4, 0)
  630. #define __null_sentinel __attribute__((__sentinel__))
  631. #define __exported __attribute__((__visibility__("default")))
  632. #define __hidden __attribute__((__visibility__("hidden")))
  633. #else
  634. # 474 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  635. #define __null_sentinel
  636. #define __exported
  637. #define __hidden
  638. #endif
  639. # 478 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  640.  
  641. /*
  642. * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
  643. * require it.
  644. */
  645. #if __GNUC_PREREQ__(4, 1)
  646. #define __offsetof(type, field) __builtin_offsetof(type, field)
  647. #else
  648. # 486 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  649. #ifndef __cplusplus
  650. #define __offsetof(type, field) \
  651. ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
  652. #else
  653. # 490 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  654. #define __offsetof(type, field) \
  655. (__offsetof__ (reinterpret_cast <__size_t> \
  656. (&reinterpret_cast <const volatile char &> \
  657. (static_cast<type *> (0)->field))))
  658. #endif
  659. # 495 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  660. #endif
  661. # 496 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  662. #define __rangeof(type, start, end) \
  663. (__offsetof(type, end) - __offsetof(type, start))
  664.  
  665. /*
  666. * Given the pointer x to the member m of the struct s, return
  667. * a pointer to the containing structure. When using GCC, we first
  668. * assign pointer x to a local variable, to check that its type is
  669. * compatible with member m.
  670. */
  671. #if __GNUC_PREREQ__(3, 1)
  672. #define __containerof(x, s, m) ({ \
  673. const volatile __typeof(((s *)0)->m) *__x = (x); \
  674. __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
  675. })
  676. #else
  677. # 511 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  678. #define __containerof(x, s, m) \
  679. __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
  680. #endif
  681. # 514 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  682.  
  683. /*
  684. * Compiler-dependent macros to declare that functions take printf-like
  685. * or scanf-like arguments. They are null except for versions of gcc
  686. * that are known to support the features properly (old versions of gcc-2
  687. * didn't permit keeping the keywords out of the application namespace).
  688. */
  689. #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
  690. #define __printflike(fmtarg, firstvararg)
  691. #define __scanflike(fmtarg, firstvararg)
  692. #define __format_arg(fmtarg)
  693. #define __strfmonlike(fmtarg, firstvararg)
  694. #define __strftimelike(fmtarg, firstvararg)
  695. #else
  696. # 528 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  697. #define __printflike(fmtarg, firstvararg) \
  698. __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
  699. #define __scanflike(fmtarg, firstvararg) \
  700. __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
  701. #define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
  702. #define __strfmonlike(fmtarg, firstvararg) \
  703. __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
  704. #define __strftimelike(fmtarg, firstvararg) \
  705. __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
  706. #endif
  707. # 538 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  708.  
  709. /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
  710. #if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
  711. defined(__GNUC__) && !defined(__INTEL_COMPILER)
  712. #define __printf0like(fmtarg, firstvararg) \
  713. __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
  714. #else
  715. # 545 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  716. #define __printf0like(fmtarg, firstvararg)
  717. #endif
  718. # 547 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  719.  
  720. #if defined(__GNUC__) || defined(__INTEL_COMPILER)
  721. #ifndef __INTEL_COMPILER
  722. #define __strong_reference(sym,aliassym) \
  723. extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
  724. #endif
  725. # 553 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  726. #ifdef __STDC__
  727. #define __weak_reference(sym,alias) \
  728. __asm__(".weak " #alias); \
  729. __asm__(".equ " #alias ", " #sym)
  730. #define __warn_references(sym,msg) \
  731. __asm__(".section .gnu.warning." #sym); \
  732. __asm__(".asciz \"" msg "\""); \
  733. __asm__(".previous")
  734. #define __sym_compat(sym,impl,verid) \
  735. __asm__(".symver " #impl ", " #sym "@" #verid)
  736. #define __sym_default(sym,impl,verid) \
  737. __asm__(".symver " #impl ", " #sym "@@" #verid)
  738. #else
  739. # 566 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  740. #define __weak_reference(sym,alias) \
  741. __asm__(".weak alias"); \
  742. __asm__(".equ alias, sym")
  743. #define __warn_references(sym,msg) \
  744. __asm__(".section .gnu.warning.sym"); \
  745. __asm__(".asciz \"msg\""); \
  746. __asm__(".previous")
  747. #define __sym_compat(sym,impl,verid) \
  748. __asm__(".symver impl, sym@verid")
  749. #define __sym_default(impl,sym,verid) \
  750. __asm__(".symver impl, sym@@verid")
  751. #endif /* __STDC__ */
  752. # 578 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  753. #endif /* __GNUC__ || __INTEL_COMPILER */
  754. # 579 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  755.  
  756. #define __GLOBL1(sym) __asm__(".globl " #sym)
  757. #define __GLOBL(sym) __GLOBL1(sym)
  758.  
  759. #if defined(__GNUC__) || defined(__INTEL_COMPILER)
  760. #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
  761. #else
  762. # 586 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  763. /*
  764. * The following definition might not work well if used in header files,
  765. * but it should be better than nothing. If you want a "do nothing"
  766. * version, then it should generate some harmless declaration, such as:
  767. * #define __IDSTRING(name,string) struct __hack
  768. */
  769. #define __IDSTRING(name,string) static const char name[] __unused = string
  770. #endif
  771. # 594 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  772.  
  773. /*
  774. * Embed the rcs id of a source file in the resulting library. Note that in
  775. * more recent ELF binutils, we use .ident allowing the ID to be stripped.
  776. * Usage:
  777. * __FBSDID("$FreeBSD$");
  778. */
  779. #ifndef __FBSDID
  780. #if !defined(lint) && !defined(STRIP_FBSDID)
  781. #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
  782. #else
  783. # 605 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  784. #define __FBSDID(s) struct __hack
  785. #endif
  786. # 607 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  787. #endif
  788. # 608 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  789.  
  790. #ifndef __RCSID
  791. #ifndef NO__RCSID
  792. #define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
  793. #else
  794. # 613 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  795. #define __RCSID(s) struct __hack
  796. #endif
  797. # 615 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  798. #endif
  799. # 616 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  800.  
  801. #ifndef __RCSID_SOURCE
  802. #ifndef NO__RCSID_SOURCE
  803. #define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
  804. #else
  805. # 621 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  806. #define __RCSID_SOURCE(s) struct __hack
  807. #endif
  808. # 623 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  809. #endif
  810. # 624 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  811.  
  812. #ifndef __SCCSID
  813. #ifndef NO__SCCSID
  814. #define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
  815. #else
  816. # 629 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  817. #define __SCCSID(s) struct __hack
  818. #endif
  819. # 631 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  820. #endif
  821. # 632 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  822.  
  823. #ifndef __COPYRIGHT
  824. #ifndef NO__COPYRIGHT
  825. #define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
  826. #else
  827. # 637 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  828. #define __COPYRIGHT(s) struct __hack
  829. #endif
  830. # 639 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  831. #endif
  832. # 640 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  833.  
  834. /*
  835. * XXXAR: For CHERI hybrid mode I removed the cast to the qualified type
  836. * because we don't know whether the input type is a capability or a pointer
  837. * and casting to the wrong one causes compiler warnings.
  838. * The real solution would be an equivalent of const_cast<> for C
  839. */
  840.  
  841. #ifndef __DECONST
  842. #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
  843. #endif
  844. # 651 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  845.  
  846. #ifndef __DEVOLATILE
  847. #define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
  848. #endif
  849. # 655 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  850.  
  851. #ifndef __DEQUALIFY
  852. #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
  853. #endif
  854. # 659 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  855.  
  856. #ifdef __CHERI__
  857. #define __DECONST_CAP(type, var) ((type)(__uintcap_t)(const void * __capability)(var))
  858. #define __DEVOLATILE_CAP(type, var) ((type)(__uintcap_t)(volatile void * __capability)(var))
  859. #define __DEQUALIFY_CAP(type, var) ((type)(__uintcap_t)(const volatile void * __capability)(var))
  860. #endif
  861. # 665 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  862.  
  863. /*-
  864. * The following definitions are an extension of the behavior originally
  865. * implemented in <sys/_posix.h>, but with a different level of granularity.
  866. * POSIX.1 requires that the macros we test be defined before any standard
  867. * header file is included.
  868. *
  869. * Here's a quick run-down of the versions:
  870. * defined(_POSIX_SOURCE) 1003.1-1988
  871. * _POSIX_C_SOURCE == 1 1003.1-1990
  872. * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
  873. * _POSIX_C_SOURCE == 199309 1003.1b-1993
  874. * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
  875. * and the omnibus ISO/IEC 9945-1: 1996
  876. * _POSIX_C_SOURCE == 200112 1003.1-2001
  877. * _POSIX_C_SOURCE == 200809 1003.1-2008
  878. *
  879. * In addition, the X/Open Portability Guide, which is now the Single UNIX
  880. * Specification, defines a feature-test macro which indicates the version of
  881. * that specification, and which subsumes _POSIX_C_SOURCE.
  882. *
  883. * Our macros begin with two underscores to avoid namespace screwage.
  884. */
  885.  
  886. /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
  887. #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
  888. #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
  889. #define _POSIX_C_SOURCE 199009
  890. #endif
  891. # 694 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  892.  
  893. /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
  894. #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
  895. #undef _POSIX_C_SOURCE
  896. #define _POSIX_C_SOURCE 199209
  897. #endif
  898. # 700 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  899.  
  900. /* Deal with various X/Open Portability Guides and Single UNIX Spec. */
  901. #ifdef _XOPEN_SOURCE
  902. #if _XOPEN_SOURCE - 0 >= 700
  903. #define __XSI_VISIBLE 700
  904. #undef _POSIX_C_SOURCE
  905. #define _POSIX_C_SOURCE 200809
  906. #elif _XOPEN_SOURCE - 0 >= 600
  907. # 708 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  908. #define __XSI_VISIBLE 600
  909. #undef _POSIX_C_SOURCE
  910. #define _POSIX_C_SOURCE 200112
  911. #elif _XOPEN_SOURCE - 0 >= 500
  912. # 712 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  913. #define __XSI_VISIBLE 500
  914. #undef _POSIX_C_SOURCE
  915. #define _POSIX_C_SOURCE 199506
  916. #endif
  917. # 716 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  918. #endif
  919. # 717 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  920.  
  921. /*
  922. * Deal with all versions of POSIX. The ordering relative to the tests above is
  923. * important.
  924. */
  925. #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
  926. #define _POSIX_C_SOURCE 198808
  927. #endif
  928. # 725 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  929. #ifdef _POSIX_C_SOURCE
  930. #if _POSIX_C_SOURCE >= 200809
  931. #define __POSIX_VISIBLE 200809
  932. #define __ISO_C_VISIBLE 1999
  933. #elif _POSIX_C_SOURCE >= 200112
  934. # 730 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  935. #define __POSIX_VISIBLE 200112
  936. #define __ISO_C_VISIBLE 1999
  937. #elif _POSIX_C_SOURCE >= 199506
  938. # 733 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  939. #define __POSIX_VISIBLE 199506
  940. #define __ISO_C_VISIBLE 1990
  941. #elif _POSIX_C_SOURCE >= 199309
  942. # 736 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  943. #define __POSIX_VISIBLE 199309
  944. #define __ISO_C_VISIBLE 1990
  945. #elif _POSIX_C_SOURCE >= 199209
  946. # 739 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  947. #define __POSIX_VISIBLE 199209
  948. #define __ISO_C_VISIBLE 1990
  949. #elif _POSIX_C_SOURCE >= 199009
  950. # 742 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  951. #define __POSIX_VISIBLE 199009
  952. #define __ISO_C_VISIBLE 1990
  953. #else
  954. # 745 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  955. #define __POSIX_VISIBLE 198808
  956. #define __ISO_C_VISIBLE 0
  957. #endif /* _POSIX_C_SOURCE */
  958. # 748 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  959. #else
  960. # 749 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  961. /*-
  962. * Deal with _ANSI_SOURCE:
  963. * If it is defined, and no other compilation environment is explicitly
  964. * requested, then define our internal feature-test macros to zero. This
  965. * makes no difference to the preprocessor (undefined symbols in preprocessing
  966. * expressions are defined to have value zero), but makes it more convenient for
  967. * a test program to print out the values.
  968. *
  969. * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
  970. * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
  971. * environment (and in fact we will never get here).
  972. */
  973. #if defined(_ANSI_SOURCE) /* Hide almost everything. */
  974. #define __POSIX_VISIBLE 0
  975. #define __XSI_VISIBLE 0
  976. #define __BSD_VISIBLE 0
  977. #define __ISO_C_VISIBLE 1990
  978. #define __EXT1_VISIBLE 0
  979. #elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
  980. # 768 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  981. #define __POSIX_VISIBLE 0
  982. #define __XSI_VISIBLE 0
  983. #define __BSD_VISIBLE 0
  984. #define __ISO_C_VISIBLE 1999
  985. #define __EXT1_VISIBLE 0
  986. #elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
  987. # 774 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  988. #define __POSIX_VISIBLE 0
  989. #define __XSI_VISIBLE 0
  990. #define __BSD_VISIBLE 0
  991. #define __ISO_C_VISIBLE 2011
  992. #define __EXT1_VISIBLE 0
  993. #else /* Default environment: show everything. */
  994. # 780 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  995. #define __POSIX_VISIBLE 200809
  996. #define __XSI_VISIBLE 700
  997. #define __BSD_VISIBLE 1
  998. #define __ISO_C_VISIBLE 2011
  999. #define __EXT1_VISIBLE 1
  1000. #endif
  1001. # 786 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1002. #endif
  1003. # 787 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1004.  
  1005. /* User override __EXT1_VISIBLE */
  1006. #if defined(__STDC_WANT_LIB_EXT1__)
  1007. #undef __EXT1_VISIBLE
  1008. #if __STDC_WANT_LIB_EXT1__
  1009. #define __EXT1_VISIBLE 1
  1010. #else
  1011. # 794 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1012. #define __EXT1_VISIBLE 0
  1013. #endif
  1014. # 796 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1015. #endif /* __STDC_WANT_LIB_EXT1__ */
  1016. # 797 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1017.  
  1018. #if defined(__mips) || defined(__powerpc64__) || defined(__riscv__)
  1019. #define __NO_TLS 1
  1020. #endif
  1021. # 801 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1022.  
  1023. /*
  1024. * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h
  1025. * translates them to __ARM_ARCH and the modern feature symbols defined by ARM.
  1026. */
  1027. #if defined(__arm__) && !defined(__ARM_ARCH)
  1028. #if 0 /* expanded by -frewrite-includes */
  1029. #include <machine/acle-compat.h>
  1030. #endif /* expanded by -frewrite-includes */
  1031. # 807 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1032. # 808 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1033. #endif
  1034. # 809 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1035.  
  1036. /*
  1037. * Nullability qualifiers: currently only supported by Clang.
  1038. */
  1039. #if !(defined(__clang__) && __has_feature(nullability))
  1040. #define _Nonnull
  1041. #define _Nullable
  1042. #define _Null_unspecified
  1043. #define __NULLABILITY_PRAGMA_PUSH
  1044. #define __NULLABILITY_PRAGMA_POP
  1045. #else
  1046. # 820 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1047. #define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \
  1048. _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
  1049. #define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
  1050. #endif
  1051. # 824 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1052.  
  1053. /*
  1054. * Type Safety Checking
  1055. *
  1056. * Clang provides additional attributes to enable checking type safety
  1057. * properties that cannot be enforced by the C type system.
  1058. */
  1059.  
  1060. #if __has_attribute(__argument_with_type_tag__) && \
  1061. __has_attribute(__type_tag_for_datatype__) && !defined(lint)
  1062. #define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
  1063. __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
  1064. #define __datatype_type_tag(kind, type) \
  1065. __attribute__((__type_tag_for_datatype__(kind, type)))
  1066. #else
  1067. # 839 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1068. #define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
  1069. #define __datatype_type_tag(kind, type)
  1070. #endif
  1071. # 842 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1072.  
  1073. /*
  1074. * Lock annotations.
  1075. *
  1076. * Clang provides support for doing basic thread-safety tests at
  1077. * compile-time, by marking which locks will/should be held when
  1078. * entering/leaving a functions.
  1079. *
  1080. * Furthermore, it is also possible to annotate variables and structure
  1081. * members to enforce that they are only accessed when certain locks are
  1082. * held.
  1083. */
  1084.  
  1085. #if __has_extension(c_thread_safety_attributes)
  1086. #define __lock_annotate(x) __attribute__((x))
  1087. #else
  1088. # 858 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1089. #define __lock_annotate(x)
  1090. #endif
  1091. # 860 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1092.  
  1093. /* Structure implements a lock. */
  1094. #define __lockable __lock_annotate(lockable)
  1095.  
  1096. /* Function acquires an exclusive or shared lock. */
  1097. #define __locks_exclusive(...) \
  1098. __lock_annotate(exclusive_lock_function(__VA_ARGS__))
  1099. #define __locks_shared(...) \
  1100. __lock_annotate(shared_lock_function(__VA_ARGS__))
  1101.  
  1102. /* Function attempts to acquire an exclusive or shared lock. */
  1103. #define __trylocks_exclusive(...) \
  1104. __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
  1105. #define __trylocks_shared(...) \
  1106. __lock_annotate(shared_trylock_function(__VA_ARGS__))
  1107.  
  1108. /* Function releases a lock. */
  1109. #define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
  1110.  
  1111. /* Function asserts that an exclusive or shared lock is held. */
  1112. #define __asserts_exclusive(...) \
  1113. __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
  1114. #define __asserts_shared(...) \
  1115. __lock_annotate(assert_shared_lock(__VA_ARGS__))
  1116.  
  1117. /* Function requires that an exclusive or shared lock is or is not held. */
  1118. #define __requires_exclusive(...) \
  1119. __lock_annotate(exclusive_locks_required(__VA_ARGS__))
  1120. #define __requires_shared(...) \
  1121. __lock_annotate(shared_locks_required(__VA_ARGS__))
  1122. #define __requires_unlocked(...) \
  1123. __lock_annotate(locks_excluded(__VA_ARGS__))
  1124.  
  1125. /* Function should not be analyzed. */
  1126. #define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
  1127.  
  1128. /* Guard variables and structure members by lock. */
  1129. #define __guarded_by(x) __lock_annotate(guarded_by(x))
  1130. #define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
  1131.  
  1132. /* Specify that a file requires capabilities */
  1133. #if __has_feature(capabilities)
  1134. #define __REQUIRE_CAPABILITIES
  1135. #else
  1136. # 904 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1137. #define __REQUIRE_CAPABILITIES \
  1138. _Pragma("GCC error \"This file requires a capability-aware compiler\"")
  1139. #endif
  1140. # 907 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1141.  
  1142. #if __has_feature(capabilities)
  1143. #define __CAPABILITY __capability
  1144. #else
  1145. # 911 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1146. #define __CAPABILITY
  1147. #endif
  1148. # 913 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1149.  
  1150. #if !__has_feature(__cheri_cast)
  1151. /* Support old compiler versions without __cheri_cast: */
  1152. #define __cheri_cast
  1153. #endif
  1154. # 918 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1155.  
  1156. #endif /* !_SYS_CDEFS_H_ */
  1157. # 920 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/cdefs.h" 3 4
  1158. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
  1159.  
  1160. /* Machine type dependent parameters. */
  1161. #if 0 /* expanded by -frewrite-includes */
  1162. #include <machine/endian.h>
  1163. #endif /* expanded by -frewrite-includes */
  1164. # 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1165. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 1 3 4
  1166. /*-
  1167. * Copyright (c) 1987, 1991 Regents of the University of California.
  1168. * All rights reserved.
  1169. *
  1170. * Redistribution and use in source and binary forms, with or without
  1171. * modification, are permitted provided that the following conditions
  1172. * are met:
  1173. * 1. Redistributions of source code must retain the above copyright
  1174. * notice, this list of conditions and the following disclaimer.
  1175. * 2. Redistributions in binary form must reproduce the above copyright
  1176. * notice, this list of conditions and the following disclaimer in the
  1177. * documentation and/or other materials provided with the distribution.
  1178. * 3. Neither the name of the University nor the names of its contributors
  1179. * may be used to endorse or promote products derived from this software
  1180. * without specific prior written permission.
  1181. *
  1182. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1183. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1184. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1185. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1186. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1187. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1188. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1189. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1190. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1191. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1192. * SUCH DAMAGE.
  1193. *
  1194. * @(#)endian.h 7.8 (Berkeley) 4/3/91
  1195. * $FreeBSD$
  1196. */
  1197.  
  1198. #ifndef _MACHINE_ENDIAN_H_
  1199. #define _MACHINE_ENDIAN_H_
  1200.  
  1201. #if 0 /* expanded by -frewrite-includes */
  1202. #include <sys/cdefs.h>
  1203. #endif /* expanded by -frewrite-includes */
  1204. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1205. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1206. #ifndef __ASSEMBLER__
  1207. #if 0 /* expanded by -frewrite-includes */
  1208. #include <sys/_types.h>
  1209. #endif /* expanded by -frewrite-includes */
  1210. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1211. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 1 3 4
  1212. /*-
  1213. * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
  1214. * All rights reserved.
  1215. *
  1216. * Redistribution and use in source and binary forms, with or without
  1217. * modification, are permitted provided that the following conditions
  1218. * are met:
  1219. * 1. Redistributions of source code must retain the above copyright
  1220. * notice, this list of conditions and the following disclaimer.
  1221. * 2. Redistributions in binary form must reproduce the above copyright
  1222. * notice, this list of conditions and the following disclaimer in the
  1223. * documentation and/or other materials provided with the distribution.
  1224. *
  1225. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  1226. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1227. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1228. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  1229. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1230. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1231. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1232. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1233. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1234. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1235. * SUCH DAMAGE.
  1236. *
  1237. * $FreeBSD$
  1238. */
  1239.  
  1240. #ifndef _SYS__TYPES_H_
  1241. #define _SYS__TYPES_H_
  1242.  
  1243. #if 0 /* expanded by -frewrite-includes */
  1244. #include <sys/cdefs.h>
  1245. #endif /* expanded by -frewrite-includes */
  1246. # 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
  1247. # 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
  1248. #if 0 /* expanded by -frewrite-includes */
  1249. #include <machine/_types.h>
  1250. #endif /* expanded by -frewrite-includes */
  1251. # 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
  1252. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 1 3 4
  1253. /*-
  1254. * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
  1255. * Copyright (c) 1990, 1993
  1256. * The Regents of the University of California. All rights reserved.
  1257. *
  1258. * Redistribution and use in source and binary forms, with or without
  1259. * modification, are permitted provided that the following conditions
  1260. * are met:
  1261. * 1. Redistributions of source code must retain the above copyright
  1262. * notice, this list of conditions and the following disclaimer.
  1263. * 2. Redistributions in binary form must reproduce the above copyright
  1264. * notice, this list of conditions and the following disclaimer in the
  1265. * documentation and/or other materials provided with the distribution.
  1266. * 3. All advertising materials mentioning features or use of this software
  1267. * must display the following acknowledgement:
  1268. * This product includes software developed by the University of
  1269. * California, Berkeley and its contributors.
  1270. * 4. Neither the name of the University nor the names of its contributors
  1271. * may be used to endorse or promote products derived from this software
  1272. * without specific prior written permission.
  1273. *
  1274. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1275. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1276. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1277. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1278. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1279. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1280. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1281. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1282. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1283. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1284. * SUCH DAMAGE.
  1285. *
  1286. * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
  1287. * From: @(#)types.h 8.3 (Berkeley) 1/5/94
  1288. * from: src/sys/i386/include/_types.h,v 1.12 2005/07/02 23:13:31 thompsa
  1289. * $FreeBSD$
  1290. */
  1291.  
  1292. #ifndef _MACHINE__TYPES_H_
  1293. #define _MACHINE__TYPES_H_
  1294.  
  1295. #ifndef _SYS_CDEFS_H_
  1296. #error this file needs sys/cdefs.h as a prerequisite
  1297. #endif
  1298. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1299.  
  1300. /*
  1301. * Basic types upon which most other types are built.
  1302. */
  1303. typedef signed char __int8_t;
  1304. typedef unsigned char __uint8_t;
  1305. typedef short __int16_t;
  1306. typedef unsigned short __uint16_t;
  1307. typedef int __int32_t;
  1308. typedef unsigned int __uint32_t;
  1309. #ifdef __mips_n64
  1310. typedef long __int64_t;
  1311. typedef unsigned long __uint64_t;
  1312. #else
  1313. # 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1314. #ifndef lint
  1315. __extension__
  1316. #endif
  1317. # 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1318. /* LONGLONG */
  1319. typedef long long __int64_t;
  1320. #ifndef lint
  1321. __extension__
  1322. #endif
  1323. # 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1324. /* LONGLONG */
  1325. typedef unsigned long long __uint64_t;
  1326. #endif
  1327. # 71 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1328.  
  1329. /*
  1330. * Standard type definitions.
  1331. */
  1332. typedef __int32_t __clock_t; /* clock()... */
  1333. typedef double __double_t;
  1334. typedef float __float_t;
  1335. #ifdef __mips_n64
  1336. #ifndef __CHERI_PURE_CAPABILITY__
  1337. typedef __int64_t __critical_t;
  1338. typedef __int64_t __intfptr_t;
  1339. typedef __int64_t __intptr_t;
  1340. #else
  1341. # 84 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1342. typedef __intcap_t __critical_t;
  1343. typedef __intcap_t __intfptr_t;
  1344. typedef __intcap_t __intptr_t;
  1345. #endif
  1346. # 88 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1347. #else
  1348. # 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1349. typedef __int32_t __critical_t;
  1350. typedef __int32_t __intfptr_t;
  1351. typedef __int32_t __intptr_t;
  1352. #endif
  1353. # 93 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1354. typedef __int64_t __intmax_t;
  1355. typedef __int32_t __int_fast8_t;
  1356. typedef __int32_t __int_fast16_t;
  1357. typedef __int32_t __int_fast32_t;
  1358. typedef __int64_t __int_fast64_t;
  1359. typedef __int8_t __int_least8_t;
  1360. typedef __int16_t __int_least16_t;
  1361. typedef __int32_t __int_least32_t;
  1362. typedef __int64_t __int_least64_t;
  1363. #if defined(__mips_n64) || defined(__mips_n32)
  1364. typedef __int64_t __register_t;
  1365. typedef __int64_t f_register_t;
  1366. #else
  1367. # 106 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1368. typedef __int32_t __register_t;
  1369. typedef __int32_t f_register_t;
  1370. #endif
  1371. # 109 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1372. #ifdef __mips_n64
  1373. typedef __int64_t __ptrdiff_t;
  1374. typedef __int64_t __segsz_t;
  1375. typedef __uint64_t __size_t;
  1376. typedef __int64_t __ssize_t;
  1377. #ifndef __CHERI_PURE_CAPABILITY__
  1378. typedef __uint64_t __uintfptr_t;
  1379. typedef __uint64_t __uintptr_t;
  1380. #else
  1381. # 118 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1382. typedef __uintcap_t __uintfptr_t;
  1383. typedef __uintcap_t __uintptr_t;
  1384. #endif
  1385. # 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1386. #else
  1387. # 122 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1388. typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
  1389. typedef __int32_t __segsz_t; /* segment size (in pages) */
  1390. typedef __uint32_t __size_t; /* sizeof() */
  1391. typedef __int32_t __ssize_t; /* byte count or error */
  1392. typedef __uint32_t __uintfptr_t;
  1393. typedef __uint32_t __uintptr_t;
  1394. #endif
  1395. # 129 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1396. typedef __int64_t __time_t; /* time()... */
  1397. typedef __uint64_t __uintmax_t;
  1398. typedef __uint32_t __uint_fast8_t;
  1399. typedef __uint32_t __uint_fast16_t;
  1400. typedef __uint32_t __uint_fast32_t;
  1401. typedef __uint64_t __uint_fast64_t;
  1402. typedef __uint8_t __uint_least8_t;
  1403. typedef __uint16_t __uint_least16_t;
  1404. typedef __uint32_t __uint_least32_t;
  1405. typedef __uint64_t __uint_least64_t;
  1406. #if defined(__mips_n64) || defined(__mips_n32)
  1407. typedef __uint64_t __u_register_t;
  1408. #else
  1409. # 142 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1410. typedef __uint32_t __u_register_t;
  1411. #endif
  1412. # 144 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1413. #ifdef __mips_n64
  1414. typedef __uint64_t __vm_offset_t;
  1415. typedef __uint64_t __vm_size_t;
  1416. #else
  1417. # 148 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1418. typedef __uint32_t __vm_offset_t;
  1419. typedef __uint32_t __vm_size_t;
  1420. #endif
  1421. # 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1422. #if defined(__mips_n64) || defined(__mips_n32) /* PHYSADDR_64_BIT */
  1423. typedef __uint64_t __vm_paddr_t;
  1424. #else
  1425. # 154 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1426. typedef __uint32_t __vm_paddr_t;
  1427. #endif
  1428. # 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1429.  
  1430. typedef int ___wchar_t;
  1431.  
  1432. #define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
  1433. #define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */
  1434.  
  1435. /*
  1436. * Unusual type definitions.
  1437. */
  1438. #ifdef __GNUCLIKE_BUILTIN_VARARGS
  1439. typedef __builtin_va_list __va_list; /* internally known to gcc */
  1440. #else
  1441. # 168 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1442. typedef char * __va_list;
  1443. #endif /* __GNUCLIKE_BUILTIN_VARARGS */
  1444. # 170 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1445. #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
  1446. && !defined(__NO_GNUC_VA_LIST)
  1447. #define __GNUC_VA_LIST
  1448. typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
  1449. #endif
  1450. # 175 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1451.  
  1452. #endif /* !_MACHINE__TYPES_H_ */
  1453. # 177 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/_types.h" 3 4
  1454. # 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 2 3 4
  1455.  
  1456. /*
  1457. * Standard type definitions.
  1458. */
  1459. typedef __int32_t __blksize_t; /* file block size */
  1460. typedef __int64_t __blkcnt_t; /* file block count */
  1461. typedef __int32_t __clockid_t; /* clock_gettime()... */
  1462. typedef __uint32_t __fflags_t; /* file flags */
  1463. typedef __uint64_t __fsblkcnt_t;
  1464. typedef __uint64_t __fsfilcnt_t;
  1465. typedef __uint32_t __gid_t;
  1466. typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
  1467. typedef __uint64_t __ino_t; /* inode number */
  1468. typedef long __key_t; /* IPC key (for Sys V IPC) */
  1469. typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
  1470. typedef __uint16_t __mode_t; /* permissions */
  1471. typedef int __accmode_t; /* access permissions */
  1472. typedef int __nl_item;
  1473. typedef __uint64_t __nlink_t; /* link count */
  1474. typedef __int64_t __off_t; /* file offset */
  1475. typedef __int64_t __off64_t; /* file offset (alias) */
  1476. typedef __int32_t __pid_t; /* process [group] */
  1477. typedef __int64_t __rlim_t; /* resource limit - intentionally */
  1478. /* signed, because of legacy code */
  1479. /* that uses -1 for RLIM_INFINITY */
  1480. typedef __uint8_t __sa_family_t;
  1481. typedef __uint32_t __socklen_t;
  1482. typedef long __suseconds_t; /* microseconds (signed) */
  1483. typedef struct __timer *__timer_t; /* timer_gettime()... */
  1484. typedef struct __mq *__mqd_t; /* mq_open()... */
  1485. typedef __uint32_t __uid_t;
  1486. typedef unsigned int __useconds_t; /* microseconds (unsigned) */
  1487. typedef int __cpuwhich_t; /* which parameter for cpuset. */
  1488. typedef int __cpulevel_t; /* level parameter for cpuset. */
  1489. typedef int __cpusetid_t; /* cpuset identifier. */
  1490.  
  1491. /*
  1492. * Unusual type definitions.
  1493. */
  1494. /*
  1495. * rune_t is declared to be an ``int'' instead of the more natural
  1496. * ``unsigned long'' or ``long''. Two things are happening here. It is not
  1497. * unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
  1498. * it looks like 10646 will be a 31 bit standard. This means that if your
  1499. * ints cannot hold 32 bits, you will be in trouble. The reason an int was
  1500. * chosen over a long is that the is*() and to*() routines take ints (says
  1501. * ANSI C), but they use __ct_rune_t instead of int.
  1502. *
  1503. * NOTE: rune_t is not covered by ANSI nor other standards, and should not
  1504. * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and
  1505. * rune_t must be the same type. Also, wint_t should be able to hold all
  1506. * members of the largest character set plus one extra value (WEOF), and
  1507. * must be at least 16 bits.
  1508. */
  1509. typedef int __ct_rune_t; /* arg type for ctype funcs */
  1510. typedef __ct_rune_t __rune_t; /* rune_t (see above) */
  1511. typedef __ct_rune_t __wint_t; /* wint_t (see above) */
  1512.  
  1513. /* Clang already provides these types as built-ins, but only in C++ mode. */
  1514. #if !defined(__clang__) || !defined(__cplusplus)
  1515. typedef __uint_least16_t __char16_t;
  1516. typedef __uint_least32_t __char32_t;
  1517. #endif
  1518. # 97 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
  1519. /* In C++11, char16_t and char32_t are built-in types. */
  1520. #if defined(__cplusplus) && __cplusplus >= 201103L
  1521. #define _CHAR16_T_DECLARED
  1522. #define _CHAR32_T_DECLARED
  1523. #endif
  1524. # 102 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
  1525.  
  1526. typedef struct {
  1527. long long __max_align1 __aligned(_Alignof(long long));
  1528. long double __max_align2 __aligned(_Alignof(long double));
  1529. } __max_align_t;
  1530.  
  1531. typedef __uint64_t __dev_t; /* device number */
  1532.  
  1533. typedef __uint32_t __fixpt_t; /* fixed point number */
  1534.  
  1535. /*
  1536. * mbstate_t is an opaque object to keep conversion state during multibyte
  1537. * stream conversions.
  1538. */
  1539. typedef union {
  1540. char __mbstate8[128];
  1541. __int64_t _mbstateL; /* for alignment */
  1542. } __mbstate_t;
  1543.  
  1544. typedef __uintmax_t __rman_res_t;
  1545.  
  1546. /*
  1547. * When the following macro is defined, the system uses 64-bit inode numbers.
  1548. * Programs can use this to avoid including <sys/param.h>, with its associated
  1549. * namespace pollution.
  1550. */
  1551. #define __INO64
  1552.  
  1553. #endif /* !_SYS__TYPES_H_ */
  1554. # 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_types.h" 3 4
  1555. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 2 3 4
  1556. #endif
  1557. # 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1558.  
  1559. #ifdef __cplusplus
  1560. extern "C" {
  1561. #endif
  1562. # 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1563.  
  1564. /*
  1565. * Definitions for byte order, according to byte significance from low
  1566. * address to high.
  1567. */
  1568. #define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
  1569. #define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
  1570. #define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
  1571.  
  1572. #ifdef __MIPSEB__
  1573. #define _BYTE_ORDER _BIG_ENDIAN
  1574. #else
  1575. # 56 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1576. #define _BYTE_ORDER _LITTLE_ENDIAN
  1577. #endif /* __MIBSEB__ */
  1578. # 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1579.  
  1580. /*
  1581. * Deprecated variants that don't have enough underscores to be useful in more
  1582. * strict namespaces.
  1583. */
  1584. #if __BSD_VISIBLE
  1585. #define LITTLE_ENDIAN _LITTLE_ENDIAN
  1586. #define BIG_ENDIAN _BIG_ENDIAN
  1587. #define PDP_ENDIAN _PDP_ENDIAN
  1588. #define BYTE_ORDER _BYTE_ORDER
  1589. #endif
  1590. # 69 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1591.  
  1592. #ifndef __ASSEMBLER__
  1593. #if defined(__GNUCLIKE_BUILTIN_CONSTANT_P) && defined(__OPTIMIZE__)
  1594. #define __is_constant(x) __builtin_constant_p(x)
  1595. #else
  1596. # 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1597. #define __is_constant(x) 0
  1598. #endif
  1599. # 76 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1600.  
  1601. #define __bswap16_const(x) (((x) >> 8) | (((x) << 8) & 0xff00))
  1602. #define __bswap32_const(x) (((x) >> 24) | (((x) >> 8) & 0xff00) | \
  1603. (((x) << 8) & 0xff0000) | (((x) << 24) & 0xff000000))
  1604. #define __bswap64_const(x) (((x) >> 56) | (((x) >> 40) & 0xff00) | \
  1605. (((x) >> 24) & 0xff0000) | (((x) >> 8) & 0xff000000) | \
  1606. (((x) << 8) & ((__uint64_t)0xff << 32)) | \
  1607. (((x) << 24) & ((__uint64_t)0xff << 40)) | \
  1608. (((x) << 40) & ((__uint64_t)0xff << 48)) | (((x) << 56)))
  1609.  
  1610. static __inline __uint16_t
  1611. __bswap16_var(__uint16_t _x)
  1612. {
  1613.  
  1614. return ((_x >> 8) | ((_x << 8) & 0xff00));
  1615. }
  1616.  
  1617. static __inline __uint32_t
  1618. __bswap32_var(__uint32_t _x)
  1619. {
  1620.  
  1621. return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff0000) |
  1622. ((_x << 24) & 0xff000000));
  1623. }
  1624.  
  1625. static __inline __uint64_t
  1626. __bswap64_var(__uint64_t _x)
  1627. {
  1628.  
  1629. return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
  1630. ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
  1631. ((_x << 24) & ((__uint64_t)0xff << 40)) |
  1632. ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
  1633. }
  1634.  
  1635. #define __bswap16(x) ((__uint16_t)(__is_constant((x)) ? \
  1636. __bswap16_const((__uint16_t)(x)) : __bswap16_var((__uint16_t)(x))))
  1637. #define __bswap32(x) ((__uint32_t)(__is_constant((x)) ? \
  1638. __bswap32_const((__uint32_t)(x)) : __bswap32_var((__uint32_t)(x))))
  1639. #define __bswap64(x) ((__uint64_t)(__is_constant((x)) ? \
  1640. __bswap64_const((__uint64_t)(x)) : __bswap64_var((__uint64_t)(x))))
  1641.  
  1642. #ifdef __MIPSEB__
  1643. #define __htonl(x) ((__uint32_t)(x))
  1644. #define __htons(x) ((__uint16_t)(x))
  1645. #define __ntohl(x) ((__uint32_t)(x))
  1646. #define __ntohs(x) ((__uint16_t)(x))
  1647. /*
  1648. * Define the order of 32-bit words in 64-bit words.
  1649. */
  1650. /*
  1651. * XXXMIPS: Additional parentheses to make gcc more happy.
  1652. */
  1653. #define _QUAD_HIGHWORD 0
  1654. #define _QUAD_LOWWORD 1
  1655. #else
  1656. # 132 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1657. #define _QUAD_HIGHWORD 1
  1658. #define _QUAD_LOWWORD 0
  1659. #define __ntohl(x) (__bswap32((x)))
  1660. #define __ntohs(x) (__bswap16((x)))
  1661. #define __htonl(x) (__bswap32((x)))
  1662. #define __htons(x) (__bswap16((x)))
  1663. #endif /* _MIPSEB */
  1664. # 139 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1665.  
  1666. #endif /* _ASSEMBLER_ */
  1667. # 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1668.  
  1669. #ifdef __cplusplus
  1670. }
  1671. #endif
  1672. # 145 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1673.  
  1674. #endif /* !_MACHINE_ENDIAN_H_ */
  1675. # 147 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/endian.h" 3 4
  1676. # 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
  1677. #if 0 /* expanded by -frewrite-includes */
  1678. #include <sys/_types.h>
  1679. #endif /* expanded by -frewrite-includes */
  1680. # 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1681. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1682.  
  1683. #if 0 /* expanded by -frewrite-includes */
  1684. #include <sys/_pthreadtypes.h>
  1685. #endif /* expanded by -frewrite-includes */
  1686. # 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1687. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 1 3 4
  1688. /*
  1689. * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
  1690. * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au>
  1691. * All rights reserved.
  1692. *
  1693. * Redistribution and use in source and binary forms, with or without
  1694. * modification, are permitted provided that the following conditions
  1695. * are met:
  1696. * 1. Redistributions of source code must retain the above copyright
  1697. * notice, this list of conditions and the following disclaimer.
  1698. * 2. Redistributions in binary form must reproduce the above copyright
  1699. * notice, this list of conditions and the following disclaimer in the
  1700. * documentation and/or other materials provided with the distribution.
  1701. * 3. All advertising materials mentioning features or use of this software
  1702. * must display the following acknowledgement:
  1703. * This product includes software developed by Chris Provenzano.
  1704. * 4. The name of Chris Provenzano may not be used to endorse or promote
  1705. * products derived from this software without specific prior written
  1706. * permission.
  1707. *
  1708. * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
  1709. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1710. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1711. * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
  1712. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  1713. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  1714. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  1715. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1716. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1717. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1718. * SUCH DAMAGE.
  1719. *
  1720. * $FreeBSD$
  1721. */
  1722.  
  1723. #ifndef _SYS__PTHREADTYPES_H_
  1724. #define _SYS__PTHREADTYPES_H_
  1725.  
  1726. /*
  1727. * Forward structure definitions.
  1728. *
  1729. * These are mostly opaque to the user.
  1730. */
  1731. struct pthread;
  1732. struct pthread_attr;
  1733. struct pthread_cond;
  1734. struct pthread_cond_attr;
  1735. struct pthread_mutex;
  1736. struct pthread_mutex_attr;
  1737. struct pthread_once;
  1738. struct pthread_rwlock;
  1739. struct pthread_rwlockattr;
  1740. struct pthread_barrier;
  1741. struct pthread_barrier_attr;
  1742. struct pthread_spinlock;
  1743.  
  1744. /*
  1745. * Primitive system data type definitions required by P1003.1c.
  1746. *
  1747. * Note that P1003.1c specifies that there are no defined comparison
  1748. * or assignment operators for the types pthread_attr_t, pthread_cond_t,
  1749. * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
  1750. */
  1751. #ifndef _PTHREAD_T_DECLARED
  1752. typedef struct pthread *pthread_t;
  1753. #define _PTHREAD_T_DECLARED
  1754. #endif
  1755. # 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 3 4
  1756. typedef struct pthread_attr *pthread_attr_t;
  1757. typedef struct pthread_mutex *pthread_mutex_t;
  1758. typedef struct pthread_mutex_attr *pthread_mutexattr_t;
  1759. typedef struct pthread_cond *pthread_cond_t;
  1760. typedef struct pthread_cond_attr *pthread_condattr_t;
  1761. typedef int pthread_key_t;
  1762. typedef struct pthread_once pthread_once_t;
  1763. typedef struct pthread_rwlock *pthread_rwlock_t;
  1764. typedef struct pthread_rwlockattr *pthread_rwlockattr_t;
  1765. typedef struct pthread_barrier *pthread_barrier_t;
  1766. typedef struct pthread_barrierattr *pthread_barrierattr_t;
  1767. typedef struct pthread_spinlock *pthread_spinlock_t;
  1768.  
  1769. /*
  1770. * Additional type definitions:
  1771. *
  1772. * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for
  1773. * use in header symbols.
  1774. */
  1775. typedef void *pthread_addr_t;
  1776. typedef void *(*pthread_startroutine_t)(void *);
  1777.  
  1778. /*
  1779. * Once definitions.
  1780. */
  1781. struct pthread_once {
  1782. int state;
  1783. pthread_mutex_t mutex;
  1784. };
  1785.  
  1786. #endif /* ! _SYS__PTHREADTYPES_H_ */
  1787. # 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_pthreadtypes.h" 3 4
  1788. # 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
  1789.  
  1790. #if __BSD_VISIBLE
  1791. typedef unsigned char u_char;
  1792. typedef unsigned short u_short;
  1793. typedef unsigned int u_int;
  1794. typedef unsigned long u_long;
  1795. #ifndef _KERNEL
  1796. typedef unsigned short ushort; /* Sys V compatibility */
  1797. typedef unsigned int uint; /* Sys V compatibility */
  1798. #endif
  1799. # 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1800. #endif
  1801. # 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1802.  
  1803. /*
  1804. * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
  1805. */
  1806. #if 0 /* expanded by -frewrite-includes */
  1807. #include <sys/_stdint.h>
  1808. #endif /* expanded by -frewrite-includes */
  1809. # 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1810. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 1 3 4
  1811. /*-
  1812. * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org>
  1813. * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
  1814. * All rights reserved.
  1815. *
  1816. * Redistribution and use in source and binary forms, with or without
  1817. * modification, are permitted provided that the following conditions
  1818. * are met:
  1819. * 1. Redistributions of source code must retain the above copyright
  1820. * notice, this list of conditions and the following disclaimer.
  1821. * 2. Redistributions in binary form must reproduce the above copyright
  1822. * notice, this list of conditions and the following disclaimer in the
  1823. * documentation and/or other materials provided with the distribution.
  1824. *
  1825. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  1826. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1827. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1828. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  1829. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1830. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1831. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1832. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1833. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1834. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1835. * SUCH DAMAGE.
  1836. *
  1837. * $FreeBSD$
  1838. */
  1839.  
  1840. #ifndef _SYS__STDINT_H_
  1841. #define _SYS__STDINT_H_
  1842.  
  1843. #ifndef _INT8_T_DECLARED
  1844. typedef __int8_t int8_t;
  1845. #define _INT8_T_DECLARED
  1846. #endif
  1847. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1848.  
  1849. #ifndef _INT16_T_DECLARED
  1850. typedef __int16_t int16_t;
  1851. #define _INT16_T_DECLARED
  1852. #endif
  1853. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1854.  
  1855. #ifndef _INT32_T_DECLARED
  1856. typedef __int32_t int32_t;
  1857. #define _INT32_T_DECLARED
  1858. #endif
  1859. # 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1860.  
  1861. #ifndef _INT64_T_DECLARED
  1862. typedef __int64_t int64_t;
  1863. #define _INT64_T_DECLARED
  1864. #endif
  1865. # 52 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1866.  
  1867. #ifndef _UINT8_T_DECLARED
  1868. typedef __uint8_t uint8_t;
  1869. #define _UINT8_T_DECLARED
  1870. #endif
  1871. # 57 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1872.  
  1873. #ifndef _UINT16_T_DECLARED
  1874. typedef __uint16_t uint16_t;
  1875. #define _UINT16_T_DECLARED
  1876. #endif
  1877. # 62 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1878.  
  1879. #ifndef _UINT32_T_DECLARED
  1880. typedef __uint32_t uint32_t;
  1881. #define _UINT32_T_DECLARED
  1882. #endif
  1883. # 67 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1884.  
  1885. #ifndef _UINT64_T_DECLARED
  1886. typedef __uint64_t uint64_t;
  1887. #define _UINT64_T_DECLARED
  1888. #endif
  1889. # 72 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1890.  
  1891. #ifndef _INTPTR_T_DECLARED
  1892. typedef __intptr_t intptr_t;
  1893. #define _INTPTR_T_DECLARED
  1894. #endif
  1895. # 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1896. #ifndef _UINTPTR_T_DECLARED
  1897. typedef __uintptr_t uintptr_t;
  1898. #define _UINTPTR_T_DECLARED
  1899. #endif
  1900. # 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1901. #ifndef _INTMAX_T_DECLARED
  1902. typedef __intmax_t intmax_t;
  1903. #define _INTMAX_T_DECLARED
  1904. #endif
  1905. # 85 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1906. #ifndef _UINTMAX_T_DECLARED
  1907. typedef __uintmax_t uintmax_t;
  1908. #define _UINTMAX_T_DECLARED
  1909. #endif
  1910. # 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1911.  
  1912. #ifndef _VADDR_T_DECLARED
  1913. #ifndef __CHERI_PURE_CAPABILITY__
  1914. typedef __uintptr_t vaddr_t;
  1915. #else
  1916. # 94 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1917. typedef __uint64_t vaddr_t;
  1918. #endif
  1919. # 96 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1920. #define _VADDR_T_DECLARED
  1921. #endif
  1922. # 98 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1923.  
  1924. #endif /* !_SYS__STDINT_H_ */
  1925. # 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_stdint.h" 3 4
  1926. # 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
  1927.  
  1928. typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */
  1929. typedef __uint16_t u_int16_t;
  1930. typedef __uint32_t u_int32_t;
  1931. typedef __uint64_t u_int64_t;
  1932.  
  1933. typedef __uint64_t u_quad_t; /* quads (deprecated) */
  1934. typedef __int64_t quad_t;
  1935. typedef quad_t * qaddr_t;
  1936.  
  1937. typedef char * caddr_t; /* core address */
  1938. typedef const char * c_caddr_t; /* core address, pointer to const */
  1939.  
  1940. #ifndef _BLKSIZE_T_DECLARED
  1941. typedef __blksize_t blksize_t;
  1942. #define _BLKSIZE_T_DECLARED
  1943. #endif
  1944. # 81 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1945.  
  1946. typedef __cpuwhich_t cpuwhich_t;
  1947. typedef __cpulevel_t cpulevel_t;
  1948. typedef __cpusetid_t cpusetid_t;
  1949.  
  1950. #ifndef _BLKCNT_T_DECLARED
  1951. typedef __blkcnt_t blkcnt_t;
  1952. #define _BLKCNT_T_DECLARED
  1953. #endif
  1954. # 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1955.  
  1956. #ifndef _CLOCK_T_DECLARED
  1957. typedef __clock_t clock_t;
  1958. #define _CLOCK_T_DECLARED
  1959. #endif
  1960. # 95 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1961.  
  1962. #ifndef _CLOCKID_T_DECLARED
  1963. typedef __clockid_t clockid_t;
  1964. #define _CLOCKID_T_DECLARED
  1965. #endif
  1966. # 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1967.  
  1968. typedef __critical_t critical_t; /* Critical section value */
  1969. typedef __int64_t daddr_t; /* disk address */
  1970.  
  1971. #ifndef _DEV_T_DECLARED
  1972. typedef __dev_t dev_t; /* device number or struct cdev */
  1973. #define _DEV_T_DECLARED
  1974. #endif
  1975. # 108 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1976.  
  1977. #ifndef _FFLAGS_T_DECLARED
  1978. typedef __fflags_t fflags_t; /* file flags */
  1979. #define _FFLAGS_T_DECLARED
  1980. #endif
  1981. # 113 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1982.  
  1983. typedef __fixpt_t fixpt_t; /* fixed point number */
  1984.  
  1985. #ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
  1986. typedef __fsblkcnt_t fsblkcnt_t;
  1987. typedef __fsfilcnt_t fsfilcnt_t;
  1988. #define _FSBLKCNT_T_DECLARED
  1989. #endif
  1990. # 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1991.  
  1992. #ifndef _GID_T_DECLARED
  1993. typedef __gid_t gid_t; /* group id */
  1994. #define _GID_T_DECLARED
  1995. #endif
  1996. # 126 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  1997.  
  1998. #ifndef _IN_ADDR_T_DECLARED
  1999. typedef __uint32_t in_addr_t; /* base type for internet address */
  2000. #define _IN_ADDR_T_DECLARED
  2001. #endif
  2002. # 131 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2003.  
  2004. #ifndef _IN_PORT_T_DECLARED
  2005. typedef __uint16_t in_port_t;
  2006. #define _IN_PORT_T_DECLARED
  2007. #endif
  2008. # 136 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2009.  
  2010. #ifndef _ID_T_DECLARED
  2011. typedef __id_t id_t; /* can hold a uid_t or pid_t */
  2012. #define _ID_T_DECLARED
  2013. #endif
  2014. # 141 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2015.  
  2016. #ifndef _INO_T_DECLARED
  2017. typedef __ino_t ino_t; /* inode number */
  2018. #define _INO_T_DECLARED
  2019. #endif
  2020. # 146 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2021.  
  2022. #ifndef _KEY_T_DECLARED
  2023. typedef __key_t key_t; /* IPC key (for Sys V IPC) */
  2024. #define _KEY_T_DECLARED
  2025. #endif
  2026. # 151 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2027.  
  2028. #ifndef _LWPID_T_DECLARED
  2029. typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */
  2030. #define _LWPID_T_DECLARED
  2031. #endif
  2032. # 156 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2033.  
  2034. #ifndef _MODE_T_DECLARED
  2035. typedef __mode_t mode_t; /* permissions */
  2036. #define _MODE_T_DECLARED
  2037. #endif
  2038. # 161 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2039.  
  2040. #ifndef _ACCMODE_T_DECLARED
  2041. typedef __accmode_t accmode_t; /* access permissions */
  2042. #define _ACCMODE_T_DECLARED
  2043. #endif
  2044. # 166 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2045.  
  2046. #ifndef _NLINK_T_DECLARED
  2047. typedef __nlink_t nlink_t; /* link count */
  2048. #define _NLINK_T_DECLARED
  2049. #endif
  2050. # 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2051.  
  2052. #ifndef _OFF_T_DECLARED
  2053. typedef __off_t off_t; /* file offset */
  2054. #define _OFF_T_DECLARED
  2055. #endif
  2056. # 176 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2057.  
  2058. #ifndef _OFF64_T_DECLARED
  2059. typedef __off64_t off64_t; /* file offset (alias) */
  2060. #define _OFF64_T_DECLARED
  2061. #endif
  2062. # 181 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2063.  
  2064. #ifndef _PID_T_DECLARED
  2065. typedef __pid_t pid_t; /* process id */
  2066. #define _PID_T_DECLARED
  2067. #endif
  2068. # 186 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2069.  
  2070. typedef __register_t register_t;
  2071.  
  2072. #ifndef _RLIM_T_DECLARED
  2073. typedef __rlim_t rlim_t; /* resource limit */
  2074. #define _RLIM_T_DECLARED
  2075. #endif
  2076. # 193 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2077.  
  2078. typedef __int64_t sbintime_t;
  2079.  
  2080. typedef __segsz_t segsz_t; /* segment size (in pages) */
  2081.  
  2082. #ifndef _SIZE_T_DECLARED
  2083. typedef __size_t size_t;
  2084. #define _SIZE_T_DECLARED
  2085. #endif
  2086. # 202 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2087.  
  2088. #ifndef _SSIZE_T_DECLARED
  2089. typedef __ssize_t ssize_t;
  2090. #define _SSIZE_T_DECLARED
  2091. #endif
  2092. # 207 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2093.  
  2094. #ifndef _SUSECONDS_T_DECLARED
  2095. typedef __suseconds_t suseconds_t; /* microseconds (signed) */
  2096. #define _SUSECONDS_T_DECLARED
  2097. #endif
  2098. # 212 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2099.  
  2100. #ifndef _TIME_T_DECLARED
  2101. typedef __time_t time_t;
  2102. #define _TIME_T_DECLARED
  2103. #endif
  2104. # 217 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2105.  
  2106. #ifndef _TIMER_T_DECLARED
  2107. typedef __timer_t timer_t;
  2108. #define _TIMER_T_DECLARED
  2109. #endif
  2110. # 222 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2111.  
  2112. #ifndef _MQD_T_DECLARED
  2113. typedef __mqd_t mqd_t;
  2114. #define _MQD_T_DECLARED
  2115. #endif
  2116. # 227 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2117.  
  2118. typedef __u_register_t u_register_t;
  2119.  
  2120. #ifndef _UID_T_DECLARED
  2121. typedef __uid_t uid_t; /* user id */
  2122. #define _UID_T_DECLARED
  2123. #endif
  2124. # 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2125.  
  2126. #ifndef _USECONDS_T_DECLARED
  2127. typedef __useconds_t useconds_t; /* microseconds (unsigned) */
  2128. #define _USECONDS_T_DECLARED
  2129. #endif
  2130. # 239 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2131.  
  2132. #ifndef _CAP_IOCTL_T_DECLARED
  2133. #define _CAP_IOCTL_T_DECLARED
  2134. typedef unsigned long cap_ioctl_t;
  2135. #endif
  2136. # 244 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2137.  
  2138. #ifndef _CAP_RIGHTS_T_DECLARED
  2139. #define _CAP_RIGHTS_T_DECLARED
  2140. struct cap_rights;
  2141.  
  2142. typedef struct cap_rights cap_rights_t;
  2143. #endif
  2144. # 251 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2145.  
  2146. typedef __vm_offset_t vm_offset_t;
  2147. typedef __int64_t vm_ooffset_t;
  2148. typedef __vm_paddr_t vm_paddr_t;
  2149. typedef __uint64_t vm_pindex_t;
  2150. typedef __vm_size_t vm_size_t;
  2151.  
  2152. typedef __rman_res_t rman_res_t;
  2153.  
  2154. #if __has_feature(capabilities)
  2155. typedef __intcap_t syscallarg_t;
  2156. #else
  2157. # 263 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2158. typedef register_t syscallarg_t;
  2159. #endif
  2160. # 265 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2161.  
  2162. #ifdef _KERNEL
  2163. typedef int boolean_t;
  2164. typedef struct device *device_t;
  2165. typedef __intfptr_t intfptr_t;
  2166.  
  2167. /*
  2168. * XXX this is fixed width for historical reasons. It should have had type
  2169. * __int_fast32_t. Fixed-width types should not be used unless binary
  2170. * compatibility is essential. Least-width types should be used even less
  2171. * since they provide smaller benefits.
  2172. *
  2173. * XXX should be MD.
  2174. *
  2175. * XXX this is bogus in -current, but still used for spl*().
  2176. */
  2177. typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */
  2178.  
  2179. typedef __uintfptr_t uintfptr_t;
  2180. typedef __uint64_t uoff_t;
  2181. typedef char vm_memattr_t; /* memory attribute codes */
  2182. typedef struct vm_page *vm_page_t;
  2183.  
  2184. #if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
  2185. #define __bool_true_false_are_defined 1
  2186. #define false 0
  2187. #define true 1
  2188. #if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
  2189. typedef int _Bool;
  2190. #endif
  2191. # 295 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2192. typedef _Bool bool;
  2193. #endif /* !__bool_true_false_are_defined && !__cplusplus */
  2194. # 297 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2195.  
  2196. #define offsetof(type, field) __offsetof(type, field)
  2197.  
  2198. #endif /* !_KERNEL */
  2199. # 301 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2200.  
  2201. /*
  2202. * The following are all things that really shouldn't exist in this header,
  2203. * since its purpose is to provide typedefs, not miscellaneous doodads.
  2204. */
  2205.  
  2206. #ifdef __POPCNT__
  2207. #define __bitcount64(x) __builtin_popcountll((__uint64_t)(x))
  2208. #define __bitcount32(x) __builtin_popcount((__uint32_t)(x))
  2209. #define __bitcount16(x) __builtin_popcount((__uint16_t)(x))
  2210. #define __bitcountl(x) __builtin_popcountl((unsigned long)(x))
  2211. #define __bitcount(x) __builtin_popcount((unsigned int)(x))
  2212. #else
  2213. # 314 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2214. /*
  2215. * Population count algorithm using SWAR approach
  2216. * - "SIMD Within A Register".
  2217. */
  2218. static __inline __uint16_t
  2219. __bitcount16(__uint16_t _x)
  2220. {
  2221.  
  2222. _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1);
  2223. _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2);
  2224. _x = (_x + (_x >> 4)) & 0x0f0f;
  2225. _x = (_x + (_x >> 8)) & 0x00ff;
  2226. return (_x);
  2227. }
  2228.  
  2229. static __inline __uint32_t
  2230. __bitcount32(__uint32_t _x)
  2231. {
  2232.  
  2233. _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1);
  2234. _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2);
  2235. _x = (_x + (_x >> 4)) & 0x0f0f0f0f;
  2236. _x = (_x + (_x >> 8));
  2237. _x = (_x + (_x >> 16)) & 0x000000ff;
  2238. return (_x);
  2239. }
  2240.  
  2241. #ifdef __LP64__
  2242. static __inline __uint64_t
  2243. __bitcount64(__uint64_t _x)
  2244. {
  2245.  
  2246. _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1);
  2247. _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2);
  2248. _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f;
  2249. _x = (_x + (_x >> 8));
  2250. _x = (_x + (_x >> 16));
  2251. _x = (_x + (_x >> 32)) & 0x000000ff;
  2252. return (_x);
  2253. }
  2254.  
  2255. #define __bitcountl(x) __bitcount64((unsigned long)(x))
  2256. #else
  2257. # 357 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2258. static __inline __uint64_t
  2259. __bitcount64(__uint64_t _x)
  2260. {
  2261.  
  2262. return (__bitcount32(_x >> 32) + __bitcount32(_x));
  2263. }
  2264.  
  2265. #define __bitcountl(x) __bitcount32((unsigned long)(x))
  2266. #endif
  2267. # 366 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2268. #define __bitcount(x) __bitcount32((unsigned int)(x))
  2269. #endif
  2270. # 368 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2271.  
  2272. #if __BSD_VISIBLE
  2273.  
  2274. #if 0 /* expanded by -frewrite-includes */
  2275. #include <sys/select.h>
  2276. #endif /* expanded by -frewrite-includes */
  2277. # 371 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2278. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 1 3 4
  2279. /*-
  2280. * Copyright (c) 1992, 1993
  2281. * The Regents of the University of California. All rights reserved.
  2282. *
  2283. * Redistribution and use in source and binary forms, with or without
  2284. * modification, are permitted provided that the following conditions
  2285. * are met:
  2286. * 1. Redistributions of source code must retain the above copyright
  2287. * notice, this list of conditions and the following disclaimer.
  2288. * 2. Redistributions in binary form must reproduce the above copyright
  2289. * notice, this list of conditions and the following disclaimer in the
  2290. * documentation and/or other materials provided with the distribution.
  2291. * 3. Neither the name of the University nor the names of its contributors
  2292. * may be used to endorse or promote products derived from this software
  2293. * without specific prior written permission.
  2294. *
  2295. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2296. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2297. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2298. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2299. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2300. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2301. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2302. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2303. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2304. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2305. * SUCH DAMAGE.
  2306. *
  2307. * $FreeBSD$
  2308. */
  2309.  
  2310. #ifndef _SYS_SELECT_H_
  2311. #define _SYS_SELECT_H_
  2312.  
  2313. #if 0 /* expanded by -frewrite-includes */
  2314. #include <sys/cdefs.h>
  2315. #endif /* expanded by -frewrite-includes */
  2316. # 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2317. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2318. #if 0 /* expanded by -frewrite-includes */
  2319. #include <sys/_types.h>
  2320. #endif /* expanded by -frewrite-includes */
  2321. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2322. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2323.  
  2324. #if 0 /* expanded by -frewrite-includes */
  2325. #include <sys/_sigset.h>
  2326. #endif /* expanded by -frewrite-includes */
  2327. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2328. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 1 3 4
  2329. /*-
  2330. * Copyright (c) 1982, 1986, 1989, 1991, 1993
  2331. * The Regents of the University of California. All rights reserved.
  2332. * (c) UNIX System Laboratories, Inc.
  2333. * All or some portions of this file are derived from material licensed
  2334. * to the University of California by American Telephone and Telegraph
  2335. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  2336. * the permission of UNIX System Laboratories, Inc.
  2337. *
  2338. * Redistribution and use in source and binary forms, with or without
  2339. * modification, are permitted provided that the following conditions
  2340. * are met:
  2341. * 1. Redistributions of source code must retain the above copyright
  2342. * notice, this list of conditions and the following disclaimer.
  2343. * 2. Redistributions in binary form must reproduce the above copyright
  2344. * notice, this list of conditions and the following disclaimer in the
  2345. * documentation and/or other materials provided with the distribution.
  2346. * 3. Neither the name of the University nor the names of its contributors
  2347. * may be used to endorse or promote products derived from this software
  2348. * without specific prior written permission.
  2349. *
  2350. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2351. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2352. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2353. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2354. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2355. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2356. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2357. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2358. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2359. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2360. * SUCH DAMAGE.
  2361. *
  2362. * @(#)signal.h 8.4 (Berkeley) 5/4/95
  2363. * $FreeBSD$
  2364. */
  2365.  
  2366. #ifndef _SYS__SIGSET_H_
  2367. #define _SYS__SIGSET_H_
  2368.  
  2369. /*
  2370. * sigset_t macros.
  2371. */
  2372. #define _SIG_WORDS 4
  2373. #define _SIG_MAXSIG 128
  2374. #define _SIG_IDX(sig) ((sig) - 1)
  2375. #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
  2376. #define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
  2377. #define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0)
  2378.  
  2379. typedef struct __sigset {
  2380. __uint32_t __bits[_SIG_WORDS];
  2381. } __sigset_t;
  2382.  
  2383. #if defined(_KERNEL) && defined(COMPAT_43)
  2384. typedef unsigned int osigset_t;
  2385. #endif
  2386. # 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 3 4
  2387.  
  2388. #endif /* !_SYS__SIGSET_H_ */
  2389. # 60 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_sigset.h" 3 4
  2390. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
  2391. #if 0 /* expanded by -frewrite-includes */
  2392. #include <sys/_timeval.h>
  2393. #endif /* expanded by -frewrite-includes */
  2394. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2395. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 1 3 4
  2396. /*-
  2397. * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
  2398. * All rights reserved.
  2399. *
  2400. * Redistribution and use in source and binary forms, with or without
  2401. * modification, are permitted provided that the following conditions
  2402. * are met:
  2403. * 1. Redistributions of source code must retain the above copyright
  2404. * notice, this list of conditions and the following disclaimer.
  2405. * 2. Redistributions in binary form must reproduce the above copyright
  2406. * notice, this list of conditions and the following disclaimer in the
  2407. * documentation and/or other materials provided with the distribution.
  2408. *
  2409. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  2410. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2411. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2412. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  2413. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2414. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2415. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2416. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2417. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2418. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2419. * SUCH DAMAGE.
  2420. *
  2421. * $FreeBSD$
  2422. */
  2423.  
  2424. #ifndef _SYS__TIMEVAL_H_
  2425. #define _SYS__TIMEVAL_H_
  2426.  
  2427. #if 0 /* expanded by -frewrite-includes */
  2428. #include <sys/_types.h>
  2429. #endif /* expanded by -frewrite-includes */
  2430. # 32 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
  2431. # 33 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
  2432.  
  2433. #ifndef _SUSECONDS_T_DECLARED
  2434. typedef __suseconds_t suseconds_t;
  2435. #define _SUSECONDS_T_DECLARED
  2436. #endif
  2437. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
  2438.  
  2439. #ifndef _TIME_T_DECLARED
  2440. typedef __time_t time_t;
  2441. #define _TIME_T_DECLARED
  2442. #endif
  2443. # 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
  2444.  
  2445. /*
  2446. * Structure returned by gettimeofday(2) system call, and used in other calls.
  2447. */
  2448. struct timeval {
  2449. time_t tv_sec; /* seconds */
  2450. suseconds_t tv_usec; /* and microseconds */
  2451. };
  2452.  
  2453. #endif /* !_SYS__TIMEVAL_H_ */
  2454. # 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timeval.h" 3 4
  2455. # 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
  2456. #if 0 /* expanded by -frewrite-includes */
  2457. #include <sys/timespec.h>
  2458. #endif /* expanded by -frewrite-includes */
  2459. # 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2460. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 1 3 4
  2461. /*-
  2462. * Copyright (c) 1982, 1986, 1993
  2463. * The Regents of the University of California. All rights reserved.
  2464. *
  2465. * Redistribution and use in source and binary forms, with or without
  2466. * modification, are permitted provided that the following conditions
  2467. * are met:
  2468. * 1. Redistributions of source code must retain the above copyright
  2469. * notice, this list of conditions and the following disclaimer.
  2470. * 2. Redistributions in binary form must reproduce the above copyright
  2471. * notice, this list of conditions and the following disclaimer in the
  2472. * documentation and/or other materials provided with the distribution.
  2473. * 3. Neither the name of the University nor the names of its contributors
  2474. * may be used to endorse or promote products derived from this software
  2475. * without specific prior written permission.
  2476. *
  2477. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2478. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2479. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2480. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2481. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2482. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2483. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2484. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2485. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2486. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2487. * SUCH DAMAGE.
  2488. *
  2489. * @(#)time.h 8.5 (Berkeley) 5/4/95
  2490. * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
  2491. * $FreeBSD$
  2492. */
  2493.  
  2494. #ifndef _SYS_TIMESPEC_H_
  2495. #define _SYS_TIMESPEC_H_
  2496.  
  2497. #if 0 /* expanded by -frewrite-includes */
  2498. #include <sys/cdefs.h>
  2499. #endif /* expanded by -frewrite-includes */
  2500. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
  2501. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
  2502. #if 0 /* expanded by -frewrite-includes */
  2503. #include <sys/_timespec.h>
  2504. #endif /* expanded by -frewrite-includes */
  2505. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
  2506. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 1 3 4
  2507. /*-
  2508. * Copyright (c) 1982, 1986, 1993
  2509. * The Regents of the University of California. All rights reserved.
  2510. *
  2511. * Redistribution and use in source and binary forms, with or without
  2512. * modification, are permitted provided that the following conditions
  2513. * are met:
  2514. * 1. Redistributions of source code must retain the above copyright
  2515. * notice, this list of conditions and the following disclaimer.
  2516. * 2. Redistributions in binary form must reproduce the above copyright
  2517. * notice, this list of conditions and the following disclaimer in the
  2518. * documentation and/or other materials provided with the distribution.
  2519. * 3. Neither the name of the University nor the names of its contributors
  2520. * may be used to endorse or promote products derived from this software
  2521. * without specific prior written permission.
  2522. *
  2523. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2524. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2525. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2526. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2527. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2528. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2529. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2530. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2531. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2532. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2533. * SUCH DAMAGE.
  2534. *
  2535. * @(#)time.h 8.5 (Berkeley) 5/4/95
  2536. * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
  2537. * $FreeBSD$
  2538. */
  2539.  
  2540. #ifndef _SYS__TIMESPEC_H_
  2541. #define _SYS__TIMESPEC_H_
  2542.  
  2543. #if 0 /* expanded by -frewrite-includes */
  2544. #include <sys/_types.h>
  2545. #endif /* expanded by -frewrite-includes */
  2546. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
  2547. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
  2548.  
  2549. #ifndef _TIME_T_DECLARED
  2550. typedef __time_t time_t;
  2551. #define _TIME_T_DECLARED
  2552. #endif
  2553. # 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
  2554.  
  2555. struct timespec {
  2556. time_t tv_sec; /* seconds */
  2557. long tv_nsec; /* and nanoseconds */
  2558. };
  2559.  
  2560. #endif /* !_SYS__TIMESPEC_H_ */
  2561. # 50 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_timespec.h" 3 4
  2562. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 2 3 4
  2563.  
  2564. #if __BSD_VISIBLE
  2565. #define TIMEVAL_TO_TIMESPEC(tv, ts) \
  2566. do { \
  2567. (ts)->tv_sec = (tv)->tv_sec; \
  2568. (ts)->tv_nsec = (tv)->tv_usec * 1000; \
  2569. } while (0)
  2570. #define TIMESPEC_TO_TIMEVAL(tv, ts) \
  2571. do { \
  2572. (tv)->tv_sec = (ts)->tv_sec; \
  2573. (tv)->tv_usec = (ts)->tv_nsec / 1000; \
  2574. } while (0)
  2575.  
  2576. #endif /* __BSD_VISIBLE */
  2577. # 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
  2578.  
  2579. /*
  2580. * Structure defined by POSIX.1b to be like a itimerval, but with
  2581. * timespecs. Used in the timer_*() system calls.
  2582. */
  2583. struct itimerspec {
  2584. struct timespec it_interval;
  2585. struct timespec it_value;
  2586. };
  2587.  
  2588. #endif /* _SYS_TIMESPEC_H_ */
  2589. # 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/timespec.h" 3 4
  2590. # 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 2 3 4
  2591.  
  2592. typedef unsigned long __fd_mask;
  2593. #if __BSD_VISIBLE
  2594. typedef __fd_mask fd_mask;
  2595. #endif
  2596. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2597.  
  2598. #ifndef _SIGSET_T_DECLARED
  2599. #define _SIGSET_T_DECLARED
  2600. typedef __sigset_t sigset_t;
  2601. #endif
  2602. # 51 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2603.  
  2604. /*
  2605. * Select uses bit masks of file descriptors in longs. These macros
  2606. * manipulate such bit fields (the filesystem macros use chars).
  2607. * FD_SETSIZE may be defined by the user, but the default here should
  2608. * be enough for most uses.
  2609. */
  2610. #ifndef FD_SETSIZE
  2611. #define FD_SETSIZE 1024
  2612. #endif
  2613. # 61 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2614.  
  2615. #define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
  2616. #if __BSD_VISIBLE
  2617. #define NFDBITS _NFDBITS
  2618. #endif
  2619. # 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2620.  
  2621. #ifndef _howmany
  2622. #define _howmany(x, y) (((x) + ((y) - 1)) / (y))
  2623. #endif
  2624. # 70 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2625.  
  2626. typedef struct fd_set {
  2627. __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
  2628. } fd_set;
  2629. #if __BSD_VISIBLE
  2630. #define fds_bits __fds_bits
  2631. #endif
  2632. # 77 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2633.  
  2634. #define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
  2635. #define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
  2636. #if __BSD_VISIBLE
  2637. #define FD_COPY(f, t) (void)(*(t) = *(f))
  2638. #endif
  2639. # 83 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2640. #define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)
  2641. #define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
  2642. #define FD_ZERO(p) do { \
  2643. fd_set *_p; \
  2644. __size_t _n; \
  2645. \
  2646. _p = (p); \
  2647. _n = _howmany(FD_SETSIZE, _NFDBITS); \
  2648. while (_n > 0) \
  2649. _p->__fds_bits[--_n] = 0; \
  2650. } while (0)
  2651.  
  2652. #ifndef _KERNEL
  2653.  
  2654. __BEGIN_DECLS
  2655. int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict,
  2656. const struct timespec *__restrict, const sigset_t *__restrict);
  2657. #ifndef _SELECT_DECLARED
  2658. #define _SELECT_DECLARED
  2659. /* XXX missing restrict type-qualifier */
  2660. int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
  2661. #endif
  2662. # 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2663. __END_DECLS
  2664. #endif /* !_KERNEL */
  2665. # 107 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2666.  
  2667. #endif /* _SYS_SELECT_H_ */
  2668. # 109 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/select.h" 3 4
  2669. # 372 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 2 3 4
  2670.  
  2671. /*
  2672. * minor() gives a cookie instead of an index since we don't want to
  2673. * change the meanings of bits 0-15 or waste time and space shifting
  2674. * bits 16-31 for devices that don't use them.
  2675. */
  2676. #define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
  2677. #define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
  2678. #define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
  2679.  
  2680. /*
  2681. * These declarations belong elsewhere, but are repeated here and in
  2682. * <stdio.h> to give broken programs a better chance of working with
  2683. * 64-bit off_t's.
  2684. */
  2685. #ifndef _KERNEL
  2686. __BEGIN_DECLS
  2687. #ifndef _FTRUNCATE_DECLARED
  2688. #define _FTRUNCATE_DECLARED
  2689. int ftruncate(int, off_t);
  2690. #endif
  2691. # 393 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2692. #ifndef _LSEEK_DECLARED
  2693. #define _LSEEK_DECLARED
  2694. off_t lseek(int, off_t, int);
  2695. #endif
  2696. # 397 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2697. #ifndef _MMAP_DECLARED
  2698. #define _MMAP_DECLARED
  2699. void * mmap(void *, size_t, int, int, int, off_t);
  2700. #endif
  2701. # 401 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2702. #ifndef _TRUNCATE_DECLARED
  2703. #define _TRUNCATE_DECLARED
  2704. int truncate(const char *, off_t);
  2705. #endif
  2706. # 405 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2707. __END_DECLS
  2708. #endif /* !_KERNEL */
  2709. # 407 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2710.  
  2711. #endif /* __BSD_VISIBLE */
  2712. # 409 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2713.  
  2714. #endif /* !_SYS_TYPES_H_ */
  2715. # 411 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/types.h" 3 4
  2716. # 32 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  2717. #if 0 /* expanded by -frewrite-includes */
  2718. #include <sys/stat.h>
  2719. #endif /* expanded by -frewrite-includes */
  2720. # 32 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  2721. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 1 3 4
  2722. /*-
  2723. * Copyright (c) 1982, 1986, 1989, 1993
  2724. * The Regents of the University of California. All rights reserved.
  2725. * (c) UNIX System Laboratories, Inc.
  2726. * All or some portions of this file are derived from material licensed
  2727. * to the University of California by American Telephone and Telegraph
  2728. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  2729. * the permission of UNIX System Laboratories, Inc.
  2730. *
  2731. * Redistribution and use in source and binary forms, with or without
  2732. * modification, are permitted provided that the following conditions
  2733. * are met:
  2734. * 1. Redistributions of source code must retain the above copyright
  2735. * notice, this list of conditions and the following disclaimer.
  2736. * 2. Redistributions in binary form must reproduce the above copyright
  2737. * notice, this list of conditions and the following disclaimer in the
  2738. * documentation and/or other materials provided with the distribution.
  2739. * 3. Neither the name of the University nor the names of its contributors
  2740. * may be used to endorse or promote products derived from this software
  2741. * without specific prior written permission.
  2742. *
  2743. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2744. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2745. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2746. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2747. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2748. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2749. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2750. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2751. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2752. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2753. * SUCH DAMAGE.
  2754. *
  2755. * @(#)stat.h 8.12 (Berkeley) 6/16/95
  2756. * $FreeBSD$
  2757. */
  2758.  
  2759. #ifndef _SYS_STAT_H_
  2760. #define _SYS_STAT_H_
  2761.  
  2762. #if 0 /* expanded by -frewrite-includes */
  2763. #include <sys/cdefs.h>
  2764. #endif /* expanded by -frewrite-includes */
  2765. # 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2766. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2767. #if 0 /* expanded by -frewrite-includes */
  2768. #include <sys/_timespec.h>
  2769. #endif /* expanded by -frewrite-includes */
  2770. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2771. # 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2772. #if 0 /* expanded by -frewrite-includes */
  2773. #include <sys/_types.h>
  2774. #endif /* expanded by -frewrite-includes */
  2775. # 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2776. # 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2777.  
  2778. #ifndef _BLKSIZE_T_DECLARED
  2779. typedef __blksize_t blksize_t;
  2780. #define _BLKSIZE_T_DECLARED
  2781. #endif
  2782. # 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2783.  
  2784. #ifndef _BLKCNT_T_DECLARED
  2785. typedef __blkcnt_t blkcnt_t;
  2786. #define _BLKCNT_T_DECLARED
  2787. #endif
  2788. # 54 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2789.  
  2790. #ifndef _DEV_T_DECLARED
  2791. typedef __dev_t dev_t;
  2792. #define _DEV_T_DECLARED
  2793. #endif
  2794. # 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2795.  
  2796. #ifndef _FFLAGS_T_DECLARED
  2797. typedef __fflags_t fflags_t;
  2798. #define _FFLAGS_T_DECLARED
  2799. #endif
  2800. # 64 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2801.  
  2802. #ifndef _GID_T_DECLARED
  2803. typedef __gid_t gid_t;
  2804. #define _GID_T_DECLARED
  2805. #endif
  2806. # 69 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2807.  
  2808. #ifndef _INO_T_DECLARED
  2809. typedef __ino_t ino_t;
  2810. #define _INO_T_DECLARED
  2811. #endif
  2812. # 74 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2813.  
  2814. #ifndef _MODE_T_DECLARED
  2815. typedef __mode_t mode_t;
  2816. #define _MODE_T_DECLARED
  2817. #endif
  2818. # 79 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2819.  
  2820. #ifndef _NLINK_T_DECLARED
  2821. typedef __nlink_t nlink_t;
  2822. #define _NLINK_T_DECLARED
  2823. #endif
  2824. # 84 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2825.  
  2826. #ifndef _OFF_T_DECLARED
  2827. typedef __off_t off_t;
  2828. #define _OFF_T_DECLARED
  2829. #endif
  2830. # 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2831.  
  2832. #ifndef _UID_T_DECLARED
  2833. typedef __uid_t uid_t;
  2834. #define _UID_T_DECLARED
  2835. #endif
  2836. # 94 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2837.  
  2838. #if !defined(_KERNEL) && __BSD_VISIBLE
  2839. /*
  2840. * XXX We get miscellaneous namespace pollution with this.
  2841. */
  2842. #if 0 /* expanded by -frewrite-includes */
  2843. #include <sys/time.h>
  2844. #endif /* expanded by -frewrite-includes */
  2845. # 99 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  2846. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 1 3 4
  2847. /*-
  2848. * Copyright (c) 1982, 1986, 1993
  2849. * The Regents of the University of California. All rights reserved.
  2850. *
  2851. * Redistribution and use in source and binary forms, with or without
  2852. * modification, are permitted provided that the following conditions
  2853. * are met:
  2854. * 1. Redistributions of source code must retain the above copyright
  2855. * notice, this list of conditions and the following disclaimer.
  2856. * 2. Redistributions in binary form must reproduce the above copyright
  2857. * notice, this list of conditions and the following disclaimer in the
  2858. * documentation and/or other materials provided with the distribution.
  2859. * 3. Neither the name of the University nor the names of its contributors
  2860. * may be used to endorse or promote products derived from this software
  2861. * without specific prior written permission.
  2862. *
  2863. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2864. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2865. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2866. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2867. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2868. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2869. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2870. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2871. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2872. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2873. * SUCH DAMAGE.
  2874. *
  2875. * @(#)time.h 8.5 (Berkeley) 5/4/95
  2876. * $FreeBSD$
  2877. */
  2878.  
  2879. #ifndef _SYS_TIME_H_
  2880. #define _SYS_TIME_H_
  2881.  
  2882. #if 0 /* expanded by -frewrite-includes */
  2883. #include <sys/_timeval.h>
  2884. #endif /* expanded by -frewrite-includes */
  2885. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  2886. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  2887. #if 0 /* expanded by -frewrite-includes */
  2888. #include <sys/types.h>
  2889. #endif /* expanded by -frewrite-includes */
  2890. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  2891. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  2892. #if 0 /* expanded by -frewrite-includes */
  2893. #include <sys/timespec.h>
  2894. #endif /* expanded by -frewrite-includes */
  2895. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  2896. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  2897.  
  2898. struct timezone {
  2899. int tz_minuteswest; /* minutes west of Greenwich */
  2900. int tz_dsttime; /* type of dst correction */
  2901. };
  2902. #define DST_NONE 0 /* not on dst */
  2903. #define DST_USA 1 /* USA style dst */
  2904. #define DST_AUST 2 /* Australian style dst */
  2905. #define DST_WET 3 /* Western European dst */
  2906. #define DST_MET 4 /* Middle European dst */
  2907. #define DST_EET 5 /* Eastern European dst */
  2908. #define DST_CAN 6 /* Canada */
  2909.  
  2910. #if __BSD_VISIBLE
  2911. struct bintime {
  2912. time_t sec;
  2913. uint64_t frac;
  2914. };
  2915.  
  2916. static __inline void
  2917. bintime_addx(struct bintime *_bt, uint64_t _x)
  2918. {
  2919. uint64_t _u;
  2920.  
  2921. _u = _bt->frac;
  2922. _bt->frac += _x;
  2923. if (_u > _bt->frac)
  2924. _bt->sec++;
  2925. }
  2926.  
  2927. static __inline void
  2928. bintime_add(struct bintime *_bt, const struct bintime *_bt2)
  2929. {
  2930. uint64_t _u;
  2931.  
  2932. _u = _bt->frac;
  2933. _bt->frac += _bt2->frac;
  2934. if (_u > _bt->frac)
  2935. _bt->sec++;
  2936. _bt->sec += _bt2->sec;
  2937. }
  2938.  
  2939. static __inline void
  2940. bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
  2941. {
  2942. uint64_t _u;
  2943.  
  2944. _u = _bt->frac;
  2945. _bt->frac -= _bt2->frac;
  2946. if (_u < _bt->frac)
  2947. _bt->sec--;
  2948. _bt->sec -= _bt2->sec;
  2949. }
  2950.  
  2951. static __inline void
  2952. bintime_mul(struct bintime *_bt, u_int _x)
  2953. {
  2954. uint64_t _p1, _p2;
  2955.  
  2956. _p1 = (_bt->frac & 0xffffffffull) * _x;
  2957. _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32);
  2958. _bt->sec *= _x;
  2959. _bt->sec += (_p2 >> 32);
  2960. _bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull);
  2961. }
  2962.  
  2963. static __inline void
  2964. bintime_shift(struct bintime *_bt, int _exp)
  2965. {
  2966.  
  2967. if (_exp > 0) {
  2968. _bt->sec <<= _exp;
  2969. _bt->sec |= _bt->frac >> (64 - _exp);
  2970. _bt->frac <<= _exp;
  2971. } else if (_exp < 0) {
  2972. _bt->frac >>= -_exp;
  2973. _bt->frac |= (uint64_t)_bt->sec << (64 + _exp);
  2974. _bt->sec >>= -_exp;
  2975. }
  2976. }
  2977.  
  2978. #define bintime_clear(a) ((a)->sec = (a)->frac = 0)
  2979. #define bintime_isset(a) ((a)->sec || (a)->frac)
  2980. #define bintime_cmp(a, b, cmp) \
  2981. (((a)->sec == (b)->sec) ? \
  2982. ((a)->frac cmp (b)->frac) : \
  2983. ((a)->sec cmp (b)->sec))
  2984.  
  2985. #define SBT_1S ((sbintime_t)1 << 32)
  2986. #define SBT_1M (SBT_1S * 60)
  2987. #define SBT_1MS (SBT_1S / 1000)
  2988. #define SBT_1US (SBT_1S / 1000000)
  2989. #define SBT_1NS (SBT_1S / 1000000000)
  2990. #define SBT_MAX 0x7fffffffffffffffLL
  2991.  
  2992. static __inline int
  2993. sbintime_getsec(sbintime_t _sbt)
  2994. {
  2995.  
  2996. return (_sbt >> 32);
  2997. }
  2998.  
  2999. static __inline sbintime_t
  3000. bttosbt(const struct bintime _bt)
  3001. {
  3002.  
  3003. return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32));
  3004. }
  3005.  
  3006. static __inline struct bintime
  3007. sbttobt(sbintime_t _sbt)
  3008. {
  3009. struct bintime _bt;
  3010.  
  3011. _bt.sec = _sbt >> 32;
  3012. _bt.frac = _sbt << 32;
  3013. return (_bt);
  3014. }
  3015.  
  3016. /*-
  3017. * Background information:
  3018. *
  3019. * When converting between timestamps on parallel timescales of differing
  3020. * resolutions it is historical and scientific practice to round down rather
  3021. * than doing 4/5 rounding.
  3022. *
  3023. * The date changes at midnight, not at noon.
  3024. *
  3025. * Even at 15:59:59.999999999 it's not four'o'clock.
  3026. *
  3027. * time_second ticks after N.999999999 not after N.4999999999
  3028. */
  3029.  
  3030. static __inline void
  3031. bintime2timespec(const struct bintime *_bt, struct timespec *_ts)
  3032. {
  3033.  
  3034. _ts->tv_sec = _bt->sec;
  3035. _ts->tv_nsec = ((uint64_t)1000000000 *
  3036. (uint32_t)(_bt->frac >> 32)) >> 32;
  3037. }
  3038.  
  3039. static __inline void
  3040. timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
  3041. {
  3042.  
  3043. _bt->sec = _ts->tv_sec;
  3044. /* 18446744073 = int(2^64 / 1000000000) */
  3045. _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL;
  3046. }
  3047.  
  3048. static __inline void
  3049. bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
  3050. {
  3051.  
  3052. _tv->tv_sec = _bt->sec;
  3053. _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32;
  3054. }
  3055.  
  3056. static __inline void
  3057. timeval2bintime(const struct timeval *_tv, struct bintime *_bt)
  3058. {
  3059.  
  3060. _bt->sec = _tv->tv_sec;
  3061. /* 18446744073709 = int(2^64 / 1000000) */
  3062. _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL;
  3063. }
  3064.  
  3065. static __inline struct timespec
  3066. sbttots(sbintime_t _sbt)
  3067. {
  3068. struct timespec _ts;
  3069.  
  3070. _ts.tv_sec = _sbt >> 32;
  3071. _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32;
  3072. return (_ts);
  3073. }
  3074.  
  3075. static __inline sbintime_t
  3076. tstosbt(struct timespec _ts)
  3077. {
  3078.  
  3079. return (((sbintime_t)_ts.tv_sec << 32) +
  3080. (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32));
  3081. }
  3082.  
  3083. static __inline struct timeval
  3084. sbttotv(sbintime_t _sbt)
  3085. {
  3086. struct timeval _tv;
  3087.  
  3088. _tv.tv_sec = _sbt >> 32;
  3089. _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32;
  3090. return (_tv);
  3091. }
  3092.  
  3093. static __inline sbintime_t
  3094. tvtosbt(struct timeval _tv)
  3095. {
  3096.  
  3097. return (((sbintime_t)_tv.tv_sec << 32) +
  3098. (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32));
  3099. }
  3100. #endif /* __BSD_VISIBLE */
  3101. # 243 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3102.  
  3103. #ifdef _KERNEL
  3104.  
  3105. /* Operations on timespecs */
  3106. #define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
  3107. #define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
  3108. #define timespeccmp(tvp, uvp, cmp) \
  3109. (((tvp)->tv_sec == (uvp)->tv_sec) ? \
  3110. ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
  3111. ((tvp)->tv_sec cmp (uvp)->tv_sec))
  3112. #define timespecadd(vvp, uvp) \
  3113. do { \
  3114. (vvp)->tv_sec += (uvp)->tv_sec; \
  3115. (vvp)->tv_nsec += (uvp)->tv_nsec; \
  3116. if ((vvp)->tv_nsec >= 1000000000) { \
  3117. (vvp)->tv_sec++; \
  3118. (vvp)->tv_nsec -= 1000000000; \
  3119. } \
  3120. } while (0)
  3121. #define timespecsub(vvp, uvp) \
  3122. do { \
  3123. (vvp)->tv_sec -= (uvp)->tv_sec; \
  3124. (vvp)->tv_nsec -= (uvp)->tv_nsec; \
  3125. if ((vvp)->tv_nsec < 0) { \
  3126. (vvp)->tv_sec--; \
  3127. (vvp)->tv_nsec += 1000000000; \
  3128. } \
  3129. } while (0)
  3130.  
  3131. /* Operations on timevals. */
  3132.  
  3133. #define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
  3134. #define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  3135. #define timevalcmp(tvp, uvp, cmp) \
  3136. (((tvp)->tv_sec == (uvp)->tv_sec) ? \
  3137. ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
  3138. ((tvp)->tv_sec cmp (uvp)->tv_sec))
  3139.  
  3140. /* timevaladd and timevalsub are not inlined */
  3141.  
  3142. #endif /* _KERNEL */
  3143. # 284 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3144.  
  3145. #ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
  3146.  
  3147. #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
  3148. #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  3149. #define timercmp(tvp, uvp, cmp) \
  3150. (((tvp)->tv_sec == (uvp)->tv_sec) ? \
  3151. ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
  3152. ((tvp)->tv_sec cmp (uvp)->tv_sec))
  3153. #define timeradd(tvp, uvp, vvp) \
  3154. do { \
  3155. (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
  3156. (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
  3157. if ((vvp)->tv_usec >= 1000000) { \
  3158. (vvp)->tv_sec++; \
  3159. (vvp)->tv_usec -= 1000000; \
  3160. } \
  3161. } while (0)
  3162. #define timersub(tvp, uvp, vvp) \
  3163. do { \
  3164. (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
  3165. (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
  3166. if ((vvp)->tv_usec < 0) { \
  3167. (vvp)->tv_sec--; \
  3168. (vvp)->tv_usec += 1000000; \
  3169. } \
  3170. } while (0)
  3171. #endif
  3172. # 312 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3173.  
  3174. /*
  3175. * Names of the interval timers, and structure
  3176. * defining a timer setting.
  3177. */
  3178. #define ITIMER_REAL 0
  3179. #define ITIMER_VIRTUAL 1
  3180. #define ITIMER_PROF 2
  3181.  
  3182. struct itimerval {
  3183. struct timeval it_interval; /* timer interval */
  3184. struct timeval it_value; /* current value */
  3185. };
  3186.  
  3187. /*
  3188. * Getkerninfo clock information structure
  3189. */
  3190. struct clockinfo {
  3191. int hz; /* clock frequency */
  3192. int tick; /* micro-seconds per hz tick */
  3193. int spare;
  3194. int stathz; /* statistics clock frequency */
  3195. int profhz; /* profiling clock frequency */
  3196. };
  3197.  
  3198. /* These macros are also in time.h. */
  3199. #ifndef CLOCK_REALTIME
  3200. #define CLOCK_REALTIME 0
  3201. #define CLOCK_VIRTUAL 1
  3202. #define CLOCK_PROF 2
  3203. #define CLOCK_MONOTONIC 4
  3204. #define CLOCK_UPTIME 5 /* FreeBSD-specific. */
  3205. #define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
  3206. #define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
  3207. #define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
  3208. #define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
  3209. #define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
  3210. #define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
  3211. #define CLOCK_SECOND 13 /* FreeBSD-specific. */
  3212. #define CLOCK_THREAD_CPUTIME_ID 14
  3213. #define CLOCK_PROCESS_CPUTIME_ID 15
  3214. #endif
  3215. # 354 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3216.  
  3217. #ifndef TIMER_ABSTIME
  3218. #define TIMER_RELTIME 0x0 /* relative timer */
  3219. #define TIMER_ABSTIME 0x1 /* absolute timer */
  3220. #endif
  3221. # 359 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3222.  
  3223. #if __BSD_VISIBLE
  3224. #define CPUCLOCK_WHICH_PID 0
  3225. #define CPUCLOCK_WHICH_TID 1
  3226. #endif
  3227. # 364 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3228.  
  3229. #ifdef _KERNEL
  3230.  
  3231. /*
  3232. * Kernel to clock driver interface.
  3233. */
  3234. void inittodr(time_t base);
  3235. void resettodr(void);
  3236.  
  3237. extern volatile time_t time_second;
  3238. extern volatile time_t time_uptime;
  3239. extern struct bintime tc_tick_bt;
  3240. extern sbintime_t tc_tick_sbt;
  3241. extern struct bintime tick_bt;
  3242. extern sbintime_t tick_sbt;
  3243. extern int tc_precexp;
  3244. extern int tc_timepercentage;
  3245. extern struct bintime bt_timethreshold;
  3246. extern struct bintime bt_tickthreshold;
  3247. extern sbintime_t sbt_timethreshold;
  3248. extern sbintime_t sbt_tickthreshold;
  3249.  
  3250. extern volatile int rtc_generation;
  3251.  
  3252. /*
  3253. * Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
  3254. *
  3255. * Functions without the "get" prefix returns the best timestamp
  3256. * we can produce in the given format.
  3257. *
  3258. * "bin" == struct bintime == seconds + 64 bit fraction of seconds.
  3259. * "nano" == struct timespec == seconds + nanoseconds.
  3260. * "micro" == struct timeval == seconds + microseconds.
  3261. *
  3262. * Functions containing "up" returns time relative to boot and
  3263. * should be used for calculating time intervals.
  3264. *
  3265. * Functions without "up" returns UTC time.
  3266. *
  3267. * Functions with the "get" prefix returns a less precise result
  3268. * much faster than the functions without "get" prefix and should
  3269. * be used where a precision of 1/hz seconds is acceptable or where
  3270. * performance is priority. (NB: "precision", _not_ "resolution" !)
  3271. */
  3272.  
  3273. void binuptime(struct bintime *bt);
  3274. void nanouptime(struct timespec *tsp);
  3275. void microuptime(struct timeval *tvp);
  3276.  
  3277. static __inline sbintime_t
  3278. sbinuptime(void)
  3279. {
  3280. struct bintime _bt;
  3281.  
  3282. binuptime(&_bt);
  3283. return (bttosbt(_bt));
  3284. }
  3285.  
  3286. void bintime(struct bintime *bt);
  3287. void nanotime(struct timespec *tsp);
  3288. void microtime(struct timeval *tvp);
  3289.  
  3290. void getbinuptime(struct bintime *bt);
  3291. void getnanouptime(struct timespec *tsp);
  3292. void getmicrouptime(struct timeval *tvp);
  3293.  
  3294. static __inline sbintime_t
  3295. getsbinuptime(void)
  3296. {
  3297. struct bintime _bt;
  3298.  
  3299. getbinuptime(&_bt);
  3300. return (bttosbt(_bt));
  3301. }
  3302.  
  3303. void getbintime(struct bintime *bt);
  3304. void getnanotime(struct timespec *tsp);
  3305. void getmicrotime(struct timeval *tvp);
  3306.  
  3307. void getboottime(struct timeval *boottime);
  3308. void getboottimebin(struct bintime *boottimebin);
  3309.  
  3310. /* Other functions */
  3311. int itimerdecr(struct itimerval *itp, int usec);
  3312. int itimerfix(struct timeval *tv);
  3313. int ppsratecheck(struct timeval *, int *, int);
  3314. int ratecheck(struct timeval *, const struct timeval *);
  3315. void timevaladd(struct timeval *t1, const struct timeval *t2);
  3316. void timevalsub(struct timeval *t1, const struct timeval *t2);
  3317. int tvtohz(struct timeval *tv);
  3318.  
  3319. #define TC_DEFAULTPERC 5
  3320.  
  3321. #define BT2FREQ(bt) \
  3322. (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \
  3323. ((bt)->frac >> 1))
  3324.  
  3325. #define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt))
  3326.  
  3327. #define FREQ2BT(freq, bt) \
  3328. { \
  3329. (bt)->sec = 0; \
  3330. (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \
  3331. }
  3332.  
  3333. #define TIMESEL(sbt, sbt2) \
  3334. (((sbt2) >= sbt_timethreshold) ? \
  3335. ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0))
  3336.  
  3337. #else /* !_KERNEL */
  3338. # 474 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3339. #if 0 /* expanded by -frewrite-includes */
  3340. #include <time.h>
  3341. #endif /* expanded by -frewrite-includes */
  3342. # 474 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3343. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 1 3 4
  3344. /*
  3345. * Copyright (c) 1989, 1993
  3346. * The Regents of the University of California. All rights reserved.
  3347. * (c) UNIX System Laboratories, Inc.
  3348. * All or some portions of this file are derived from material licensed
  3349. * to the University of California by American Telephone and Telegraph
  3350. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  3351. * the permission of UNIX System Laboratories, Inc.
  3352. *
  3353. * Redistribution and use in source and binary forms, with or without
  3354. * modification, are permitted provided that the following conditions
  3355. * are met:
  3356. * 1. Redistributions of source code must retain the above copyright
  3357. * notice, this list of conditions and the following disclaimer.
  3358. * 2. Redistributions in binary form must reproduce the above copyright
  3359. * notice, this list of conditions and the following disclaimer in the
  3360. * documentation and/or other materials provided with the distribution.
  3361. * 3. Neither the name of the University nor the names of its contributors
  3362. * may be used to endorse or promote products derived from this software
  3363. * without specific prior written permission.
  3364. *
  3365. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  3366. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3367. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3368. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  3369. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  3370. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  3371. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  3372. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  3373. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  3374. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3375. * SUCH DAMAGE.
  3376. *
  3377. * @(#)time.h 8.3 (Berkeley) 1/21/94
  3378. */
  3379.  
  3380. /*
  3381. * $FreeBSD$
  3382. */
  3383.  
  3384. #ifndef _TIME_H_
  3385. #define _TIME_H_
  3386.  
  3387. #if 0 /* expanded by -frewrite-includes */
  3388. #include <sys/cdefs.h>
  3389. #endif /* expanded by -frewrite-includes */
  3390. # 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3391. # 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3392. #if 0 /* expanded by -frewrite-includes */
  3393. #include <sys/_null.h>
  3394. #endif /* expanded by -frewrite-includes */
  3395. # 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3396. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 1 3 4
  3397. /*-
  3398. * Copyright (c) 2003 Marcel Moolenaar
  3399. * All rights reserved.
  3400. *
  3401. * Redistribution and use in source and binary forms, with or without
  3402. * modification, are permitted provided that the following conditions
  3403. * are met:
  3404. *
  3405. * 1. Redistributions of source code must retain the above copyright
  3406. * notice, this list of conditions and the following disclaimer.
  3407. * 2. Redistributions in binary form must reproduce the above copyright
  3408. * notice, this list of conditions and the following disclaimer in the
  3409. * documentation and/or other materials provided with the distribution.
  3410. *
  3411. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  3412. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  3413. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  3414. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  3415. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  3416. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  3417. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3418. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3419. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3420. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3421. *
  3422. * $FreeBSD$
  3423. */
  3424.  
  3425. #ifndef NULL
  3426.  
  3427. #if !defined(__cplusplus)
  3428. #define NULL ((void *)0)
  3429. #else
  3430. # 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3431. #if __cplusplus >= 201103L
  3432. #define NULL nullptr
  3433. #elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
  3434. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3435. #define NULL __null
  3436. #else
  3437. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3438. #if defined(__LP64__)
  3439. #define NULL (0L)
  3440. #else
  3441. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3442. #define NULL 0
  3443. #endif /* __LP64__ */
  3444. # 44 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3445. #endif /* __GNUG__ */
  3446. # 45 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3447. #endif /* !__cplusplus */
  3448. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3449.  
  3450. #endif
  3451. # 48 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/_null.h" 3 4
  3452. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 2 3 4
  3453. #if 0 /* expanded by -frewrite-includes */
  3454. #include <sys/_types.h>
  3455. #endif /* expanded by -frewrite-includes */
  3456. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3457. # 47 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3458.  
  3459. #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
  3460. /*
  3461. * Frequency of the clock ticks reported by times(). Deprecated - use
  3462. * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
  3463. */
  3464. #define CLK_TCK 128
  3465. #endif
  3466. # 55 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3467.  
  3468. /* Frequency of the clock ticks reported by clock(). */
  3469. #define CLOCKS_PER_SEC 128
  3470.  
  3471. #ifndef _CLOCK_T_DECLARED
  3472. typedef __clock_t clock_t;
  3473. #define _CLOCK_T_DECLARED
  3474. #endif
  3475. # 63 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3476.  
  3477. #ifndef _TIME_T_DECLARED
  3478. typedef __time_t time_t;
  3479. #define _TIME_T_DECLARED
  3480. #endif
  3481. # 68 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3482.  
  3483. #ifndef _SIZE_T_DECLARED
  3484. typedef __size_t size_t;
  3485. #define _SIZE_T_DECLARED
  3486. #endif
  3487. # 73 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3488.  
  3489. #if __POSIX_VISIBLE >= 199309
  3490. /*
  3491. * New in POSIX 1003.1b-1993.
  3492. */
  3493. #ifndef _CLOCKID_T_DECLARED
  3494. typedef __clockid_t clockid_t;
  3495. #define _CLOCKID_T_DECLARED
  3496. #endif
  3497. # 82 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3498.  
  3499. #ifndef _TIMER_T_DECLARED
  3500. typedef __timer_t timer_t;
  3501. #define _TIMER_T_DECLARED
  3502. #endif
  3503. # 87 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3504.  
  3505. #if 0 /* expanded by -frewrite-includes */
  3506. #include <sys/timespec.h>
  3507. #endif /* expanded by -frewrite-includes */
  3508. # 88 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3509. # 89 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3510. #endif /* __POSIX_VISIBLE >= 199309 */
  3511. # 90 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3512.  
  3513. #if __POSIX_VISIBLE >= 200112
  3514. #ifndef _PID_T_DECLARED
  3515. typedef __pid_t pid_t;
  3516. #define _PID_T_DECLARED
  3517. #endif
  3518. # 96 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3519. #endif
  3520. # 97 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3521.  
  3522. /* These macros are also in sys/time.h. */
  3523. #if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
  3524. #define CLOCK_REALTIME 0
  3525. #ifdef __BSD_VISIBLE
  3526. #define CLOCK_VIRTUAL 1
  3527. #define CLOCK_PROF 2
  3528. #endif
  3529. # 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3530. #define CLOCK_MONOTONIC 4
  3531. #define CLOCK_UPTIME 5 /* FreeBSD-specific. */
  3532. #define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
  3533. #define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
  3534. #define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
  3535. #define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
  3536. #define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
  3537. #define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
  3538. #define CLOCK_SECOND 13 /* FreeBSD-specific. */
  3539. #define CLOCK_THREAD_CPUTIME_ID 14
  3540. #define CLOCK_PROCESS_CPUTIME_ID 15
  3541. #endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
  3542. # 117 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3543.  
  3544. #if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
  3545. #if __BSD_VISIBLE
  3546. #define TIMER_RELTIME 0x0 /* relative timer */
  3547. #endif
  3548. # 122 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3549. #define TIMER_ABSTIME 0x1 /* absolute timer */
  3550. #endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
  3551. # 124 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3552.  
  3553. struct tm {
  3554. int tm_sec; /* seconds after the minute [0-60] */
  3555. int tm_min; /* minutes after the hour [0-59] */
  3556. int tm_hour; /* hours since midnight [0-23] */
  3557. int tm_mday; /* day of the month [1-31] */
  3558. int tm_mon; /* months since January [0-11] */
  3559. int tm_year; /* years since 1900 */
  3560. int tm_wday; /* days since Sunday [0-6] */
  3561. int tm_yday; /* days since January 1 [0-365] */
  3562. int tm_isdst; /* Daylight Savings Time flag */
  3563. long tm_gmtoff; /* offset from UTC in seconds */
  3564. char *tm_zone; /* timezone abbreviation */
  3565. };
  3566.  
  3567. #if __POSIX_VISIBLE
  3568. extern char *tzname[];
  3569. #endif
  3570. # 142 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3571.  
  3572. __BEGIN_DECLS
  3573. char *asctime(const struct tm *);
  3574. clock_t clock(void);
  3575. char *ctime(const time_t *);
  3576. double difftime(time_t, time_t);
  3577. /* XXX missing: getdate() */
  3578. struct tm *gmtime(const time_t *);
  3579. struct tm *localtime(const time_t *);
  3580. time_t mktime(struct tm *);
  3581. size_t strftime(char * __restrict, size_t, const char * __restrict,
  3582. const struct tm * __restrict);
  3583. time_t time(time_t *);
  3584. #if __POSIX_VISIBLE >= 200112
  3585. struct sigevent;
  3586. int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
  3587. int timer_delete(timer_t);
  3588. int timer_gettime(timer_t, struct itimerspec *);
  3589. int timer_getoverrun(timer_t);
  3590. int timer_settime(timer_t, int, const struct itimerspec *__restrict,
  3591. struct itimerspec *__restrict);
  3592. #endif
  3593. # 164 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3594. #if __POSIX_VISIBLE
  3595. void tzset(void);
  3596. #endif
  3597. # 167 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3598.  
  3599. #if __POSIX_VISIBLE >= 199309
  3600. int clock_getres(clockid_t, struct timespec *);
  3601. int clock_gettime(clockid_t, struct timespec *);
  3602. int clock_settime(clockid_t, const struct timespec *);
  3603. int nanosleep(const struct timespec *, struct timespec *);
  3604. #endif /* __POSIX_VISIBLE >= 199309 */
  3605. # 174 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3606.  
  3607. #if __POSIX_VISIBLE >= 200112
  3608. int clock_getcpuclockid(pid_t, clockid_t *);
  3609. int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
  3610. #endif
  3611. # 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3612.  
  3613. #if __POSIX_VISIBLE >= 199506
  3614. char *asctime_r(const struct tm *, char *);
  3615. char *ctime_r(const time_t *, char *);
  3616. struct tm *gmtime_r(const time_t *, struct tm *);
  3617. struct tm *localtime_r(const time_t *, struct tm *);
  3618. #endif
  3619. # 186 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3620.  
  3621. #if __XSI_VISIBLE
  3622. char *strptime(const char * __restrict, const char * __restrict,
  3623. struct tm * __restrict);
  3624. #endif
  3625. # 191 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3626.  
  3627. #if __BSD_VISIBLE
  3628. char *timezone(int, int); /* XXX XSI conflict */
  3629. void tzsetwall(void);
  3630. time_t timelocal(struct tm * const);
  3631. time_t timegm(struct tm * const);
  3632. int timer_oshandle_np(timer_t timerid);
  3633. #endif /* __BSD_VISIBLE */
  3634. # 199 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3635.  
  3636. #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
  3637. #if 0 /* expanded by -frewrite-includes */
  3638. #include <xlocale/_time.h>
  3639. #endif /* expanded by -frewrite-includes */
  3640. # 201 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3641. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 1 3 4
  3642. /*-
  3643. * Copyright (c) 2011, 2012 The FreeBSD Foundation
  3644. * All rights reserved.
  3645. *
  3646. * This software was developed by David Chisnall under sponsorship from
  3647. * the FreeBSD Foundation.
  3648. *
  3649. * Redistribution and use in source and binary forms, with or without
  3650. * modification, are permitted provided that the following conditions
  3651. * are met:
  3652. * 1. Redistributions of source code must retain the above copyright
  3653. * notice, this list of conditions and the following disclaimer.
  3654. * 2. Redistributions in binary form must reproduce the above copyright
  3655. * notice, this list of conditions and the following disclaimer in the
  3656. * documentation and/or other materials provided with the distribution.
  3657. *
  3658. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  3659. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3660. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3661. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  3662. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  3663. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  3664. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  3665. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  3666. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  3667. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3668. * SUCH DAMAGE.
  3669. *
  3670. * $FreeBSD$
  3671. */
  3672.  
  3673. #ifndef _LOCALE_T_DEFINED
  3674. #define _LOCALE_T_DEFINED
  3675. typedef struct _xlocale *locale_t;
  3676. #endif
  3677. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
  3678.  
  3679. /*
  3680. * This file is included from both locale.h and xlocale.h. We need to expose
  3681. * the declarations unconditionally if we are included from xlocale.h, but only
  3682. * if we are in POSIX2008 mode if included from locale.h.
  3683. */
  3684. #ifndef _XLOCALE_LOCALE1_H
  3685. #define _XLOCALE_LOCALE1_H
  3686.  
  3687. size_t strftime_l(char * __restrict, size_t, const char * __restrict,
  3688. const struct tm * __restrict, locale_t) __strftimelike(3, 0);
  3689.  
  3690. #endif /* _XLOCALE_LOCALE1_H */
  3691. # 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
  3692.  
  3693. #ifdef _XLOCALE_H_
  3694. #ifndef _XLOCALE_LOCALE2_H
  3695. #define _XLOCALE_LOCALE2_H
  3696.  
  3697. char *strptime_l(const char * __restrict, const char * __restrict,
  3698. struct tm * __restrict, locale_t);
  3699.  
  3700. #endif /* _XLOCALE_LOCALE2_H */
  3701. # 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
  3702. #endif /* _XLOCALE_H_ */
  3703. # 59 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/xlocale/_time.h" 3 4
  3704. # 202 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 2 3 4
  3705. #endif
  3706. # 203 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3707. __END_DECLS
  3708.  
  3709. #endif /* !_TIME_H_ */
  3710. # 206 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/time.h" 3 4
  3711. # 475 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 2 3 4
  3712.  
  3713. #if 0 /* expanded by -frewrite-includes */
  3714. #include <sys/cdefs.h>
  3715. #endif /* expanded by -frewrite-includes */
  3716. # 476 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3717. # 477 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3718. #if 0 /* expanded by -frewrite-includes */
  3719. #include <sys/select.h>
  3720. #endif /* expanded by -frewrite-includes */
  3721. # 477 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3722. # 478 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3723.  
  3724. __BEGIN_DECLS
  3725. int setitimer(int, const struct itimerval *, struct itimerval *);
  3726. int utimes(const char *, const struct timeval *);
  3727.  
  3728. #if __BSD_VISIBLE
  3729. int adjtime(const struct timeval *, struct timeval *);
  3730. int clock_getcpuclockid2(id_t, int, clockid_t *);
  3731. int futimes(int, const struct timeval *);
  3732. int futimesat(int, const char *, const struct timeval [2]);
  3733. int lutimes(const char *, const struct timeval *);
  3734. int settimeofday(const struct timeval *, const struct timezone *);
  3735. #endif
  3736. # 491 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3737.  
  3738. #if __XSI_VISIBLE
  3739. int getitimer(int, struct itimerval *);
  3740. int gettimeofday(struct timeval *, struct timezone *);
  3741. #endif
  3742. # 496 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3743.  
  3744. __END_DECLS
  3745.  
  3746. #endif /* !_KERNEL */
  3747. # 500 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3748.  
  3749. #endif /* !_SYS_TIME_H_ */
  3750. # 502 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/time.h" 3 4
  3751. # 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 2 3 4
  3752. #endif
  3753. # 101 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3754.  
  3755. #ifdef _KERNEL
  3756. struct ostat {
  3757. __uint16_t st_dev; /* inode's device */
  3758. __uint32_t st_ino; /* inode's number */
  3759. mode_t st_mode; /* inode protection mode */
  3760. __uint16_t st_nlink; /* number of hard links */
  3761. __uint16_t st_uid; /* user ID of the file's owner */
  3762. __uint16_t st_gid; /* group ID of the file's group */
  3763. __uint16_t st_rdev; /* device type */
  3764. __int32_t st_size; /* file size, in bytes */
  3765. struct timespec st_atim; /* time of last access */
  3766. struct timespec st_mtim; /* time of last data modification */
  3767. struct timespec st_ctim; /* time of last file status change */
  3768. __int32_t st_blksize; /* optimal blocksize for I/O */
  3769. __int32_t st_blocks; /* blocks allocated for file */
  3770. fflags_t st_flags; /* user defined flags for file */
  3771. __uint32_t st_gen; /* file generation number */
  3772. };
  3773. #endif
  3774. # 121 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3775.  
  3776. #if defined(_WANT_FREEBSD11_STAT) || defined(_KERNEL)
  3777. struct freebsd11_stat {
  3778. __uint32_t st_dev; /* inode's device */
  3779. __uint32_t st_ino; /* inode's number */
  3780. mode_t st_mode; /* inode protection mode */
  3781. __uint16_t st_nlink; /* number of hard links */
  3782. uid_t st_uid; /* user ID of the file's owner */
  3783. gid_t st_gid; /* group ID of the file's group */
  3784. __uint32_t st_rdev; /* device type */
  3785. struct timespec st_atim; /* time of last access */
  3786. struct timespec st_mtim; /* time of last data modification */
  3787. struct timespec st_ctim; /* time of last file status change */
  3788. off_t st_size; /* file size, in bytes */
  3789. blkcnt_t st_blocks; /* blocks allocated for file */
  3790. blksize_t st_blksize; /* optimal blocksize for I/O */
  3791. fflags_t st_flags; /* user defined flags for file */
  3792. __uint32_t st_gen; /* file generation number */
  3793. __int32_t st_lspare;
  3794. struct timespec st_birthtim; /* time of file creation */
  3795. /*
  3796. * Explicitly pad st_birthtim to 16 bytes so that the size of
  3797. * struct stat is backwards compatible. We use bitfields instead
  3798. * of an array of chars so that this doesn't require a C99 compiler
  3799. * to compile if the size of the padding is 0. We use 2 bitfields
  3800. * to cover up to 64 bits on 32-bit machines. We assume that
  3801. * CHAR_BIT is 8...
  3802. */
  3803. unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
  3804. unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
  3805. };
  3806. #endif /* _WANT_FREEBSD11_STAT || _KERNEL */
  3807. # 153 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3808.  
  3809. #if defined(__i386__)
  3810. #define __STAT_TIME_T_EXT 1
  3811. #endif
  3812. # 157 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3813.  
  3814. struct stat {
  3815. dev_t st_dev; /* inode's device */
  3816. ino_t st_ino; /* inode's number */
  3817. nlink_t st_nlink; /* number of hard links */
  3818. mode_t st_mode; /* inode protection mode */
  3819. __int16_t st_padding0;
  3820. uid_t st_uid; /* user ID of the file's owner */
  3821. gid_t st_gid; /* group ID of the file's group */
  3822. __int32_t st_padding1;
  3823. dev_t st_rdev; /* device type */
  3824. #ifdef __STAT_TIME_T_EXT
  3825. __int32_t st_atim_ext;
  3826. #endif
  3827. # 171 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3828. struct timespec st_atim; /* time of last access */
  3829. #ifdef __STAT_TIME_T_EXT
  3830. __int32_t st_mtim_ext;
  3831. #endif
  3832. # 175 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3833. struct timespec st_mtim; /* time of last data modification */
  3834. #ifdef __STAT_TIME_T_EXT
  3835. __int32_t st_ctim_ext;
  3836. #endif
  3837. # 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3838. struct timespec st_ctim; /* time of last file status change */
  3839. #ifdef __STAT_TIME_T_EXT
  3840. __int32_t st_btim_ext;
  3841. #endif
  3842. # 183 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3843. struct timespec st_birthtim; /* time of file creation */
  3844. off_t st_size; /* file size, in bytes */
  3845. blkcnt_t st_blocks; /* blocks allocated for file */
  3846. blksize_t st_blksize; /* optimal blocksize for I/O */
  3847. fflags_t st_flags; /* user defined flags for file */
  3848. __uint64_t st_gen; /* file generation number */
  3849. __uint64_t st_spare[10];
  3850. };
  3851.  
  3852. #ifdef _KERNEL
  3853. struct nstat {
  3854. __uint32_t st_dev; /* inode's device */
  3855. __uint32_t st_ino; /* inode's number */
  3856. __uint32_t st_mode; /* inode protection mode */
  3857. __uint32_t st_nlink; /* number of hard links */
  3858. uid_t st_uid; /* user ID of the file's owner */
  3859. gid_t st_gid; /* group ID of the file's group */
  3860. __uint32_t st_rdev; /* device type */
  3861. struct timespec st_atim; /* time of last access */
  3862. struct timespec st_mtim; /* time of last data modification */
  3863. struct timespec st_ctim; /* time of last file status change */
  3864. off_t st_size; /* file size, in bytes */
  3865. blkcnt_t st_blocks; /* blocks allocated for file */
  3866. blksize_t st_blksize; /* optimal blocksize for I/O */
  3867. fflags_t st_flags; /* user defined flags for file */
  3868. __uint32_t st_gen; /* file generation number */
  3869. struct timespec st_birthtim; /* time of file creation */
  3870. /*
  3871. * See comment in the definition of struct freebsd11_stat
  3872. * above about the following padding.
  3873. */
  3874. unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
  3875. unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
  3876. };
  3877. #endif
  3878. # 218 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3879.  
  3880. #ifndef _KERNEL
  3881. #define st_atime st_atim.tv_sec
  3882. #define st_mtime st_mtim.tv_sec
  3883. #define st_ctime st_ctim.tv_sec
  3884. #if __BSD_VISIBLE
  3885. #define st_birthtime st_birthtim.tv_sec
  3886. #endif
  3887. # 226 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3888.  
  3889. /* For compatibility. */
  3890. #if __BSD_VISIBLE
  3891. #define st_atimespec st_atim
  3892. #define st_mtimespec st_mtim
  3893. #define st_ctimespec st_ctim
  3894. #define st_birthtimespec st_birthtim
  3895. #endif
  3896. # 234 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3897. #endif /* !_KERNEL */
  3898. # 235 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3899.  
  3900. #define S_ISUID 0004000 /* set user id on execution */
  3901. #define S_ISGID 0002000 /* set group id on execution */
  3902. #if __BSD_VISIBLE
  3903. #define S_ISTXT 0001000 /* sticky bit */
  3904. #endif
  3905. # 241 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3906.  
  3907. #define S_IRWXU 0000700 /* RWX mask for owner */
  3908. #define S_IRUSR 0000400 /* R for owner */
  3909. #define S_IWUSR 0000200 /* W for owner */
  3910. #define S_IXUSR 0000100 /* X for owner */
  3911.  
  3912. #if __BSD_VISIBLE
  3913. #define S_IREAD S_IRUSR
  3914. #define S_IWRITE S_IWUSR
  3915. #define S_IEXEC S_IXUSR
  3916. #endif
  3917. # 252 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3918.  
  3919. #define S_IRWXG 0000070 /* RWX mask for group */
  3920. #define S_IRGRP 0000040 /* R for group */
  3921. #define S_IWGRP 0000020 /* W for group */
  3922. #define S_IXGRP 0000010 /* X for group */
  3923.  
  3924. #define S_IRWXO 0000007 /* RWX mask for other */
  3925. #define S_IROTH 0000004 /* R for other */
  3926. #define S_IWOTH 0000002 /* W for other */
  3927. #define S_IXOTH 0000001 /* X for other */
  3928.  
  3929. #if __XSI_VISIBLE
  3930. #define S_IFMT 0170000 /* type of file mask */
  3931. #define S_IFIFO 0010000 /* named pipe (fifo) */
  3932. #define S_IFCHR 0020000 /* character special */
  3933. #define S_IFDIR 0040000 /* directory */
  3934. #define S_IFBLK 0060000 /* block special */
  3935. #define S_IFREG 0100000 /* regular */
  3936. #define S_IFLNK 0120000 /* symbolic link */
  3937. #define S_IFSOCK 0140000 /* socket */
  3938. #define S_ISVTX 0001000 /* save swapped text even after use */
  3939. #endif
  3940. # 274 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3941. #if __BSD_VISIBLE
  3942. #define S_IFWHT 0160000 /* whiteout */
  3943. #endif
  3944. # 277 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3945.  
  3946. #define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
  3947. #define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
  3948. #define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
  3949. #define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
  3950. #define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
  3951. #if __POSIX_VISIBLE >= 200112
  3952. #define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
  3953. #define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
  3954. #endif
  3955. # 287 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3956. #if __BSD_VISIBLE
  3957. #define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
  3958. #endif
  3959. # 290 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3960.  
  3961. #if __BSD_VISIBLE
  3962. #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
  3963. /* 7777 */
  3964. #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
  3965. /* 0666 */
  3966. #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
  3967.  
  3968. #define S_BLKSIZE 512 /* block size used in the stat struct */
  3969.  
  3970. /*
  3971. * Definitions of flags stored in file flags word.
  3972. *
  3973. * Super-user and owner changeable flags.
  3974. */
  3975. #define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
  3976. #define UF_NODUMP 0x00000001 /* do not dump file */
  3977. #define UF_IMMUTABLE 0x00000002 /* file may not be changed */
  3978. #define UF_APPEND 0x00000004 /* writes to file may only append */
  3979. #define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
  3980. #define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
  3981. /*
  3982. * These two bits are defined in MacOS X. They are not currently used in
  3983. * FreeBSD.
  3984. */
  3985. #if 0
  3986. #define UF_COMPRESSED 0x00000020 /* file is compressed */
  3987. #define UF_TRACKED 0x00000040 /* renames and deletes are tracked */
  3988. #endif
  3989. # 319 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  3990.  
  3991. #define UF_SYSTEM 0x00000080 /* Windows system file bit */
  3992. #define UF_SPARSE 0x00000100 /* sparse file */
  3993. #define UF_OFFLINE 0x00000200 /* file is offline */
  3994. #define UF_REPARSE 0x00000400 /* Windows reparse point file bit */
  3995. #define UF_ARCHIVE 0x00000800 /* file needs to be archived */
  3996. #define UF_READONLY 0x00001000 /* Windows readonly file bit */
  3997. /* This is the same as the MacOS X definition of UF_HIDDEN. */
  3998. #define UF_HIDDEN 0x00008000 /* file is hidden */
  3999.  
  4000. /*
  4001. * Super-user changeable flags.
  4002. */
  4003. #define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
  4004. #define SF_ARCHIVED 0x00010000 /* file is archived */
  4005. #define SF_IMMUTABLE 0x00020000 /* file may not be changed */
  4006. #define SF_APPEND 0x00040000 /* writes to file may only append */
  4007. #define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
  4008. #define SF_SNAPSHOT 0x00200000 /* snapshot inode */
  4009.  
  4010. #ifdef _KERNEL
  4011. /*
  4012. * Shorthand abbreviations of above.
  4013. */
  4014. #define OPAQUE (UF_OPAQUE)
  4015. #define APPEND (UF_APPEND | SF_APPEND)
  4016. #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
  4017. #define NOUNLINK (UF_NOUNLINK | SF_NOUNLINK)
  4018. #endif
  4019. # 348 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4020.  
  4021. #endif /* __BSD_VISIBLE */
  4022. # 350 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4023.  
  4024. #if __POSIX_VISIBLE >= 200809
  4025. #define UTIME_NOW -1
  4026. #define UTIME_OMIT -2
  4027. #endif
  4028. # 355 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4029.  
  4030. #ifndef _KERNEL
  4031. __BEGIN_DECLS
  4032. #if __BSD_VISIBLE
  4033. int chflags(const char *, unsigned long);
  4034. int chflagsat(int, const char *, unsigned long, int);
  4035. #endif
  4036. # 362 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4037. int chmod(const char *, mode_t);
  4038. #if __BSD_VISIBLE
  4039. int fchflags(int, unsigned long);
  4040. #endif
  4041. # 366 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4042. #if __POSIX_VISIBLE >= 200112
  4043. int fchmod(int, mode_t);
  4044. #endif
  4045. # 369 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4046. #if __POSIX_VISIBLE >= 200809
  4047. int fchmodat(int, const char *, mode_t, int);
  4048. int futimens(int fd, const struct timespec times[2]);
  4049. int utimensat(int fd, const char *path, const struct timespec times[2],
  4050. int flag);
  4051. #endif
  4052. # 375 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4053. int fstat(int, struct stat *);
  4054. #if __BSD_VISIBLE
  4055. int lchflags(const char *, unsigned long);
  4056. int lchmod(const char *, mode_t);
  4057. #endif
  4058. # 380 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4059. #if __POSIX_VISIBLE >= 200112
  4060. int lstat(const char * __restrict, struct stat * __restrict);
  4061. #endif
  4062. # 383 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4063. int mkdir(const char *, mode_t);
  4064. int mkfifo(const char *, mode_t);
  4065. #if !defined(_MKNOD_DECLARED) && __XSI_VISIBLE
  4066. int mknod(const char *, mode_t, dev_t);
  4067. #define _MKNOD_DECLARED
  4068. #endif
  4069. # 389 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4070. int stat(const char * __restrict, struct stat * __restrict);
  4071. mode_t umask(mode_t);
  4072. #if __POSIX_VISIBLE >= 200809
  4073. int fstatat(int, const char *, struct stat *, int);
  4074. int mkdirat(int, const char *, mode_t);
  4075. int mkfifoat(int, const char *, mode_t);
  4076. #endif
  4077. # 396 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4078. #if __XSI_VISIBLE >= 700
  4079. int mknodat(int, const char *, mode_t, dev_t);
  4080. #endif
  4081. # 399 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4082. __END_DECLS
  4083. #endif /* !_KERNEL */
  4084. # 401 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4085.  
  4086. #endif /* !_SYS_STAT_H_ */
  4087. # 403 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/sys/stat.h" 3 4
  4088. # 33 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  4089.  
  4090. #if 0 /* expanded by -frewrite-includes */
  4091. #include <cheri/cheri.h>
  4092. #endif /* expanded by -frewrite-includes */
  4093. # 34 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  4094. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 1 3 4
  4095. /*-
  4096. * Copyright (c) 2011-2017 Robert N. M. Watson
  4097. * Copyright (c) 2015 SRI International
  4098. * All rights reserved.
  4099. *
  4100. * This software was developed by SRI International and the University of
  4101. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  4102. * ("CTSRD"), as part of the DARPA CRASH research programme.
  4103. *
  4104. * Redistribution and use in source and binary forms, with or without
  4105. * modification, are permitted provided that the following conditions
  4106. * are met:
  4107. * 1. Redistributions of source code must retain the above copyright
  4108. * notice, this list of conditions and the following disclaimer.
  4109. * 2. Redistributions in binary form must reproduce the above copyright
  4110. * notice, this list of conditions and the following disclaimer in the
  4111. * documentation and/or other materials provided with the distribution.
  4112. *
  4113. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  4114. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4115. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  4116. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  4117. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  4118. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  4119. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  4120. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  4121. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  4122. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4123. * SUCH DAMAGE.
  4124. */
  4125.  
  4126. #ifndef _SYS_CHERI_H_
  4127. #define _SYS_CHERI_H_
  4128.  
  4129. #ifdef _KERNEL
  4130. #if 0 /* expanded by -frewrite-includes */
  4131. #include <sys/sysctl.h> /* SYSCTL_DECL() */
  4132. #endif /* expanded by -frewrite-includes */
  4133. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4134. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4135. #if 0 /* expanded by -frewrite-includes */
  4136. #include <sys/systm.h> /* CTASSERT() */
  4137. #endif /* expanded by -frewrite-includes */
  4138. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4139. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4140. #endif
  4141. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4142.  
  4143. #if 0 /* expanded by -frewrite-includes */
  4144. #include <sys/types.h>
  4145. #endif /* expanded by -frewrite-includes */
  4146. # 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4147. # 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4148.  
  4149. #if 0 /* expanded by -frewrite-includes */
  4150. #include <machine/cherireg.h> /* CHERICAP_SIZE. */
  4151. #endif /* expanded by -frewrite-includes */
  4152. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4153. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 1 3 4
  4154. /*-
  4155. * Copyright (c) 2011-2017 Robert N. M. Watson
  4156. * All rights reserved.
  4157. *
  4158. * This software was developed by SRI International and the University of
  4159. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  4160. * ("CTSRD"), as part of the DARPA CRASH research programme.
  4161. *
  4162. * Redistribution and use in source and binary forms, with or without
  4163. * modification, are permitted provided that the following conditions
  4164. * are met:
  4165. * 1. Redistributions of source code must retain the above copyright
  4166. * notice, this list of conditions and the following disclaimer.
  4167. * 2. Redistributions in binary form must reproduce the above copyright
  4168. * notice, this list of conditions and the following disclaimer in the
  4169. * documentation and/or other materials provided with the distribution.
  4170. *
  4171. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  4172. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4173. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  4174. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  4175. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  4176. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  4177. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  4178. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  4179. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  4180. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4181. * SUCH DAMAGE.
  4182. */
  4183.  
  4184. #ifndef _MIPS_INCLUDE_CHERIREG_H_
  4185. #define _MIPS_INCLUDE_CHERIREG_H_
  4186.  
  4187. /*
  4188. * The size of in-memory capabilities in bytes; minimum alignment is also
  4189. * assumed to be this size.
  4190. */
  4191. #if defined(_MIPS_SZCAP) && (_MIPS_SZCAP != 128) && (_MIPS_SZCAP != 256)
  4192. #error "_MIPS_SZCAP defined but neither 128 nor 256"
  4193. #endif
  4194. # 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4195.  
  4196. #if defined(CPU_CHERI128) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 128))
  4197. #define CHERICAP_SIZE 16
  4198. #define CHERICAP_SHIFT 4
  4199. #else
  4200. # 46 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4201. #define CHERICAP_SIZE 32
  4202. #define CHERICAP_SHIFT 5
  4203. #endif
  4204. # 49 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4205.  
  4206. /*
  4207. * CHERI ISA-defined constants for capabilities -- suitable for inclusion from
  4208. * assembly source code.
  4209. *
  4210. * XXXRW: CHERI_UNSEALED is not currently considered part of the perms word,
  4211. * but perhaps it should be.
  4212. */
  4213. #define CHERI_PERM_GLOBAL (1 << 0) /* 0x00000001 */
  4214. #define CHERI_PERM_EXECUTE (1 << 1) /* 0x00000002 */
  4215. #define CHERI_PERM_LOAD (1 << 2) /* 0x00000004 */
  4216. #define CHERI_PERM_STORE (1 << 3) /* 0x00000008 */
  4217. #define CHERI_PERM_LOAD_CAP (1 << 4) /* 0x00000010 */
  4218. #define CHERI_PERM_STORE_CAP (1 << 5) /* 0x00000020 */
  4219. #define CHERI_PERM_STORE_LOCAL_CAP (1 << 6) /* 0x00000040 */
  4220. #define CHERI_PERM_SEAL (1 << 7) /* 0x00000080 */
  4221. #define CHERI_PERM_CCALL (1 << 8) /* 0x00000100 */
  4222. #define CHERI_PERM_RESERVED1 (1 << 9) /* 0x00000200 */
  4223. #define CHERI_PERM_SYSTEM_REGS (1 << 10) /* 0x00000400 */
  4224.  
  4225. /*
  4226. * User-defined permission bits.
  4227. *
  4228. * 256-bit CHERI has a substantially larger number of software-defined
  4229. * permissions.
  4230. */
  4231. #define CHERI256_PERM_SW0 (1 << 15) /* 0x00008000 */
  4232. #define CHERI256_PERM_SW1 (1 << 16) /* 0x00010000 */
  4233. #define CHERI256_PERM_SW2 (1 << 17) /* 0x00020000 */
  4234. #define CHERI256_PERM_SW3 (1 << 18) /* 0x00040000 */
  4235. #define CHERI256_PERM_SW4 (1 << 19) /* 0x00080000 */
  4236. #define CHERI256_PERM_SW5 (1 << 20) /* 0x00100000 */
  4237. #define CHERI256_PERM_SW6 (1 << 21) /* 0x00200000 */
  4238. #define CHERI256_PERM_SW7 (1 << 22) /* 0x00400000 */
  4239. #define CHERI256_PERM_SW8 (1 << 23) /* 0x00800000 */
  4240. #define CHERI256_PERM_SW9 (1 << 24) /* 0x01000000 */
  4241. #define CHERI256_PERM_SW10 (1 << 25) /* 0x02000000 */
  4242. #define CHERI256_PERM_SW11 (1 << 26) /* 0x04000000 */
  4243. #define CHERI256_PERM_SW12 (1 << 27) /* 0x08000000 */
  4244. #define CHERI256_PERM_SW13 (1 << 28) /* 0x10000000 */
  4245. #define CHERI256_PERM_SW14 (1 << 29) /* 0x20000000 */
  4246. #define CHERI256_PERM_SW15 (1 << 30) /* 0x40000000 */
  4247.  
  4248. #define CHERI128_PERM_SW0 (1 << 15) /* 0x00008000 */
  4249. #define CHERI128_PERM_SW1 (1 << 16) /* 0x00010000 */
  4250. #define CHERI128_PERM_SW2 (1 << 17) /* 0x00020000 */
  4251. #define CHERI128_PERM_SW3 (1 << 18) /* 0x00040000 */
  4252.  
  4253. #if (CHERICAP_SIZE == 32)
  4254. #define CHERI_PERM_SW0 CHERI256_PERM_SW0
  4255. #define CHERI_PERM_SW1 CHERI256_PERM_SW1
  4256. #define CHERI_PERM_SW2 CHERI256_PERM_SW2
  4257. #define CHERI_PERM_SW3 CHERI256_PERM_SW3
  4258. #define CHERI_PERM_SW4 CHERI256_PERM_SW4
  4259. #define CHERI_PERM_SW5 CHERI256_PERM_SW5
  4260. #define CHERI_PERM_SW6 CHERI256_PERM_SW6
  4261. #define CHERI_PERM_SW7 CHERI256_PERM_SW7
  4262. #define CHERI_PERM_SW8 CHERI256_PERM_SW8
  4263. #define CHERI_PERM_SW9 CHERI256_PERM_SW9
  4264. #define CHERI_PERM_SW10 CHERI256_PERM_SW10
  4265. #define CHERI_PERM_SW11 CHERI256_PERM_SW11
  4266. #define CHERI_PERM_SW12 CHERI256_PERM_SW12
  4267. #define CHERI_PERM_SW13 CHERI256_PERM_SW13
  4268. #define CHERI_PERM_SW14 CHERI256_PERM_SW14
  4269. #define CHERI_PERM_SW15 CHERI256_PERM_SW15
  4270. #else /* (!(CHERICAP_SIZE == 32)) */
  4271. # 115 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4272. #define CHERI_PERM_SW0 CHERI128_PERM_SW0
  4273. #define CHERI_PERM_SW1 CHERI128_PERM_SW1
  4274. #define CHERI_PERM_SW2 CHERI128_PERM_SW2
  4275. #define CHERI_PERM_SW3 CHERI128_PERM_SW3
  4276. #endif /* (!(CHERICAP_SIZE == 32)) */
  4277. # 120 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4278.  
  4279. /*
  4280. * The kernel snags one for the software-defined permissions for the purposes
  4281. * of authorising system calls from $pcc. This is a bit of an oddity:
  4282. * normally, we check permissions on data capabilities, not code capabilities,
  4283. * but aligns with 'privilege' checks: e.g., $epcc access. We may wish to
  4284. * switch to another model, such as having userspace register one or more
  4285. * class capabilities as suitable for system-call use.
  4286. */
  4287. #define CHERI_PERM_SYSCALL CHERI_PERM_SW0
  4288.  
  4289. /*
  4290. * Use another software-defined permission to restrict the ability to change
  4291. * the page mapping underlying a capability. This can't be the same
  4292. * permission bit as CHERI_PERM_SYSCALL because $pcc should not confer the
  4293. * right rewrite or remap executable memory.
  4294. */
  4295. #define CHERI_PERM_CHERIABI_VMMAP CHERI_PERM_SW1
  4296.  
  4297. /*
  4298. * Macros defining initial permission sets for various scenarios; details
  4299. * depend on the permissions available on 256-bit or 128-bit CHERI:
  4300. *
  4301. * CHERI_PERMS_SWALL: Mask of all available software-defined permissions
  4302. * CHERI_PERMS_HWALL: Mask of all available hardware-defined permissions
  4303. */
  4304. #if (CHERICAP_SIZE == 32)
  4305. #define CHERI_PERMS_SWALL \
  4306. (CHERI_PERM_SW0 | CHERI_PERM_SW1 | CHERI_PERM_SW2 | \
  4307. CHERI_PERM_SW3 | CHERI_PERM_SW4 | CHERI_PERM_SW5 | \
  4308. CHERI_PERM_SW6 | CHERI_PERM_SW7 | CHERI_PERM_SW8 | \
  4309. CHERI_PERM_SW9 | CHERI_PERM_SW10 | CHERI_PERM_SW11 | \
  4310. CHERI_PERM_SW12 | CHERI_PERM_SW13 | CHERI_PERM_SW14 | \
  4311. CHERI_PERM_SW15)
  4312. #else /* (!(CHERICAP_SIZE == 32)) */
  4313. # 155 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4314. #define CHERI_PERMS_SWALL \
  4315. (CHERI_PERM_SW0 | CHERI_PERM_SW1 | CHERI_PERM_SW2 | \
  4316. CHERI_PERM_SW3)
  4317. #endif /* (!(CHERICAP_SIZE == 32)) */
  4318. # 159 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4319.  
  4320. #define CHERI_PERMS_HWALL \
  4321. (CHERI_PERM_GLOBAL | CHERI_PERM_EXECUTE | \
  4322. CHERI_PERM_LOAD | CHERI_PERM_STORE | CHERI_PERM_LOAD_CAP | \
  4323. CHERI_PERM_STORE_CAP | CHERI_PERM_STORE_LOCAL_CAP | \
  4324. CHERI_PERM_SEAL | CHERI_PERM_CCALL | CHERI_PERM_RESERVED1 | \
  4325. CHERI_PERM_SYSTEM_REGS)
  4326.  
  4327. /*
  4328. * Root "object-type" capability for the kernel. This can be used neither as
  4329. * a data nor code capability.
  4330. */
  4331. #define CHERI_PERM_KERN_TYPE (CHERI_PERM_GLOBAL | CHERI_PERM_SEAL)
  4332.  
  4333. /*
  4334. * Basic userspace permission mask; CHERI_PERM_EXECUTE will be added for
  4335. * executable capabilities ($pcc); CHERI_PERM_STORE, CHERI_PERM_STORE_CAP,
  4336. * and CHERI_PERM_STORE_LOCAL_CAP will be added for data permissions ($c0).
  4337. *
  4338. * No variation required between 256-bit and 128-bit CHERI.
  4339. */
  4340. #define CHERI_PERMS_USERSPACE \
  4341. (CHERI_PERM_GLOBAL | CHERI_PERM_LOAD | CHERI_PERM_LOAD_CAP | \
  4342. CHERI_PERM_CCALL | (CHERI_PERMS_SWALL & ~CHERI_PERM_CHERIABI_VMMAP))
  4343.  
  4344. #define CHERI_PERMS_USERSPACE_CODE \
  4345. (CHERI_PERMS_USERSPACE | CHERI_PERM_EXECUTE)
  4346.  
  4347. #define CHERI_PERMS_USERSPACE_SEALCAP \
  4348. (CHERI_PERM_GLOBAL | CHERI_PERM_SEAL)
  4349.  
  4350. /*
  4351. * _DATA includes _VMMAP to support MAP_CHERI_DDC. This should be removed
  4352. * when all consumers are migrated. Current consumers:
  4353. * - TLS mini-allocator
  4354. */
  4355. #define CHERI_PERMS_USERSPACE_DATA \
  4356. (CHERI_PERMS_USERSPACE | \
  4357. CHERI_PERM_STORE | \
  4358. CHERI_PERM_STORE_CAP | \
  4359. CHERI_PERM_STORE_LOCAL_CAP | \
  4360. CHERI_PERM_CHERIABI_VMMAP)
  4361.  
  4362. /*
  4363. * Corresponding permission masks for kernel code and data; these are
  4364. * currently a bit broad, and should be narrowed over time as the kernel
  4365. * becomes more capability-aware.
  4366. */
  4367. #define CHERI_PERMS_KERNEL \
  4368. (CHERI_PERM_GLOBAL | CHERI_PERM_LOAD | CHERI_PERM_LOAD_CAP) \
  4369.  
  4370. #define CHERI_PERMS_KERNEL_CODE \
  4371. (CHERI_PERMS_KERNEL | CHERI_PERM_EXECUTE)
  4372.  
  4373. #define CHERI_PERMS_KERNEL_DATA \
  4374. (CHERI_PERMS_KERNEL | CHERI_PERM_STORE | CHERI_PERM_STORE_CAP | \
  4375. CHERI_PERM_STORE_LOCAL_CAP)
  4376.  
  4377. /*
  4378. * The CHERI object-type space is split between userspace and kernel,
  4379. * permitting kernel object references to be delegated to userspace (if
  4380. * desired). Currently, we provide 23 bits of namespace to each, with the top
  4381. * bit set for kernel object types, but it is easy to imagine other splits.
  4382. * User and kernel software should be written so as to not place assumptions
  4383. * about the specific values used here, as they may change.
  4384. */
  4385. #define CHERI_OTYPE_USER_MIN (0)
  4386. #define CHERI_OTYPE_USER_MAX ((1 << 23) - 1)
  4387. #define CHERI_OTYPE_KERN_MIN (1 << 23)
  4388. #define CHERI_OTYPE_KERN_MAX ((1 << 24) - 1)
  4389.  
  4390. #define CHERI_OTYPE_KERN_FLAG (1 << 23)
  4391. #define CHERI_OTYPE_ISKERN(x) (((x) & CHERI_OTYPE_KERN_FLAG) != 0)
  4392. #define CHERI_OTYPE_ISUSER(x) (!(CHERI_OTYPE_ISKERN(x)))
  4393.  
  4394. /*
  4395. * When performing a userspace-to-userspace CCall, capability flow-control
  4396. * checks normally prevent local capabilities from being delegated. This can
  4397. * be disabled on call (but not return) by using an object type with the 22nd
  4398. * bit set -- combined with a suitable selector on the CCall instruction to
  4399. * ensure that this behaviour is intended.
  4400. */
  4401. #define CHERI_OTYPE_LOCALOK_SHIFT (22)
  4402. #define CHERI_OTYPE_LOCALOK_FLAG (1 << CHERI_OTYPE_LOCALOK_SHIFT
  4403. #define CHERI_OTYPE_IS_LOCALOK(x) (((x) & CHERI_OTYPE_LOCALOK_FLAG) != 0)
  4404.  
  4405. /*
  4406. * Definition for a highly privileged kernel capability able to name the
  4407. * entire address space, and suitable to derive all other kernel-related
  4408. * capabilities from, including sealing capabilities.
  4409. */
  4410. #define CHERI_CAP_KERN_PERMS \
  4411. (CHERI_PERMS_SWALL | CHERI_PERMS_HWALL)
  4412. #define CHERI_CAP_KERN_BASE 0x0
  4413. #define CHERI_CAP_KERN_LENGTH 0xffffffffffffffff
  4414. #define CHERI_CAP_KERN_OFFSET 0x0
  4415.  
  4416. /*
  4417. * Definition for userspace "unprivileged" capability able to name the user
  4418. * portion of the address space.
  4419. */
  4420. #define CHERI_CAP_USER_CODE_PERMS CHERI_PERMS_USERSPACE_CODE
  4421. #define CHERI_CAP_USER_CODE_BASE VM_MINUSER_ADDRESS
  4422. #define CHERI_CAP_USER_CODE_LENGTH (VM_MAXUSER_ADDRESS - VM_MINUSER_ADDRESS)
  4423. #define CHERI_CAP_USER_CODE_OFFSET 0x0
  4424.  
  4425. #define CHERI_CAP_USER_DATA_PERMS CHERI_PERMS_USERSPACE_DATA
  4426. #define CHERI_CAP_USER_DATA_BASE VM_MINUSER_ADDRESS
  4427. #define CHERI_CAP_USER_DATA_LENGTH (VM_MAXUSER_ADDRESS - VM_MINUSER_ADDRESS)
  4428. #define CHERI_CAP_USER_DATA_OFFSET 0x0
  4429.  
  4430. #define CHERI_CAP_USER_MMAP_PERMS \
  4431. (CHERI_PERMS_USERSPACE_DATA | CHERI_PERMS_USERSPACE_CODE | \
  4432. CHERI_PERM_CHERIABI_VMMAP)
  4433. /* Start at 256MB to avoid low PC values in sandboxes */
  4434. #define CHERI_CAP_USER_MMAP_BASE (VM_MINUSER_ADDRESS + 0x10000000)
  4435. #define CHERI_CAP_USER_MMAP_LENGTH \
  4436. (VM_MAXUSER_ADDRESS + CHERI_CAP_USER_MMAP_BASE)
  4437. #define CHERI_CAP_USER_MMAP_OFFSET 0x0
  4438.  
  4439. /*
  4440. * Root sealing capability for all userspace object capabilities. This is
  4441. * made available to userspace via a sysarch(2).
  4442. */
  4443. #define CHERI_SEALCAP_USERSPACE_PERMS CHERI_PERMS_USERSPACE_SEALCAP
  4444. #define CHERI_SEALCAP_USERSPACE_BASE CHERI_OTYPE_USER_MIN
  4445. #define CHERI_SEALCAP_USERSPACE_LENGTH \
  4446. (CHERI_OTYPE_USER_MAX - CHERI_OTYPE_USER_MIN + 1)
  4447. #define CHERI_SEALCAP_USERSPACE_OFFSET 0x0
  4448.  
  4449. /*
  4450. * A blend of hardware and software allocation of capability registers.
  4451. * Ideally, this list wouldn't exist here, but be purely in the assembler.
  4452. */
  4453. #define CHERI_CR_C0 0 /* MIPS fetch/load/store capability. */
  4454. #define CHERI_CR_DDC CHERI_CR_C0
  4455. #define CHERI_CR_C1 1
  4456. #define CHERI_CR_C2 2
  4457. #define CHERI_CR_C3 3
  4458. #define CHERI_CR_C4 4
  4459. #define CHERI_CR_C5 5
  4460. #define CHERI_CR_C6 6
  4461. #define CHERI_CR_C7 7
  4462. #define CHERI_CR_C8 8
  4463. #define CHERI_CR_C9 9
  4464. #define CHERI_CR_C10 10
  4465. #define CHERI_CR_C11 11
  4466. #define CHERI_CR_STC CHERI_CR_C11
  4467. #define CHERI_CR_C12 12
  4468. #define CHERI_CR_C13 13
  4469. #define CHERI_CR_C14 14
  4470. #define CHERI_CR_C15 15
  4471. #define CHERI_CR_C16 16
  4472. #define CHERI_CR_C17 17
  4473. #define CHERI_CR_C18 18
  4474. #define CHERI_CR_C19 19
  4475. #define CHERI_CR_C20 20
  4476. #define CHERI_CR_C21 21
  4477. #define CHERI_CR_C22 22
  4478. #define CHERI_CR_C23 23
  4479. #define CHERI_CR_C24 24
  4480. #define CHERI_CR_C25 25
  4481. #define CHERI_CR_C26 26
  4482. #define CHERI_CR_IDC CHERI_CR_C26
  4483. #define CHERI_CR_C27 27
  4484. #define CHERI_CR_KR1C CHERI_CR_C27
  4485. #define CHERI_CR_C28 28
  4486. #define CHERI_CR_KR2C CHERI_CR_C28
  4487. #define CHERI_CR_C29 29
  4488. #define CHERI_CR_KCC CHERI_CR_C29
  4489. #define CHERI_CR_C30 30
  4490. #define CHERI_CR_KDC CHERI_CR_C30
  4491. #define CHERI_CR_C31 31
  4492. #define CHERI_CR_EPCC CHERI_CR_C31
  4493.  
  4494. #define CHERI_CR_CTEMP0 CHERI_CR_C13 /* C capability manipulation. */
  4495. #define CHERI_CR_CTEMP1 CHERI_CR_C14 /* C capability manipulation. */
  4496. #define CHERI_CR_SEC0 CHERI_CR_KR2C /* Saved $c0 in exception handler. */
  4497.  
  4498. /*
  4499. * Offsets of registers in struct cheri_kframe -- must match the definition in
  4500. * cheri.h.
  4501. */
  4502. #define CHERIKFRAME_OFF_C17 0
  4503. #define CHERIKFRAME_OFF_C18 1
  4504. #define CHERIKFRAME_OFF_C19 2
  4505. #define CHERIKFRAME_OFF_C20 3
  4506. #define CHERIKFRAME_OFF_C21 4
  4507. #define CHERIKFRAME_OFF_C22 5
  4508. #define CHERIKFRAME_OFF_C23 6
  4509. #define CHERIKFRAME_OFF_C24 7
  4510.  
  4511. /*
  4512. * List of CHERI capability cause code constants, which are used to
  4513. * characterise various CP2 exceptions.
  4514. */
  4515. #define CHERI_EXCCODE_NONE 0x00
  4516. #define CHERI_EXCCODE_LENGTH 0x01
  4517. #define CHERI_EXCCODE_TAG 0x02
  4518. #define CHERI_EXCCODE_SEAL 0x03
  4519. #define CHERI_EXCCODE_TYPE 0x04
  4520. #define CHERI_EXCCODE_CALL 0x05
  4521. #define CHERI_EXCCODE_RETURN 0x06
  4522. #define CHERI_EXCCODE_UNDERFLOW 0x07
  4523. #define CHERI_EXCCODE_USER_PERM 0x08
  4524. #define CHERI_EXCCODE_PERM_USER CHERI_EXCCODE_USER_PERM
  4525. #define CHERI_EXCCODE_TLBSTORE 0x09
  4526. #define CHERI_EXCCODE_IMPRECISE 0x0a
  4527. #define _CHERI_EXCCODE_RESERVED0b 0x0b
  4528. #define _CHERI_EXCCODE_RESERVED0c 0x0c
  4529. #define _CHERI_EXCCODE_RESERVED0d 0x0d
  4530. #define _CHERI_EXCCODE_RESERVED0e 0x0e
  4531. #define _CHERI_EXCCODE_RESERVED0f 0x0f
  4532. #define CHERI_EXCCODE_GLOBAL 0x10
  4533. #define CHERI_EXCCODE_PERM_EXECUTE 0x11
  4534. #define CHERI_EXCCODE_PERM_LOAD 0x12
  4535. #define CHERI_EXCCODE_PERM_STORE 0x13
  4536. #define CHERI_EXCCODE_PERM_LOADCAP 0x14
  4537. #define CHERI_EXCCODE_PERM_STORECAP 0x15
  4538. #define CHERI_EXCCODE_STORE_LOCALCAP 0x16
  4539. #define CHERI_EXCCODE_PERM_SEAL 0x17
  4540. #define CHERI_EXCCODE_SYSTEM_REGS 0x18
  4541. #define CHERI_EXCCODE_PERM_CCALL 0x19
  4542. #define CHERI_EXCCODE_CCALL_IDC 0x1a
  4543. #define _CHERI_EXCCODE_RESERVED1b 0x1b
  4544. #define _CHERI_EXCCODE_RESERVED1c 0x1c
  4545. #define _CHERI_EXCCODE_RESERVED1d 0x1d
  4546. #define _CHERI_EXCCODE_RESERVED1e 0x1e
  4547. #define _CHERI_EXCCODE_RESERVED1f 0x1f
  4548.  
  4549. /*
  4550. * User-defined CHERI exception codes are numbered 128...255.
  4551. */
  4552. #define CHERI_EXCCODE_SW_BASE 0x80
  4553. #define CHERI_EXCCODE_SW_LOCALARG 0x80 /* Non-global CCall argument. */
  4554. #define CHERI_EXCCODE_SW_LOCALRET 0x81 /* Non-global CReturn value. */
  4555. #define CHERI_EXCCODE_SW_CCALLREGS 0x82 /* Incorrect CCall registers. */
  4556. #define CHERI_EXCCODE_SW_OVERFLOW 0x83 /* Trusted stack overflow. */
  4557. #define CHERI_EXCCODE_SW_UNDERFLOW 0x84 /* Trusted stack underflow. */
  4558.  
  4559. /*
  4560. * How to turn the cause register into an exception code and register number.
  4561. */
  4562. #define CHERI_CAPCAUSE_EXCCODE_MASK 0xff00
  4563. #define CHERI_CAPCAUSE_EXCCODE_SHIFT 8
  4564. #define CHERI_CAPCAUSE_REGNUM_MASK 0xff
  4565.  
  4566. /*
  4567. * Location of the CHERI CCall/CReturn software-path exception vector.
  4568. */
  4569. #define CHERI_CCALL_EXC_VEC ((intptr_t)(int32_t)0x80000280)
  4570.  
  4571. #if CHERICAP_SIZE == 32
  4572. #define CHERI_ALIGN_SHIFT(l) 0ULL
  4573. #define CHERI_SEAL_ALIGN_SHIFT(l) 0ULL
  4574. #else /* (!(CHERICAP_SIZE == 32)) */
  4575. # 415 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4576.  
  4577. #define CHERI_BASELEN_BITS 20
  4578. #define CHERI_SEAL_BASELEN_BITS 5
  4579. #define CHERI_SLOP_BITS 2
  4580. #define CHERI_ADDR_BITS 64
  4581. #define CHERI_SEAL_MIN_ALIGN 12
  4582.  
  4583. /*
  4584. * Use __builtin_clzll() to implement flsll() on clang where emission of
  4585. * DCLZ instructions is correctly conditionalized.
  4586. */
  4587. #ifdef __clang__
  4588. #define _flsll(x) (64 - __builtin_clzll(x))
  4589. #else
  4590. # 429 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4591. #define _flsll(x) flsll(x)
  4592. #endif
  4593. # 431 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4594. #define CHERI_ALIGN_SHIFT(l) \
  4595. ((_flsll(l) <= (CHERI_BASELEN_BITS - CHERI_SLOP_BITS)) ? 0ULL : \
  4596. (_flsll(l) - (CHERI_BASELEN_BITS - CHERI_SLOP_BITS)))
  4597. #define _CHERI_SEAL_ALIGN_SHIFT(l) \
  4598. ((_flsll(l) <= (CHERI_SEAL_BASELEN_BITS)) ? 0ULL : \
  4599. (_flsll(l) - (CHERI_SEAL_BASELEN_BITS)))
  4600. #define CHERI_SEAL_ALIGN_SHIFT(l) \
  4601. (_CHERI_SEAL_ALIGN_SHIFT(l) < CHERI_SEAL_MIN_ALIGN ? \
  4602. CHERI_SEAL_MIN_ALIGN : _CHERI_SEAL_ALIGN_SHIFT(l))
  4603. #endif /* (!(CHERICAP_SIZE == 32)) */
  4604. # 441 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4605.  
  4606. #define CHERI_ALIGN_MASK(l) ~(~0ULL << CHERI_ALIGN_SHIFT(l))
  4607. #define CHERI_SEAL_ALIGN_MASK(l) ~(~0ULL << CHERI_SEAL_ALIGN_SHIFT(l))
  4608.  
  4609. #endif /* _MIPS_INCLUDE_CHERIREG_H_ */
  4610. # 446 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cherireg.h" 3 4
  4611. # 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 2 3 4
  4612.  
  4613. /*
  4614. * Canonical C-language representation of a capability for compilers that
  4615. * don't support capabilities directly. The in-memory layout is sensitive to
  4616. * the microarchitecture, and hence treated as opaque. Fields must be
  4617. * accessed via the ISA.
  4618. */
  4619. struct chericap {
  4620. uint8_t c_data[CHERICAP_SIZE];
  4621. } __packed __aligned(CHERICAP_SIZE);
  4622. #ifdef _KERNEL
  4623. CTASSERT(sizeof(struct chericap) == CHERICAP_SIZE);
  4624. #endif
  4625. # 56 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4626.  
  4627. /*
  4628. * Canonical C-language representation of a CHERI object capability -- code and
  4629. * data capabilities in registers or memory.
  4630. */
  4631. struct cheri_object {
  4632. #if !defined(_KERNEL) && __has_feature(capabilities)
  4633. __capability void *co_codecap;
  4634. __capability void *co_datacap;
  4635. #else
  4636. # 66 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4637. struct chericap co_codecap;
  4638. struct chericap co_datacap;
  4639. #endif
  4640. # 69 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4641. };
  4642.  
  4643. #if !defined(_KERNEL) && __has_feature(capabilities)
  4644. #define CHERI_OBJECT_INIT_NULL {NULL, NULL}
  4645. #define CHERI_OBJECT_ISNULL(co) \
  4646. ((co).co_codecap == NULL && (co).co_datacap == NULL)
  4647. #endif
  4648. # 76 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4649.  
  4650. /*
  4651. * Data structure describing CHERI's sigaltstack-like extensions to signal
  4652. * delivery. In the event that a thread takes a signal when $pcc doesn't hold
  4653. * CHERI_PERM_SYSCALL, we will need to install new $pcc, $ddc, $csp, and $idc
  4654. * state, and move execution to the per-thread alternative stack, whose
  4655. * pointer should (presumably) be relative to the $ddc/$csp defined here.
  4656. */
  4657. struct cheri_signal {
  4658. #if __has_feature(capabilities)
  4659. void * __capability csig_pcc;
  4660. void * __capability csig_ddc;
  4661. void * __capability csig_csp;
  4662. void * __capability csig_idc;
  4663. void * __capability csig_default_stack;
  4664. void * __capability csig_sigcode;
  4665. #else
  4666. # 93 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4667. struct chericap csig_pcc;
  4668. struct chericap csig_ddc;
  4669. struct chericap csig_csp;
  4670. struct chericap csig_idc;
  4671. struct chericap csig_default_stack;
  4672. struct chericap csig_sigcode;
  4673. #endif
  4674. # 100 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4675. };
  4676.  
  4677. /*
  4678. * APIs that act on C language representations of capabilities -- but not
  4679. * capabilities themselves.
  4680. */
  4681. #ifdef _KERNEL
  4682. void cheri_capability_set(void * __capability *capp, uint32_t uperms,
  4683. vaddr_t basep, size_t length, off_t off);
  4684.  
  4685. /*
  4686. * CHERI capability utility functions.
  4687. */
  4688. void cheri_bcopy(void *src, void *dst, size_t len);
  4689. void *cheri_memcpy(void *dst, void *src, size_t len);
  4690.  
  4691. /*
  4692. * CHERI context management functions.
  4693. */
  4694. struct cheri_frame;
  4695. struct thread;
  4696. struct trapframe;
  4697. const char *cheri_exccode_string(uint8_t exccode);
  4698. void cheri_exec_setregs(struct thread *td, u_long entry_addr);
  4699. void cheri_log_cheri_frame(struct trapframe *frame);
  4700. void cheri_log_exception(struct trapframe *frame, int trap_type);
  4701. void cheri_log_exception_registers(struct trapframe *frame);
  4702. void cheri_newthread_setregs(struct thread *td, u_long entry_addr);
  4703. int cheri_syscall_authorize(struct thread *td, u_int code,
  4704. int nargs, syscallarg_t *args);
  4705. int cheri_signal_sandboxed(struct thread *td);
  4706. void cheri_sendsig(struct thread *td);
  4707. void cheri_trapframe_from_cheriframe(struct trapframe *frame,
  4708. struct cheri_frame *cfp);
  4709. void cheri_trapframe_to_cheriframe(struct trapframe *frame,
  4710. struct cheri_frame *cfp);
  4711.  
  4712. /*
  4713. * Functions to set up and manipulate CHERI contexts and stacks.
  4714. */
  4715. struct pcb;
  4716. struct sysarch_args;
  4717. void cheri_sealcap_copy(struct proc *dst, struct proc *src);
  4718. void cheri_signal_copy(struct pcb *dst, struct pcb *src);
  4719. void cheri_stack_copy(struct pcb *dst, struct pcb *src);
  4720. void cheri_stack_init(struct pcb *pcb);
  4721. int cheri_stack_unwind(struct thread *td, struct trapframe *tf,
  4722. int signum);
  4723. int cheri_sysarch_getsealcap(struct thread *td, struct sysarch_args *uap);
  4724. int cheri_sysarch_getstack(struct thread *td, struct sysarch_args *uap);
  4725. int cheri_sysarch_setstack(struct thread *td, struct sysarch_args *uap);
  4726.  
  4727. /*
  4728. * Global sysctl definitions.
  4729. */
  4730. SYSCTL_DECL(_security_cheri);
  4731. SYSCTL_DECL(_security_cheri_stats);
  4732. extern u_int security_cheri_debugger_on_sandbox_signal;
  4733. extern u_int security_cheri_debugger_on_sandbox_syscall;
  4734. extern u_int security_cheri_debugger_on_sandbox_unwind;
  4735. extern u_int security_cheri_debugger_on_sigprot;
  4736. extern u_int security_cheri_sandboxed_signals;
  4737. extern u_int security_cheri_syscall_violations;
  4738.  
  4739. /*
  4740. * Functions exposed to machine-independent code that must interact with
  4741. * CHERI-specific features; e.g., ktrace.
  4742. */
  4743. struct ktr_ccall;
  4744. struct ktr_creturn;
  4745. struct ktr_cexception;
  4746. struct thr_param_c;
  4747. void cheriabi_thr_new_md(struct thread *parent_td,
  4748. struct thr_param_c *param);
  4749. void ktrccall_mdfill(struct pcb *pcb, struct ktr_ccall *kc);
  4750. void ktrcreturn_mdfill(struct pcb *pcb, struct ktr_creturn *kr);
  4751. void ktrcexception_mdfill(struct trapframe *frame,
  4752. struct ktr_cexception *ke);
  4753. #endif /* !_KERNEL */
  4754. # 179 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4755.  
  4756. /*
  4757. * Nested include of machine-dependent definitions, which likely depend on
  4758. * first having defined chericap.h.
  4759. */
  4760. #if 0 /* expanded by -frewrite-includes */
  4761. #include <machine/cheri.h>
  4762. #endif /* expanded by -frewrite-includes */
  4763. # 184 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  4764. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 1 3 4
  4765. /*-
  4766. * Copyright (c) 2011-2017 Robert N. M. Watson
  4767. * Copyright (c) 2015 SRI International
  4768. * All rights reserved.
  4769. *
  4770. * This software was developed by SRI International and the University of
  4771. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  4772. * ("CTSRD"), as part of the DARPA CRASH research programme.
  4773. *
  4774. * Redistribution and use in source and binary forms, with or without
  4775. * modification, are permitted provided that the following conditions
  4776. * are met:
  4777. * 1. Redistributions of source code must retain the above copyright
  4778. * notice, this list of conditions and the following disclaimer.
  4779. * 2. Redistributions in binary form must reproduce the above copyright
  4780. * notice, this list of conditions and the following disclaimer in the
  4781. * documentation and/or other materials provided with the distribution.
  4782. *
  4783. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  4784. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4785. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  4786. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  4787. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  4788. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  4789. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  4790. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  4791. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  4792. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4793. * SUCH DAMAGE.
  4794. */
  4795.  
  4796. #ifndef _MIPS_INCLUDE_CHERI_H_
  4797. #define _MIPS_INCLUDE_CHERI_H_
  4798.  
  4799. #ifdef _KERNEL
  4800. #if 0 /* expanded by -frewrite-includes */
  4801. #include <sys/sysctl.h> /* SYSCTL_DECL() */
  4802. #endif /* expanded by -frewrite-includes */
  4803. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4804. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4805. #if 0 /* expanded by -frewrite-includes */
  4806. #include <sys/systm.h> /* CTASSERT() */
  4807. #endif /* expanded by -frewrite-includes */
  4808. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4809. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4810. #endif
  4811. # 39 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4812.  
  4813. #if 0 /* expanded by -frewrite-includes */
  4814. #include <machine/cherireg.h>
  4815. #endif /* expanded by -frewrite-includes */
  4816. # 40 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4817. # 41 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4818.  
  4819. #if 0 /* expanded by -frewrite-includes */
  4820. #include <sys/types.h>
  4821. #endif /* expanded by -frewrite-includes */
  4822. # 42 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4823. # 43 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4824.  
  4825. /*
  4826. * In the past, struct cheri_frame was the in-kernel and kernel<->user
  4827. * structure holding CHERI register state for context switching. It is now a
  4828. * public structure for kernel<->user interaction (e.g., signals), and struct
  4829. * trapframe is used within the kernel. Regardless, correct preservation of
  4830. * state in this structure is critical to both correctness and security.
  4831. */
  4832. struct cheri_frame {
  4833. /* DDC has special properties for MIPS load/store instructions. */
  4834. #if __has_feature(capabilities)
  4835. void * __capability cf_ddc;
  4836. #else
  4837. # 56 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4838. struct chericap cf_ddc;
  4839. #endif
  4840. # 58 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4841.  
  4842. /*
  4843. * General-purpose capabilities -- note, numbering is from v1.17 of
  4844. * the CHERI ISA spec (ISAv5 draft).
  4845. */
  4846. #if __has_feature(capabilities)
  4847. void * __capability cf_c1;
  4848. void * __capability cf_c2;
  4849. void * __capability cf_c3;
  4850. void * __capability cf_c4;
  4851. void * __capability cf_c5;
  4852. void * __capability cf_c6;
  4853. void * __capability cf_c7;
  4854. void * __capability cf_c8;
  4855. void * __capability cf_c9;
  4856. void * __capability cf_c10;
  4857. void * __capability cf_csp;
  4858. void * __capability cf_c12;
  4859. void * __capability cf_c13;
  4860. void * __capability cf_c14;
  4861. void * __capability cf_c15;
  4862. void * __capability cf_c16;
  4863. void * __capability cf_c17;
  4864. void * __capability cf_c18;
  4865. void * __capability cf_c19;
  4866. void * __capability cf_c20;
  4867. void * __capability cf_c21;
  4868. void * __capability cf_c22;
  4869. void * __capability cf_c23;
  4870. void * __capability cf_c24;
  4871. void * __capability cf_c25;
  4872. void * __capability cf_idc;
  4873. #else
  4874. # 91 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4875. struct chericap cf_c1, cf_c2, cf_c3, cf_c4;
  4876. struct chericap cf_c5, cf_c6, cf_c7;
  4877. struct chericap cf_c8, cf_c9, cf_c10, cf_csp, cf_c12;
  4878. struct chericap cf_c13, cf_c14, cf_c15, cf_c16, cf_c17;
  4879. struct chericap cf_c18, cf_c19, cf_c20, cf_c21, cf_c22;
  4880. struct chericap cf_c23, cf_c24, cf_c25, cf_idc;
  4881. #endif
  4882. # 98 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4883.  
  4884. /*
  4885. * Program counter capability -- extracted from exception frame EPCC.
  4886. */
  4887. #if __has_feature(capabilities)
  4888. void * __capability cf_pcc;
  4889. #else
  4890. # 105 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4891. struct chericap cf_pcc;
  4892. #endif
  4893. # 107 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4894.  
  4895. /*
  4896. * Padded out non-capability registers.
  4897. *
  4898. * XXXRW: The comment below on only updating for CP2 exceptions is
  4899. * incorrect, but should be made correct.
  4900. */
  4901. register_t cf_capcause; /* Updated only on CP2 exceptions. */
  4902. register_t cf_capvalid;
  4903. #if (defined(CPU_CHERI) && !defined(CPU_CHERI128)) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 256))
  4904. register_t _cf_pad1[2];
  4905. #endif
  4906. # 119 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4907. };
  4908.  
  4909. #ifdef _KERNEL
  4910. #if __has_feature(capabilities)
  4911. CTASSERT(sizeof(void * __capability) == CHERICAP_SIZE);
  4912. CTASSERT(offsetof(struct cheri_frame, cf_c1) == sizeof(void * __capability));
  4913. #endif
  4914. # 126 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4915. /* 28 capability registers + capcause + padding. */
  4916. CTASSERT(sizeof(struct cheri_frame) == (29 * CHERICAP_SIZE));
  4917. #endif
  4918. # 129 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4919.  
  4920. #ifdef _KERNEL
  4921. /*
  4922. * Data structure defining kernel per-thread caller-save state used in
  4923. * voluntary context switches. This is morally equivalent to pcb_context[].
  4924. */
  4925. struct cheri_kframe {
  4926. void * __capability ckf_c17;
  4927. void * __capability ckf_c18;
  4928. void * __capability ckf_c19;
  4929. void * __capability ckf_c20;
  4930. void * __capability ckf_c21;
  4931. void * __capability ckf_c22;
  4932. void * __capability ckf_c23;
  4933. void * __capability ckf_c24;
  4934. };
  4935. #endif
  4936. # 146 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  4937.  
  4938. /*
  4939. * CHERI capability register manipulation macros.
  4940. */
  4941. #define CHERI_CGETBASE(v, cb) do { \
  4942. __asm__ __volatile__ ( \
  4943. ".set push\n" \
  4944. ".set noreorder\n" \
  4945. "cgetbase %0, $c%1\n" \
  4946. ".set pop\n" \
  4947. : "=r" (v) : "i" (cb)); \
  4948. } while (0)
  4949.  
  4950. #define CHERI_CGETLEN(v, cb) do { \
  4951. __asm__ __volatile__ ( \
  4952. ".set push\n" \
  4953. ".set noreorder\n" \
  4954. "cgetlen %0, $c%1\n" \
  4955. ".set pop\n" \
  4956. : "=r" (v) :"i" (cb)); \
  4957. } while (0)
  4958.  
  4959. #define CHERI_CGETOFFSET(v, cb) do { \
  4960. __asm__ __volatile__ ( \
  4961. ".set push\n" \
  4962. ".set noreorder\n" \
  4963. "cgetoffset %0, $c%1\n" \
  4964. ".set pop\n" \
  4965. : "=r" (v) : "i" (cb)); \
  4966. } while (0)
  4967.  
  4968. #define CHERI_CGETTAG(v, cb) do { \
  4969. __asm__ __volatile__ ( \
  4970. ".set push\n" \
  4971. ".set noreorder\n" \
  4972. "cgettag %0, $c%1\n" \
  4973. ".set pop\n" \
  4974. : "=r" (v) : "i" (cb)); \
  4975. } while (0)
  4976.  
  4977. #define CHERI_CGETSEALED(v, cb) do { \
  4978. __asm__ __volatile__ ( \
  4979. ".set push\n" \
  4980. ".set noreorder\n" \
  4981. "cgetsealed %0, $c%1\n" \
  4982. ".set pop\n" \
  4983. : "=r" (v) : "i" (cb)); \
  4984. } while (0)
  4985.  
  4986. #define CHERI_CGETPERM(v, cb) do { \
  4987. __asm__ __volatile__ ( \
  4988. ".set push\n" \
  4989. ".set noreorder\n" \
  4990. "cgetperm %0, $c%1\n" \
  4991. ".set pop\n" \
  4992. : "=r" (v) : "i" (cb)); \
  4993. } while (0)
  4994.  
  4995. #define CHERI_CGETTYPE(v, cb) do { \
  4996. __asm__ __volatile__ ( \
  4997. ".set push\n" \
  4998. ".set noreorder\n" \
  4999. "cgettype %0, $c%1\n" \
  5000. ".set pop\n" \
  5001. : "=r" (v) : "i" (cb)); \
  5002. } while (0)
  5003.  
  5004. #define CHERI_CGETCAUSE(v) do { \
  5005. __asm__ __volatile__ ( \
  5006. ".set push\n" \
  5007. ".set noreorder\n" \
  5008. "cgetcause %0\n" \
  5009. ".set pop\n" \
  5010. : "=r" (v)); \
  5011. } while (0)
  5012.  
  5013. #define CHERI_CTOPTR(v, cb, ct) do { \
  5014. __asm__ __volatile__ ( \
  5015. ".set push\n" \
  5016. ".set noreorder\n" \
  5017. "ctoptr %0, $c%1, $c%2\n" \
  5018. ".set pop\n" \
  5019. : "=r" (v) : "i" (cb), "i" (ct)); \
  5020. } while (0)
  5021.  
  5022. /*
  5023. * Note that despite effectively being a CMove, CGetDefault doesn't require a
  5024. * memory clobber: if it's writing to $ddc, it's a nop; otherwise, it's not
  5025. * writing to $ddc so no clobber is needed.
  5026. */
  5027. #define CHERI_CGETDEFAULT(cd) do { \
  5028. __asm__ __volatile__ ( \
  5029. ".set push\n" \
  5030. ".set noreorder\n" \
  5031. "cgetdefault $c%0\n" \
  5032. ".set pop\n" \
  5033. : : "i" (cd)); \
  5034. } while (0)
  5035.  
  5036. /*
  5037. * Instructions that check capability values and could throw exceptions; no
  5038. * capability-register value changes, so no clobbers required.
  5039. */
  5040. #define CHERI_CCHECKPERM(cs, v) do { \
  5041. __asm__ __volatile__ ( \
  5042. ".set push\n" \
  5043. ".set noreorder\n" \
  5044. "ccheckperm $c%0, %1\n" \
  5045. ".set pop\n" \
  5046. : : "i" (cd), "r" (v)); \
  5047. } while (0)
  5048.  
  5049. #define CHERI_CCHECKTYPE(cs, cb) do { \
  5050. __asm__ __volatile__ ( \
  5051. ".set push\n" \
  5052. ".set noreorder\n" \
  5053. "cchecktype $c%0, $c%1\n" \
  5054. ".set pop\n" \
  5055. : : "i" (cs), "i" (cb)); \
  5056. } while (0)
  5057.  
  5058. /*
  5059. * Instructions relating to capability invocation, return, sealing, and
  5060. * unsealing. Memory clobbers are required for register manipulation when
  5061. * targeting $ddc. They are also required for both CCall and CReturn to
  5062. * ensure that any memory write-back is done before invocation.
  5063. *
  5064. * XXXRW: Is the latter class of cases required?
  5065. */
  5066. #define CHERI_CSEAL(cd, cs, ct) do { \
  5067. if ((cd) == 0) \
  5068. __asm__ __volatile__ ( \
  5069. ".set push\n" \
  5070. ".set noreorder\n" \
  5071. "cseal $c%0, $c%1, $c%2\n" \
  5072. ".set pop\n" \
  5073. : : "i" (cd), "i" (cs), "i" (ct) : "memory"); \
  5074. else \
  5075. __asm__ __volatile__ ( \
  5076. ".set push\n" \
  5077. ".set noreorder\n" \
  5078. "cseal $c%0, $c%1, $c%2\n" \
  5079. ".set pop\n" \
  5080. : : "i" (cd), "i" (cs), "i" (ct)); \
  5081. } while (0)
  5082.  
  5083. #define CHERI_CUNSEAL(cd, cb, ct) do { \
  5084. if ((cd) == 0) \
  5085. __asm__ __volatile__ ( \
  5086. ".set push\n" \
  5087. ".set noreorder\n" \
  5088. "cunseal $c%0, $c%1, $c%2\n" \
  5089. ".set pop\n" \
  5090. : : "i" (cd), "i" (cb), "i" (ct) : "memory"); \
  5091. else \
  5092. __asm__ __volatile__ ( \
  5093. ".set push\n" \
  5094. ".set noreorder\n" \
  5095. "cunseal $c%0, $c%1, $c%2\n" \
  5096. ".set pop\n" \
  5097. : : "i" (cd), "i" (cb), "i" (ct)); \
  5098. } while (0)
  5099.  
  5100. #define CHERI_CCALL(cs, cb) do { \
  5101. __asm__ __volatile__ ( \
  5102. ".set push\n" \
  5103. ".set noreorder\n" \
  5104. "ccall $c%0, $c%1\n" \
  5105. ".set pop\n" \
  5106. : : "i" (cs), "i" (cb) : "memory"); \
  5107. } while (0)
  5108.  
  5109. #define CHERI_CRETURN() do { \
  5110. __asm__ __volatile__ ( \
  5111. ".set push\n" \
  5112. ".set noreorder\n" \
  5113. "creturn\n" \
  5114. ".set pop\n" \
  5115. : : : "memory"); \
  5116. } while (0)
  5117.  
  5118. /*
  5119. * Capability store; while this doesn't muck with $ddc, it does require a
  5120. * memory clobber.
  5121. */
  5122. #define CHERI_CSC(cs, cb, regbase, offset) do { \
  5123. __asm__ __volatile__ ( \
  5124. ".set push\n" \
  5125. ".set noreorder\n" \
  5126. "csc $c%0, %1, %2($c%3)\n" \
  5127. ".set pop\n" \
  5128. : : "i" (cs), "r" (regbase), "i" (offset), "i" (cb) : \
  5129. "memory"); \
  5130. } while (0)
  5131.  
  5132. /*
  5133. * Data stores; while these don't muck with $ddc, they do require memory
  5134. * clobbers.
  5135. */
  5136. #define CHERI_CSB(rs, rt, offset, cb) do { \
  5137. __asm__ __volatile__ ( \
  5138. ".set push\n" \
  5139. ".set noreorder\n" \
  5140. "csb %0, %1, %2($c%3)\n" \
  5141. ".set pop\n" \
  5142. : : "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5143. } while (0)
  5144.  
  5145. #define CHERI_CSH(rs, rt, offset, cb) do { \
  5146. __asm__ __volatile__ ( \
  5147. ".set push\n" \
  5148. ".set noreorder\n" \
  5149. "csh %0, %1, %2($c%3)\n" \
  5150. ".set pop\n" \
  5151. : : "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5152. } while (0)
  5153.  
  5154. #define CHERI_CSW(rs, rt, offset, cb) do { \
  5155. __asm__ __volatile__ ( \
  5156. ".set push\n" \
  5157. ".set noreorder\n" \
  5158. "csw %0, %1, %2($c%3)\n" \
  5159. ".set pop\n" \
  5160. : : "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5161. } while (0)
  5162.  
  5163. #define CHERI_CSD(rs, rt, offset, cb) do { \
  5164. __asm__ __volatile__ ( \
  5165. ".set push\n" \
  5166. ".set noreorder\n" \
  5167. "csd %0, %1, %2($c%3)\n" \
  5168. ".set pop\n" \
  5169. : : "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5170. } while (0)
  5171.  
  5172. /*
  5173. * Data loads: while these don't much with $ddc, they do require memory
  5174. * clobbers.
  5175. */
  5176. #define CHERI_CLB(rd, rt, offset, cb) do { \
  5177. __asm__ __volatile__ ( \
  5178. ".set push\n" \
  5179. ".set noreorder\n" \
  5180. "clb %0, %1, %2($c%3)\n" \
  5181. ".set pop\n" \
  5182. : "=r" (rd) : "r" (rt), "i" (offset),"i" (cb) : "memory"); \
  5183. } while (0)
  5184.  
  5185. #define CHERI_CLH(rd, rt, offset, cb) do { \
  5186. __asm__ __volatile__ ( \
  5187. ".set push\n" \
  5188. ".set noreorder\n" \
  5189. "clh %0, %1, %2($c%3)\n" \
  5190. ".set pop\n" \
  5191. : "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5192. } while (0)
  5193.  
  5194. #define CHERI_CLW(rd, rt, offset, cb) do { \
  5195. __asm__ __volatile__ ( \
  5196. ".set push\n" \
  5197. ".set noreorder\n" \
  5198. "clw %0, %1, %2($c%3)\n" \
  5199. ".set pop\n" \
  5200. : "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5201. } while (0)
  5202.  
  5203. #define CHERI_CLD(rd, rt, offset, cb) do { \
  5204. __asm__ __volatile__ ( \
  5205. ".set push\n" \
  5206. ".set noreorder\n" \
  5207. "cld %0, %1, %2($c%3)\n" \
  5208. ".set pop\n" \
  5209. : "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5210. } while (0)
  5211.  
  5212. #define CHERI_CLBU(rd, rt, offset, cb) do { \
  5213. __asm__ __volatile__ ( \
  5214. ".set push\n" \
  5215. ".set noreorder\n" \
  5216. "clbu %0, %1, %2($c%3)\n" \
  5217. ".set pop\n" \
  5218. : "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5219. } while (0)
  5220.  
  5221. #define CHERI_CLHU(rd, rt, offset, cb) do { \
  5222. __asm__ __volatile__ ( \
  5223. ".set push\n" \
  5224. ".set noreorder\n" \
  5225. "clhu %0, %1, %2($c%3)\n" \
  5226. ".set pop\n" \
  5227. : "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5228. } while (0)
  5229.  
  5230. #define CHERI_CLWU(rd, rt, offset, cb) do { \
  5231. __asm__ __volatile__ ( \
  5232. ".set push\n" \
  5233. ".set noreorder\n" \
  5234. "clwu %0, %1, %2($c%3)\n" \
  5235. ".set pop\n" \
  5236. : "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \
  5237. } while (0)
  5238.  
  5239. /*
  5240. * Routines that modify or replace values in capability registers, and that if
  5241. * if used on $ddc, require the compiler to write registers back to memory,
  5242. * and reload afterwards, since we may effectively be changing the compiler-
  5243. * visible address space. This is also necessary for permissions changes as
  5244. * well, to ensure that write-back occurs before a possible loss of store
  5245. * permission.
  5246. */
  5247. #define CHERI_CGETPCC(v, cd) do { \
  5248. if ((cd) == 0) \
  5249. __asm__ __volatile__ ( \
  5250. ".set push\n" \
  5251. ".set noreorder\n" \
  5252. "cgetpcc %0, $c%1\n" \
  5253. ".set pop\n" \
  5254. : "=r" (v) : "i" (cd) : "memory"); \
  5255. else \
  5256. __asm__ __volatile__ ( \
  5257. ".set push\n" \
  5258. ".set noreorder\n" \
  5259. "cgetpcc %0, $c%1\n" \
  5260. ".set pop\n" \
  5261. : "=r" (v) : "i" (cd)); \
  5262. } while (0)
  5263.  
  5264. #define CHERI_CINCBASE(cd, cb, v) do { \
  5265. if ((cd) == 0) \
  5266. __asm__ __volatile__ ( \
  5267. ".set push\n" \
  5268. ".set noreorder\n" \
  5269. "cincbase $c%0, $c%1, %2\n" \
  5270. ".set pop\n" \
  5271. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5272. else \
  5273. __asm__ __volatile__ ( \
  5274. ".set push\n" \
  5275. ".set noreorder\n" \
  5276. "cincbase $c%0, $c%1, %2\n" \
  5277. ".set pop\n" \
  5278. : : "i" (cd), "i" (cb), "r" (v)); \
  5279. } while (0)
  5280.  
  5281. #define CHERI_CINCOFFSET(cd, cb, v) do { \
  5282. if ((cd) == 0) \
  5283. __asm__ __volatile__ ( \
  5284. ".set push\n" \
  5285. ".set noreorder\n" \
  5286. "cincoffset $c%0, $c%1, %2\n" \
  5287. ".set pop\n" \
  5288. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5289. else \
  5290. __asm__ __volatile__ ( \
  5291. ".set push\n" \
  5292. ".set noreorder\n" \
  5293. "cincoffset $c%0, $c%1, %2\n" \
  5294. ".set pop\n" \
  5295. : : "i" (cd), "i" (cb), "r" (v)); \
  5296. } while (0)
  5297.  
  5298. #if (defined(CPU_CHERI) && !defined(CPU_CHERI128)) || (defined(_MIPS_SZCAP) && (_MIPS_SZCAP == 256))
  5299. #define CHERI_CMOVE(cd, cb) do { \
  5300. if ((cd) == 0) \
  5301. __asm__ __volatile__ ( \
  5302. ".set push\n" \
  5303. ".set noreorder\n" \
  5304. "cmove $c%0, $c%1\n" \
  5305. ".set pop\n" \
  5306. : : "i" (cd), "i" (cb) : "memory"); \
  5307. else \
  5308. __asm__ __volatile__ ( \
  5309. ".set push\n" \
  5310. ".set noreorder\n" \
  5311. "cmove $c%0, $c%1\n" \
  5312. ".set pop\n" \
  5313. : : "i" (cd), "i" (cb)); \
  5314. } while (0)
  5315. #else /* 128-bit CHERI */
  5316. # 525 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5317. #define CHERI_CMOVE(cd, cb) CHERI_CINCOFFSET(cd, cb, 0)
  5318. #endif /* 128-bit CHERI */
  5319. # 527 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5320.  
  5321. #define CHERI_CSETDEFAULT(cb) do { \
  5322. __asm__ __volatile__ ( \
  5323. ".set push\n" \
  5324. ".set noreorder\n" \
  5325. "csetdefault %c%0\n" \
  5326. ".set pop\n" \
  5327. : : "i" (cb) : "memory"); \
  5328. } while (0)
  5329.  
  5330. #define CHERI_CSETLEN(cd, cb, v) do { \
  5331. if ((cd) == 0) \
  5332. __asm__ __volatile__ ( \
  5333. ".set push\n" \
  5334. ".set noreorder\n" \
  5335. "csetlen $c%0, $c%1, %2\n" \
  5336. ".set pop\n" \
  5337. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5338. else \
  5339. __asm__ __volatile__ ( \
  5340. ".set push\n" \
  5341. ".set noreorder\n" \
  5342. "csetlen $c%0, $c%1, %2\n" \
  5343. ".set pop\n" \
  5344. : : "i" (cd), "i" (cb), "r" (v)); \
  5345. } while (0)
  5346.  
  5347. #define CHERI_CSETOFFSET(cd, cb, v) do { \
  5348. if ((cd) == 0) \
  5349. __asm__ __volatile__ ( \
  5350. ".set push\n" \
  5351. ".set noreorder\n" \
  5352. "csetoffset $c%0, $c%1, %2\n" \
  5353. ".set pop\n" \
  5354. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5355. else \
  5356. __asm__ __volatile__ ( \
  5357. ".set push\n" \
  5358. ".set noreorder\n" \
  5359. "csetoffset $c%0, $c%1, %2\n" \
  5360. ".set pop\n" \
  5361. : : "i" (cd), "i" (cb), "r" (v)); \
  5362. } while (0)
  5363.  
  5364. #define CHERI_CCLEARTAG(cd, cb) do { \
  5365. if ((cd) == 0) \
  5366. __asm__ __volatile__ ( \
  5367. ".set push\n" \
  5368. ".set noreorder\n" \
  5369. "ccleartag $c%0, $c%1\n" \
  5370. ".set pop\n" \
  5371. : : "i" (cd), "i" (cb) : "memory"); \
  5372. else \
  5373. __asm__ __volatile__ ( \
  5374. ".set push\n" \
  5375. ".set noreorder\n" \
  5376. "ccleartag $c%0, $c%1\n" \
  5377. ".set pop\n" \
  5378. : : "i" (cd), "i" (cb)); \
  5379. } while (0)
  5380.  
  5381. #define CHERI_CANDPERM(cd, cb, v) do { \
  5382. if ((cd) == 0) \
  5383. __asm__ __volatile__ ( \
  5384. ".set push\n" \
  5385. ".set noreorder\n" \
  5386. "candperm $c%0, $c%1, %2\n" \
  5387. ".set pop\n" \
  5388. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5389. else \
  5390. __asm__ __volatile__ ( \
  5391. ".set push\n" \
  5392. ".set noreorder\n" \
  5393. "candperm $c%0, $c%1, %2\n" \
  5394. ".set pop\n" \
  5395. : : "i" (cd), "i" (cb), "r" (v)); \
  5396. } while (0)
  5397.  
  5398. #define CHERI_CSETBOUNDS(cd, cb, v) do { \
  5399. if ((cd) == 0) \
  5400. __asm__ __volatile__ ( \
  5401. ".set push\n" \
  5402. ".set noreorder\n" \
  5403. "csetbounds $c%0, $c%1, %2\n" \
  5404. ".set pop\n" \
  5405. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5406. else \
  5407. __asm__ __volatile__ ( \
  5408. ".set push\n" \
  5409. ".set noreorder\n" \
  5410. "csetbounds $c%0, $c%1, %2\n" \
  5411. ".set pop\n" \
  5412. : : "i" (cd), "i" (cb), "r" (v)); \
  5413. } while (0)
  5414.  
  5415. #define CHERI_CFROMPTR(cd, cb, v) do { \
  5416. if ((cd) == 0) \
  5417. __asm__ __volatile__ ( \
  5418. ".set push\n" \
  5419. ".set noreorder\n" \
  5420. "cfromptr $c%0, $c%1, %2\n" \
  5421. ".set pop\n" \
  5422. : : "i" (cd), "i" (cb), "r" (v) : "memory"); \
  5423. else \
  5424. __asm__ __volatile__ ( \
  5425. ".set push\n" \
  5426. ".set noreorder\n" \
  5427. "cfromptr $c%0, $c%1, %2\n" \
  5428. ".set pop\n" \
  5429. : : "i" (cd), "i" (cb), "r" (v)); \
  5430. } while (0)
  5431.  
  5432. #define CHERI_CLC(cd, cb, regbase, offset) do { \
  5433. if ((cd) == 0) \
  5434. __asm__ __volatile__ ( \
  5435. ".set push\n" \
  5436. ".set noreorder\n" \
  5437. "clc $c%0, %1, %2($c%3)\n" \
  5438. ".set pop\n" \
  5439. : : "i" (cd), "r" (regbase), "i" (offset), "i" (cb) \
  5440. : "memory"); \
  5441. else \
  5442. __asm__ __volatile__ ( \
  5443. ".set push\n" \
  5444. ".set noreorder\n" \
  5445. "clc $c%0, %1, %2($c%3)\n" \
  5446. ".set pop\n" \
  5447. : : "i" (cd), "r" (regbase), "i" (offset), \
  5448. "i" (cb)); \
  5449. } while (0)
  5450.  
  5451. /*
  5452. * Utility functions for the kernel -- as they depend on $kdc.
  5453. */
  5454. #ifdef _KERNEL
  5455. static inline void
  5456. cheri_capability_load(u_int crn_to, struct chericap *cp)
  5457. {
  5458.  
  5459. CHERI_CLC(crn_to, CHERI_CR_KDC, cp, 0);
  5460. }
  5461.  
  5462. static inline void
  5463. cheri_capability_setoffset(struct chericap *cp, register_t offset)
  5464. {
  5465.  
  5466. CHERI_CLC(CHERI_CR_CTEMP0, CHERI_CR_KDC, cp, 0);
  5467. CHERI_CSETOFFSET(CHERI_CR_CTEMP0, CHERI_CR_CTEMP0, offset);
  5468. CHERI_CSC(CHERI_CR_CTEMP0, CHERI_CR_KDC, (register_t)cp, 0);
  5469. }
  5470. #endif
  5471. # 678 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5472.  
  5473. /*
  5474. * CHERI-MIPS-specific kernel utility functions.
  5475. */
  5476. #ifdef _KERNEL
  5477. struct sysentvec;
  5478. void cheri_capability_set_user_sealcap(void *__capability *);
  5479. void cheri_capability_set_user_sigcode(void *__capability *,
  5480. struct sysentvec *);
  5481. int cheri_capcause_to_sicode(register_t capcause);
  5482.  
  5483. void hybridabi_exec_setregs(struct thread *td, unsigned long entry_addr);
  5484. void hybridabi_newthread_setregs(struct thread *td,
  5485. unsigned long entry_addr);
  5486. #endif
  5487. # 693 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5488.  
  5489. /*
  5490. * Routines for measuring time -- depends on a later MIPS userspace cycle
  5491. * counter.
  5492. */
  5493. static __inline uint32_t
  5494. cheri_get_cyclecount(void)
  5495. {
  5496. uint64_t _time;
  5497.  
  5498. __asm__ __volatile__ (
  5499. ".set push\n"
  5500. ".set noreorder\n"
  5501. "rdhwr %0, $2\n"
  5502. ".set pop\n"
  5503. : "=r" (_time));
  5504. return (_time & 0xffffffff);
  5505. }
  5506.  
  5507. /*
  5508. * Special marker NOPs recognised by analyse_trace.py to start / stop region
  5509. * of interest in trace.
  5510. */
  5511. #define CHERI_START_TRACE do { \
  5512. __asm__ __volatile__("li $0, 0xbeef"); \
  5513. } while(0)
  5514. #define CHERI_STOP_TRACE do { \
  5515. __asm__ __volatile__("li $0, 0xdead"); \
  5516. } while(0)
  5517.  
  5518. #ifdef _KERNEL
  5519. /*
  5520. * Special marker NOP to log messages in instruction traces.
  5521. */
  5522. void cheri_trace_log(void *buf, size_t len, int format);
  5523.  
  5524. #define CHERI_TRACE_STRING(s) \
  5525. cheri_trace_log((s), strlen((s)), 0);
  5526. #define CHERI_TRACE_MEM(buf, len) \
  5527. cheri_trace_log((buf), (len), 1);
  5528.  
  5529. #define CHERI_CAP_PRINT(crn) do { \
  5530. uintmax_t c_perms, c_otype, c_base, c_length, c_offset; \
  5531. u_int ctag, c_sealed; \
  5532. \
  5533. CHERI_CGETTAG(ctag, (crn)); \
  5534. CHERI_CGETSEALED(c_sealed, (crn)); \
  5535. CHERI_CGETPERM(c_perms, (crn)); \
  5536. CHERI_CGETTYPE(c_otype, (crn)); \
  5537. CHERI_CGETBASE(c_base, (crn)); \
  5538. CHERI_CGETLEN(c_length, (crn)); \
  5539. CHERI_CGETOFFSET(c_offset, (crn)); \
  5540. printf("v:%u s:%u p:%08jx b:%016jx l:%016jx o:%jx t:%jx\n", \
  5541. ctag, c_sealed, c_perms, c_base, c_length, c_offset, \
  5542. c_otype); \
  5543. } while (0)
  5544.  
  5545. #define CHERI_REG_PRINT(crn, num) do { \
  5546. printf("$c%02u: ", num); \
  5547. CHERI_CAP_PRINT(crn); \
  5548. } while (0)
  5549.  
  5550. #ifdef DDB
  5551. #define DB_CHERI_CAP_PRINT(crn) do { \
  5552. uintmax_t c_perms, c_otype, c_base, c_length, c_offset; \
  5553. u_int ctag, c_sealed; \
  5554. \
  5555. CHERI_CGETTAG(ctag, (crn)); \
  5556. CHERI_CGETSEALED(c_sealed, (crn)); \
  5557. CHERI_CGETPERM(c_perms, (crn)); \
  5558. CHERI_CGETTYPE(c_otype, (crn)); \
  5559. CHERI_CGETBASE(c_base, (crn)); \
  5560. CHERI_CGETLEN(c_length, (crn)); \
  5561. CHERI_CGETOFFSET(c_offset, (crn)); \
  5562. db_printf("v:%u s:%u p:%08jx b:%016jx l:%016jx o:%jx t:%jx\n", \
  5563. ctag, c_sealed, c_perms, c_base, c_length, c_offset, \
  5564. c_otype); \
  5565. } while (0)
  5566.  
  5567. #define DB_CHERI_REG_PRINT(crn, num) do { \
  5568. db_printf("$c%02u: ", num); \
  5569. DB_CHERI_CAP_PRINT(crn); \
  5570. } while (0)
  5571. #endif /* !DDB */
  5572. # 777 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5573. #endif /* !_KERNEL */
  5574. # 778 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5575.  
  5576. #endif /* _MIPS_INCLUDE_CHERI_H_ */
  5577. # 780 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheri.h" 3 4
  5578. # 185 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 2 3 4
  5579.  
  5580. #endif /* _SYS_CHERI_H_ */
  5581. # 187 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheri.h" 3 4
  5582. # 35 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  5583. #if 0 /* expanded by -frewrite-includes */
  5584. #include <cheri/cheric.h>
  5585. #endif /* expanded by -frewrite-includes */
  5586. # 35 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  5587. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 1 3 4
  5588. /*-
  5589. * Copyright (c) 2013-2016 Robert N. M. Watson
  5590. * All rights reserved.
  5591. *
  5592. * This software was developed by SRI International and the University of
  5593. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  5594. * ("CTSRD"), as part of the DARPA CRASH research programme.
  5595. *
  5596. * Redistribution and use in source and binary forms, with or without
  5597. * modification, are permitted provided that the following conditions
  5598. * are met:
  5599. * 1. Redistributions of source code must retain the above copyright
  5600. * notice, this list of conditions and the following disclaimer.
  5601. * 2. Redistributions in binary form must reproduce the above copyright
  5602. * notice, this list of conditions and the following disclaimer in the
  5603. * documentation and/or other materials provided with the distribution.
  5604. *
  5605. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  5606. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5607. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  5608. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  5609. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  5610. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  5611. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  5612. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  5613. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  5614. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5615. * SUCH DAMAGE.
  5616. */
  5617.  
  5618. #ifndef _SYS_CHERIC_H_
  5619. #define _SYS_CHERIC_H_
  5620.  
  5621. #if 0 /* expanded by -frewrite-includes */
  5622. #include <sys/cdefs.h>
  5623. #endif /* expanded by -frewrite-includes */
  5624. # 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5625. # 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5626. #if 0 /* expanded by -frewrite-includes */
  5627. #include <sys/types.h>
  5628. #endif /* expanded by -frewrite-includes */
  5629. # 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5630. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5631.  
  5632. #if 0 /* expanded by -frewrite-includes */
  5633. #include <machine/cherireg.h> /* Permission definitions. */
  5634. #endif /* expanded by -frewrite-includes */
  5635. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5636. # 38 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5637.  
  5638. #if __has_feature(capabilities)
  5639.  
  5640. /*
  5641. * Programmer-friendly macros for CHERI-aware C code -- requires use of
  5642. * CHERI-aware Clang/LLVM, and full capability context switching, so not yet
  5643. * usable in the kernel.
  5644. */
  5645. #define cheri_getlen(x) __builtin_mips_cheri_get_cap_length((x))
  5646. #define cheri_getbase(x) __builtin_mips_cheri_get_cap_base((x))
  5647. #define cheri_getoffset(x) __builtin_mips_cheri_cap_offset_get((x))
  5648. #define cheri_getperm(x) __builtin_mips_cheri_get_cap_perms((x))
  5649. #define cheri_getsealed(x) __builtin_mips_cheri_get_cap_sealed((x))
  5650. #define cheri_gettag(x) __builtin_mips_cheri_get_cap_tag((x))
  5651. #define cheri_gettype(x) __builtin_mips_cheri_get_cap_type((x))
  5652.  
  5653. #define cheri_andperm(x, y) __builtin_mips_cheri_and_cap_perms((x), (y))
  5654. #define cheri_cleartag(x) __builtin_mips_cheri_clear_cap_tag((x))
  5655. #define cheri_incoffset(x, y) __builtin_mips_cheri_cap_offset_increment((x), (y))
  5656. #define cheri_setoffset(x, y) __builtin_mips_cheri_cap_offset_set((x), (y))
  5657.  
  5658. #define cheri_seal(x, y) __builtin_mips_cheri_seal_cap((x), (y))
  5659. #define cheri_unseal(x, y) __builtin_mips_cheri_unseal_cap((x), (y))
  5660.  
  5661. #define cheri_getcause() __builtin_mips_cheri_get_cause()
  5662. #define cheri_setcause(x) __builtin_mips_cheri_set_cause(x)
  5663.  
  5664. #define cheri_ccheckperm(c, p) __builtin_mips_cheri_check_perms((c), (p))
  5665. #define cheri_cchecktype(c, t) __builtin_mips_cheri_check_type((c), (t))
  5666.  
  5667. #define cheri_getdefault() __builtin_mips_cheri_get_global_data_cap()
  5668. #define cheri_getidc() __builtin_mips_cheri_get_invoke_data_cap()
  5669. #define cheri_getkr0c() __builtin_mips_cheri_get_kernel_cap1()
  5670. #define cheri_getkr1c() __builtin_mips_cheri_get_kernel_cap2()
  5671. #define cheri_getkcc() __builtin_mips_cheri_get_kernel_code_cap()
  5672. #define cheri_getkdc() __builtin_mips_cheri_get_kernel_data_cap()
  5673. #define cheri_getepcc() __builtin_mips_cheri_get_exception_program_counter_cap()
  5674. #define cheri_getpcc() __builtin_mips_cheri_get_program_counter_cap()
  5675. #define cheri_getstack() __builtin_cheri_stack_get()
  5676.  
  5677. #define cheri_local(c) cheri_andperm((c), ~CHERI_PERM_GLOBAL)
  5678.  
  5679. #define cheri_csetbounds(x, y) __builtin_cheri_bounds_set((x), (y))
  5680.  
  5681. /*
  5682. * Two variations on cheri_ptr() based on whether we are looking for a code or
  5683. * data capability. The compiler's use of CFromPtr will be with respect to
  5684. * $ddc or $pcc depending on the type of the pointer derived, so we need to
  5685. * use types to differentiate the two versions at compile time. We don't
  5686. * provide the full set of function variations for code pointers as they
  5687. * haven't proven necessary as yet.
  5688. *
  5689. * XXXRW: Ideally, casting via a function pointer would cause the compiler to
  5690. * derive the capability using CFromPtr on $pcc rather than on $ddc. This
  5691. * appears not currently to be the case, so manually derive using
  5692. * cheri_getpcc() for now.
  5693. */
  5694. static __inline void * __capability
  5695. cheri_codeptr(const void *ptr, size_t len)
  5696. {
  5697. #ifdef NOTYET
  5698. void (* __capability c)(void) = ptr;
  5699. #else
  5700. # 101 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5701. void * __capability c = cheri_setoffset(cheri_getpcc(),
  5702. (register_t)ptr);
  5703. #endif
  5704. # 104 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5705.  
  5706. /* Assume CFromPtr without base set, availability of CSetBounds. */
  5707. return (cheri_csetbounds(c, len));
  5708. }
  5709.  
  5710. static __inline void * __capability
  5711. cheri_codeptrperm(const void *ptr, size_t len, register_t perm)
  5712. {
  5713.  
  5714. return (cheri_andperm(cheri_codeptr(ptr, len),
  5715. perm | CHERI_PERM_GLOBAL));
  5716. }
  5717.  
  5718. static __inline void * __capability
  5719. cheri_ptr(const void *ptr, size_t len)
  5720. {
  5721.  
  5722. /* Assume CFromPtr without base set, availability of CSetBounds. */
  5723. return (cheri_csetbounds((__cheri_cast const void * __capability)ptr, len));
  5724. }
  5725.  
  5726. static __inline void * __capability
  5727. cheri_ptrperm(const void *ptr, size_t len, register_t perm)
  5728. {
  5729.  
  5730. return (cheri_andperm(cheri_ptr(ptr, len), perm | CHERI_PERM_GLOBAL));
  5731. }
  5732.  
  5733. static __inline void * __capability
  5734. cheri_ptrpermoff(const void *ptr, size_t len, register_t perm, off_t off)
  5735. {
  5736.  
  5737. return (cheri_setoffset(cheri_ptrperm(ptr, len, perm), off));
  5738. }
  5739.  
  5740. /*
  5741. * Construct a capability suitable to describe a type identified by 'ptr';
  5742. * set it to zero-length with the offset equal to the base. The caller must
  5743. * provide a root capability (in the old world order, derived from $ddc, but
  5744. * in the new world order, likely extracted from the kernel using sysarch(2)).
  5745. *
  5746. * The caller may wish to assert various properties about the returned
  5747. * capability, including that CHERI_PERM_SEAL is set.
  5748. */
  5749. static __inline void * __capability
  5750. cheri_maketype(void * __capability root_type, register_t type)
  5751. {
  5752. void * __capability c;
  5753.  
  5754. c = root_type;
  5755. c = cheri_setoffset(c, type); /* Set type as desired. */
  5756. c = cheri_csetbounds(c, 1); /* ISA implies length of 1. */
  5757. c = cheri_andperm(c, CHERI_PERM_GLOBAL | CHERI_PERM_SEAL); /* Perms. */
  5758. return (c);
  5759. }
  5760.  
  5761. static __inline void * __capability
  5762. cheri_zerocap(void)
  5763. {
  5764. return (void * __capability)0;
  5765. }
  5766.  
  5767. static __inline uint64_t
  5768. cheri_bytes_remaining(const void * __capability cap)
  5769. {
  5770. if (cheri_getoffset(cap) >= cheri_getlen(cap))
  5771. return 0;
  5772. return cheri_getlen(cap) - cheri_getoffset(cap);
  5773. }
  5774.  
  5775. /*
  5776. * Turn a pointer into a capability with the bounds set to
  5777. * sizeof(*ptr)
  5778. */
  5779. /* XXX: work around CTSRD-CHERI/clang#157 */
  5780. #ifdef __CHERI_PURE_CAPABILITY__
  5781. #define cheri_ptr_to_bounded_cap(ptr) __extension__({ \
  5782. typedef __typeof__(ptr) __ptr_type; \
  5783. (__ptr_type)cheri_ptr((ptr), sizeof(*(ptr))); \
  5784. })
  5785. #else
  5786. # 185 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5787. #define cheri_ptr_to_bounded_cap(ptr) cheri_ptr((ptr), sizeof(*(ptr)))
  5788. #endif
  5789. # 187 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5790. /*
  5791. * Convert a capability to a pointer. Returns NULL if there are less than
  5792. * min_size accessible bytes remiaing in cap.
  5793. */
  5794. #define cheri_cap_to_ptr(cap, min_size) __extension__({ \
  5795. typedef __typeof__(*(cap)) __underlying_type; \
  5796. __underlying_type* __result = 0; \
  5797. if (cheri_bytes_remaining(cap) >= (uint64_t)min_size) { \
  5798. __result = (__cheri_cast __underlying_type*)(cap); \
  5799. } __result; })
  5800.  
  5801. /*
  5802. * Convert an untyped capability to a pointer of type \p type.
  5803. * This macro checks that there are at least sizeof(type) bytes accessible
  5804. * from \p cap.
  5805. */
  5806. #define cheri_cap_to_typed_ptr(cap, type) \
  5807. (type *)cheri_cap_to_ptr(cap, sizeof(type))
  5808.  
  5809.  
  5810. #define CHERI_PRINT_PTR(ptr) \
  5811. printf("%s: " #ptr " b:%016jx l:%016zx o:%jx\n", __func__, \
  5812. cheri_getbase((const void * __capability)(ptr)), \
  5813. cheri_getlen((const void * __capability)(ptr)), \
  5814. cheri_getoffset((const void * __capability)(ptr)))
  5815. #endif
  5816. # 213 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5817.  
  5818. #if 0 /* expanded by -frewrite-includes */
  5819. #include <machine/cheric.h>
  5820. #endif /* expanded by -frewrite-includes */
  5821. # 214 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5822. # 1 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 1 3 4
  5823. /*-
  5824. * Copyright (c) 2013-2016 Robert N. M. Watson
  5825. * All rights reserved.
  5826. *
  5827. * This software was developed by SRI International and the University of
  5828. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  5829. * ("CTSRD"), as part of the DARPA CRASH research programme.
  5830. *
  5831. * Redistribution and use in source and binary forms, with or without
  5832. * modification, are permitted provided that the following conditions
  5833. * are met:
  5834. * 1. Redistributions of source code must retain the above copyright
  5835. * notice, this list of conditions and the following disclaimer.
  5836. * 2. Redistributions in binary form must reproduce the above copyright
  5837. * notice, this list of conditions and the following disclaimer in the
  5838. * documentation and/or other materials provided with the distribution.
  5839. *
  5840. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  5841. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5842. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  5843. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  5844. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  5845. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  5846. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  5847. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  5848. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  5849. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5850. * SUCH DAMAGE.
  5851. */
  5852.  
  5853. #ifndef _MIPS_INCLUDE_CHERIC_H_
  5854. #define _MIPS_INCLUDE_CHERIC_H_
  5855.  
  5856. #if 0 /* expanded by -frewrite-includes */
  5857. #include <sys/cdefs.h>
  5858. #endif /* expanded by -frewrite-includes */
  5859. # 34 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
  5860. # 35 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
  5861.  
  5862. #if 0 /* expanded by -frewrite-includes */
  5863. #include <cheri/cheri.h>
  5864. #endif /* expanded by -frewrite-includes */
  5865. # 36 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
  5866. # 37 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
  5867.  
  5868. #if !defined(_KERNEL) && __has_feature(capabilities)
  5869. #define cheri_getreg(x) ({ \
  5870. __capability void *_cap; \
  5871. __asm __volatile ("cmove %0, $c" #x : "=C" (_cap)); \
  5872. _cap; \
  5873. })
  5874.  
  5875. #define cheri_setreg(x, cap) do { \
  5876. if ((x) == 0) \
  5877. __asm __volatile ("cmove $c" #x ", %0" : : "C" (cap) : \
  5878. "memory"); \
  5879. else \
  5880. __asm __volatile ("cmove $c" #x ", %0" : : "C" (cap)); \
  5881. } while (0)
  5882. #endif
  5883. # 53 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
  5884.  
  5885. #endif /* _MIPS_INCLUDE_CHERIC_H_ */
  5886. # 55 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/machine/cheric.h" 3 4
  5887. # 215 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 2 3 4
  5888.  
  5889. #endif /* _SYS_CHERIC_H_ */
  5890. # 217 "/home/rnw24/obj/mips.mips64/home/rnw24/git/cheribsd/tmp/usr/include/cheri/cheric.h" 3 4
  5891. # 36 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  5892.  
  5893. #if 0 /* expanded by -frewrite-includes */
  5894. #include "cheri_ccall.h"
  5895. #endif /* expanded by -frewrite-includes */
  5896. # 37 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  5897. # 1 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.h" 1
  5898. /*-
  5899. * Copyright (c) 2017 Robert N. M. Watson
  5900. * All rights reserved.
  5901. *
  5902. * This software was developed by SRI International and the University of
  5903. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  5904. * ("CTSRD"), as part of the DARPA CRASH research programme.
  5905. *
  5906. * Redistribution and use in source and binary forms, with or without
  5907. * modification, are permitted provided that the following conditions
  5908. * are met:
  5909. * 1. Redistributions of source code must retain the above copyright
  5910. * notice, this list of conditions and the following disclaimer.
  5911. * 2. Redistributions in binary form must reproduce the above copyright
  5912. * notice, this list of conditions and the following disclaimer in the
  5913. * documentation and/or other materials provided with the distribution.
  5914. *
  5915. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  5916. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5917. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  5918. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  5919. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  5920. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  5921. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  5922. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  5923. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  5924. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5925. * SUCH DAMAGE.
  5926. */
  5927.  
  5928. #ifndef _CHERI_CCALL_H_
  5929. #define _CHERI_CCALL_H_
  5930.  
  5931. /*
  5932. * Private interfaces to return sealed capabilities to call an object's rtld,
  5933. * invoke the object, or return (from any object).
  5934. */
  5935. struct sandbox_object;
  5936. struct cheri_object cheri_sandbox_make_sealed_invoke_object(
  5937. struct sandbox_object *sbop);
  5938. struct cheri_object cheri_sandbox_make_sealed_rtld_object(
  5939. struct sandbox_object *sbop);
  5940. struct cheri_object cheri_make_sealed_return_object(void);
  5941.  
  5942. #endif /* _CHERI_CCALL_H_ */
  5943. # 46 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.h"
  5944. # 38 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  5945. #if 0 /* expanded by -frewrite-includes */
  5946. #include "cheri_class.h"
  5947. #endif /* expanded by -frewrite-includes */
  5948. # 38 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  5949. # 1 "/home/rnw24/git/cheribsd/lib/libcheri/mips64/cheri_class.h" 1
  5950. /*-
  5951. * Copyright (c) 2012-2017 Robert N. M. Watson
  5952. * All rights reserved.
  5953. *
  5954. * This software was developed by SRI International and the University of
  5955. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  5956. * ("CTSRD"), as part of the DARPA CRASH research programme.
  5957. *
  5958. * Redistribution and use in source and binary forms, with or without
  5959. * modification, are permitted provided that the following conditions
  5960. * are met:
  5961. * 1. Redistributions of source code must retain the above copyright
  5962. * notice, this list of conditions and the following disclaimer.
  5963. * 2. Redistributions in binary form must reproduce the above copyright
  5964. * notice, this list of conditions and the following disclaimer in the
  5965. * documentation and/or other materials provided with the distribution.
  5966. *
  5967. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  5968. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5969. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  5970. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  5971. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  5972. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  5973. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  5974. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  5975. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  5976. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5977. * SUCH DAMAGE.
  5978. */
  5979.  
  5980. #ifndef _CHERI_CLASS_H_
  5981. #define _CHERI_CLASS_H_
  5982.  
  5983. /*
  5984. * Fields to insert at the front of the 'sandbox_object' data structure that
  5985. * will be used during protection-domain switching to set up the target
  5986. * execution context. These are used for both loaded classes and system
  5987. * classes.
  5988. *
  5989. * __sandbox_object_idc IDC to install for both rtld and invocation
  5990. * entry. The entry vector code will also use
  5991. * this capability, with offset set to zero, as
  5992. * the installed DDC.
  5993. *
  5994. * __sandbox_object_rtld_pcc PCC to install for rtld operations.
  5995. *
  5996. * __sandbox_object_invoke_pcc PCC to install on invocation.
  5997. *
  5998. * __sandbox_vtable VTable pointer used for CHERI system classes;
  5999. * unused for loaded (confined) classes.
  6000. */
  6001. #define LIBCHERI_SANDBOX_OBJECT_FIELDS \
  6002. __capability void *__sandbox_object_idc; \
  6003. __capability void *__sandbox_object_rtld_pcc; \
  6004. __capability void *__sandbox_object_invoke_pcc; \
  6005. __capability intptr_t *__sandbox_vtable
  6006.  
  6007. #define LIBCHERI_SANDBOX_OBJECT_INIT(sbop, idc, rtld_pcc, invoke_pcc, vtable)\
  6008. (sbop)->__sandbox_object_idc = (idc); \
  6009. (sbop)->__sandbox_object_rtld_pcc = (rtld_pcc); \
  6010. (sbop)->__sandbox_object_invoke_pcc = (invoke_pcc); \
  6011. (sbop)->__sandbox_vtable = (vtable)
  6012.  
  6013. #define LIBCHERI_SANDBOX_OBJECT_FINI(sbop) \
  6014. (sbop)->__sandbox_object_idc = NULL; \
  6015. (sbop)->__sandbox_object_rtld_pcc = NULL; \
  6016. (sbop)->__sandbox_object_invoke_pcc = NULL; \
  6017. free_c((sbop)->__sandbox_vtable); \
  6018. (sbop)->__sandbox_vtable = NULL
  6019.  
  6020. #endif /* _CHERI_CLASS_H_ */
  6021. # 72 "/home/rnw24/git/cheribsd/lib/libcheri/mips64/cheri_class.h"
  6022. # 39 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  6023. #if 0 /* expanded by -frewrite-includes */
  6024. #include "cheri_type.h"
  6025. #endif /* expanded by -frewrite-includes */
  6026. # 39 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  6027. # 1 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_type.h" 1
  6028. /*-
  6029. * Copyright (c) 2014 Robert N. M. Watson
  6030. * All rights reserved.
  6031. *
  6032. * This software was developed by SRI International and the University of
  6033. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  6034. * ("CTSRD"), as part of the DARPA CRASH research programme.
  6035. *
  6036. * Redistribution and use in source and binary forms, with or without
  6037. * modification, are permitted provided that the following conditions
  6038. * are met:
  6039. * 1. Redistributions of source code must retain the above copyright
  6040. * notice, this list of conditions and the following disclaimer.
  6041. * 2. Redistributions in binary form must reproduce the above copyright
  6042. * notice, this list of conditions and the following disclaimer in the
  6043. * documentation and/or other materials provided with the distribution.
  6044. *
  6045. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  6046. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6047. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  6048. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  6049. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  6050. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  6051. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  6052. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  6053. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  6054. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6055. * SUCH DAMAGE.
  6056. */
  6057.  
  6058. #ifndef _CHERI_TYPE_H_
  6059. #define _CHERI_TYPE_H_
  6060.  
  6061. __capability void *cheri_type_alloc(void);
  6062. __capability void *cheri_system_type_alloc(void);
  6063.  
  6064. #endif /* !_CHERI_TYPE_H_ */
  6065. # 38 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_type.h"
  6066. # 40 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  6067. #if 0 /* expanded by -frewrite-includes */
  6068. #include "libcheri_init.h"
  6069. #endif /* expanded by -frewrite-includes */
  6070. # 40 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  6071. # 1 "/home/rnw24/git/cheribsd/lib/libcheri/libcheri_init.h" 1
  6072. /*-
  6073. * Copyright (c) 2017 Robert N. M. Watson
  6074. * All rights reserved.
  6075. *
  6076. * This software was developed by SRI International and the University of
  6077. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  6078. * ("CTSRD"), as part of the DARPA CRASH research programme.
  6079. *
  6080. * Redistribution and use in source and binary forms, with or without
  6081. * modification, are permitted provided that the following conditions
  6082. * are met:
  6083. * 1. Redistributions of source code must retain the above copyright
  6084. * notice, this list of conditions and the following disclaimer.
  6085. * 2. Redistributions in binary form must reproduce the above copyright
  6086. * notice, this list of conditions and the following disclaimer in the
  6087. * documentation and/or other materials provided with the distribution.
  6088. *
  6089. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  6090. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6091. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  6092. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  6093. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  6094. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  6095. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  6096. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  6097. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  6098. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6099. * SUCH DAMAGE.
  6100. */
  6101.  
  6102. #ifndef _LIBCHERI_INIT_H_
  6103. #define _LIBCHERI_INIT_H_
  6104.  
  6105. void cheri_ccall_init(void);
  6106. void cheri_stack_init(void);
  6107. void cheri_enter_init(void);
  6108. void sandbox_init(void);
  6109.  
  6110. #endif /* _LIBCHERI_INIT_H_ */
  6111. # 40 "/home/rnw24/git/cheribsd/lib/libcheri/libcheri_init.h"
  6112. # 41 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  6113. #if 0 /* expanded by -frewrite-includes */
  6114. #include "sandbox_internal.h"
  6115. #endif /* expanded by -frewrite-includes */
  6116. # 41 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  6117. # 1 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h" 1
  6118. /*-
  6119. * Copyright (c) 2012-2017 Robert N. M. Watson
  6120. * Copyright (c) 2015 SRI International
  6121. * All rights reserved.
  6122. *
  6123. * This software was developed by SRI International and the University of
  6124. * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
  6125. * ("CTSRD"), as part of the DARPA CRASH research programme.
  6126. *
  6127. * Redistribution and use in source and binary forms, with or without
  6128. * modification, are permitted provided that the following conditions
  6129. * are met:
  6130. * 1. Redistributions of source code must retain the above copyright
  6131. * notice, this list of conditions and the following disclaimer.
  6132. * 2. Redistributions in binary form must reproduce the above copyright
  6133. * notice, this list of conditions and the following disclaimer in the
  6134. * documentation and/or other materials provided with the distribution.
  6135. *
  6136. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  6137. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6138. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  6139. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  6140. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  6141. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  6142. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  6143. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  6144. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  6145. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6146. * SUCH DAMAGE.
  6147. */
  6148.  
  6149. #ifndef _SANDBOX_INTERNAL_H_
  6150. #define _SANDBOX_INTERNAL_H_
  6151.  
  6152. #if 0 /* expanded by -frewrite-includes */
  6153. #include <sys/stat.h>
  6154. #endif /* expanded by -frewrite-includes */
  6155. # 35 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h"
  6156. # 36 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h"
  6157.  
  6158. #if 0 /* expanded by -frewrite-includes */
  6159. #include "cheri_class.h"
  6160. #endif /* expanded by -frewrite-includes */
  6161. # 37 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h"
  6162. # 38 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h"
  6163.  
  6164. extern int sb_verbose;
  6165.  
  6166. /*
  6167. * Description of a 'sandbox class': an instance of code that may be sandboxed
  6168. * and invoked, along with statistics/monitoring information, etc.
  6169. *
  6170. * NB: For now, support up to 'SANDBOX_CLASS_METHOD_COUNT' sets of method
  6171. * statistics, which will be indexed by method number. If the requested
  6172. * method number isn't in range, use the catchall entry instead.
  6173. */
  6174. #define SANDBOX_CLASS_METHOD_COUNT 32
  6175. struct sandbox_class {
  6176. char *sbc_path;
  6177. int sbc_fd;
  6178. struct stat sbc_stat;
  6179. size_t sbc_codelen;
  6180. void *sbc_codemem;
  6181. struct sandbox_map *sbc_codemap;
  6182. struct sandbox_map *sbc_datamap;
  6183.  
  6184. /*
  6185. * The class's code capabilities, in various incarnations required for
  6186. * class creation. These will be used for all objects in the class.
  6187. */
  6188. __capability void *sbc_classcap_rtld; /* Ctor/dtor */
  6189. __capability void *sbc_classcap_invoke; /* Object invoke */
  6190.  
  6191. /*
  6192. * Class CCall methods.
  6193. */
  6194. struct sandbox_provided_classes *sbc_provided_classes;
  6195. struct sandbox_required_methods *sbc_required_methods;
  6196.  
  6197. /*
  6198. * Class and invoke() method statistics.
  6199. */
  6200. struct sandbox_class_stat *sbc_sandbox_class_statp;
  6201. struct sandbox_method_stat *sbc_sandbox_method_nonamep;
  6202. struct sandbox_method_stat *sbc_sandbox_methods[
  6203. SANDBOX_CLASS_METHOD_COUNT];
  6204. };
  6205.  
  6206. /*-
  6207. * Description of a 'sandbox object' or 'sandbox instance': an in-flight
  6208. * combination of code and data. Currently, due to compiler limitations, we
  6209. * must conflate 'code', 'heap', and 'stack', but eventually would like to
  6210. * allow one VM mapping of code to serve many object instances. This would
  6211. * also ease supporting multithreaded objects.
  6212. *
  6213. * TODO:
  6214. * - Add atomically set flag and assertion to ensure single-threaded entry to
  6215. * the sandbox.
  6216. */
  6217. struct
  6218. #if _MIPS_SZCAP == 128
  6219. __attribute__ ((aligned(4096)))
  6220. #endif
  6221. # 96 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h"
  6222. sandbox_object {
  6223. /*
  6224. * IMPORTANT: These fields must be at the top of the sandbox_object,
  6225. * and in this specific order, as corresponding offsets to them are
  6226. * included in assembly domain-transition code in
  6227. * cheri_ccall_trampoline.S.
  6228. *
  6229. * sbo_idc IDC to install for both rtld and invocation entry.
  6230. * The entry vector code will also use this
  6231. * capability, with offset set to zero, as the
  6232. * installed DDC.
  6233. *
  6234. * sbo_rtld_pcc PCC to install for rtld operations.
  6235. *
  6236. * sbo_invoke_pcc PCC to install on invocation.
  6237. *
  6238. * sbo_vtable VTable pointer used for CHERI system classes;
  6239. * unused for loaded (confined) classes.
  6240. *
  6241. * These capabilities are used by libcheri itself when accessing data
  6242. * from within the CCall trampoline, so that we don't have to assume
  6243. * that the sandbox_object pointer is DDC-relative:
  6244. *
  6245. * sbo_libcheri_tls Access TLS relative to this register.
  6246. *
  6247. * XXXRW: It would be nice if the offsets to these fields were in
  6248. * shared headers, allowing compile-time asserts to be used to check
  6249. * binary compatibility has not been broken.
  6250. */
  6251. __capability void *sbo_idc; /* Capability offset 0. */
  6252. __capability void *sbo_rtld_pcc; /* Capability offset 1. */
  6253. __capability void *sbo_invoke_pcc;/* Capability offset 2. */
  6254. __capability void *sbo_vtable; /* Capability offset 3. */
  6255. __capability void *sbo_ddc; /* Capability offset 4. */
  6256. __capability void *sbo_libcheri_tls; /* Capability offset 5. */
  6257.  
  6258. /*
  6259. * Further fields are unknown to the assembly domain-transition code.
  6260. */
  6261. struct sandbox_class *sbo_sandbox_classp;
  6262. struct sandbox_object *sbo_sandbox_system_objectp;
  6263. void *sbo_datamem;
  6264. void *sbo_stackmem;
  6265.  
  6266. register_t sbo_datalen;
  6267. register_t sbo_heapbase;
  6268. register_t sbo_heaplen;
  6269. register_t sbo_stacklen;
  6270. uint sbo_flags; /* Sandbox flags. */
  6271.  
  6272. /*
  6273. * Sealed code and data capabilities suitable to access the object's
  6274. * run-time linker methods and also general object-capability
  6275. * invocation.
  6276. */
  6277. struct cheri_object sbo_cheri_object_rtld;
  6278. struct cheri_object sbo_cheri_object_invoke;
  6279.  
  6280. /*
  6281. * System-object capabilities that can be passed to the object.
  6282. */
  6283. struct cheri_object sbo_cheri_object_system;
  6284.  
  6285. /*
  6286. * Stack capability that will also be installed in the object.
  6287. */
  6288. __capability void *sbo_stackcap;
  6289.  
  6290. /*
  6291. * Sandbox statistics.
  6292. */
  6293. struct sandbox_object_stat *sbo_sandbox_object_statp;
  6294.  
  6295. /*
  6296. * Private data for system objects.
  6297. */
  6298. __capability void *sbo_private_data;
  6299. };
  6300.  
  6301. /*
  6302. * A classic 'sandbox' is actually a combination of a sandbox class and a
  6303. * sandbox object. We continue to support this model as it is used in some
  6304. * CHERI demo and test code.
  6305. */
  6306. struct sandbox {
  6307. struct sandbox_class *sb_sandbox_classp;
  6308. struct sandbox_object *sb_sandbox_objectp;
  6309. };
  6310.  
  6311. int sandbox_class_load(struct sandbox_class *sbcp);
  6312. void sandbox_class_unload(struct sandbox_class *sbcp);
  6313. int sandbox_object_load(struct sandbox_class *sbcp,
  6314. struct sandbox_object *sbop);
  6315. int sandbox_object_protect(struct sandbox_class *sbcp,
  6316. struct sandbox_object *sbop);
  6317. int sandbox_object_reload(struct sandbox_object *sbop);
  6318. void sandbox_object_unload(struct sandbox_object *sbop);
  6319.  
  6320. #endif /* !_SANDBOX_INTERNAL_H_ */
  6321. # 195 "/home/rnw24/git/cheribsd/lib/libcheri/sandbox_internal.h"
  6322. # 42 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c" 2
  6323.  
  6324. /*
  6325. * This call provides the C implementation of the userspace CCall trampoline
  6326. * for libcheri. Three object types are used: CCall paths into rtld
  6327. * initialisation, invocation, and CReturn.
  6328. *
  6329. * For CCall data capabilities, we use the sandbox object pointer, where we
  6330. * can find any data required to perform the domain transition, including a
  6331. * suitable capability for use with TLS. Currently, this means deriving these
  6332. * sealed data capabilities from DDC.
  6333. *
  6334. * For CReturn data capabilities, we use a pointer to a global data structure
  6335. * that contains a suitable capability for use with TLS -- as with above, we
  6336. * currently derive this capability from DDC.
  6337. *
  6338. * XXXRW: Will we also want to do something to provide per-thread execution
  6339. * stacks to handle failures in CCall and CReturn.
  6340. *
  6341. * XXXRW: How to handle signal delivery during CCall and CReturn?
  6342. */
  6343.  
  6344. /*
  6345. * External assembly for CCall and CReturn vectors. Ideally the rtld and
  6346. * general invocation vectors might be shared, but userspace CCall cannot
  6347. * currently reliable access the operand object type.
  6348. */
  6349. extern void libcheri_ccall_rtld_vector;
  6350. extern void libcheri_ccall_invoke_vector;
  6351. extern void libcheri_creturn_vector;
  6352.  
  6353. /*
  6354. * Sealing capabilities used to seal invocation, rtld, and creturn
  6355. * capabilities.
  6356. */
  6357. static __capability void *cheri_ccall_invoke_type;
  6358. static __capability void *cheri_ccall_rtld_type;
  6359. static __capability void *cheri_creturn_type;
  6360.  
  6361. /*
  6362. * Sealed capabilities shared across all sandbox objects: code for invocation
  6363. * and rtld; code and data for creturn.
  6364. */
  6365. static __capability void *cheri_ccall_invoke_sealed_code;
  6366. static __capability void *cheri_ccall_rtld_sealed_code;
  6367. static struct cheri_object cheri_creturn_object;
  6368.  
  6369. static
  6370. #if _MIPS_SZCAP == 128
  6371. __attribute__ ((aligned(4096)))
  6372. #endif
  6373. # 92 "/home/rnw24/git/cheribsd/lib/libcheri/cheri_ccall.c"
  6374. void *cheri_creturn_data;
  6375.  
  6376. /*
  6377. * One-time initialisation of libcheri on startup: (1) Initialise sealing
  6378. * capabilities for invocation, rtld, and creturn; and (2) Initialise sealed
  6379. * capabilities where the values will be shared across many sandboxes.
  6380. */
  6381. void
  6382. cheri_ccall_init(void)
  6383. {
  6384. __capability void *cap;
  6385.  
  6386. /*
  6387. * Initialise sealing capabilities for invocation, rtld, and creturn,
  6388. *
  6389. */
  6390. cheri_ccall_invoke_type = cheri_type_alloc();
  6391. cheri_ccall_rtld_type = cheri_type_alloc();
  6392. cheri_creturn_type = cheri_type_alloc();
  6393.  
  6394. /*
  6395. * Pointer to the invocation vector.
  6396. */
  6397. cap = cheri_getpcc();
  6398. cap = cheri_setoffset(cap, (vaddr_t)&libcheri_ccall_invoke_vector);
  6399. cheri_ccall_invoke_sealed_code = cheri_seal(cap,
  6400. cheri_ccall_invoke_type);
  6401.  
  6402. /*
  6403. * Pointer to the rtld vector.
  6404. */
  6405. cap = cheri_getpcc();
  6406. cap = cheri_setoffset(cap, (vaddr_t)&libcheri_ccall_rtld_vector);
  6407. cheri_ccall_rtld_sealed_code = cheri_seal(cap, cheri_ccall_rtld_type);
  6408.  
  6409. /*
  6410. * Pointer to the creturn vector, with global bounds in order to
  6411. * provide access to the trusted stack (etc). There is no
  6412. * call-specific data, so use dummy data.
  6413. *
  6414. * XXXRW: Global bounds only for code, not data..?
  6415. */
  6416. cap = cheri_getpcc();
  6417. cap = cheri_setoffset(cap, (vaddr_t)&libcheri_creturn_vector);
  6418. cheri_creturn_object.co_codecap = cheri_seal(cap, cheri_creturn_type);
  6419.  
  6420. cap = cheri_getdefault();
  6421. cap = cheri_setoffset(cap, (vaddr_t)&cheri_creturn_data);
  6422. cheri_creturn_object.co_datacap = cheri_seal(cap, cheri_creturn_type);
  6423. }
  6424.  
  6425. /*
  6426. * Return various sealed capabilities for a sandbox object instance.
  6427. */
  6428. struct cheri_object
  6429. cheri_sandbox_make_sealed_invoke_object(
  6430. __capability struct sandbox_object *sbop)
  6431. {
  6432. struct cheri_object co;
  6433.  
  6434. co.co_codecap = cheri_ccall_invoke_sealed_code;
  6435.  
  6436. /*
  6437. * Pointer to sandbox description; struct sandbox_object must itself
  6438. * provide indirect access to a suitable DDC (etc) for the trampoline.
  6439. */
  6440. co.co_datacap = cheri_seal(sbop, cheri_ccall_invoke_type);
  6441. return (co);
  6442. }
  6443.  
  6444. struct cheri_object
  6445. cheri_sandbox_make_sealed_rtld_object(
  6446. __capability struct sandbox_object *sbop)
  6447. {
  6448. struct cheri_object co;
  6449.  
  6450. co.co_codecap = cheri_ccall_rtld_sealed_code;
  6451.  
  6452. /*
  6453. * Pointer to sandbox description; struct sandbox_object must itself
  6454. * provide indirect access to a suitable DDC (etc) for the trampoline.
  6455. */
  6456. co.co_datacap = cheri_seal(sbop, cheri_ccall_rtld_type);
  6457. return (co);
  6458. }
  6459.  
  6460. struct cheri_object
  6461. cheri_make_sealed_return_object(void)
  6462. {
  6463.  
  6464. return (cheri_creturn_object);
  6465. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement