FreeBSD Bugzilla – Attachment 154676 Details for
Bug 198806
kern_cons.c compiler internal error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
/tmp/kern_cons-b94774.c
kern_cons-b94774.c (text/plain), 935.52 KB, created by
Larry Rosenman
on 2015-03-22 21:27:14 UTC
(
hide
)
Description:
/tmp/kern_cons-b94774.c
Filename:
MIME Type:
Creator:
Larry Rosenman
Created:
2015-03-22 21:27:14 UTC
Size:
935.52 KB
patch
obsolete
># 1 "<built-in>" ># 1 "./opt_global.h" 1 >#define PCI_IOV 1 >#define AUDIT 1 >#define MAC 1 >#define INVARIANT_SUPPORT 1 >#define SMP 1 >#define XENHVM 1 >#define DEV_NETMAP 1 >#define INVARIANTS 1 >#define NEW_PCIB 1 >#define KDTRACE_HOOKS 1 >#define KDB 1 ># 1 "<built-in>" 2 ># 1 "/usr/src/sys/kern/kern_cons.c" >/*- > * Copyright (c) 1988 University of Utah. > * Copyright (c) 1991 The Regents of the University of California. > * Copyright (c) 1999 Michael Smith > * Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> > * > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * the Systems Programming Group of the University of Utah Computer > * Science Department. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)cons.c 7.2 (Berkeley) 5/9/91 > */ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/cdefs.h" 1 >/*- > * Copyright (c) 1991, 1993 > * The Regents of the University of California. All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * Berkeley Software Design, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 > * $FreeBSD: head/sys/sys/cdefs.h 280346 2015-03-22 15:37:05Z pfg $ > */ > >#ifndef _SYS_CDEFS_H_ >#define _SYS_CDEFS_H_ > >/* > * Testing against Clang-specific extensions. > */ > >#ifndef __has_extension >#define __has_extension __has_feature >#endif ># 46 "/usr/src/sys/sys/cdefs.h" >#ifndef __has_feature >#define __has_feature(x) 0 >#endif ># 49 "/usr/src/sys/sys/cdefs.h" >#ifndef __has_include >#define __has_include(x) 0 >#endif ># 52 "/usr/src/sys/sys/cdefs.h" >#ifndef __has_builtin >#define __has_builtin(x) 0 >#endif ># 55 "/usr/src/sys/sys/cdefs.h" > >#if defined(__cplusplus) >#define __BEGIN_DECLS extern "C" { >#define __END_DECLS } >#else ># 60 "/usr/src/sys/sys/cdefs.h" >#define __BEGIN_DECLS >#define __END_DECLS >#endif ># 63 "/usr/src/sys/sys/cdefs.h" > >/* > * This code has been put in place to help reduce the addition of > * compiler specific defines in FreeBSD code. It helps to aid in > * having a compiler-agnostic source tree. > */ > >#if defined(__GNUC__) || defined(__INTEL_COMPILER) > >#if __GNUC__ >= 3 || defined(__INTEL_COMPILER) >#define __GNUCLIKE_ASM 3 >#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS >#else ># 76 "/usr/src/sys/sys/cdefs.h" >#define __GNUCLIKE_ASM 2 >#endif ># 78 "/usr/src/sys/sys/cdefs.h" >#define __GNUCLIKE___TYPEOF 1 >#define __GNUCLIKE___OFFSETOF 1 >#define __GNUCLIKE___SECTION 1 > >#ifndef __INTEL_COMPILER ># define __GNUCLIKE_CTOR_SECTION_HANDLING 1 >#endif ># 85 "/usr/src/sys/sys/cdefs.h" > >#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 ># if defined(__INTEL_COMPILER) && defined(__cplusplus) \ > && __INTEL_COMPILER < 800 ># undef __GNUCLIKE_BUILTIN_CONSTANT_P ># endif ># 91 "/usr/src/sys/sys/cdefs.h" > >#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER) ># define __GNUCLIKE_BUILTIN_VARARGS 1 ># define __GNUCLIKE_BUILTIN_STDARG 1 ># define __GNUCLIKE_BUILTIN_VAALIST 1 >#endif ># 97 "/usr/src/sys/sys/cdefs.h" > >#if defined(__GNUC__) ># define __GNUC_VA_LIST_COMPATIBILITY 1 >#endif ># 101 "/usr/src/sys/sys/cdefs.h" > >/* > * Compiler memory barriers, specific to gcc and clang. > */ >#if defined(__GNUC__) >#define __compiler_membar() __asm __volatile(" " : : : "memory") >#endif ># 108 "/usr/src/sys/sys/cdefs.h" > >#ifndef __INTEL_COMPILER ># define __GNUCLIKE_BUILTIN_NEXT_ARG 1 ># define __GNUCLIKE_MATH_BUILTIN_RELOPS >#endif ># 113 "/usr/src/sys/sys/cdefs.h" > >#define __GNUCLIKE_BUILTIN_MEMCPY 1 > >/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ >#define __CC_SUPPORTS_INLINE 1 >#define __CC_SUPPORTS___INLINE 1 >#define __CC_SUPPORTS___INLINE__ 1 > >#define __CC_SUPPORTS___FUNC__ 1 >#define __CC_SUPPORTS_WARNING 1 > >#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ > >#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 > >#endif /* __GNUC__ || __INTEL_COMPILER */ ># 129 "/usr/src/sys/sys/cdefs.h" > >/* > * Macro to test if we're using a specific version of gcc or later. > */ >#if defined(__GNUC__) && !defined(__INTEL_COMPILER) >#define __GNUC_PREREQ__(ma, mi) \ > (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) >#else ># 137 "/usr/src/sys/sys/cdefs.h" >#define __GNUC_PREREQ__(ma, mi) 0 >#endif ># 139 "/usr/src/sys/sys/cdefs.h" > >/* > * The __CONCAT macro is used to concatenate parts of symbol names, e.g. > * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. > * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI > * mode -- there must be no spaces between its arguments, and for nested > * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also > * concatenate double-quoted strings produced by the __STRING macro, but > * this only works with ANSI C. > * > * __XSTRING is like __STRING, but it expands any macros in its argument > * first. It is only available with ANSI C. > */ >#if defined(__STDC__) || defined(__cplusplus) >#define __P(protos) protos /* full-blown ANSI C */ >#define __CONCAT1(x,y) x ## y >#define __CONCAT(x,y) __CONCAT1(x,y) >#define __STRING(x) #x /* stringify without expanding x */ >#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ > >#define __const const /* define reserved names to standard */ >#define __signed signed >#define __volatile volatile >#if defined(__cplusplus) >#define __inline inline /* convert to C++ keyword */ >#else ># 165 "/usr/src/sys/sys/cdefs.h" >#if !(defined(__CC_SUPPORTS___INLINE)) >#define __inline /* delete GCC keyword */ >#endif /* ! __CC_SUPPORTS___INLINE */ ># 168 "/usr/src/sys/sys/cdefs.h" >#endif /* !__cplusplus */ ># 169 "/usr/src/sys/sys/cdefs.h" > >#else /* !(__STDC__ || __cplusplus) */ ># 171 "/usr/src/sys/sys/cdefs.h" >#define __P(protos) () /* traditional C preprocessor */ >#define __CONCAT(x,y) x/**/y >#define __STRING(x) "x" > >#if !defined(__CC_SUPPORTS___INLINE) >#define __const /* delete pseudo-ANSI C keywords */ >#define __inline >#define __signed >#define __volatile >/* > * In non-ANSI C environments, new programs will want ANSI-only C keywords > * deleted from the program and old programs will want them left alone. > * When using a compiler other than gcc, programs using the ANSI C keywords > * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. > * When using "gcc -traditional", we assume that this is the intent; if > * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. > */ >#ifndef NO_ANSI_KEYWORDS >#define const /* delete ANSI C keywords */ >#define inline >#define signed >#define volatile >#endif /* !NO_ANSI_KEYWORDS */ ># 194 "/usr/src/sys/sys/cdefs.h" >#endif /* !__CC_SUPPORTS___INLINE */ ># 195 "/usr/src/sys/sys/cdefs.h" >#endif /* !(__STDC__ || __cplusplus) */ ># 196 "/usr/src/sys/sys/cdefs.h" > >/* > * Compiler-dependent macros to help declare dead (non-returning) and > * pure (no side effects) functions, and unused variables. They are > * null except for versions of gcc that are known to support the features > * properly (old versions of gcc-2 supported the dead and pure features > * in a different (wrong) way). If we do not provide an implementation > * for a given compiler, let the compile fail if it is told to use > * a feature that we cannot live without. > */ >#ifdef lint >#define __dead2 >#define __pure2 >#define __unused >#define __packed >#define __aligned(x) >#define __section(x) >#define __weak >#else ># 215 "/usr/src/sys/sys/cdefs.h" >#define __weak __attribute__((__weak__)) >#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) >#define __dead2 >#define __pure2 >#define __unused >#endif ># 221 "/usr/src/sys/sys/cdefs.h" >#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER) >#define __dead2 __attribute__((__noreturn__)) >#define __pure2 __attribute__((__const__)) >#define __unused >/* XXX Find out what to do for __packed, __aligned and __section */ >#endif ># 227 "/usr/src/sys/sys/cdefs.h" >#if __GNUC_PREREQ__(2, 7) >#define __dead2 __attribute__((__noreturn__)) >#define __pure2 __attribute__((__const__)) >#define __unused __attribute__((__unused__)) >#define __used __attribute__((__used__)) >#define __packed __attribute__((__packed__)) >#define __aligned(x) __attribute__((__aligned__(x))) >#define __section(x) __attribute__((__section__(x))) >#endif ># 236 "/usr/src/sys/sys/cdefs.h" >#if defined(__INTEL_COMPILER) >#define __dead2 __attribute__((__noreturn__)) >#define __pure2 __attribute__((__const__)) >#define __unused __attribute__((__unused__)) >#define __used __attribute__((__used__)) >#define __packed __attribute__((__packed__)) >#define __aligned(x) __attribute__((__aligned__(x))) >#define __section(x) __attribute__((__section__(x))) >#endif ># 245 "/usr/src/sys/sys/cdefs.h" >#endif ># 246 "/usr/src/sys/sys/cdefs.h" > >#if !__GNUC_PREREQ__(2, 95) >#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) >#endif ># 250 "/usr/src/sys/sys/cdefs.h" > >/* > * Keywords added in C11. > */ > >#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint) > >#if !__has_extension(c_alignas) >#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ > __has_extension(cxx_alignas) >#define _Alignas(x) alignas(x) >#else ># 262 "/usr/src/sys/sys/cdefs.h" >/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */ >#define _Alignas(x) __aligned(x) >#endif ># 265 "/usr/src/sys/sys/cdefs.h" >#endif ># 266 "/usr/src/sys/sys/cdefs.h" > >#if defined(__cplusplus) && __cplusplus >= 201103L >#define _Alignof(x) alignof(x) >#else ># 270 "/usr/src/sys/sys/cdefs.h" >#define _Alignof(x) __alignof(x) >#endif ># 272 "/usr/src/sys/sys/cdefs.h" > >#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) >/* > * No native support for _Atomic(). Place object in structure to prevent > * most forms of direct non-atomic access. > */ >#define _Atomic(T) struct { T volatile __val; } >#endif ># 280 "/usr/src/sys/sys/cdefs.h" > >#if defined(__cplusplus) && __cplusplus >= 201103L >#define _Noreturn [[noreturn]] >#else ># 284 "/usr/src/sys/sys/cdefs.h" >#define _Noreturn __dead2 >#endif ># 286 "/usr/src/sys/sys/cdefs.h" > >#if !__has_extension(c_static_assert) >#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ > __has_extension(cxx_static_assert) >#define _Static_assert(x, y) static_assert(x, y) >#elif __GNUC_PREREQ__(4,6) ># 292 "/usr/src/sys/sys/cdefs.h" >/* Nothing, gcc 4.6 and higher has _Static_assert built-in */ >#elif defined(__COUNTER__) ># 294 "/usr/src/sys/sys/cdefs.h" >#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) >#define __Static_assert(x, y) ___Static_assert(x, y) >#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \ > __unused >#else ># 299 "/usr/src/sys/sys/cdefs.h" >#define _Static_assert(x, y) struct __hack >#endif ># 301 "/usr/src/sys/sys/cdefs.h" >#endif ># 302 "/usr/src/sys/sys/cdefs.h" > >#if !__has_extension(c_thread_local) >/* > * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode > * without actually supporting the thread_local keyword. Don't check for > * the presence of C++11 when defining _Thread_local. > */ >#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ > __has_extension(cxx_thread_local) >#define _Thread_local thread_local >#else ># 313 "/usr/src/sys/sys/cdefs.h" >#define _Thread_local __thread >#endif ># 315 "/usr/src/sys/sys/cdefs.h" >#endif ># 316 "/usr/src/sys/sys/cdefs.h" > >#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */ ># 318 "/usr/src/sys/sys/cdefs.h" > >/* > * Emulation of C11 _Generic(). Unlike the previously defined C11 > * keywords, it is not possible to implement this using exactly the same > * syntax. Therefore implement something similar under the name > * __generic(). Unlike _Generic(), this macro can only distinguish > * between a single type, so it requires nested invocations to > * distinguish multiple cases. > */ > >#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ > __has_extension(c_generic_selections) >#define __generic(expr, t, yes, no) \ > _Generic(expr, t: yes, default: no) >#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) ># 333 "/usr/src/sys/sys/cdefs.h" >#define __generic(expr, t, yes, no) \ > __builtin_choose_expr( \ > __builtin_types_compatible_p(__typeof(expr), t), yes, no) >#endif ># 337 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(2, 96) >#define __malloc_like __attribute__((__malloc__)) >#define __pure __attribute__((__pure__)) >#else ># 342 "/usr/src/sys/sys/cdefs.h" >#define __malloc_like >#define __pure >#endif ># 345 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) >#define __always_inline __attribute__((__always_inline__)) >#else ># 349 "/usr/src/sys/sys/cdefs.h" >#define __always_inline >#endif ># 351 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 1) >#define __noinline __attribute__ ((__noinline__)) >#else ># 355 "/usr/src/sys/sys/cdefs.h" >#define __noinline >#endif ># 357 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 3) >#define __nonnull(...) __attribute__((__nonnull__(__VA_ARGS__))) >#else ># 361 "/usr/src/sys/sys/cdefs.h" >#define __nonnull(...) >#endif ># 363 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 4) >#define __fastcall __attribute__((__fastcall__)) >#else ># 367 "/usr/src/sys/sys/cdefs.h" >#define __fastcall >#endif ># 369 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(4, 1) >#define __returns_twice __attribute__((__returns_twice__)) >#else ># 373 "/usr/src/sys/sys/cdefs.h" >#define __returns_twice >#endif ># 375 "/usr/src/sys/sys/cdefs.h" > >/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ >#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) >#define __func__ NULL >#endif ># 380 "/usr/src/sys/sys/cdefs.h" > >#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 >#define __LONG_LONG_SUPPORTED >#endif ># 384 "/usr/src/sys/sys/cdefs.h" > >/* C++11 exposes a load of C99 stuff */ >#if defined(__cplusplus) && __cplusplus >= 201103L >#define __LONG_LONG_SUPPORTED >#ifndef __STDC_LIMIT_MACROS >#define __STDC_LIMIT_MACROS >#endif ># 391 "/usr/src/sys/sys/cdefs.h" >#ifndef __STDC_CONSTANT_MACROS >#define __STDC_CONSTANT_MACROS >#endif ># 394 "/usr/src/sys/sys/cdefs.h" >#endif ># 395 "/usr/src/sys/sys/cdefs.h" > >/* > * GCC 2.95 provides `__restrict' as an extension to C90 to support the > * C99-specific `restrict' type qualifier. We happen to use `__restrict' as > * a way to define the `restrict' type qualifier without disturbing older > * software that is unaware of C99 keywords. > */ >#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) >#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint) >#define __restrict >#else ># 406 "/usr/src/sys/sys/cdefs.h" >#define __restrict restrict >#endif ># 408 "/usr/src/sys/sys/cdefs.h" >#endif ># 409 "/usr/src/sys/sys/cdefs.h" > >/* > * GNU C version 2.96 adds explicit branch prediction so that > * the CPU back-end can hint the processor and also so that > * code blocks can be reordered such that the predicted path > * sees a more linear flow, thus improving cache behavior, etc. > * > * The following two macros provide us with a way to utilize this > * compiler feature. Use __predict_true() if you expect the expression > * to evaluate to true, and __predict_false() if you expect the > * expression to evaluate to false. > * > * A few notes about usage: > * > * * Generally, __predict_false() error condition checks (unless > * you have some _strong_ reason to do otherwise, in which case > * document it), and/or __predict_true() `no-error' condition > * checks, assuming you want to optimize for the no-error case. > * > * * Other than that, if you don't know the likelihood of a test > * succeeding from empirical or other `hard' evidence, don't > * make predictions. > * > * * These are meant to be used in places that are run `a lot'. > * It is wasteful to make predictions in code that is run > * seldomly (e.g. at subsystem initialization time) as the > * basic block reordering that this affects can often generate > * larger code. > */ >#if __GNUC_PREREQ__(2, 96) >#define __predict_true(exp) __builtin_expect((exp), 1) >#define __predict_false(exp) __builtin_expect((exp), 0) >#else ># 442 "/usr/src/sys/sys/cdefs.h" >#define __predict_true(exp) (exp) >#define __predict_false(exp) (exp) >#endif ># 445 "/usr/src/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(4, 2) >#define __hidden __attribute__((__visibility__("hidden"))) >#define __exported __attribute__((__visibility__("default"))) >#else ># 450 "/usr/src/sys/sys/cdefs.h" >#define __hidden >#define __exported >#endif ># 453 "/usr/src/sys/sys/cdefs.h" > >/* > * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> > * require it. > */ >#if __GNUC_PREREQ__(4, 1) >#define __offsetof(type, field) __builtin_offsetof(type, field) >#else ># 461 "/usr/src/sys/sys/cdefs.h" >#ifndef __cplusplus >#define __offsetof(type, field) \ > ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) >#else ># 465 "/usr/src/sys/sys/cdefs.h" >#define __offsetof(type, field) \ > (__offsetof__ (reinterpret_cast <__size_t> \ > (&reinterpret_cast <const volatile char &> \ > (static_cast<type *> (0)->field)))) >#endif ># 470 "/usr/src/sys/sys/cdefs.h" >#endif ># 471 "/usr/src/sys/sys/cdefs.h" >#define __rangeof(type, start, end) \ > (__offsetof(type, end) - __offsetof(type, start)) > >/* > * Given the pointer x to the member m of the struct s, return > * a pointer to the containing structure. When using GCC, we first > * assign pointer x to a local variable, to check that its type is > * compatible with member m. > */ >#if __GNUC_PREREQ__(3, 1) >#define __containerof(x, s, m) ({ \ > const volatile __typeof(((s *)0)->m) *__x = (x); \ > __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ >}) >#else ># 486 "/usr/src/sys/sys/cdefs.h" >#define __containerof(x, s, m) \ > __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) >#endif ># 489 "/usr/src/sys/sys/cdefs.h" > >/* > * Compiler-dependent macros to declare that functions take printf-like > * or scanf-like arguments. They are null except for versions of gcc > * that are known to support the features properly (old versions of gcc-2 > * didn't permit keeping the keywords out of the application namespace). > */ >#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) >#define __printflike(fmtarg, firstvararg) >#define __scanflike(fmtarg, firstvararg) >#define __format_arg(fmtarg) >#define __strfmonlike(fmtarg, firstvararg) >#define __strftimelike(fmtarg, firstvararg) >#else ># 503 "/usr/src/sys/sys/cdefs.h" >#define __printflike(fmtarg, firstvararg) \ > __attribute__((__format__ (__printf__, fmtarg, firstvararg))) >#define __scanflike(fmtarg, firstvararg) \ > __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) >#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) >#define __strfmonlike(fmtarg, firstvararg) \ > __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) >#define __strftimelike(fmtarg, firstvararg) \ > __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) >#endif ># 513 "/usr/src/sys/sys/cdefs.h" > >/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ >#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ > defined(__GNUC__) && !defined(__INTEL_COMPILER) >#define __printf0like(fmtarg, firstvararg) \ > __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) >#else ># 520 "/usr/src/sys/sys/cdefs.h" >#define __printf0like(fmtarg, firstvararg) >#endif ># 522 "/usr/src/sys/sys/cdefs.h" > >#if defined(__GNUC__) || defined(__INTEL_COMPILER) >#ifndef __INTEL_COMPILER >#define __strong_reference(sym,aliassym) \ > extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) >#endif ># 528 "/usr/src/sys/sys/cdefs.h" >#ifdef __STDC__ >#define __weak_reference(sym,alias) \ > __asm__(".weak " #alias); \ > __asm__(".equ " #alias ", " #sym) >#define __warn_references(sym,msg) \ > __asm__(".section .gnu.warning." #sym); \ > __asm__(".asciz \"" msg "\""); \ > __asm__(".previous") >#define __sym_compat(sym,impl,verid) \ > __asm__(".symver " #impl ", " #sym "@" #verid) >#define __sym_default(sym,impl,verid) \ > __asm__(".symver " #impl ", " #sym "@@" #verid) >#else ># 541 "/usr/src/sys/sys/cdefs.h" >#define __weak_reference(sym,alias) \ > __asm__(".weak alias"); \ > __asm__(".equ alias, sym") >#define __warn_references(sym,msg) \ > __asm__(".section .gnu.warning.sym"); \ > __asm__(".asciz \"msg\""); \ > __asm__(".previous") >#define __sym_compat(sym,impl,verid) \ > __asm__(".symver impl, sym@verid") >#define __sym_default(impl,sym,verid) \ > __asm__(".symver impl, sym@@verid") >#endif /* __STDC__ */ ># 553 "/usr/src/sys/sys/cdefs.h" >#endif /* __GNUC__ || __INTEL_COMPILER */ ># 554 "/usr/src/sys/sys/cdefs.h" > >#define __GLOBL1(sym) __asm__(".globl " #sym) >#define __GLOBL(sym) __GLOBL1(sym) > >#if defined(__GNUC__) || defined(__INTEL_COMPILER) >#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"") >#else ># 561 "/usr/src/sys/sys/cdefs.h" >/* > * The following definition might not work well if used in header files, > * but it should be better than nothing. If you want a "do nothing" > * version, then it should generate some harmless declaration, such as: > * #define __IDSTRING(name,string) struct __hack > */ >#define __IDSTRING(name,string) static const char name[] __unused = string >#endif ># 569 "/usr/src/sys/sys/cdefs.h" > >/* > * Embed the rcs id of a source file in the resulting library. Note that in > * more recent ELF binutils, we use .ident allowing the ID to be stripped. > * Usage: > * __FBSDID("$FreeBSD: head/sys/sys/cdefs.h 280346 2015-03-22 15:37:05Z pfg $"); > */ >#ifndef __FBSDID >#if !defined(lint) && !defined(STRIP_FBSDID) >#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) >#else ># 580 "/usr/src/sys/sys/cdefs.h" >#define __FBSDID(s) struct __hack >#endif ># 582 "/usr/src/sys/sys/cdefs.h" >#endif ># 583 "/usr/src/sys/sys/cdefs.h" > >#ifndef __RCSID >#ifndef NO__RCSID >#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) >#else ># 588 "/usr/src/sys/sys/cdefs.h" >#define __RCSID(s) struct __hack >#endif ># 590 "/usr/src/sys/sys/cdefs.h" >#endif ># 591 "/usr/src/sys/sys/cdefs.h" > >#ifndef __RCSID_SOURCE >#ifndef NO__RCSID_SOURCE >#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s) >#else ># 596 "/usr/src/sys/sys/cdefs.h" >#define __RCSID_SOURCE(s) struct __hack >#endif ># 598 "/usr/src/sys/sys/cdefs.h" >#endif ># 599 "/usr/src/sys/sys/cdefs.h" > >#ifndef __SCCSID >#ifndef NO__SCCSID >#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s) >#else ># 604 "/usr/src/sys/sys/cdefs.h" >#define __SCCSID(s) struct __hack >#endif ># 606 "/usr/src/sys/sys/cdefs.h" >#endif ># 607 "/usr/src/sys/sys/cdefs.h" > >#ifndef __COPYRIGHT >#ifndef NO__COPYRIGHT >#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s) >#else ># 612 "/usr/src/sys/sys/cdefs.h" >#define __COPYRIGHT(s) struct __hack >#endif ># 614 "/usr/src/sys/sys/cdefs.h" >#endif ># 615 "/usr/src/sys/sys/cdefs.h" > >#ifndef __DECONST >#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) >#endif ># 619 "/usr/src/sys/sys/cdefs.h" > >#ifndef __DEVOLATILE >#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) >#endif ># 623 "/usr/src/sys/sys/cdefs.h" > >#ifndef __DEQUALIFY >#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) >#endif ># 627 "/usr/src/sys/sys/cdefs.h" > >/*- > * The following definitions are an extension of the behavior originally > * implemented in <sys/_posix.h>, but with a different level of granularity. > * POSIX.1 requires that the macros we test be defined before any standard > * header file is included. > * > * Here's a quick run-down of the versions: > * defined(_POSIX_SOURCE) 1003.1-1988 > * _POSIX_C_SOURCE == 1 1003.1-1990 > * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option > * _POSIX_C_SOURCE == 199309 1003.1b-1993 > * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, > * and the omnibus ISO/IEC 9945-1: 1996 > * _POSIX_C_SOURCE == 200112 1003.1-2001 > * _POSIX_C_SOURCE == 200809 1003.1-2008 > * > * In addition, the X/Open Portability Guide, which is now the Single UNIX > * Specification, defines a feature-test macro which indicates the version of > * that specification, and which subsumes _POSIX_C_SOURCE. > * > * Our macros begin with two underscores to avoid namespace screwage. > */ > >/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ >#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 >#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ >#define _POSIX_C_SOURCE 199009 >#endif ># 656 "/usr/src/sys/sys/cdefs.h" > >/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ >#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 199209 >#endif ># 662 "/usr/src/sys/sys/cdefs.h" > >/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ >#ifdef _XOPEN_SOURCE >#if _XOPEN_SOURCE - 0 >= 700 >#define __XSI_VISIBLE 700 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 200809 >#elif _XOPEN_SOURCE - 0 >= 600 ># 670 "/usr/src/sys/sys/cdefs.h" >#define __XSI_VISIBLE 600 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 200112 >#elif _XOPEN_SOURCE - 0 >= 500 ># 674 "/usr/src/sys/sys/cdefs.h" >#define __XSI_VISIBLE 500 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 199506 >#endif ># 678 "/usr/src/sys/sys/cdefs.h" >#endif ># 679 "/usr/src/sys/sys/cdefs.h" > >/* > * Deal with all versions of POSIX. The ordering relative to the tests above is > * important. > */ >#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) >#define _POSIX_C_SOURCE 198808 >#endif ># 687 "/usr/src/sys/sys/cdefs.h" >#ifdef _POSIX_C_SOURCE >#if _POSIX_C_SOURCE >= 200809 >#define __POSIX_VISIBLE 200809 >#define __ISO_C_VISIBLE 1999 >#elif _POSIX_C_SOURCE >= 200112 ># 692 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 200112 >#define __ISO_C_VISIBLE 1999 >#elif _POSIX_C_SOURCE >= 199506 ># 695 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199506 >#define __ISO_C_VISIBLE 1990 >#elif _POSIX_C_SOURCE >= 199309 ># 698 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199309 >#define __ISO_C_VISIBLE 1990 >#elif _POSIX_C_SOURCE >= 199209 ># 701 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199209 >#define __ISO_C_VISIBLE 1990 >#elif _POSIX_C_SOURCE >= 199009 ># 704 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199009 >#define __ISO_C_VISIBLE 1990 >#else ># 707 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 198808 >#define __ISO_C_VISIBLE 0 >#endif /* _POSIX_C_SOURCE */ ># 710 "/usr/src/sys/sys/cdefs.h" >#else ># 711 "/usr/src/sys/sys/cdefs.h" >/*- > * Deal with _ANSI_SOURCE: > * If it is defined, and no other compilation environment is explicitly > * requested, then define our internal feature-test macros to zero. This > * makes no difference to the preprocessor (undefined symbols in preprocessing > * expressions are defined to have value zero), but makes it more convenient for > * a test program to print out the values. > * > * If a program mistakenly defines _ANSI_SOURCE and some other macro such as > * _POSIX_C_SOURCE, we will assume that it wants the broader compilation > * environment (and in fact we will never get here). > */ >#if defined(_ANSI_SOURCE) /* Hide almost everything. */ >#define __POSIX_VISIBLE 0 >#define __XSI_VISIBLE 0 >#define __BSD_VISIBLE 0 >#define __ISO_C_VISIBLE 1990 >#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ ># 729 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 0 >#define __XSI_VISIBLE 0 >#define __BSD_VISIBLE 0 >#define __ISO_C_VISIBLE 1999 >#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ ># 734 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 0 >#define __XSI_VISIBLE 0 >#define __BSD_VISIBLE 0 >#define __ISO_C_VISIBLE 2011 >#else /* Default environment: show everything. */ ># 739 "/usr/src/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 200809 >#define __XSI_VISIBLE 700 >#define __BSD_VISIBLE 1 >#define __ISO_C_VISIBLE 2011 >#endif ># 744 "/usr/src/sys/sys/cdefs.h" >#endif ># 745 "/usr/src/sys/sys/cdefs.h" > >#if defined(__mips) || defined(__powerpc64__) >#define __NO_TLS 1 >#endif ># 749 "/usr/src/sys/sys/cdefs.h" > >/* > * Lock annotations. > * > * Clang provides support for doing basic thread-safety tests at > * compile-time, by marking which locks will/should be held when > * entering/leaving a functions. > * > * Furthermore, it is also possible to annotate variables and structure > * members to enforce that they are only accessed when certain locks are > * held. > */ > >#if __has_extension(c_thread_safety_attributes) >#define __lock_annotate(x) __attribute__((x)) >#else ># 765 "/usr/src/sys/sys/cdefs.h" >#define __lock_annotate(x) >#endif ># 767 "/usr/src/sys/sys/cdefs.h" > >/* Structure implements a lock. */ >#define __lockable __lock_annotate(lockable) > >/* Function acquires an exclusive or shared lock. */ >#define __locks_exclusive(...) \ > __lock_annotate(exclusive_lock_function(__VA_ARGS__)) >#define __locks_shared(...) \ > __lock_annotate(shared_lock_function(__VA_ARGS__)) > >/* Function attempts to acquire an exclusive or shared lock. */ >#define __trylocks_exclusive(...) \ > __lock_annotate(exclusive_trylock_function(__VA_ARGS__)) >#define __trylocks_shared(...) \ > __lock_annotate(shared_trylock_function(__VA_ARGS__)) > >/* Function releases a lock. */ >#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__)) > >/* Function asserts that an exclusive or shared lock is held. */ >#define __asserts_exclusive(...) \ > __lock_annotate(assert_exclusive_lock(__VA_ARGS__)) >#define __asserts_shared(...) \ > __lock_annotate(assert_shared_lock(__VA_ARGS__)) > >/* Function requires that an exclusive or shared lock is or is not held. */ >#define __requires_exclusive(...) \ > __lock_annotate(exclusive_locks_required(__VA_ARGS__)) >#define __requires_shared(...) \ > __lock_annotate(shared_locks_required(__VA_ARGS__)) >#define __requires_unlocked(...) \ > __lock_annotate(locks_excluded(__VA_ARGS__)) > >/* Function should not be analyzed. */ >#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis) > >/* Guard variables and structure members by lock. */ >#define __guarded_by(x) __lock_annotate(guarded_by(x)) >#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x)) > >#endif /* !_SYS_CDEFS_H_ */ ># 808 "/usr/src/sys/sys/cdefs.h" ># 41 "/usr/src/sys/kern/kern_cons.c" 2 >__FBSDID("$FreeBSD: head/sys/kern/kern_cons.c 280015 2015-03-15 00:36:08Z ian $"); > >#if 0 /* expanded by -frewrite-includes */ >#include "opt_ddb.h" >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/kern/kern_cons.c" ># 1 "./opt_ddb.h" 1 >#define DDB 1 >#define DDB_CTF 1 ># 44 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include "opt_syscons.h" >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/kern/kern_cons.c" ># 1 "./opt_syscons.h" 1 >#define SC_PIXEL_MODE 1 >#define DEV_VT 1 >#define DEV_SC 1 ># 45 "/usr/src/sys/kern/kern_cons.c" 2 > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/param.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)param.h 8.3 (Berkeley) 4/4/95 > * $FreeBSD: head/sys/sys/param.h 280306 2015-03-20 23:48:11Z jkim $ > */ > >#ifndef _SYS_PARAM_H_ >#define _SYS_PARAM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_null.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/param.h" ># 1 "/usr/src/sys/sys/_null.h" 1 >/*- > * Copyright (c) 2003 Marcel Moolenaar > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_null.h 228918 2011-12-27 21:36:31Z theraven $ > */ > >#ifndef NULL > >#if !defined(__cplusplus) >#define NULL ((void *)0) >#else ># 34 "/usr/src/sys/sys/_null.h" >#if __cplusplus >= 201103L >#define NULL nullptr >#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 ># 37 "/usr/src/sys/sys/_null.h" >#define NULL __null >#else ># 39 "/usr/src/sys/sys/_null.h" >#if defined(__LP64__) >#define NULL (0L) >#else ># 42 "/usr/src/sys/sys/_null.h" >#define NULL 0 >#endif /* __LP64__ */ ># 44 "/usr/src/sys/sys/_null.h" >#endif /* __GNUG__ */ ># 45 "/usr/src/sys/sys/_null.h" >#endif /* !__cplusplus */ ># 46 "/usr/src/sys/sys/_null.h" > >#endif ># 48 "/usr/src/sys/sys/_null.h" ># 42 "/usr/src/sys/sys/param.h" 2 > >#define BSD 199506 /* System version (year & month). */ >#define BSD4_3 1 >#define BSD4_4 1 > >/* > * __FreeBSD_version numbers are documented in the Porter's Handbook. > * If you bump the version for any reason, you should update the documentation > * there. > * Currently this lives here in the doc/ repository: > * > * head/en_US.ISO8859-1/books/porters-handbook/book.xml > * > * scheme is: <major><two digit minor>Rxx > * 'R' is in the range 0 to 4 if this is a release branch or > * x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is > * in the range 5 to 9. > */ >#undef __FreeBSD_version >#define __FreeBSD_version 1100066 /* Master, propagated to newvers */ > >/* > * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, > * which by definition is always true on FreeBSD. This macro is also defined > * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD. > * > * It is tempting to use this macro in userland code when we want to enable > * kernel-specific routines, and in fact it's fine to do this in code that > * is part of FreeBSD itself. However, be aware that as presence of this > * macro is still not widespread (e.g. older FreeBSD versions, 3rd party > * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in > * external applications without also checking for __FreeBSD__ as an > * alternative. > */ >#undef __FreeBSD_kernel__ >#define __FreeBSD_kernel__ > >#ifdef _KERNEL >#define P_OSREL_SIGWAIT 700000 >#define P_OSREL_SIGSEGV 700004 >#define P_OSREL_MAP_ANON 800104 >#define P_OSREL_MAP_FSTRICT 1100036 > >#define P_OSREL_MAJOR(x) ((x) / 100000) >#endif ># 87 "/usr/src/sys/sys/param.h" > >#ifndef LOCORE >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 89 "/usr/src/sys/sys/param.h" ># 1 "/usr/src/sys/sys/types.h" 1 >/*- > * Copyright (c) 1982, 1986, 1991, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)types.h 8.6 (Berkeley) 2/19/95 > * $FreeBSD: head/sys/sys/types.h 280279 2015-03-20 10:27:06Z jhb $ > */ > >#ifndef _SYS_TYPES_H_ >#define _SYS_TYPES_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/types.h" ># 42 "/usr/src/sys/sys/types.h" > >/* Machine type dependent parameters. */ >#if 0 /* expanded by -frewrite-includes */ >#include <machine/endian.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/types.h" ># 1 "./machine/endian.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/endian.h 232266 2012-02-28 19:39:54Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/endian.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/endian.h" ># 1 "./x86/endian.h" 1 >/*- > * Copyright (c) 1987, 1991 Regents of the University of California. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)endian.h 7.8 (Berkeley) 4/3/91 > * $FreeBSD: head/sys/x86/include/endian.h 233684 2012-03-29 23:31:48Z dim $ > */ > >#ifndef _MACHINE_ENDIAN_H_ >#define _MACHINE_ENDIAN_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "./x86/endian.h" ># 37 "./x86/endian.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "./x86/endian.h" ># 1 "/usr/src/sys/sys/_types.h" 1 >/*- > * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_types.h 276660 2015-01-04 15:26:02Z kevlo $ > */ > >#ifndef _SYS__TYPES_H_ >#define _SYS__TYPES_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/_types.h" ># 33 "/usr/src/sys/sys/_types.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_types.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/sys/sys/_types.h" ># 1 "./machine/_types.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/_types.h 232261 2012-02-28 18:15:28Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_types.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_types.h" ># 1 "./x86/_types.h" 1 >/*- > * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 > * From: @(#)types.h 8.3 (Berkeley) 1/5/94 > * $FreeBSD: head/sys/x86/include/_types.h 263998 2014-04-01 14:46:11Z tijl $ > */ > >#ifndef _MACHINE__TYPES_H_ >#define _MACHINE__TYPES_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 45 "./x86/_types.h" > >#define __NO_STRICT_ALIGNMENT > >/* > * Basic types upon which most other types are built. > */ >typedef signed char __int8_t; >typedef unsigned char __uint8_t; >typedef short __int16_t; >typedef unsigned short __uint16_t; >typedef int __int32_t; >typedef unsigned int __uint32_t; >#ifdef __LP64__ >typedef long __int64_t; >typedef unsigned long __uint64_t; >#else ># 61 "./x86/_types.h" >#ifndef lint >__extension__ >#endif ># 64 "./x86/_types.h" >/* LONGLONG */ >typedef long long __int64_t; >#ifndef lint >__extension__ >#endif ># 69 "./x86/_types.h" >/* LONGLONG */ >typedef unsigned long long __uint64_t; >#endif ># 72 "./x86/_types.h" > >/* > * Standard type definitions. > */ >#ifdef __LP64__ >typedef __int32_t __clock_t; /* clock()... */ >typedef __int64_t __critical_t; >typedef double __double_t; >typedef float __float_t; >typedef __int64_t __intfptr_t; >typedef __int64_t __intptr_t; >#else ># 84 "./x86/_types.h" >typedef unsigned long __clock_t; >typedef __int32_t __critical_t; >typedef long double __double_t; >typedef long double __float_t; >typedef __int32_t __intfptr_t; >typedef __int32_t __intptr_t; >#endif ># 91 "./x86/_types.h" >typedef __int64_t __intmax_t; >typedef __int32_t __int_fast8_t; >typedef __int32_t __int_fast16_t; >typedef __int32_t __int_fast32_t; >typedef __int64_t __int_fast64_t; >typedef __int8_t __int_least8_t; >typedef __int16_t __int_least16_t; >typedef __int32_t __int_least32_t; >typedef __int64_t __int_least64_t; >#ifdef __LP64__ >typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */ >typedef __int64_t __register_t; >typedef __int64_t __segsz_t; /* segment size (in pages) */ >typedef __uint64_t __size_t; /* sizeof() */ >typedef __int64_t __ssize_t; /* byte count or error */ >typedef __int64_t __time_t; /* time()... */ >typedef __uint64_t __uintfptr_t; >typedef __uint64_t __uintptr_t; >#else ># 110 "./x86/_types.h" >typedef __int32_t __ptrdiff_t; >typedef __int32_t __register_t; >typedef __int32_t __segsz_t; >typedef __uint32_t __size_t; >typedef __int32_t __ssize_t; >typedef __int32_t __time_t; >typedef __uint32_t __uintfptr_t; >typedef __uint32_t __uintptr_t; >#endif ># 119 "./x86/_types.h" >typedef __uint64_t __uintmax_t; >typedef __uint32_t __uint_fast8_t; >typedef __uint32_t __uint_fast16_t; >typedef __uint32_t __uint_fast32_t; >typedef __uint64_t __uint_fast64_t; >typedef __uint8_t __uint_least8_t; >typedef __uint16_t __uint_least16_t; >typedef __uint32_t __uint_least32_t; >typedef __uint64_t __uint_least64_t; >#ifdef __LP64__ >typedef __uint64_t __u_register_t; >typedef __uint64_t __vm_offset_t; >typedef __uint64_t __vm_paddr_t; >typedef __uint64_t __vm_size_t; >#else ># 134 "./x86/_types.h" >typedef __uint32_t __u_register_t; >typedef __uint32_t __vm_offset_t; >#ifdef PAE >typedef __uint64_t __vm_paddr_t; >#else ># 139 "./x86/_types.h" >typedef __uint32_t __vm_paddr_t; >#endif ># 141 "./x86/_types.h" >typedef __uint32_t __vm_size_t; >#endif ># 143 "./x86/_types.h" >typedef __int64_t __vm_ooffset_t; >typedef __uint64_t __vm_pindex_t; >typedef int ___wchar_t; > >#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */ >#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */ > >/* > * Unusual type definitions. > */ >#ifdef __GNUCLIKE_BUILTIN_VARARGS >typedef __builtin_va_list __va_list; /* internally known to gcc */ >#elif defined(lint) ># 156 "./x86/_types.h" >typedef char * __va_list; /* pretend */ >#endif ># 158 "./x86/_types.h" >#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \ > && !defined(__NO_GNUC_VA_LIST) >#define __GNUC_VA_LIST >typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/ >#endif ># 163 "./x86/_types.h" > >#endif /* !_MACHINE__TYPES_H_ */ ># 165 "./x86/_types.h" ># 7 "./machine/_types.h" 2 ># 34 "/usr/src/sys/sys/_types.h" 2 > >/* > * Standard type definitions. > */ >typedef __int32_t __blksize_t; /* file block size */ >typedef __int64_t __blkcnt_t; /* file block count */ >typedef __int32_t __clockid_t; /* clock_gettime()... */ >typedef __uint32_t __fflags_t; /* file flags */ >typedef __uint64_t __fsblkcnt_t; >typedef __uint64_t __fsfilcnt_t; >typedef __uint32_t __gid_t; >typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */ >typedef __uint32_t __ino_t; /* inode number */ >typedef long __key_t; /* IPC key (for Sys V IPC) */ >typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */ >typedef __uint16_t __mode_t; /* permissions */ >typedef int __accmode_t; /* access permissions */ >typedef int __nl_item; >typedef __uint16_t __nlink_t; /* link count */ >typedef __int64_t __off_t; /* file offset */ >typedef __int32_t __pid_t; /* process [group] */ >typedef __int64_t __rlim_t; /* resource limit - intentionally */ > /* signed, because of legacy code */ > /* that uses -1 for RLIM_INFINITY */ >typedef __uint8_t __sa_family_t; >typedef __uint32_t __socklen_t; >typedef long __suseconds_t; /* microseconds (signed) */ >typedef struct __timer *__timer_t; /* timer_gettime()... */ >typedef struct __mq *__mqd_t; /* mq_open()... */ >typedef __uint32_t __uid_t; >typedef unsigned int __useconds_t; /* microseconds (unsigned) */ >typedef int __cpuwhich_t; /* which parameter for cpuset. */ >typedef int __cpulevel_t; /* level parameter for cpuset. */ >typedef int __cpusetid_t; /* cpuset identifier. */ > >/* > * Unusual type definitions. > */ >/* > * rune_t is declared to be an ``int'' instead of the more natural > * ``unsigned long'' or ``long''. Two things are happening here. It is not > * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, > * it looks like 10646 will be a 31 bit standard. This means that if your > * ints cannot hold 32 bits, you will be in trouble. The reason an int was > * chosen over a long is that the is*() and to*() routines take ints (says > * ANSI C), but they use __ct_rune_t instead of int. > * > * NOTE: rune_t is not covered by ANSI nor other standards, and should not > * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and > * rune_t must be the same type. Also, wint_t should be able to hold all > * members of the largest character set plus one extra value (WEOF), and > * must be at least 16 bits. > */ >typedef int __ct_rune_t; /* arg type for ctype funcs */ >typedef __ct_rune_t __rune_t; /* rune_t (see above) */ >typedef __ct_rune_t __wint_t; /* wint_t (see above) */ > >/* Clang already provides these types as built-ins, but only in C++ mode. */ >#if !defined(__clang__) || !defined(__cplusplus) >typedef __uint_least16_t __char16_t; >typedef __uint_least32_t __char32_t; >#endif ># 96 "/usr/src/sys/sys/_types.h" >/* In C++11, char16_t and char32_t are built-in types. */ >#if defined(__cplusplus) && __cplusplus >= 201103L >#define _CHAR16_T_DECLARED >#define _CHAR32_T_DECLARED >#endif ># 101 "/usr/src/sys/sys/_types.h" > >typedef __uint32_t __dev_t; /* device number */ > >typedef __uint32_t __fixpt_t; /* fixed point number */ > >/* > * mbstate_t is an opaque object to keep conversion state during multibyte > * stream conversions. > */ >typedef union { > char __mbstate8[128]; > __int64_t _mbstateL; /* for alignment */ >} __mbstate_t; > >#endif /* !_SYS__TYPES_H_ */ ># 116 "/usr/src/sys/sys/_types.h" ># 38 "./x86/endian.h" 2 > >/* > * Define the order of 32-bit words in 64-bit words. > */ >#define _QUAD_HIGHWORD 1 >#define _QUAD_LOWWORD 0 > >/* > * Definitions for byte order, according to byte significance from low > * address to high. > */ >#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ >#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ >#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ > >#define _BYTE_ORDER _LITTLE_ENDIAN > >/* > * Deprecated variants that don't have enough underscores to be useful in more > * strict namespaces. > */ >#if __BSD_VISIBLE >#define LITTLE_ENDIAN _LITTLE_ENDIAN >#define BIG_ENDIAN _BIG_ENDIAN >#define PDP_ENDIAN _PDP_ENDIAN >#define BYTE_ORDER _BYTE_ORDER >#endif ># 65 "./x86/endian.h" > >#define __bswap16_gen(x) (__uint16_t)((x) << 8 | (x) >> 8) >#define __bswap32_gen(x) \ > (((__uint32_t)__bswap16((x) & 0xffff) << 16) | __bswap16((x) >> 16)) >#define __bswap64_gen(x) \ > (((__uint64_t)__bswap32((x) & 0xffffffff) << 32) | __bswap32((x) >> 32)) > >#ifdef __GNUCLIKE_BUILTIN_CONSTANT_P >#define __bswap16(x) \ > ((__uint16_t)(__builtin_constant_p(x) ? \ > __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) >#define __bswap32(x) \ > (__builtin_constant_p(x) ? \ > __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x)) >#define __bswap64(x) \ > (__builtin_constant_p(x) ? \ > __bswap64_gen((__uint64_t)(x)) : __bswap64_var(x)) >#else ># 83 "./x86/endian.h" >/* XXX these are broken for use in static initializers. */ >#define __bswap16(x) __bswap16_var(x) >#define __bswap32(x) __bswap32_var(x) >#define __bswap64(x) __bswap64_var(x) >#endif ># 88 "./x86/endian.h" > >/* These are defined as functions to avoid multiple evaluation of x. */ > >static __inline __uint16_t >__bswap16_var(__uint16_t _x) >{ > > return (__bswap16_gen(_x)); >} > >static __inline __uint32_t >__bswap32_var(__uint32_t _x) >{ > >#ifdef __GNUCLIKE_ASM > __asm("bswap %0" : "+r" (_x)); > return (_x); >#else ># 106 "./x86/endian.h" > return (__bswap32_gen(_x)); >#endif ># 108 "./x86/endian.h" >} > >static __inline __uint64_t >__bswap64_var(__uint64_t _x) >{ > >#if defined(__amd64__) && defined(__GNUCLIKE_ASM) > __asm("bswap %0" : "+r" (_x)); > return (_x); >#else ># 118 "./x86/endian.h" > /* > * It is important for the optimizations that the following is not > * really generic, but expands to 2 __bswap32_var()'s. > */ > return (__bswap64_gen(_x)); >#endif ># 124 "./x86/endian.h" >} > >#define __htonl(x) __bswap32(x) >#define __htons(x) __bswap16(x) >#define __ntohl(x) __bswap32(x) >#define __ntohs(x) __bswap16(x) > >#endif /* !_MACHINE_ENDIAN_H_ */ ># 132 "./x86/endian.h" ># 7 "./machine/endian.h" 2 ># 45 "/usr/src/sys/sys/types.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/types.h" ># 46 "/usr/src/sys/sys/types.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_pthreadtypes.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/sys/sys/types.h" ># 1 "/usr/src/sys/sys/_pthreadtypes.h" 1 >/* > * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu > * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Chris Provenzano. > * 4. The name of Chris Provenzano may not be used to endorse or promote > * products derived from this software without specific prior written > * permission. > * > * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_pthreadtypes.h 189828 2009-03-14 20:10:14Z das $ > */ > >#ifndef _SYS__PTHREADTYPES_H_ >#define _SYS__PTHREADTYPES_H_ > >/* > * Forward structure definitions. > * > * These are mostly opaque to the user. > */ >struct pthread; >struct pthread_attr; >struct pthread_cond; >struct pthread_cond_attr; >struct pthread_mutex; >struct pthread_mutex_attr; >struct pthread_once; >struct pthread_rwlock; >struct pthread_rwlockattr; >struct pthread_barrier; >struct pthread_barrier_attr; >struct pthread_spinlock; > >/* > * Primitive system data type definitions required by P1003.1c. > * > * Note that P1003.1c specifies that there are no defined comparison > * or assignment operators for the types pthread_attr_t, pthread_cond_t, > * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t. > */ >#ifndef _PTHREAD_T_DECLARED >typedef struct pthread *pthread_t; >#define _PTHREAD_T_DECLARED >#endif ># 68 "/usr/src/sys/sys/_pthreadtypes.h" >typedef struct pthread_attr *pthread_attr_t; >typedef struct pthread_mutex *pthread_mutex_t; >typedef struct pthread_mutex_attr *pthread_mutexattr_t; >typedef struct pthread_cond *pthread_cond_t; >typedef struct pthread_cond_attr *pthread_condattr_t; >typedef int pthread_key_t; >typedef struct pthread_once pthread_once_t; >typedef struct pthread_rwlock *pthread_rwlock_t; >typedef struct pthread_rwlockattr *pthread_rwlockattr_t; >typedef struct pthread_barrier *pthread_barrier_t; >typedef struct pthread_barrierattr *pthread_barrierattr_t; >typedef struct pthread_spinlock *pthread_spinlock_t; > >/* > * Additional type definitions: > * > * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for > * use in header symbols. > */ >typedef void *pthread_addr_t; >typedef void *(*pthread_startroutine_t)(void *); > >/* > * Once definitions. > */ >struct pthread_once { > int state; > pthread_mutex_t mutex; >}; > >#endif /* ! _SYS__PTHREADTYPES_H_ */ ># 99 "/usr/src/sys/sys/_pthreadtypes.h" ># 48 "/usr/src/sys/sys/types.h" 2 > >#if __BSD_VISIBLE >typedef unsigned char u_char; >typedef unsigned short u_short; >typedef unsigned int u_int; >typedef unsigned long u_long; >#ifndef _KERNEL >typedef unsigned short ushort; /* Sys V compatibility */ >typedef unsigned int uint; /* Sys V compatibility */ >#endif ># 58 "/usr/src/sys/sys/types.h" >#endif ># 59 "/usr/src/sys/sys/types.h" > >/* > * XXX POSIX sized integrals that should appear only in <sys/stdint.h>. > */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 63 "/usr/src/sys/sys/types.h" ># 1 "/usr/src/sys/sys/_stdint.h" 1 >/*- > * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org> > * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_stdint.h 222813 2011-06-07 08:46:13Z attilio $ > */ > >#ifndef _SYS__STDINT_H_ >#define _SYS__STDINT_H_ > >#ifndef _INT8_T_DECLARED >typedef __int8_t int8_t; >#define _INT8_T_DECLARED >#endif ># 37 "/usr/src/sys/sys/_stdint.h" > >#ifndef _INT16_T_DECLARED >typedef __int16_t int16_t; >#define _INT16_T_DECLARED >#endif ># 42 "/usr/src/sys/sys/_stdint.h" > >#ifndef _INT32_T_DECLARED >typedef __int32_t int32_t; >#define _INT32_T_DECLARED >#endif ># 47 "/usr/src/sys/sys/_stdint.h" > >#ifndef _INT64_T_DECLARED >typedef __int64_t int64_t; >#define _INT64_T_DECLARED >#endif ># 52 "/usr/src/sys/sys/_stdint.h" > >#ifndef _UINT8_T_DECLARED >typedef __uint8_t uint8_t; >#define _UINT8_T_DECLARED >#endif ># 57 "/usr/src/sys/sys/_stdint.h" > >#ifndef _UINT16_T_DECLARED >typedef __uint16_t uint16_t; >#define _UINT16_T_DECLARED >#endif ># 62 "/usr/src/sys/sys/_stdint.h" > >#ifndef _UINT32_T_DECLARED >typedef __uint32_t uint32_t; >#define _UINT32_T_DECLARED >#endif ># 67 "/usr/src/sys/sys/_stdint.h" > >#ifndef _UINT64_T_DECLARED >typedef __uint64_t uint64_t; >#define _UINT64_T_DECLARED >#endif ># 72 "/usr/src/sys/sys/_stdint.h" > >#ifndef _INTPTR_T_DECLARED >typedef __intptr_t intptr_t; >#define _INTPTR_T_DECLARED >#endif ># 77 "/usr/src/sys/sys/_stdint.h" >#ifndef _UINTPTR_T_DECLARED >typedef __uintptr_t uintptr_t; >#define _UINTPTR_T_DECLARED >#endif ># 81 "/usr/src/sys/sys/_stdint.h" > >#endif /* !_SYS__STDINT_H_ */ ># 83 "/usr/src/sys/sys/_stdint.h" ># 64 "/usr/src/sys/sys/types.h" 2 > >typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */ >typedef __uint16_t u_int16_t; >typedef __uint32_t u_int32_t; >typedef __uint64_t u_int64_t; > >typedef __uint64_t u_quad_t; /* quads (deprecated) */ >typedef __int64_t quad_t; >typedef quad_t * qaddr_t; > >typedef char * caddr_t; /* core address */ >typedef const char * c_caddr_t; /* core address, pointer to const */ > >#ifndef _BLKSIZE_T_DECLARED >typedef __blksize_t blksize_t; >#define _BLKSIZE_T_DECLARED >#endif ># 81 "/usr/src/sys/sys/types.h" > >typedef __cpuwhich_t cpuwhich_t; >typedef __cpulevel_t cpulevel_t; >typedef __cpusetid_t cpusetid_t; > >#ifndef _BLKCNT_T_DECLARED >typedef __blkcnt_t blkcnt_t; >#define _BLKCNT_T_DECLARED >#endif ># 90 "/usr/src/sys/sys/types.h" > >#ifndef _CLOCK_T_DECLARED >typedef __clock_t clock_t; >#define _CLOCK_T_DECLARED >#endif ># 95 "/usr/src/sys/sys/types.h" > >#ifndef _CLOCKID_T_DECLARED >typedef __clockid_t clockid_t; >#define _CLOCKID_T_DECLARED >#endif ># 100 "/usr/src/sys/sys/types.h" > >typedef __critical_t critical_t; /* Critical section value */ >typedef __int64_t daddr_t; /* disk address */ > >#ifndef _DEV_T_DECLARED >typedef __dev_t dev_t; /* device number or struct cdev */ >#define _DEV_T_DECLARED >#endif ># 108 "/usr/src/sys/sys/types.h" > >#ifndef _FFLAGS_T_DECLARED >typedef __fflags_t fflags_t; /* file flags */ >#define _FFLAGS_T_DECLARED >#endif ># 113 "/usr/src/sys/sys/types.h" > >typedef __fixpt_t fixpt_t; /* fixed point number */ > >#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */ >typedef __fsblkcnt_t fsblkcnt_t; >typedef __fsfilcnt_t fsfilcnt_t; >#define _FSBLKCNT_T_DECLARED >#endif ># 121 "/usr/src/sys/sys/types.h" > >#ifndef _GID_T_DECLARED >typedef __gid_t gid_t; /* group id */ >#define _GID_T_DECLARED >#endif ># 126 "/usr/src/sys/sys/types.h" > >#ifndef _IN_ADDR_T_DECLARED >typedef __uint32_t in_addr_t; /* base type for internet address */ >#define _IN_ADDR_T_DECLARED >#endif ># 131 "/usr/src/sys/sys/types.h" > >#ifndef _IN_PORT_T_DECLARED >typedef __uint16_t in_port_t; >#define _IN_PORT_T_DECLARED >#endif ># 136 "/usr/src/sys/sys/types.h" > >#ifndef _ID_T_DECLARED >typedef __id_t id_t; /* can hold a uid_t or pid_t */ >#define _ID_T_DECLARED >#endif ># 141 "/usr/src/sys/sys/types.h" > >#ifndef _INO_T_DECLARED >typedef __ino_t ino_t; /* inode number */ >#define _INO_T_DECLARED >#endif ># 146 "/usr/src/sys/sys/types.h" > >#ifndef _KEY_T_DECLARED >typedef __key_t key_t; /* IPC key (for Sys V IPC) */ >#define _KEY_T_DECLARED >#endif ># 151 "/usr/src/sys/sys/types.h" > >#ifndef _LWPID_T_DECLARED >typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */ >#define _LWPID_T_DECLARED >#endif ># 156 "/usr/src/sys/sys/types.h" > >#ifndef _MODE_T_DECLARED >typedef __mode_t mode_t; /* permissions */ >#define _MODE_T_DECLARED >#endif ># 161 "/usr/src/sys/sys/types.h" > >#ifndef _ACCMODE_T_DECLARED >typedef __accmode_t accmode_t; /* access permissions */ >#define _ACCMODE_T_DECLARED >#endif ># 166 "/usr/src/sys/sys/types.h" > >#ifndef _NLINK_T_DECLARED >typedef __nlink_t nlink_t; /* link count */ >#define _NLINK_T_DECLARED >#endif ># 171 "/usr/src/sys/sys/types.h" > >#ifndef _OFF_T_DECLARED >typedef __off_t off_t; /* file offset */ >#define _OFF_T_DECLARED >#endif ># 176 "/usr/src/sys/sys/types.h" > >#ifndef _PID_T_DECLARED >typedef __pid_t pid_t; /* process id */ >#define _PID_T_DECLARED >#endif ># 181 "/usr/src/sys/sys/types.h" > >typedef __register_t register_t; > >#ifndef _RLIM_T_DECLARED >typedef __rlim_t rlim_t; /* resource limit */ >#define _RLIM_T_DECLARED >#endif ># 188 "/usr/src/sys/sys/types.h" > >typedef __int64_t sbintime_t; > >typedef __segsz_t segsz_t; /* segment size (in pages) */ > >#ifndef _SIZE_T_DECLARED >typedef __size_t size_t; >#define _SIZE_T_DECLARED >#endif ># 197 "/usr/src/sys/sys/types.h" > >#ifndef _SSIZE_T_DECLARED >typedef __ssize_t ssize_t; >#define _SSIZE_T_DECLARED >#endif ># 202 "/usr/src/sys/sys/types.h" > >#ifndef _SUSECONDS_T_DECLARED >typedef __suseconds_t suseconds_t; /* microseconds (signed) */ >#define _SUSECONDS_T_DECLARED >#endif ># 207 "/usr/src/sys/sys/types.h" > >#ifndef _TIME_T_DECLARED >typedef __time_t time_t; >#define _TIME_T_DECLARED >#endif ># 212 "/usr/src/sys/sys/types.h" > >#ifndef _TIMER_T_DECLARED >typedef __timer_t timer_t; >#define _TIMER_T_DECLARED >#endif ># 217 "/usr/src/sys/sys/types.h" > >#ifndef _MQD_T_DECLARED >typedef __mqd_t mqd_t; >#define _MQD_T_DECLARED >#endif ># 222 "/usr/src/sys/sys/types.h" > >typedef __u_register_t u_register_t; > >#ifndef _UID_T_DECLARED >typedef __uid_t uid_t; /* user id */ >#define _UID_T_DECLARED >#endif ># 229 "/usr/src/sys/sys/types.h" > >#ifndef _USECONDS_T_DECLARED >typedef __useconds_t useconds_t; /* microseconds (unsigned) */ >#define _USECONDS_T_DECLARED >#endif ># 234 "/usr/src/sys/sys/types.h" > >#ifndef _CAP_IOCTL_T_DECLARED >#define _CAP_IOCTL_T_DECLARED >typedef unsigned long cap_ioctl_t; >#endif ># 239 "/usr/src/sys/sys/types.h" > >#ifndef _CAP_RIGHTS_T_DECLARED >#define _CAP_RIGHTS_T_DECLARED >struct cap_rights; > >typedef struct cap_rights cap_rights_t; >#endif ># 246 "/usr/src/sys/sys/types.h" > >typedef __vm_offset_t vm_offset_t; >typedef __vm_ooffset_t vm_ooffset_t; >typedef __vm_paddr_t vm_paddr_t; >typedef __vm_pindex_t vm_pindex_t; >typedef __vm_size_t vm_size_t; > >#ifdef _KERNEL >typedef int boolean_t; >typedef struct device *device_t; >typedef __intfptr_t intfptr_t; > >/* > * XXX this is fixed width for historical reasons. It should have had type > * __int_fast32_t. Fixed-width types should not be used unless binary > * compatibility is essential. Least-width types should be used even less > * since they provide smaller benefits. > * > * XXX should be MD. > * > * XXX this is bogus in -current, but still used for spl*(). > */ >typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */ > >typedef __uintfptr_t uintfptr_t; >typedef __uint64_t uoff_t; >typedef char vm_memattr_t; /* memory attribute codes */ >typedef struct vm_page *vm_page_t; > >#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus) >#define __bool_true_false_are_defined 1 >#define false 0 >#define true 1 >#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER) >typedef int _Bool; >#endif ># 282 "/usr/src/sys/sys/types.h" >typedef _Bool bool; >#endif /* !__bool_true_false_are_defined && !__cplusplus */ ># 284 "/usr/src/sys/sys/types.h" > >#define offsetof(type, field) __offsetof(type, field) > >#endif /* !_KERNEL */ ># 288 "/usr/src/sys/sys/types.h" > >/* > * The following are all things that really shouldn't exist in this header, > * since its purpose is to provide typedefs, not miscellaneous doodads. > */ >#if __BSD_VISIBLE > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/select.h> >#endif /* expanded by -frewrite-includes */ ># 295 "/usr/src/sys/sys/types.h" ># 1 "/usr/src/sys/sys/select.h" 1 >/*- > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/select.h 265051 2014-04-28 13:42:41Z emaste $ > */ > >#ifndef _SYS_SELECT_H_ >#define _SYS_SELECT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/select.h" ># 36 "/usr/src/sys/sys/select.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/select.h" ># 37 "/usr/src/sys/sys/select.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sigset.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/select.h" ># 1 "/usr/src/sys/sys/_sigset.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)signal.h 8.4 (Berkeley) 5/4/95 > * $FreeBSD: head/sys/sys/_sigset.h 139825 2005-01-07 02:29:27Z imp $ > */ > >#ifndef _SYS__SIGSET_H_ >#define _SYS__SIGSET_H_ > >/* > * sigset_t macros. > */ >#define _SIG_WORDS 4 >#define _SIG_MAXSIG 128 >#define _SIG_IDX(sig) ((sig) - 1) >#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) >#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) >#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) > >typedef struct __sigset { > __uint32_t __bits[_SIG_WORDS]; >} __sigset_t; > >#if defined(_KERNEL) && defined(COMPAT_43) >typedef unsigned int osigset_t; >#endif ># 58 "/usr/src/sys/sys/_sigset.h" > >#endif /* !_SYS__SIGSET_H_ */ ># 60 "/usr/src/sys/sys/_sigset.h" ># 39 "/usr/src/sys/sys/select.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timeval.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/select.h" ># 1 "/usr/src/sys/sys/_timeval.h" 1 >/*- > * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_timeval.h 158471 2006-05-12 05:04:46Z jhb $ > */ > >#ifndef _SYS__TIMEVAL_H_ >#define _SYS__TIMEVAL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/_timeval.h" ># 33 "/usr/src/sys/sys/_timeval.h" > >#ifndef _SUSECONDS_T_DECLARED >typedef __suseconds_t suseconds_t; >#define _SUSECONDS_T_DECLARED >#endif ># 38 "/usr/src/sys/sys/_timeval.h" > >#ifndef _TIME_T_DECLARED >typedef __time_t time_t; >#define _TIME_T_DECLARED >#endif ># 43 "/usr/src/sys/sys/_timeval.h" > >/* > * Structure returned by gettimeofday(2) system call, and used in other calls. > */ >struct timeval { > time_t tv_sec; /* seconds */ > suseconds_t tv_usec; /* and microseconds */ >}; > >#endif /* !_SYS__TIMEVAL_H_ */ ># 53 "/usr/src/sys/sys/_timeval.h" ># 40 "/usr/src/sys/sys/select.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/timespec.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/select.h" ># 1 "/usr/src/sys/sys/timespec.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)time.h 8.5 (Berkeley) 5/4/95 > * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp > * $FreeBSD: head/sys/sys/timespec.h 205792 2010-03-28 13:13:22Z ed $ > */ > >#ifndef _SYS_TIMESPEC_H_ >#define _SYS_TIMESPEC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/timespec.h" ># 38 "/usr/src/sys/sys/timespec.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timespec.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/timespec.h" ># 1 "/usr/src/sys/sys/_timespec.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)time.h 8.5 (Berkeley) 5/4/95 > * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp > * $FreeBSD: head/sys/sys/_timespec.h 205792 2010-03-28 13:13:22Z ed $ > */ > >#ifndef _SYS__TIMESPEC_H_ >#define _SYS__TIMESPEC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/_timespec.h" ># 38 "/usr/src/sys/sys/_timespec.h" > >#ifndef _TIME_T_DECLARED >typedef __time_t time_t; >#define _TIME_T_DECLARED >#endif ># 43 "/usr/src/sys/sys/_timespec.h" > >struct timespec { > time_t tv_sec; /* seconds */ > long tv_nsec; /* and nanoseconds */ >}; > >#endif /* !_SYS__TIMESPEC_H_ */ ># 50 "/usr/src/sys/sys/_timespec.h" ># 39 "/usr/src/sys/sys/timespec.h" 2 > >#if __BSD_VISIBLE >#define TIMEVAL_TO_TIMESPEC(tv, ts) \ > do { \ > (ts)->tv_sec = (tv)->tv_sec; \ > (ts)->tv_nsec = (tv)->tv_usec * 1000; \ > } while (0) >#define TIMESPEC_TO_TIMEVAL(tv, ts) \ > do { \ > (tv)->tv_sec = (ts)->tv_sec; \ > (tv)->tv_usec = (ts)->tv_nsec / 1000; \ > } while (0) > >#endif /* __BSD_VISIBLE */ ># 53 "/usr/src/sys/sys/timespec.h" > >/* > * Structure defined by POSIX.1b to be like a itimerval, but with > * timespecs. Used in the timer_*() system calls. > */ >struct itimerspec { > struct timespec it_interval; > struct timespec it_value; >}; > >#endif /* _SYS_TIMESPEC_H_ */ ># 64 "/usr/src/sys/sys/timespec.h" ># 41 "/usr/src/sys/sys/select.h" 2 > >typedef unsigned long __fd_mask; >#if __BSD_VISIBLE >typedef __fd_mask fd_mask; >#endif ># 46 "/usr/src/sys/sys/select.h" > >#ifndef _SIGSET_T_DECLARED >#define _SIGSET_T_DECLARED >typedef __sigset_t sigset_t; >#endif ># 51 "/usr/src/sys/sys/select.h" > >/* > * Select uses bit masks of file descriptors in longs. These macros > * manipulate such bit fields (the filesystem macros use chars). > * FD_SETSIZE may be defined by the user, but the default here should > * be enough for most uses. > */ >#ifndef FD_SETSIZE >#define FD_SETSIZE 1024 >#endif ># 61 "/usr/src/sys/sys/select.h" > >#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */ >#if __BSD_VISIBLE >#define NFDBITS _NFDBITS >#endif ># 66 "/usr/src/sys/sys/select.h" > >#ifndef _howmany >#define _howmany(x, y) (((x) + ((y) - 1)) / (y)) >#endif ># 70 "/usr/src/sys/sys/select.h" > >typedef struct fd_set { > __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; >} fd_set; >#if __BSD_VISIBLE >#define fds_bits __fds_bits >#endif ># 77 "/usr/src/sys/sys/select.h" > >#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) >#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) >#if __BSD_VISIBLE >#define FD_COPY(f, t) (void)(*(t) = *(f)) >#endif ># 83 "/usr/src/sys/sys/select.h" >#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) >#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) >#define FD_ZERO(p) do { \ > fd_set *_p; \ > __size_t _n; \ > \ > _p = (p); \ > _n = _howmany(FD_SETSIZE, _NFDBITS); \ > while (_n > 0) \ > _p->__fds_bits[--_n] = 0; \ >} while (0) > >#ifndef _KERNEL > >__BEGIN_DECLS >int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, > const struct timespec *__restrict, const sigset_t *__restrict); >#ifndef _SELECT_DECLARED >#define _SELECT_DECLARED >/* XXX missing restrict type-qualifier */ >int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); >#endif ># 105 "/usr/src/sys/sys/select.h" >__END_DECLS >#endif /* !_KERNEL */ ># 107 "/usr/src/sys/sys/select.h" > >#endif /* _SYS_SELECT_H_ */ ># 109 "/usr/src/sys/sys/select.h" ># 296 "/usr/src/sys/sys/types.h" 2 > >#ifdef __POPCNT__ >#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x)) >#define __bitcount32(x) __builtin_popcount((__uint32_t)(x)) >#define __bitcount16(x) __builtin_popcount((__uint16_t)(x)) >#define __bitcountl(x) __builtin_popcountl((unsigned long)(x)) >#define __bitcount(x) __builtin_popcount((unsigned int)(x)) >#else ># 304 "/usr/src/sys/sys/types.h" >/* > * Population count algorithm using SWAR approach > * - "SIMD Within A Register". > */ >static __inline __uint16_t >__bitcount16(__uint16_t _x) >{ > > _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1); > _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2); > _x = (_x + (_x >> 4)) & 0x0f0f; > _x = (_x + (_x >> 8)) & 0x00ff; > return (_x); >} > >static __inline __uint32_t >__bitcount32(__uint32_t _x) >{ > > _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1); > _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2); > _x = (_x + (_x >> 4)) & 0x0f0f0f0f; > _x = (_x + (_x >> 8)); > _x = (_x + (_x >> 16)) & 0x000000ff; > return (_x); >} > >#ifdef __LP64__ >static __inline __uint64_t >__bitcount64(__uint64_t _x) >{ > > _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1); > _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2); > _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f; > _x = (_x + (_x >> 8)); > _x = (_x + (_x >> 16)); > _x = (_x + (_x >> 32)) & 0x000000ff; > return (_x); >} > >#define __bitcountl(x) __bitcount64((unsigned long)(x)) >#else ># 347 "/usr/src/sys/sys/types.h" >static __inline __uint64_t >__bitcount64(__uint64_t _x) >{ > > return (__bitcount32(_x >> 32) + __bitcount32(_x)); >} > >#define __bitcountl(x) __bitcount32((unsigned long)(x)) >#endif ># 356 "/usr/src/sys/sys/types.h" >#define __bitcount(x) __bitcount32((unsigned int)(x)) >#endif ># 358 "/usr/src/sys/sys/types.h" > >/* > * minor() gives a cookie instead of an index since we don't want to > * change the meanings of bits 0-15 or waste time and space shifting > * bits 16-31 for devices that don't use them. > */ >#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ >#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ >#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ > >/* > * These declarations belong elsewhere, but are repeated here and in > * <stdio.h> to give broken programs a better chance of working with > * 64-bit off_t's. > */ >#ifndef _KERNEL >__BEGIN_DECLS >#ifndef _FTRUNCATE_DECLARED >#define _FTRUNCATE_DECLARED >int ftruncate(int, off_t); >#endif ># 379 "/usr/src/sys/sys/types.h" >#ifndef _LSEEK_DECLARED >#define _LSEEK_DECLARED >off_t lseek(int, off_t, int); >#endif ># 383 "/usr/src/sys/sys/types.h" >#ifndef _MMAP_DECLARED >#define _MMAP_DECLARED >void * mmap(void *, size_t, int, int, int, off_t); >#endif ># 387 "/usr/src/sys/sys/types.h" >#ifndef _TRUNCATE_DECLARED >#define _TRUNCATE_DECLARED >int truncate(const char *, off_t); >#endif ># 391 "/usr/src/sys/sys/types.h" >__END_DECLS >#endif /* !_KERNEL */ ># 393 "/usr/src/sys/sys/types.h" > >#endif /* __BSD_VISIBLE */ ># 395 "/usr/src/sys/sys/types.h" > >#endif /* !_SYS_TYPES_H_ */ ># 397 "/usr/src/sys/sys/types.h" ># 90 "/usr/src/sys/sys/param.h" 2 >#endif ># 91 "/usr/src/sys/sys/param.h" > >/* > * Machine-independent constants (some used in following include files). > * Redefined constants are from POSIX 1003.1 limits file. > * > * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) > */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/syslimits.h> >#endif /* expanded by -frewrite-includes */ ># 98 "/usr/src/sys/sys/param.h" ># 1 "/usr/src/sys/sys/syslimits.h" 1 >/*- > * Copyright (c) 1988, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: head/sys/sys/syslimits.h 194498 2009-06-19 17:10:35Z brooks $ > */ > >#ifndef _SYS_SYSLIMITS_H_ >#define _SYS_SYSLIMITS_H_ > >#if !defined(_KERNEL) && !defined(_LIMITS_H_) && !defined(_SYS_PARAM_H_) >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 40 "/usr/src/sys/sys/syslimits.h" >#ifdef __CC_SUPPORTS_WARNING >#warning "No user-serviceable parts inside." >#endif ># 43 "/usr/src/sys/sys/syslimits.h" >#endif ># 44 "/usr/src/sys/sys/syslimits.h" > >/* > * Do not add any new variables here. (See the comment at the end of > * the file for why.) > */ >#define ARG_MAX 262144 /* max bytes for an exec function */ >#ifndef CHILD_MAX >#define CHILD_MAX 40 /* max simultaneous processes */ >#endif ># 53 "/usr/src/sys/sys/syslimits.h" >#define LINK_MAX 32767 /* max file link count */ >#define MAX_CANON 255 /* max bytes in term canon input line */ >#define MAX_INPUT 255 /* max bytes in terminal input */ >#define NAME_MAX 255 /* max bytes in a file name */ >#ifndef NGROUPS_MAX >#define NGROUPS_MAX 1023 /* max supplemental group id's */ >#endif ># 60 "/usr/src/sys/sys/syslimits.h" >#ifndef OPEN_MAX >#define OPEN_MAX 64 /* max open files per process */ >#endif ># 63 "/usr/src/sys/sys/syslimits.h" >#define PATH_MAX 1024 /* max bytes in pathname */ >#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ >#define IOV_MAX 1024 /* max elements in i/o vector */ > >/* > * We leave the following values undefined to force applications to either > * assume conservative values or call sysconf() to get the current value. > * > * HOST_NAME_MAX > * > * (We should do this for most of the values currently defined here, > * but many programs are not prepared to deal with this yet.) > */ >#endif ># 77 "/usr/src/sys/sys/syslimits.h" ># 99 "/usr/src/sys/sys/param.h" 2 > >#define MAXCOMLEN 19 /* max command name remembered */ >#define MAXINTERP PATH_MAX /* max interpreter file name length */ >#define MAXLOGNAME 33 /* max login name length (incl. NUL) */ >#define MAXUPRC CHILD_MAX /* max simultaneous processes */ >#define NCARGS ARG_MAX /* max bytes for an exec function */ >#define NGROUPS (NGROUPS_MAX+1) /* max number groups */ >#define NOFILE OPEN_MAX /* max open files per process */ >#define NOGROUP 65535 /* marker for empty group set member */ >#define MAXHOSTNAMELEN 256 /* max hostname size */ >#define SPECNAMELEN 63 /* max length of devicename */ > >/* More types and definitions used throughout the kernel. */ >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 113 "/usr/src/sys/sys/param.h" ># 114 "/usr/src/sys/sys/param.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/errno.h> >#endif /* expanded by -frewrite-includes */ ># 114 "/usr/src/sys/sys/param.h" ># 1 "/usr/src/sys/sys/errno.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)errno.h 8.5 (Berkeley) 1/21/94 > * $FreeBSD: head/sys/sys/errno.h 250250 2013-05-04 19:07:22Z pluknet $ > */ > >#ifndef _SYS_ERRNO_H_ >#define _SYS_ERRNO_H_ > >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/errno.h" ># 43 "/usr/src/sys/sys/errno.h" >__BEGIN_DECLS >int * __error(void); >__END_DECLS >#define errno (* __error()) >#endif ># 48 "/usr/src/sys/sys/errno.h" > >#define EPERM 1 /* Operation not permitted */ >#define ENOENT 2 /* No such file or directory */ >#define ESRCH 3 /* No such process */ >#define EINTR 4 /* Interrupted system call */ >#define EIO 5 /* Input/output error */ >#define ENXIO 6 /* Device not configured */ >#define E2BIG 7 /* Argument list too long */ >#define ENOEXEC 8 /* Exec format error */ >#define EBADF 9 /* Bad file descriptor */ >#define ECHILD 10 /* No child processes */ >#define EDEADLK 11 /* Resource deadlock avoided */ > /* 11 was EAGAIN */ >#define ENOMEM 12 /* Cannot allocate memory */ >#define EACCES 13 /* Permission denied */ >#define EFAULT 14 /* Bad address */ >#ifndef _POSIX_SOURCE >#define ENOTBLK 15 /* Block device required */ >#endif ># 67 "/usr/src/sys/sys/errno.h" >#define EBUSY 16 /* Device busy */ >#define EEXIST 17 /* File exists */ >#define EXDEV 18 /* Cross-device link */ >#define ENODEV 19 /* Operation not supported by device */ >#define ENOTDIR 20 /* Not a directory */ >#define EISDIR 21 /* Is a directory */ >#define EINVAL 22 /* Invalid argument */ >#define ENFILE 23 /* Too many open files in system */ >#define EMFILE 24 /* Too many open files */ >#define ENOTTY 25 /* Inappropriate ioctl for device */ >#ifndef _POSIX_SOURCE >#define ETXTBSY 26 /* Text file busy */ >#endif ># 80 "/usr/src/sys/sys/errno.h" >#define EFBIG 27 /* File too large */ >#define ENOSPC 28 /* No space left on device */ >#define ESPIPE 29 /* Illegal seek */ >#define EROFS 30 /* Read-only filesystem */ >#define EMLINK 31 /* Too many links */ >#define EPIPE 32 /* Broken pipe */ > >/* math software */ >#define EDOM 33 /* Numerical argument out of domain */ >#define ERANGE 34 /* Result too large */ > >/* non-blocking and interrupt i/o */ >#define EAGAIN 35 /* Resource temporarily unavailable */ >#ifndef _POSIX_SOURCE >#define EWOULDBLOCK EAGAIN /* Operation would block */ >#define EINPROGRESS 36 /* Operation now in progress */ >#define EALREADY 37 /* Operation already in progress */ > >/* ipc/network software -- argument errors */ >#define ENOTSOCK 38 /* Socket operation on non-socket */ >#define EDESTADDRREQ 39 /* Destination address required */ >#define EMSGSIZE 40 /* Message too long */ >#define EPROTOTYPE 41 /* Protocol wrong type for socket */ >#define ENOPROTOOPT 42 /* Protocol not available */ >#define EPROTONOSUPPORT 43 /* Protocol not supported */ >#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ >#define EOPNOTSUPP 45 /* Operation not supported */ >#define ENOTSUP EOPNOTSUPP /* Operation not supported */ >#define EPFNOSUPPORT 46 /* Protocol family not supported */ >#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ >#define EADDRINUSE 48 /* Address already in use */ >#define EADDRNOTAVAIL 49 /* Can't assign requested address */ > >/* ipc/network software -- operational errors */ >#define ENETDOWN 50 /* Network is down */ >#define ENETUNREACH 51 /* Network is unreachable */ >#define ENETRESET 52 /* Network dropped connection on reset */ >#define ECONNABORTED 53 /* Software caused connection abort */ >#define ECONNRESET 54 /* Connection reset by peer */ >#define ENOBUFS 55 /* No buffer space available */ >#define EISCONN 56 /* Socket is already connected */ >#define ENOTCONN 57 /* Socket is not connected */ >#define ESHUTDOWN 58 /* Can't send after socket shutdown */ >#define ETOOMANYREFS 59 /* Too many references: can't splice */ >#define ETIMEDOUT 60 /* Operation timed out */ >#define ECONNREFUSED 61 /* Connection refused */ > >#define ELOOP 62 /* Too many levels of symbolic links */ >#endif /* _POSIX_SOURCE */ ># 129 "/usr/src/sys/sys/errno.h" >#define ENAMETOOLONG 63 /* File name too long */ > >/* should be rearranged */ >#ifndef _POSIX_SOURCE >#define EHOSTDOWN 64 /* Host is down */ >#define EHOSTUNREACH 65 /* No route to host */ >#endif /* _POSIX_SOURCE */ ># 136 "/usr/src/sys/sys/errno.h" >#define ENOTEMPTY 66 /* Directory not empty */ > >/* quotas & mush */ >#ifndef _POSIX_SOURCE >#define EPROCLIM 67 /* Too many processes */ >#define EUSERS 68 /* Too many users */ >#define EDQUOT 69 /* Disc quota exceeded */ > >/* Network File System */ >#define ESTALE 70 /* Stale NFS file handle */ >#define EREMOTE 71 /* Too many levels of remote in path */ >#define EBADRPC 72 /* RPC struct is bad */ >#define ERPCMISMATCH 73 /* RPC version wrong */ >#define EPROGUNAVAIL 74 /* RPC prog. not avail */ >#define EPROGMISMATCH 75 /* Program version wrong */ >#define EPROCUNAVAIL 76 /* Bad procedure for program */ >#endif /* _POSIX_SOURCE */ ># 153 "/usr/src/sys/sys/errno.h" > >#define ENOLCK 77 /* No locks available */ >#define ENOSYS 78 /* Function not implemented */ > >#ifndef _POSIX_SOURCE >#define EFTYPE 79 /* Inappropriate file type or format */ >#define EAUTH 80 /* Authentication error */ >#define ENEEDAUTH 81 /* Need authenticator */ >#define EIDRM 82 /* Identifier removed */ >#define ENOMSG 83 /* No message of desired type */ >#define EOVERFLOW 84 /* Value too large to be stored in data type */ >#define ECANCELED 85 /* Operation canceled */ >#define EILSEQ 86 /* Illegal byte sequence */ >#define ENOATTR 87 /* Attribute not found */ > >#define EDOOFUS 88 /* Programming error */ >#endif /* _POSIX_SOURCE */ ># 170 "/usr/src/sys/sys/errno.h" > >#define EBADMSG 89 /* Bad message */ >#define EMULTIHOP 90 /* Multihop attempted */ >#define ENOLINK 91 /* Link has been severed */ >#define EPROTO 92 /* Protocol error */ > >#ifndef _POSIX_SOURCE >#define ENOTCAPABLE 93 /* Capabilities insufficient */ >#define ECAPMODE 94 /* Not permitted in capability mode */ >#define ENOTRECOVERABLE 95 /* State not recoverable */ >#define EOWNERDEAD 96 /* Previous owner died */ >#endif /* _POSIX_SOURCE */ ># 182 "/usr/src/sys/sys/errno.h" > >#ifndef _POSIX_SOURCE >#define ELAST 96 /* Must be equal largest errno */ >#endif /* _POSIX_SOURCE */ ># 186 "/usr/src/sys/sys/errno.h" > >#ifdef _KERNEL >/* pseudo-errors returned inside kernel to modify return to process */ >#define ERESTART (-1) /* restart syscall */ >#define EJUSTRETURN (-2) /* don't modify regs, just return */ >#define ENOIOCTL (-3) /* ioctl not handled by this layer */ >#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */ >#endif ># 194 "/usr/src/sys/sys/errno.h" > >#endif ># 196 "/usr/src/sys/sys/errno.h" ># 115 "/usr/src/sys/sys/param.h" 2 >#ifndef LOCORE >#if 0 /* expanded by -frewrite-includes */ >#include <sys/time.h> >#endif /* expanded by -frewrite-includes */ ># 116 "/usr/src/sys/sys/param.h" ># 1 "/usr/src/sys/sys/time.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)time.h 8.5 (Berkeley) 5/4/95 > * $FreeBSD: head/sys/sys/time.h 275985 2014-12-21 05:07:11Z imp $ > */ > >#ifndef _SYS_TIME_H_ >#define _SYS_TIME_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timeval.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/time.h" ># 37 "/usr/src/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/time.h" ># 38 "/usr/src/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/timespec.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/time.h" ># 39 "/usr/src/sys/sys/time.h" > >struct timezone { > int tz_minuteswest; /* minutes west of Greenwich */ > int tz_dsttime; /* type of dst correction */ >}; >#define DST_NONE 0 /* not on dst */ >#define DST_USA 1 /* USA style dst */ >#define DST_AUST 2 /* Australian style dst */ >#define DST_WET 3 /* Western European dst */ >#define DST_MET 4 /* Middle European dst */ >#define DST_EET 5 /* Eastern European dst */ >#define DST_CAN 6 /* Canada */ > >#if __BSD_VISIBLE >struct bintime { > time_t sec; > uint64_t frac; >}; > >static __inline void >bintime_addx(struct bintime *_bt, uint64_t _x) >{ > uint64_t _u; > > _u = _bt->frac; > _bt->frac += _x; > if (_u > _bt->frac) > _bt->sec++; >} > >static __inline void >bintime_add(struct bintime *_bt, const struct bintime *_bt2) >{ > uint64_t _u; > > _u = _bt->frac; > _bt->frac += _bt2->frac; > if (_u > _bt->frac) > _bt->sec++; > _bt->sec += _bt2->sec; >} > >static __inline void >bintime_sub(struct bintime *_bt, const struct bintime *_bt2) >{ > uint64_t _u; > > _u = _bt->frac; > _bt->frac -= _bt2->frac; > if (_u < _bt->frac) > _bt->sec--; > _bt->sec -= _bt2->sec; >} > >static __inline void >bintime_mul(struct bintime *_bt, u_int _x) >{ > uint64_t _p1, _p2; > > _p1 = (_bt->frac & 0xffffffffull) * _x; > _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32); > _bt->sec *= _x; > _bt->sec += (_p2 >> 32); > _bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull); >} > >static __inline void >bintime_shift(struct bintime *_bt, int _exp) >{ > > if (_exp > 0) { > _bt->sec <<= _exp; > _bt->sec |= _bt->frac >> (64 - _exp); > _bt->frac <<= _exp; > } else if (_exp < 0) { > _bt->frac >>= -_exp; > _bt->frac |= (uint64_t)_bt->sec << (64 + _exp); > _bt->sec >>= -_exp; > } >} > >#define bintime_clear(a) ((a)->sec = (a)->frac = 0) >#define bintime_isset(a) ((a)->sec || (a)->frac) >#define bintime_cmp(a, b, cmp) \ > (((a)->sec == (b)->sec) ? \ > ((a)->frac cmp (b)->frac) : \ > ((a)->sec cmp (b)->sec)) > >#define SBT_1S ((sbintime_t)1 << 32) >#define SBT_1M (SBT_1S * 60) >#define SBT_1MS (SBT_1S / 1000) >#define SBT_1US (SBT_1S / 1000000) >#define SBT_1NS (SBT_1S / 1000000000) >#define SBT_MAX 0x7fffffffffffffffLL > >static __inline int >sbintime_getsec(sbintime_t _sbt) >{ > > return (_sbt >> 32); >} > >static __inline sbintime_t >bttosbt(const struct bintime _bt) >{ > > return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32)); >} > >static __inline struct bintime >sbttobt(sbintime_t _sbt) >{ > struct bintime _bt; > > _bt.sec = _sbt >> 32; > _bt.frac = _sbt << 32; > return (_bt); >} > >/*- > * Background information: > * > * When converting between timestamps on parallel timescales of differing > * resolutions it is historical and scientific practice to round down rather > * than doing 4/5 rounding. > * > * The date changes at midnight, not at noon. > * > * Even at 15:59:59.999999999 it's not four'o'clock. > * > * time_second ticks after N.999999999 not after N.4999999999 > */ > >static __inline void >bintime2timespec(const struct bintime *_bt, struct timespec *_ts) >{ > > _ts->tv_sec = _bt->sec; > _ts->tv_nsec = ((uint64_t)1000000000 * > (uint32_t)(_bt->frac >> 32)) >> 32; >} > >static __inline void >timespec2bintime(const struct timespec *_ts, struct bintime *_bt) >{ > > _bt->sec = _ts->tv_sec; > /* 18446744073 = int(2^64 / 1000000000) */ > _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; >} > >static __inline void >bintime2timeval(const struct bintime *_bt, struct timeval *_tv) >{ > > _tv->tv_sec = _bt->sec; > _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32; >} > >static __inline void >timeval2bintime(const struct timeval *_tv, struct bintime *_bt) >{ > > _bt->sec = _tv->tv_sec; > /* 18446744073709 = int(2^64 / 1000000) */ > _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL; >} > >static __inline struct timespec >sbttots(sbintime_t _sbt) >{ > struct timespec _ts; > > _ts.tv_sec = _sbt >> 32; > _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32; > return (_ts); >} > >static __inline sbintime_t >tstosbt(struct timespec _ts) >{ > > return (((sbintime_t)_ts.tv_sec << 32) + > (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32)); >} > >static __inline struct timeval >sbttotv(sbintime_t _sbt) >{ > struct timeval _tv; > > _tv.tv_sec = _sbt >> 32; > _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32; > return (_tv); >} > >static __inline sbintime_t >tvtosbt(struct timeval _tv) >{ > > return (((sbintime_t)_tv.tv_sec << 32) + > (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32)); >} >#endif /* __BSD_VISIBLE */ ># 243 "/usr/src/sys/sys/time.h" > >#ifdef _KERNEL > >/* Operations on timespecs */ >#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) >#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) >#define timespeccmp(tvp, uvp, cmp) \ > (((tvp)->tv_sec == (uvp)->tv_sec) ? \ > ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ > ((tvp)->tv_sec cmp (uvp)->tv_sec)) >#define timespecadd(vvp, uvp) \ > do { \ > (vvp)->tv_sec += (uvp)->tv_sec; \ > (vvp)->tv_nsec += (uvp)->tv_nsec; \ > if ((vvp)->tv_nsec >= 1000000000) { \ > (vvp)->tv_sec++; \ > (vvp)->tv_nsec -= 1000000000; \ > } \ > } while (0) >#define timespecsub(vvp, uvp) \ > do { \ > (vvp)->tv_sec -= (uvp)->tv_sec; \ > (vvp)->tv_nsec -= (uvp)->tv_nsec; \ > if ((vvp)->tv_nsec < 0) { \ > (vvp)->tv_sec--; \ > (vvp)->tv_nsec += 1000000000; \ > } \ > } while (0) > >/* Operations on timevals. */ > >#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) >#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) >#define timevalcmp(tvp, uvp, cmp) \ > (((tvp)->tv_sec == (uvp)->tv_sec) ? \ > ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ > ((tvp)->tv_sec cmp (uvp)->tv_sec)) > >/* timevaladd and timevalsub are not inlined */ > >#endif /* _KERNEL */ ># 284 "/usr/src/sys/sys/time.h" > >#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */ > >#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) >#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) >#define timercmp(tvp, uvp, cmp) \ > (((tvp)->tv_sec == (uvp)->tv_sec) ? \ > ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ > ((tvp)->tv_sec cmp (uvp)->tv_sec)) >#define timeradd(tvp, uvp, vvp) \ > do { \ > (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ > (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ > if ((vvp)->tv_usec >= 1000000) { \ > (vvp)->tv_sec++; \ > (vvp)->tv_usec -= 1000000; \ > } \ > } while (0) >#define timersub(tvp, uvp, vvp) \ > do { \ > (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ > (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ > if ((vvp)->tv_usec < 0) { \ > (vvp)->tv_sec--; \ > (vvp)->tv_usec += 1000000; \ > } \ > } while (0) >#endif ># 312 "/usr/src/sys/sys/time.h" > >/* > * Names of the interval timers, and structure > * defining a timer setting. > */ >#define ITIMER_REAL 0 >#define ITIMER_VIRTUAL 1 >#define ITIMER_PROF 2 > >struct itimerval { > struct timeval it_interval; /* timer interval */ > struct timeval it_value; /* current value */ >}; > >/* > * Getkerninfo clock information structure > */ >struct clockinfo { > int hz; /* clock frequency */ > int tick; /* micro-seconds per hz tick */ > int spare; > int stathz; /* statistics clock frequency */ > int profhz; /* profiling clock frequency */ >}; > >/* These macros are also in time.h. */ >#ifndef CLOCK_REALTIME >#define CLOCK_REALTIME 0 >#define CLOCK_VIRTUAL 1 >#define CLOCK_PROF 2 >#define CLOCK_MONOTONIC 4 >#define CLOCK_UPTIME 5 /* FreeBSD-specific. */ >#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ >#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ >#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ >#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ >#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ >#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ >#define CLOCK_SECOND 13 /* FreeBSD-specific. */ >#define CLOCK_THREAD_CPUTIME_ID 14 >#define CLOCK_PROCESS_CPUTIME_ID 15 >#endif ># 354 "/usr/src/sys/sys/time.h" > >#ifndef TIMER_ABSTIME >#define TIMER_RELTIME 0x0 /* relative timer */ >#define TIMER_ABSTIME 0x1 /* absolute timer */ >#endif ># 359 "/usr/src/sys/sys/time.h" > >#if __BSD_VISIBLE >#define CPUCLOCK_WHICH_PID 0 >#define CPUCLOCK_WHICH_TID 1 >#endif ># 364 "/usr/src/sys/sys/time.h" > >#ifdef _KERNEL > >/* > * Kernel to clock driver interface. > */ >void inittodr(time_t base); >void resettodr(void); > >extern volatile time_t time_second; >extern volatile time_t time_uptime; >extern struct bintime boottimebin; >extern struct timeval boottime; >extern struct bintime tc_tick_bt; >extern sbintime_t tc_tick_sbt; >extern struct bintime tick_bt; >extern sbintime_t tick_sbt; >extern int tc_precexp; >extern int tc_timepercentage; >extern struct bintime bt_timethreshold; >extern struct bintime bt_tickthreshold; >extern sbintime_t sbt_timethreshold; >extern sbintime_t sbt_tickthreshold; > >/* > * Functions for looking at our clock: [get]{bin,nano,micro}[up]time() > * > * Functions without the "get" prefix returns the best timestamp > * we can produce in the given format. > * > * "bin" == struct bintime == seconds + 64 bit fraction of seconds. > * "nano" == struct timespec == seconds + nanoseconds. > * "micro" == struct timeval == seconds + microseconds. > * > * Functions containing "up" returns time relative to boot and > * should be used for calculating time intervals. > * > * Functions without "up" returns UTC time. > * > * Functions with the "get" prefix returns a less precise result > * much faster than the functions without "get" prefix and should > * be used where a precision of 1/hz seconds is acceptable or where > * performance is priority. (NB: "precision", _not_ "resolution" !) > */ > >void binuptime(struct bintime *bt); >void nanouptime(struct timespec *tsp); >void microuptime(struct timeval *tvp); > >static __inline sbintime_t >sbinuptime(void) >{ > struct bintime _bt; > > binuptime(&_bt); > return (bttosbt(_bt)); >} > >void bintime(struct bintime *bt); >void nanotime(struct timespec *tsp); >void microtime(struct timeval *tvp); > >void getbinuptime(struct bintime *bt); >void getnanouptime(struct timespec *tsp); >void getmicrouptime(struct timeval *tvp); > >static __inline sbintime_t >getsbinuptime(void) >{ > struct bintime _bt; > > getbinuptime(&_bt); > return (bttosbt(_bt)); >} > >void getbintime(struct bintime *bt); >void getnanotime(struct timespec *tsp); >void getmicrotime(struct timeval *tvp); > >/* Other functions */ >int itimerdecr(struct itimerval *itp, int usec); >int itimerfix(struct timeval *tv); >int ppsratecheck(struct timeval *, int *, int); >int ratecheck(struct timeval *, const struct timeval *); >void timevaladd(struct timeval *t1, const struct timeval *t2); >void timevalsub(struct timeval *t1, const struct timeval *t2); >int tvtohz(struct timeval *tv); > >#define TC_DEFAULTPERC 5 > >#define BT2FREQ(bt) \ > (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ > ((bt)->frac >> 1)) > >#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) > >#define FREQ2BT(freq, bt) \ >{ \ > (bt)->sec = 0; \ > (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ >} > >#define TIMESEL(sbt, sbt2) \ > (((sbt2) >= sbt_timethreshold) ? \ > ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0)) > >#else /* !_KERNEL */ ># 471 "/usr/src/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <time.h> >#endif /* expanded by -frewrite-includes */ ># 471 "/usr/src/sys/sys/time.h" ># 472 "/usr/src/sys/sys/time.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 473 "/usr/src/sys/sys/time.h" ># 474 "/usr/src/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/select.h> >#endif /* expanded by -frewrite-includes */ ># 474 "/usr/src/sys/sys/time.h" ># 475 "/usr/src/sys/sys/time.h" > >__BEGIN_DECLS >int setitimer(int, const struct itimerval *, struct itimerval *); >int utimes(const char *, const struct timeval *); > >#if __BSD_VISIBLE >int adjtime(const struct timeval *, struct timeval *); >int clock_getcpuclockid2(id_t, int, clockid_t *); >int futimes(int, const struct timeval *); >int futimesat(int, const char *, const struct timeval [2]); >int lutimes(const char *, const struct timeval *); >int settimeofday(const struct timeval *, const struct timezone *); >#endif ># 488 "/usr/src/sys/sys/time.h" > >#if __XSI_VISIBLE >int getitimer(int, struct itimerval *); >int gettimeofday(struct timeval *, struct timezone *); >#endif ># 493 "/usr/src/sys/sys/time.h" > >__END_DECLS > >#endif /* !_KERNEL */ ># 497 "/usr/src/sys/sys/time.h" > >#endif /* !_SYS_TIME_H_ */ ># 499 "/usr/src/sys/sys/time.h" ># 117 "/usr/src/sys/sys/param.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/priority.h> >#endif /* expanded by -frewrite-includes */ ># 117 "/usr/src/sys/sys/param.h" ># 1 "/usr/src/sys/sys/priority.h" 1 >/*- > * Copyright (c) 1994, Henrik Vestergaard Draboel > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Henrik Vestergaard Draboel. > * 4. The name of the author may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/priority.h 221829 2011-05-13 05:27:58Z mdf $ > */ > >#ifndef _SYS_PRIORITY_H_ >#define _SYS_PRIORITY_H_ > >/* > * Process priority specifications. > */ > >/* > * Priority classes. > */ > >#define PRI_ITHD 1 /* Interrupt thread. */ >#define PRI_REALTIME 2 /* Real time process. */ >#define PRI_TIMESHARE 3 /* Time sharing process. */ >#define PRI_IDLE 4 /* Idle process. */ > >/* > * PRI_FIFO is POSIX.1B SCHED_FIFO. > */ > >#define PRI_FIFO_BIT 8 >#define PRI_FIFO (PRI_FIFO_BIT | PRI_REALTIME) > >#define PRI_BASE(P) ((P) & ~PRI_FIFO_BIT) >#define PRI_IS_REALTIME(P) (PRI_BASE(P) == PRI_REALTIME) >#define PRI_NEED_RR(P) ((P) != PRI_FIFO) > >/* > * Priorities. Note that with 64 run queues, differences less than 4 are > * insignificant. > */ > >/* > * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ) > * are insignificant. Ranges are as follows: > * > * Interrupt threads: 0 - 47 > * Realtime user threads: 48 - 79 > * Top half kernel threads: 80 - 119 > * Time sharing user threads: 120 - 223 > * Idle user threads: 224 - 255 > * > * XXX If/When the specific interrupt thread and top half thread ranges > * disappear, a larger range can be used for user processes. > */ > >#define PRI_MIN (0) /* Highest priority. */ >#define PRI_MAX (255) /* Lowest priority. */ > >#define PRI_MIN_ITHD (PRI_MIN) >#define PRI_MAX_ITHD (PRI_MIN_REALTIME - 1) > >#define PI_REALTIME (PRI_MIN_ITHD + 0) >#define PI_AV (PRI_MIN_ITHD + 4) >#define PI_NET (PRI_MIN_ITHD + 8) >#define PI_DISK (PRI_MIN_ITHD + 12) >#define PI_TTY (PRI_MIN_ITHD + 16) >#define PI_DULL (PRI_MIN_ITHD + 20) >#define PI_SOFT (PRI_MIN_ITHD + 24) >#define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) > >#define PRI_MIN_REALTIME (48) >#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) > >#define PRI_MIN_KERN (80) >#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) > >#define PSWP (PRI_MIN_KERN + 0) >#define PVM (PRI_MIN_KERN + 4) >#define PINOD (PRI_MIN_KERN + 8) >#define PRIBIO (PRI_MIN_KERN + 12) >#define PVFS (PRI_MIN_KERN + 16) >#define PZERO (PRI_MIN_KERN + 20) >#define PSOCK (PRI_MIN_KERN + 24) >#define PWAIT (PRI_MIN_KERN + 28) >#define PLOCK (PRI_MIN_KERN + 32) >#define PPAUSE (PRI_MIN_KERN + 36) > >#define PRI_MIN_TIMESHARE (120) >#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) > >#define PUSER (PRI_MIN_TIMESHARE) > >#define PRI_MIN_IDLE (224) >#define PRI_MAX_IDLE (PRI_MAX) > >#ifdef _KERNEL >/* Other arguments for kern_yield(9). */ >#define PRI_USER -2 /* Change to current user priority. */ >#define PRI_UNCHANGED -1 /* Do not change priority. */ >#endif ># 125 "/usr/src/sys/sys/priority.h" > >struct priority { > u_char pri_class; /* Scheduling class. */ > u_char pri_level; /* Normal priority level. */ > u_char pri_native; /* Priority before propogation. */ > u_char pri_user; /* User priority based on p_cpu and p_nice. */ >}; > >#endif /* !_SYS_PRIORITY_H_ */ ># 134 "/usr/src/sys/sys/priority.h" ># 118 "/usr/src/sys/sys/param.h" 2 >#endif ># 119 "/usr/src/sys/sys/param.h" > >#ifndef FALSE >#define FALSE 0 >#endif ># 123 "/usr/src/sys/sys/param.h" >#ifndef TRUE >#define TRUE 1 >#endif ># 126 "/usr/src/sys/sys/param.h" >#endif ># 127 "/usr/src/sys/sys/param.h" > >#ifndef _KERNEL >/* Signals. */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/signal.h> >#endif /* expanded by -frewrite-includes */ ># 130 "/usr/src/sys/sys/param.h" ># 131 "/usr/src/sys/sys/param.h" >#endif ># 132 "/usr/src/sys/sys/param.h" > >/* Machine type dependent parameters. */ >#if 0 /* expanded by -frewrite-includes */ >#include <machine/param.h> >#endif /* expanded by -frewrite-includes */ ># 134 "/usr/src/sys/sys/param.h" ># 1 "./machine/param.h" 1 >/*- > * Copyright (c) 2002 David E. O'Brien. All rights reserved. > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * the Systems Programming Group of the University of Utah Computer > * Science Department and Ralph Campbell. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)param.h 8.1 (Berkeley) 6/10/93 > * $FreeBSD: head/sys/amd64/include/param.h 270223 2014-08-20 16:06:24Z jhb $ > */ > > >#ifndef _AMD64_INCLUDE_PARAM_H_ >#define _AMD64_INCLUDE_PARAM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_align.h> >#endif /* expanded by -frewrite-includes */ ># 46 "./machine/param.h" ># 1 "./machine/_align.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_align.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_align.h" ># 1 "./x86/_align.h" 1 >/*- > * Copyright (c) 2001 David E. O'Brien > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)param.h 5.8 (Berkeley) 6/28/91 > * $FreeBSD: head/sys/x86/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ > */ > >#ifndef _X86_INCLUDE__ALIGN_H_ >#define _X86_INCLUDE__ALIGN_H_ > >/* > * Round p (pointer or byte index) up to a correctly-aligned value > * for all data types (int, long, ...). The result is unsigned int > * and must be cast to any desired pointer type. > */ >#define _ALIGNBYTES (sizeof(register_t) - 1) >#define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) > >#endif /* !_X86_INCLUDE__ALIGN_H_ */ ># 53 "./x86/_align.h" ># 7 "./machine/_align.h" 2 ># 47 "./machine/param.h" 2 > >/* > * Machine dependent constants for AMD64. > */ > > >#define __HAVE_ACPI >#define __PCI_REROUTE_INTERRUPT > >#ifndef MACHINE >#define MACHINE "amd64" >#endif ># 59 "./machine/param.h" >#ifndef MACHINE_ARCH >#define MACHINE_ARCH "amd64" >#endif ># 62 "./machine/param.h" >#ifndef MACHINE_ARCH32 >#define MACHINE_ARCH32 "i386" >#endif ># 65 "./machine/param.h" > >#if defined(SMP) || defined(KLD_MODULE) >#ifndef MAXCPU >#define MAXCPU 256 >#endif ># 70 "./machine/param.h" >#else ># 71 "./machine/param.h" >#define MAXCPU 1 >#endif ># 73 "./machine/param.h" > >#ifndef MAXMEMDOM >#define MAXMEMDOM 1 >#endif ># 77 "./machine/param.h" > >#define ALIGNBYTES _ALIGNBYTES >#define ALIGN(p) _ALIGN(p) >/* > * ALIGNED_POINTER is a boolean macro that checks whether an address > * is valid to fetch data elements of type t from on this architecture. > * This does not reflect the optimal alignment, just the possibility > * (within reasonable limits). > */ >#define ALIGNED_POINTER(p, t) 1 > >/* > * CACHE_LINE_SIZE is the compile-time maximum cache line size for an > * architecture. It should be used with appropriate caution. > */ >#define CACHE_LINE_SHIFT 7 >#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) > >/* Size of the level 1 page table units */ >#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) >#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ >#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ >#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ >#define PAGE_MASK (PAGE_SIZE-1) >/* Size of the level 2 page directory units */ >#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) >#define NPDEPGSHIFT 9 /* LOG2(NPDEPG) */ >#define PDRSHIFT 21 /* LOG2(NBPDR) */ >#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ >#define PDRMASK (NBPDR-1) >/* Size of the level 3 page directory pointer table units */ >#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t))) >#define NPDPEPGSHIFT 9 /* LOG2(NPDPEPG) */ >#define PDPSHIFT 30 /* LOG2(NBPDP) */ >#define NBPDP (1<<PDPSHIFT) /* bytes/page dir ptr table */ >#define PDPMASK (NBPDP-1) >/* Size of the level 4 page-map level-4 table units */ >#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) >#define NPML4EPGSHIFT 9 /* LOG2(NPML4EPG) */ >#define PML4SHIFT 39 /* LOG2(NBPML4) */ >#define NBPML4 (1UL<<PML4SHIFT)/* bytes/page map lev4 table */ >#define PML4MASK (NBPML4-1) > >#define MAXPAGESIZES 3 /* maximum number of supported page sizes */ > >#define IOPAGES 2 /* pages of i/o permission bitmap */ >/* > * I/O permission bitmap has a bit for each I/O port plus an additional > * byte at the end with all bits set. See section "I/O Permission Bit Map" > * in the Intel SDM for more details. > */ >#define IOPERM_BITMAP_SIZE (IOPAGES * PAGE_SIZE + 1) > >#ifndef KSTACK_PAGES >#define KSTACK_PAGES 4 /* pages of kstack (with pcb) */ >#endif ># 133 "./machine/param.h" >#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ > >/* > * Mach derived conversion macros > */ >#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) >#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK)) >#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK) >#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) >#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK) > >#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) >#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) > >#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) >#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) > >#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) > >#endif /* !_AMD64_INCLUDE_PARAM_H_ */ ># 153 "./machine/param.h" ># 135 "/usr/src/sys/sys/param.h" 2 >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/limits.h> >#endif /* expanded by -frewrite-includes */ ># 136 "/usr/src/sys/sys/param.h" ># 137 "/usr/src/sys/sys/param.h" >#endif ># 138 "/usr/src/sys/sys/param.h" > >#ifndef DEV_BSHIFT >#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ >#endif ># 142 "/usr/src/sys/sys/param.h" >#define DEV_BSIZE (1<<DEV_BSHIFT) > >#ifndef BLKDEV_IOSIZE >#define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */ >#endif ># 147 "/usr/src/sys/sys/param.h" >#ifndef DFLTPHYS >#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ >#endif ># 150 "/usr/src/sys/sys/param.h" >#ifndef MAXPHYS >#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ >#endif ># 153 "/usr/src/sys/sys/param.h" >#ifndef MAXDUMPPGS >#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) >#endif ># 156 "/usr/src/sys/sys/param.h" > >/* > * Constants related to network buffer management. > * MCLBYTES must be no larger than PAGE_SIZE. > */ >#ifndef MSIZE >#define MSIZE 256 /* size of an mbuf */ >#endif ># 164 "/usr/src/sys/sys/param.h" > >#ifndef MCLSHIFT >#define MCLSHIFT 11 /* convert bytes to mbuf clusters */ >#endif /* MCLSHIFT */ ># 168 "/usr/src/sys/sys/param.h" > >#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ > >#if PAGE_SIZE < 2048 >#define MJUMPAGESIZE MCLBYTES >#elif PAGE_SIZE <= 8192 ># 174 "/usr/src/sys/sys/param.h" >#define MJUMPAGESIZE PAGE_SIZE >#else ># 176 "/usr/src/sys/sys/param.h" >#define MJUMPAGESIZE (8 * 1024) >#endif ># 178 "/usr/src/sys/sys/param.h" > >#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */ >#define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */ > >/* > * Some macros for units conversion > */ > >/* clicks to bytes */ >#ifndef ctob >#define ctob(x) ((x)<<PAGE_SHIFT) >#endif ># 190 "/usr/src/sys/sys/param.h" > >/* bytes to clicks */ >#ifndef btoc >#define btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT) >#endif ># 195 "/usr/src/sys/sys/param.h" > >/* > * btodb() is messy and perhaps slow because `bytes' may be an off_t. We > * want to shift an unsigned type to avoid sign extension and we don't > * want to widen `bytes' unnecessarily. Assume that the result fits in > * a daddr_t. > */ >#ifndef btodb >#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ > (sizeof (bytes) > sizeof(long) \ > ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ > : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) >#endif ># 208 "/usr/src/sys/sys/param.h" > >#ifndef dbtob >#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ > ((off_t)(db) << DEV_BSHIFT) >#endif ># 213 "/usr/src/sys/sys/param.h" > >#define PRIMASK 0x0ff >#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ >#define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ > >#define NZERO 0 /* default "nice" */ > >#define NBBY 8 /* number of bits in a byte */ >#define NBPW sizeof(int) /* number of bytes per word (integer) */ > >#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ > >#define NODEV (dev_t)(-1) /* non-existent device */ > >/* > * File system parameters and macros. > * > * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes > * per block. MAXBSIZE may be made larger without effecting > * any existing filesystems as long as it does not exceed MAXPHYS, > * and may be made smaller at the risk of not being able to use > * filesystems which require a block size exceeding MAXBSIZE. > * > * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the > * minimum KVM memory reservation the kernel is willing to make. > * Filesystems can of course request smaller chunks. Actual > * backing memory uses a chunk size of a page (PAGE_SIZE). > * > * If you make BKVASIZE too small you risk seriously fragmenting > * the buffer KVM map which may slow things down a bit. If you > * make it too big the kernel will not be able to optimally use > * the KVM memory reserved for the buffer cache and will wind > * up with too-few buffers. > * > * The default is 16384, roughly 2x the block size used by a > * normal UFS filesystem. > */ >#define MAXBSIZE 65536 /* must be power of 2 */ >#define BKVASIZE 16384 /* must be power of 2 */ >#define BKVAMASK (BKVASIZE-1) > >/* > * MAXPATHLEN defines the longest permissible path length after expanding > * symbolic links. It is used to allocate a temporary buffer from the buffer > * pool in which to do the name expansion, hence should be a power of two, > * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the > * maximum number of symbolic links that may be expanded in a path name. > * It should be set high enough to allow all legitimate uses, but halt > * infinite loops reasonably quickly. > */ >#define MAXPATHLEN PATH_MAX >#define MAXSYMLINKS 32 > >/* Bit map related macros. */ >#define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY)) >#define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY))) >#define isset(a,i) \ > (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) >#define isclr(a,i) \ > ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) > >/* Macros for counting and rounding. */ >#ifndef howmany >#define howmany(x, y) (((x)+((y)-1))/(y)) >#endif ># 278 "/usr/src/sys/sys/param.h" >#define nitems(x) (sizeof((x)) / sizeof((x)[0])) >#define rounddown(x, y) (((x)/(y))*(y)) >#define rounddown2(x, y) ((x)&(~((y)-1))) /* if y is power of two */ >#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ >#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ >#define powerof2(x) ((((x)-1)&(x))==0) > >/* Macros for min/max. */ >#define MIN(a,b) (((a)<(b))?(a):(b)) >#define MAX(a,b) (((a)>(b))?(a):(b)) > >#ifdef _KERNEL >/* > * Basic byte order function prototypes for non-inline functions. > */ >#ifndef LOCORE >#ifndef _BYTEORDER_PROTOTYPED >#define _BYTEORDER_PROTOTYPED >__BEGIN_DECLS >__uint32_t htonl(__uint32_t); >__uint16_t htons(__uint16_t); >__uint32_t ntohl(__uint32_t); >__uint16_t ntohs(__uint16_t); >__END_DECLS >#endif ># 303 "/usr/src/sys/sys/param.h" >#endif ># 304 "/usr/src/sys/sys/param.h" > >#ifndef lint >#ifndef _BYTEORDER_FUNC_DEFINED >#define _BYTEORDER_FUNC_DEFINED >#define htonl(x) __htonl(x) >#define htons(x) __htons(x) >#define ntohl(x) __ntohl(x) >#define ntohs(x) __ntohs(x) >#endif /* !_BYTEORDER_FUNC_DEFINED */ ># 313 "/usr/src/sys/sys/param.h" >#endif /* lint */ ># 314 "/usr/src/sys/sys/param.h" >#endif /* _KERNEL */ ># 315 "/usr/src/sys/sys/param.h" > >/* > * Scale factor for scaled integers used to count %cpu time and load avgs. > * > * The number of CPU `tick's that map to a unique `%age' can be expressed > * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that > * can be calculated (assuming 32 bits) can be closely approximated using > * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). > * > * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', > * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. > */ >#define FSHIFT 11 /* bits to right of fixed binary point */ >#define FSCALE (1<<FSHIFT) > >#define dbtoc(db) /* calculates devblks to pages */ \ > ((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT)) > >#define ctodb(db) /* calculates pages to devblks */ \ > ((db) << (PAGE_SHIFT - DEV_BSHIFT)) > >/* > * Old spelling of __containerof(). > */ >#define member2struct(s, m, x) \ > ((struct s *)(void *)((char *)(x) - offsetof(struct s, m))) > >/* > * Access a variable length array that has been declared as a fixed > * length array. > */ >#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) > >#endif /* _SYS_PARAM_H_ */ ># 349 "/usr/src/sys/sys/param.h" ># 47 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/systm.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/systm.h" 1 >/*- > * Copyright (c) 1982, 1988, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)systm.h 8.7 (Berkeley) 3/29/95 > * $FreeBSD: head/sys/sys/systm.h 280279 2015-03-20 10:27:06Z jhb $ > */ > >#ifndef _SYS_SYSTM_H_ >#define _SYS_SYSTM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/systm.h" ># 1 "./machine/atomic.h" 1 >/*- > * Copyright (c) 1998 Doug Rabson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/amd64/include/atomic.h 254618 2013-08-21 22:05:58Z jkim $ > */ >#ifndef _MACHINE_ATOMIC_H_ >#define _MACHINE_ATOMIC_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 34 "./machine/atomic.h" > >#define mb() __asm __volatile("mfence;" : : : "memory") >#define wmb() __asm __volatile("sfence;" : : : "memory") >#define rmb() __asm __volatile("lfence;" : : : "memory") > >/* > * Various simple operations on memory, each of which is atomic in the > * presence of interrupts and multiple processors. > * > * atomic_set_char(P, V) (*(u_char *)(P) |= (V)) > * atomic_clear_char(P, V) (*(u_char *)(P) &= ~(V)) > * atomic_add_char(P, V) (*(u_char *)(P) += (V)) > * atomic_subtract_char(P, V) (*(u_char *)(P) -= (V)) > * > * atomic_set_short(P, V) (*(u_short *)(P) |= (V)) > * atomic_clear_short(P, V) (*(u_short *)(P) &= ~(V)) > * atomic_add_short(P, V) (*(u_short *)(P) += (V)) > * atomic_subtract_short(P, V) (*(u_short *)(P) -= (V)) > * > * atomic_set_int(P, V) (*(u_int *)(P) |= (V)) > * atomic_clear_int(P, V) (*(u_int *)(P) &= ~(V)) > * atomic_add_int(P, V) (*(u_int *)(P) += (V)) > * atomic_subtract_int(P, V) (*(u_int *)(P) -= (V)) > * atomic_swap_int(P, V) (return (*(u_int *)(P)); *(u_int *)(P) = (V);) > * atomic_readandclear_int(P) (return (*(u_int *)(P)); *(u_int *)(P) = 0;) > * > * atomic_set_long(P, V) (*(u_long *)(P) |= (V)) > * atomic_clear_long(P, V) (*(u_long *)(P) &= ~(V)) > * atomic_add_long(P, V) (*(u_long *)(P) += (V)) > * atomic_subtract_long(P, V) (*(u_long *)(P) -= (V)) > * atomic_swap_long(P, V) (return (*(u_long *)(P)); *(u_long *)(P) = (V);) > * atomic_readandclear_long(P) (return (*(u_long *)(P)); *(u_long *)(P) = 0;) > */ > >/* > * The above functions are expanded inline in the statically-linked > * kernel. Lock prefixes are generated if an SMP kernel is being > * built. > * > * Kernel modules call real functions which are built into the kernel. > * This allows kernel modules to be portable between UP and SMP systems. > */ >#if defined(KLD_MODULE) || !defined(__GNUCLIKE_ASM) >#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \ >void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \ >void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v) > >int atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src); >int atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src); >u_int atomic_fetchadd_int(volatile u_int *p, u_int v); >u_long atomic_fetchadd_long(volatile u_long *p, u_long v); >int atomic_testandset_int(volatile u_int *p, u_int v); >int atomic_testandset_long(volatile u_long *p, u_int v); > >#define ATOMIC_LOAD(TYPE, LOP) \ >u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p) >#define ATOMIC_STORE(TYPE) \ >void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) > >#else /* !KLD_MODULE && __GNUCLIKE_ASM */ ># 94 "./machine/atomic.h" > >/* > * For userland, always use lock prefixes so that the binaries will run > * on both SMP and !SMP systems. > */ >#if defined(SMP) || !defined(_KERNEL) >#define MPLOCKED "lock ; " >#else ># 102 "./machine/atomic.h" >#define MPLOCKED >#endif ># 104 "./machine/atomic.h" > >/* > * The assembly is volatilized to avoid code chunk removal by the compiler. > * GCC aggressively reorders operations and memory clobbering is necessary > * in order to avoid that for memory barriers. > */ >#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \ >static __inline void \ >atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ >{ \ > __asm __volatile(MPLOCKED OP \ > : "+m" (*p) \ > : CONS (V) \ > : "cc"); \ >} \ > \ >static __inline void \ >atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ >{ \ > __asm __volatile(MPLOCKED OP \ > : "+m" (*p) \ > : CONS (V) \ > : "memory", "cc"); \ >} \ >struct __hack > >/* > * Atomic compare and set, used by the mutex functions > * > * if (*dst == expect) *dst = src (all 32 bit words) > * > * Returns 0 on failure, non-zero on success > */ > >static __inline int >atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " cmpxchgl %3,%1 ; " > " sete %0 ; " > "# atomic_cmpset_int" > : "=q" (res), /* 0 */ > "+m" (*dst), /* 1 */ > "+a" (expect) /* 2 */ > : "r" (src) /* 3 */ > : "memory", "cc"); > return (res); >} > >static __inline int >atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " cmpxchgq %3,%1 ; " > " sete %0 ; " > "# atomic_cmpset_long" > : "=q" (res), /* 0 */ > "+m" (*dst), /* 1 */ > "+a" (expect) /* 2 */ > : "r" (src) /* 3 */ > : "memory", "cc"); > return (res); >} > >/* > * Atomically add the value of v to the integer pointed to by p and return > * the previous value of *p. > */ >static __inline u_int >atomic_fetchadd_int(volatile u_int *p, u_int v) >{ > > __asm __volatile( > " " MPLOCKED " " > " xaddl %0,%1 ; " > "# atomic_fetchadd_int" > : "+r" (v), /* 0 */ > "+m" (*p) /* 1 */ > : : "cc"); > return (v); >} > >/* > * Atomically add the value of v to the long integer pointed to by p and return > * the previous value of *p. > */ >static __inline u_long >atomic_fetchadd_long(volatile u_long *p, u_long v) >{ > > __asm __volatile( > " " MPLOCKED " " > " xaddq %0,%1 ; " > "# atomic_fetchadd_long" > : "+r" (v), /* 0 */ > "+m" (*p) /* 1 */ > : : "cc"); > return (v); >} > >static __inline int >atomic_testandset_int(volatile u_int *p, u_int v) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " btsl %2,%1 ; " > " setc %0 ; " > "# atomic_testandset_int" > : "=q" (res), /* 0 */ > "+m" (*p) /* 1 */ > : "Ir" (v & 0x1f) /* 2 */ > : "cc"); > return (res); >} > >static __inline int >atomic_testandset_long(volatile u_long *p, u_int v) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " btsq %2,%1 ; " > " setc %0 ; " > "# atomic_testandset_long" > : "=q" (res), /* 0 */ > "+m" (*p) /* 1 */ > : "Jr" ((u_long)(v & 0x3f)) /* 2 */ > : "cc"); > return (res); >} > >/* > * We assume that a = b will do atomic loads and stores. Due to the > * IA32 memory model, a simple store guarantees release semantics. > * > * However, loads may pass stores, so for atomic_load_acq we have to > * ensure a Store/Load barrier to do the load in SMP kernels. We use > * "lock cmpxchg" as recommended by the AMD Software Optimization > * Guide, and not mfence. For UP kernels, however, the cache of the > * single processor is always consistent, so we only need to take care > * of the compiler. > */ >#define ATOMIC_STORE(TYPE) \ >static __inline void \ >atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ >{ \ > __compiler_membar(); \ > *p = v; \ >} \ >struct __hack > >#if defined(_KERNEL) && !defined(SMP) > >#define ATOMIC_LOAD(TYPE, LOP) \ >static __inline u_##TYPE \ >atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ >{ \ > u_##TYPE tmp; \ > \ > tmp = *p; \ > __compiler_membar(); \ > return (tmp); \ >} \ >struct __hack > >#else /* !(_KERNEL && !SMP) */ ># 279 "./machine/atomic.h" > >#define ATOMIC_LOAD(TYPE, LOP) \ >static __inline u_##TYPE \ >atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ >{ \ > u_##TYPE res; \ > \ > __asm __volatile(MPLOCKED LOP \ > : "=a" (res), /* 0 */ \ > "+m" (*p) /* 1 */ \ > : : "memory", "cc"); \ > return (res); \ >} \ >struct __hack > >#endif /* _KERNEL && !SMP */ ># 295 "./machine/atomic.h" > >#endif /* KLD_MODULE || !__GNUCLIKE_ASM */ ># 297 "./machine/atomic.h" > >ATOMIC_ASM(set, char, "orb %b1,%0", "iq", v); >ATOMIC_ASM(clear, char, "andb %b1,%0", "iq", ~v); >ATOMIC_ASM(add, char, "addb %b1,%0", "iq", v); >ATOMIC_ASM(subtract, char, "subb %b1,%0", "iq", v); > >ATOMIC_ASM(set, short, "orw %w1,%0", "ir", v); >ATOMIC_ASM(clear, short, "andw %w1,%0", "ir", ~v); >ATOMIC_ASM(add, short, "addw %w1,%0", "ir", v); >ATOMIC_ASM(subtract, short, "subw %w1,%0", "ir", v); > >ATOMIC_ASM(set, int, "orl %1,%0", "ir", v); >ATOMIC_ASM(clear, int, "andl %1,%0", "ir", ~v); >ATOMIC_ASM(add, int, "addl %1,%0", "ir", v); >ATOMIC_ASM(subtract, int, "subl %1,%0", "ir", v); > >ATOMIC_ASM(set, long, "orq %1,%0", "ir", v); >ATOMIC_ASM(clear, long, "andq %1,%0", "ir", ~v); >ATOMIC_ASM(add, long, "addq %1,%0", "ir", v); >ATOMIC_ASM(subtract, long, "subq %1,%0", "ir", v); > >ATOMIC_LOAD(char, "cmpxchgb %b0,%1"); >ATOMIC_LOAD(short, "cmpxchgw %w0,%1"); >ATOMIC_LOAD(int, "cmpxchgl %0,%1"); >ATOMIC_LOAD(long, "cmpxchgq %0,%1"); > >ATOMIC_STORE(char); >ATOMIC_STORE(short); >ATOMIC_STORE(int); >ATOMIC_STORE(long); > >#undef ATOMIC_ASM >#undef ATOMIC_LOAD >#undef ATOMIC_STORE > >#ifndef WANT_FUNCTIONS > >/* Read the current value and store a new value in the destination. */ >#ifdef __GNUCLIKE_ASM > >static __inline u_int >atomic_swap_int(volatile u_int *p, u_int v) >{ > > __asm __volatile( > " xchgl %1,%0 ; " > "# atomic_swap_int" > : "+r" (v), /* 0 */ > "+m" (*p)); /* 1 */ > return (v); >} > >static __inline u_long >atomic_swap_long(volatile u_long *p, u_long v) >{ > > __asm __volatile( > " xchgq %1,%0 ; " > "# atomic_swap_long" > : "+r" (v), /* 0 */ > "+m" (*p)); /* 1 */ > return (v); >} > >#else /* !__GNUCLIKE_ASM */ ># 362 "./machine/atomic.h" > >u_int atomic_swap_int(volatile u_int *p, u_int v); >u_long atomic_swap_long(volatile u_long *p, u_long v); > >#endif /* __GNUCLIKE_ASM */ ># 367 "./machine/atomic.h" > >#define atomic_set_acq_char atomic_set_barr_char >#define atomic_set_rel_char atomic_set_barr_char >#define atomic_clear_acq_char atomic_clear_barr_char >#define atomic_clear_rel_char atomic_clear_barr_char >#define atomic_add_acq_char atomic_add_barr_char >#define atomic_add_rel_char atomic_add_barr_char >#define atomic_subtract_acq_char atomic_subtract_barr_char >#define atomic_subtract_rel_char atomic_subtract_barr_char > >#define atomic_set_acq_short atomic_set_barr_short >#define atomic_set_rel_short atomic_set_barr_short >#define atomic_clear_acq_short atomic_clear_barr_short >#define atomic_clear_rel_short atomic_clear_barr_short >#define atomic_add_acq_short atomic_add_barr_short >#define atomic_add_rel_short atomic_add_barr_short >#define atomic_subtract_acq_short atomic_subtract_barr_short >#define atomic_subtract_rel_short atomic_subtract_barr_short > >#define atomic_set_acq_int atomic_set_barr_int >#define atomic_set_rel_int atomic_set_barr_int >#define atomic_clear_acq_int atomic_clear_barr_int >#define atomic_clear_rel_int atomic_clear_barr_int >#define atomic_add_acq_int atomic_add_barr_int >#define atomic_add_rel_int atomic_add_barr_int >#define atomic_subtract_acq_int atomic_subtract_barr_int >#define atomic_subtract_rel_int atomic_subtract_barr_int >#define atomic_cmpset_acq_int atomic_cmpset_int >#define atomic_cmpset_rel_int atomic_cmpset_int > >#define atomic_set_acq_long atomic_set_barr_long >#define atomic_set_rel_long atomic_set_barr_long >#define atomic_clear_acq_long atomic_clear_barr_long >#define atomic_clear_rel_long atomic_clear_barr_long >#define atomic_add_acq_long atomic_add_barr_long >#define atomic_add_rel_long atomic_add_barr_long >#define atomic_subtract_acq_long atomic_subtract_barr_long >#define atomic_subtract_rel_long atomic_subtract_barr_long >#define atomic_cmpset_acq_long atomic_cmpset_long >#define atomic_cmpset_rel_long atomic_cmpset_long > >#define atomic_readandclear_int(p) atomic_swap_int(p, 0) >#define atomic_readandclear_long(p) atomic_swap_long(p, 0) > >/* Operations on 8-bit bytes. */ >#define atomic_set_8 atomic_set_char >#define atomic_set_acq_8 atomic_set_acq_char >#define atomic_set_rel_8 atomic_set_rel_char >#define atomic_clear_8 atomic_clear_char >#define atomic_clear_acq_8 atomic_clear_acq_char >#define atomic_clear_rel_8 atomic_clear_rel_char >#define atomic_add_8 atomic_add_char >#define atomic_add_acq_8 atomic_add_acq_char >#define atomic_add_rel_8 atomic_add_rel_char >#define atomic_subtract_8 atomic_subtract_char >#define atomic_subtract_acq_8 atomic_subtract_acq_char >#define atomic_subtract_rel_8 atomic_subtract_rel_char >#define atomic_load_acq_8 atomic_load_acq_char >#define atomic_store_rel_8 atomic_store_rel_char > >/* Operations on 16-bit words. */ >#define atomic_set_16 atomic_set_short >#define atomic_set_acq_16 atomic_set_acq_short >#define atomic_set_rel_16 atomic_set_rel_short >#define atomic_clear_16 atomic_clear_short >#define atomic_clear_acq_16 atomic_clear_acq_short >#define atomic_clear_rel_16 atomic_clear_rel_short >#define atomic_add_16 atomic_add_short >#define atomic_add_acq_16 atomic_add_acq_short >#define atomic_add_rel_16 atomic_add_rel_short >#define atomic_subtract_16 atomic_subtract_short >#define atomic_subtract_acq_16 atomic_subtract_acq_short >#define atomic_subtract_rel_16 atomic_subtract_rel_short >#define atomic_load_acq_16 atomic_load_acq_short >#define atomic_store_rel_16 atomic_store_rel_short > >/* Operations on 32-bit double words. */ >#define atomic_set_32 atomic_set_int >#define atomic_set_acq_32 atomic_set_acq_int >#define atomic_set_rel_32 atomic_set_rel_int >#define atomic_clear_32 atomic_clear_int >#define atomic_clear_acq_32 atomic_clear_acq_int >#define atomic_clear_rel_32 atomic_clear_rel_int >#define atomic_add_32 atomic_add_int >#define atomic_add_acq_32 atomic_add_acq_int >#define atomic_add_rel_32 atomic_add_rel_int >#define atomic_subtract_32 atomic_subtract_int >#define atomic_subtract_acq_32 atomic_subtract_acq_int >#define atomic_subtract_rel_32 atomic_subtract_rel_int >#define atomic_load_acq_32 atomic_load_acq_int >#define atomic_store_rel_32 atomic_store_rel_int >#define atomic_cmpset_32 atomic_cmpset_int >#define atomic_cmpset_acq_32 atomic_cmpset_acq_int >#define atomic_cmpset_rel_32 atomic_cmpset_rel_int >#define atomic_swap_32 atomic_swap_int >#define atomic_readandclear_32 atomic_readandclear_int >#define atomic_fetchadd_32 atomic_fetchadd_int >#define atomic_testandset_32 atomic_testandset_int > >/* Operations on 64-bit quad words. */ >#define atomic_set_64 atomic_set_long >#define atomic_set_acq_64 atomic_set_acq_long >#define atomic_set_rel_64 atomic_set_rel_long >#define atomic_clear_64 atomic_clear_long >#define atomic_clear_acq_64 atomic_clear_acq_long >#define atomic_clear_rel_64 atomic_clear_rel_long >#define atomic_add_64 atomic_add_long >#define atomic_add_acq_64 atomic_add_acq_long >#define atomic_add_rel_64 atomic_add_rel_long >#define atomic_subtract_64 atomic_subtract_long >#define atomic_subtract_acq_64 atomic_subtract_acq_long >#define atomic_subtract_rel_64 atomic_subtract_rel_long >#define atomic_load_acq_64 atomic_load_acq_long >#define atomic_store_rel_64 atomic_store_rel_long >#define atomic_cmpset_64 atomic_cmpset_long >#define atomic_cmpset_acq_64 atomic_cmpset_acq_long >#define atomic_cmpset_rel_64 atomic_cmpset_rel_long >#define atomic_swap_64 atomic_swap_long >#define atomic_readandclear_64 atomic_readandclear_long >#define atomic_testandset_64 atomic_testandset_long > >/* Operations on pointers. */ >#define atomic_set_ptr atomic_set_long >#define atomic_set_acq_ptr atomic_set_acq_long >#define atomic_set_rel_ptr atomic_set_rel_long >#define atomic_clear_ptr atomic_clear_long >#define atomic_clear_acq_ptr atomic_clear_acq_long >#define atomic_clear_rel_ptr atomic_clear_rel_long >#define atomic_add_ptr atomic_add_long >#define atomic_add_acq_ptr atomic_add_acq_long >#define atomic_add_rel_ptr atomic_add_rel_long >#define atomic_subtract_ptr atomic_subtract_long >#define atomic_subtract_acq_ptr atomic_subtract_acq_long >#define atomic_subtract_rel_ptr atomic_subtract_rel_long >#define atomic_load_acq_ptr atomic_load_acq_long >#define atomic_store_rel_ptr atomic_store_rel_long >#define atomic_cmpset_ptr atomic_cmpset_long >#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long >#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long >#define atomic_swap_ptr atomic_swap_long >#define atomic_readandclear_ptr atomic_readandclear_long > >#endif /* !WANT_FUNCTIONS */ ># 510 "./machine/atomic.h" > >#endif /* !_MACHINE_ATOMIC_H_ */ ># 512 "./machine/atomic.h" ># 42 "/usr/src/sys/sys/systm.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/systm.h" ># 1 "./machine/cpufunc.h" 1 >/*- > * Copyright (c) 2003 Peter Wemm. > * Copyright (c) 1993 The Regents of the University of California. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/amd64/include/cpufunc.h 278473 2015-02-09 21:00:56Z kib $ > */ > >/* > * Functions to provide access to special i386 instructions. > * This in included in sys/systm.h, and that file should be > * used in preference to this. > */ > >#ifndef _MACHINE_CPUFUNC_H_ >#define _MACHINE_CPUFUNC_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 45 "./machine/cpufunc.h" > >struct region_descriptor; > >#define readb(va) (*(volatile uint8_t *) (va)) >#define readw(va) (*(volatile uint16_t *) (va)) >#define readl(va) (*(volatile uint32_t *) (va)) >#define readq(va) (*(volatile uint64_t *) (va)) > >#define writeb(va, d) (*(volatile uint8_t *) (va) = (d)) >#define writew(va, d) (*(volatile uint16_t *) (va) = (d)) >#define writel(va, d) (*(volatile uint32_t *) (va) = (d)) >#define writeq(va, d) (*(volatile uint64_t *) (va) = (d)) > >#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE) > >static __inline void >breakpoint(void) >{ > __asm __volatile("int $3"); >} > >static __inline u_int >bsfl(u_int mask) >{ > u_int result; > > __asm __volatile("bsfl %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline u_long >bsfq(u_long mask) >{ > u_long result; > > __asm __volatile("bsfq %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline u_int >bsrl(u_int mask) >{ > u_int result; > > __asm __volatile("bsrl %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline u_long >bsrq(u_long mask) >{ > u_long result; > > __asm __volatile("bsrq %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline void >clflush(u_long addr) >{ > > __asm __volatile("clflush %0" : : "m" (*(char *)addr)); >} > >static __inline void >clts(void) >{ > > __asm __volatile("clts"); >} > >static __inline void >disable_intr(void) >{ > __asm __volatile("cli" : : : "memory"); >} > >static __inline void >do_cpuid(u_int ax, u_int *p) >{ > __asm __volatile("cpuid" > : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) > : "0" (ax)); >} > >static __inline void >cpuid_count(u_int ax, u_int cx, u_int *p) >{ > __asm __volatile("cpuid" > : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) > : "0" (ax), "c" (cx)); >} > >static __inline void >enable_intr(void) >{ > __asm __volatile("sti"); >} > >#ifdef _KERNEL > >#define HAVE_INLINE_FFS >#define ffs(x) __builtin_ffs(x) > >#define HAVE_INLINE_FFSL > >static __inline int >ffsl(long mask) >{ > return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1); >} > >#define HAVE_INLINE_FFSLL > >static __inline int >ffsll(long long mask) >{ > return (ffsl((long)mask)); >} > >#define HAVE_INLINE_FLS > >static __inline int >fls(int mask) >{ > return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1); >} > >#define HAVE_INLINE_FLSL > >static __inline int >flsl(long mask) >{ > return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1); >} > >#define HAVE_INLINE_FLSLL > >static __inline int >flsll(long long mask) >{ > return (flsl((long)mask)); >} > >#endif /* _KERNEL */ ># 190 "./machine/cpufunc.h" > >static __inline void >halt(void) >{ > __asm __volatile("hlt"); >} > >static __inline u_char >inb(u_int port) >{ > u_char data; > > __asm __volatile("inb %w1, %0" : "=a" (data) : "Nd" (port)); > return (data); >} > >static __inline u_int >inl(u_int port) >{ > u_int data; > > __asm __volatile("inl %w1, %0" : "=a" (data) : "Nd" (port)); > return (data); >} > >static __inline void >insb(u_int port, void *addr, size_t count) >{ > __asm __volatile("cld; rep; insb" > : "+D" (addr), "+c" (count) > : "d" (port) > : "memory"); >} > >static __inline void >insw(u_int port, void *addr, size_t count) >{ > __asm __volatile("cld; rep; insw" > : "+D" (addr), "+c" (count) > : "d" (port) > : "memory"); >} > >static __inline void >insl(u_int port, void *addr, size_t count) >{ > __asm __volatile("cld; rep; insl" > : "+D" (addr), "+c" (count) > : "d" (port) > : "memory"); >} > >static __inline void >invd(void) >{ > __asm __volatile("invd"); >} > >static __inline u_short >inw(u_int port) >{ > u_short data; > > __asm __volatile("inw %w1, %0" : "=a" (data) : "Nd" (port)); > return (data); >} > >static __inline void >outb(u_int port, u_char data) >{ > __asm __volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); >} > >static __inline void >outl(u_int port, u_int data) >{ > __asm __volatile("outl %0, %w1" : : "a" (data), "Nd" (port)); >} > >static __inline void >outsb(u_int port, const void *addr, size_t count) >{ > __asm __volatile("cld; rep; outsb" > : "+S" (addr), "+c" (count) > : "d" (port)); >} > >static __inline void >outsw(u_int port, const void *addr, size_t count) >{ > __asm __volatile("cld; rep; outsw" > : "+S" (addr), "+c" (count) > : "d" (port)); >} > >static __inline void >outsl(u_int port, const void *addr, size_t count) >{ > __asm __volatile("cld; rep; outsl" > : "+S" (addr), "+c" (count) > : "d" (port)); >} > >static __inline void >outw(u_int port, u_short data) >{ > __asm __volatile("outw %0, %w1" : : "a" (data), "Nd" (port)); >} > >static __inline u_long >popcntq(u_long mask) >{ > u_long result; > > __asm __volatile("popcntq %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline void >lfence(void) >{ > > __asm __volatile("lfence" : : : "memory"); >} > >static __inline void >mfence(void) >{ > > __asm __volatile("mfence" : : : "memory"); >} > >static __inline void >ia32_pause(void) >{ > __asm __volatile("pause"); >} > >static __inline u_long >read_rflags(void) >{ > u_long rf; > > __asm __volatile("pushfq; popq %0" : "=r" (rf)); > return (rf); >} > >static __inline uint64_t >rdmsr(u_int msr) >{ > uint32_t low, high; > > __asm __volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr)); > return (low | ((uint64_t)high << 32)); >} > >static __inline uint32_t >rdmsr32(u_int msr) >{ > uint32_t low; > > __asm __volatile("rdmsr" : "=a" (low) : "c" (msr) : "rdx"); > return (low); >} > >static __inline uint64_t >rdpmc(u_int pmc) >{ > uint32_t low, high; > > __asm __volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (pmc)); > return (low | ((uint64_t)high << 32)); >} > >static __inline uint64_t >rdtsc(void) >{ > uint32_t low, high; > > __asm __volatile("rdtsc" : "=a" (low), "=d" (high)); > return (low | ((uint64_t)high << 32)); >} > >static __inline uint32_t >rdtsc32(void) >{ > uint32_t rv; > > __asm __volatile("rdtsc" : "=a" (rv) : : "edx"); > return (rv); >} > >static __inline void >wbinvd(void) >{ > __asm __volatile("wbinvd"); >} > >static __inline void >write_rflags(u_long rf) >{ > __asm __volatile("pushq %0; popfq" : : "r" (rf)); >} > >static __inline void >wrmsr(u_int msr, uint64_t newval) >{ > uint32_t low, high; > > low = newval; > high = newval >> 32; > __asm __volatile("wrmsr" : : "a" (low), "d" (high), "c" (msr)); >} > >static __inline void >load_cr0(u_long data) >{ > > __asm __volatile("movq %0,%%cr0" : : "r" (data)); >} > >static __inline u_long >rcr0(void) >{ > u_long data; > > __asm __volatile("movq %%cr0,%0" : "=r" (data)); > return (data); >} > >static __inline u_long >rcr2(void) >{ > u_long data; > > __asm __volatile("movq %%cr2,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_cr3(u_long data) >{ > > __asm __volatile("movq %0,%%cr3" : : "r" (data) : "memory"); >} > >static __inline u_long >rcr3(void) >{ > u_long data; > > __asm __volatile("movq %%cr3,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_cr4(u_long data) >{ > __asm __volatile("movq %0,%%cr4" : : "r" (data)); >} > >static __inline u_long >rcr4(void) >{ > u_long data; > > __asm __volatile("movq %%cr4,%0" : "=r" (data)); > return (data); >} > >static __inline u_long >rxcr(u_int reg) >{ > u_int low, high; > > __asm __volatile("xgetbv" : "=a" (low), "=d" (high) : "c" (reg)); > return (low | ((uint64_t)high << 32)); >} > >static __inline void >load_xcr(u_int reg, u_long val) >{ > u_int low, high; > > low = val; > high = val >> 32; > __asm __volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high)); >} > >/* > * Global TLB flush (except for thise for pages marked PG_G) > */ >static __inline void >invltlb(void) >{ > > load_cr3(rcr3()); >} > >#ifndef CR4_PGE >#define CR4_PGE 0x00000080 /* Page global enable */ >#endif ># 492 "./machine/cpufunc.h" > >/* > * Perform the guaranteed invalidation of all TLB entries. This > * includes the global entries, and entries in all PCIDs, not only the > * current context. The function works both on non-PCID CPUs and CPUs > * with the PCID turned off or on. See IA-32 SDM Vol. 3a 4.10.4.1 > * Operations that Invalidate TLBs and Paging-Structure Caches. > */ >static __inline void >invltlb_globpcid(void) >{ > uint64_t cr4; > > cr4 = rcr4(); > load_cr4(cr4 & ~CR4_PGE); > /* > * Although preemption at this point could be detrimental to > * performance, it would not lead to an error. PG_G is simply > * ignored if CR4.PGE is clear. Moreover, in case this block > * is re-entered, the load_cr4() either above or below will > * modify CR4.PGE flushing the TLB. > */ > load_cr4(cr4 | CR4_PGE); >} > >/* > * TLB flush for an individual page (even if it has PG_G). > * Only works on 486+ CPUs (i386 does not have PG_G). > */ >static __inline void >invlpg(u_long addr) >{ > > __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); >} > >#define INVPCID_ADDR 0 >#define INVPCID_CTX 1 >#define INVPCID_CTXGLOB 2 >#define INVPCID_ALLCTX 3 > >struct invpcid_descr { > uint64_t pcid:12 __packed; > uint64_t pad:52 __packed; > uint64_t addr; >} __packed; > >static __inline void >invpcid(struct invpcid_descr *d, int type) >{ > > /* invpcid (%rdx),%rax */ > __asm __volatile(".byte 0x66,0x0f,0x38,0x82,0x02" > : : "d" (d), "a" ((u_long)type) : "memory"); >} > >static __inline u_short >rfs(void) >{ > u_short sel; > __asm __volatile("movw %%fs,%0" : "=rm" (sel)); > return (sel); >} > >static __inline u_short >rgs(void) >{ > u_short sel; > __asm __volatile("movw %%gs,%0" : "=rm" (sel)); > return (sel); >} > >static __inline u_short >rss(void) >{ > u_short sel; > __asm __volatile("movw %%ss,%0" : "=rm" (sel)); > return (sel); >} > >static __inline void >load_ds(u_short sel) >{ > __asm __volatile("movw %0,%%ds" : : "rm" (sel)); >} > >static __inline void >load_es(u_short sel) >{ > __asm __volatile("movw %0,%%es" : : "rm" (sel)); >} > >static __inline void >cpu_monitor(const void *addr, u_long extensions, u_int hints) >{ > > __asm __volatile("monitor" > : : "a" (addr), "c" (extensions), "d" (hints)); >} > >static __inline void >cpu_mwait(u_long extensions, u_int hints) >{ > > __asm __volatile("mwait" : : "a" (hints), "c" (extensions)); >} > >#ifdef _KERNEL >/* This is defined in <machine/specialreg.h> but is too painful to get to */ >#ifndef MSR_FSBASE >#define MSR_FSBASE 0xc0000100 >#endif ># 604 "./machine/cpufunc.h" >static __inline void >load_fs(u_short sel) >{ > /* Preserve the fsbase value across the selector load */ > __asm __volatile("rdmsr; movw %0,%%fs; wrmsr" > : : "rm" (sel), "c" (MSR_FSBASE) : "eax", "edx"); >} > >#ifndef MSR_GSBASE >#define MSR_GSBASE 0xc0000101 >#endif ># 615 "./machine/cpufunc.h" >static __inline void >load_gs(u_short sel) >{ > /* > * Preserve the gsbase value across the selector load. > * Note that we have to disable interrupts because the gsbase > * being trashed happens to be the kernel gsbase at the time. > */ > __asm __volatile("pushfq; cli; rdmsr; movw %0,%%gs; wrmsr; popfq" > : : "rm" (sel), "c" (MSR_GSBASE) : "eax", "edx"); >} >#else ># 627 "./machine/cpufunc.h" >/* Usable by userland */ >static __inline void >load_fs(u_short sel) >{ > __asm __volatile("movw %0,%%fs" : : "rm" (sel)); >} > >static __inline void >load_gs(u_short sel) >{ > __asm __volatile("movw %0,%%gs" : : "rm" (sel)); >} >#endif ># 640 "./machine/cpufunc.h" > >static __inline void >lidt(struct region_descriptor *addr) >{ > __asm __volatile("lidt (%0)" : : "r" (addr)); >} > >static __inline void >lldt(u_short sel) >{ > __asm __volatile("lldt %0" : : "r" (sel)); >} > >static __inline void >ltr(u_short sel) >{ > __asm __volatile("ltr %0" : : "r" (sel)); >} > >static __inline uint64_t >rdr0(void) >{ > uint64_t data; > __asm __volatile("movq %%dr0,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr0(uint64_t dr0) >{ > __asm __volatile("movq %0,%%dr0" : : "r" (dr0)); >} > >static __inline uint64_t >rdr1(void) >{ > uint64_t data; > __asm __volatile("movq %%dr1,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr1(uint64_t dr1) >{ > __asm __volatile("movq %0,%%dr1" : : "r" (dr1)); >} > >static __inline uint64_t >rdr2(void) >{ > uint64_t data; > __asm __volatile("movq %%dr2,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr2(uint64_t dr2) >{ > __asm __volatile("movq %0,%%dr2" : : "r" (dr2)); >} > >static __inline uint64_t >rdr3(void) >{ > uint64_t data; > __asm __volatile("movq %%dr3,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr3(uint64_t dr3) >{ > __asm __volatile("movq %0,%%dr3" : : "r" (dr3)); >} > >static __inline uint64_t >rdr4(void) >{ > uint64_t data; > __asm __volatile("movq %%dr4,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr4(uint64_t dr4) >{ > __asm __volatile("movq %0,%%dr4" : : "r" (dr4)); >} > >static __inline uint64_t >rdr5(void) >{ > uint64_t data; > __asm __volatile("movq %%dr5,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr5(uint64_t dr5) >{ > __asm __volatile("movq %0,%%dr5" : : "r" (dr5)); >} > >static __inline uint64_t >rdr6(void) >{ > uint64_t data; > __asm __volatile("movq %%dr6,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr6(uint64_t dr6) >{ > __asm __volatile("movq %0,%%dr6" : : "r" (dr6)); >} > >static __inline uint64_t >rdr7(void) >{ > uint64_t data; > __asm __volatile("movq %%dr7,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr7(uint64_t dr7) >{ > __asm __volatile("movq %0,%%dr7" : : "r" (dr7)); >} > >static __inline register_t >intr_disable(void) >{ > register_t rflags; > > rflags = read_rflags(); > disable_intr(); > return (rflags); >} > >static __inline void >intr_restore(register_t rflags) >{ > write_rflags(rflags); >} > >#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */ ># 788 "./machine/cpufunc.h" > >int breakpoint(void); >u_int bsfl(u_int mask); >u_int bsrl(u_int mask); >void clflush(u_long addr); >void clts(void); >void cpuid_count(u_int ax, u_int cx, u_int *p); >void disable_intr(void); >void do_cpuid(u_int ax, u_int *p); >void enable_intr(void); >void halt(void); >void ia32_pause(void); >u_char inb(u_int port); >u_int inl(u_int port); >void insb(u_int port, void *addr, size_t count); >void insl(u_int port, void *addr, size_t count); >void insw(u_int port, void *addr, size_t count); >register_t intr_disable(void); >void intr_restore(register_t rf); >void invd(void); >void invlpg(u_int addr); >void invltlb(void); >u_short inw(u_int port); >void lidt(struct region_descriptor *addr); >void lldt(u_short sel); >void load_cr0(u_long cr0); >void load_cr3(u_long cr3); >void load_cr4(u_long cr4); >void load_dr0(uint64_t dr0); >void load_dr1(uint64_t dr1); >void load_dr2(uint64_t dr2); >void load_dr3(uint64_t dr3); >void load_dr4(uint64_t dr4); >void load_dr5(uint64_t dr5); >void load_dr6(uint64_t dr6); >void load_dr7(uint64_t dr7); >void load_fs(u_short sel); >void load_gs(u_short sel); >void ltr(u_short sel); >void outb(u_int port, u_char data); >void outl(u_int port, u_int data); >void outsb(u_int port, const void *addr, size_t count); >void outsl(u_int port, const void *addr, size_t count); >void outsw(u_int port, const void *addr, size_t count); >void outw(u_int port, u_short data); >u_long rcr0(void); >u_long rcr2(void); >u_long rcr3(void); >u_long rcr4(void); >uint64_t rdmsr(u_int msr); >uint32_t rdmsr32(u_int msr); >uint64_t rdpmc(u_int pmc); >uint64_t rdr0(void); >uint64_t rdr1(void); >uint64_t rdr2(void); >uint64_t rdr3(void); >uint64_t rdr4(void); >uint64_t rdr5(void); >uint64_t rdr6(void); >uint64_t rdr7(void); >uint64_t rdtsc(void); >u_long read_rflags(void); >u_int rfs(void); >u_int rgs(void); >void wbinvd(void); >void write_rflags(u_int rf); >void wrmsr(u_int msr, uint64_t newval); > >#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */ ># 857 "./machine/cpufunc.h" > >void reset_dbregs(void); > >#ifdef _KERNEL >int rdmsr_safe(u_int msr, uint64_t *val); >int wrmsr_safe(u_int msr, uint64_t newval); >#endif ># 864 "./machine/cpufunc.h" > >#endif /* !_MACHINE_CPUFUNC_H_ */ ># 866 "./machine/cpufunc.h" ># 43 "/usr/src/sys/sys/systm.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/callout.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/systm.h" ># 1 "/usr/src/sys/sys/callout.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)callout.h 8.2 (Berkeley) 1/21/94 > * $FreeBSD: head/sys/sys/callout.h 278469 2015-02-09 19:19:44Z rrs $ > */ > >#ifndef _SYS_CALLOUT_H_ >#define _SYS_CALLOUT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_callout.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/callout.h" ># 1 "/usr/src/sys/sys/_callout.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)callout.h 8.2 (Berkeley) 1/21/94 > * $FreeBSD: head/sys/sys/_callout.h 277528 2015-01-22 11:12:42Z hselasky $ > */ > >#ifndef _SYS__CALLOUT_H >#define _SYS__CALLOUT_H > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/_callout.h" ># 1 "/usr/src/sys/sys/queue.h" 1 >/*- > * Copyright (c) 1991, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)queue.h 8.5 (Berkeley) 8/20/94 > * $FreeBSD: head/sys/sys/queue.h 279242 2015-02-24 17:36:44Z hselasky $ > */ > >#ifndef _SYS_QUEUE_H_ >#define _SYS_QUEUE_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/queue.h" ># 37 "/usr/src/sys/sys/queue.h" > >/* > * This file defines four types of data structures: singly-linked lists, > * singly-linked tail queues, lists and tail queues. > * > * A singly-linked list is headed by a single forward pointer. The elements > * are singly linked for minimum space and pointer manipulation overhead at > * the expense of O(n) removal for arbitrary elements. New elements can be > * added to the list after an existing element or at the head of the list. > * Elements being removed from the head of the list should use the explicit > * macro for this purpose for optimum efficiency. A singly-linked list may > * only be traversed in the forward direction. Singly-linked lists are ideal > * for applications with large datasets and few or no removals or for > * implementing a LIFO queue. > * > * A singly-linked tail queue is headed by a pair of pointers, one to the > * head of the list and the other to the tail of the list. The elements are > * singly linked for minimum space and pointer manipulation overhead at the > * expense of O(n) removal for arbitrary elements. New elements can be added > * to the list after an existing element, at the head of the list, or at the > * end of the list. Elements being removed from the head of the tail queue > * should use the explicit macro for this purpose for optimum efficiency. > * A singly-linked tail queue may only be traversed in the forward direction. > * Singly-linked tail queues are ideal for applications with large datasets > * and few or no removals or for implementing a FIFO queue. > * > * A list is headed by a single forward pointer (or an array of forward > * pointers for a hash table header). The elements are doubly linked > * so that an arbitrary element can be removed without a need to > * traverse the list. New elements can be added to the list before > * or after an existing element or at the head of the list. A list > * may be traversed in either direction. > * > * A tail queue is headed by a pair of pointers, one to the head of the > * list and the other to the tail of the list. The elements are doubly > * linked so that an arbitrary element can be removed without a need to > * traverse the list. New elements can be added to the list before or > * after an existing element, at the head of the list, or at the end of > * the list. A tail queue may be traversed in either direction. > * > * For details on the use of these macros, see the queue(3) manual page. > * > * > * SLIST LIST STAILQ TAILQ > * _HEAD + + + + > * _HEAD_INITIALIZER + + + + > * _ENTRY + + + + > * _INIT + + + + > * _EMPTY + + + + > * _FIRST + + + + > * _NEXT + + + + > * _PREV - + - + > * _LAST - - + + > * _FOREACH + + + + > * _FOREACH_FROM + + + + > * _FOREACH_SAFE + + + + > * _FOREACH_FROM_SAFE + + + + > * _FOREACH_REVERSE - - - + > * _FOREACH_REVERSE_FROM - - - + > * _FOREACH_REVERSE_SAFE - - - + > * _FOREACH_REVERSE_FROM_SAFE - - - + > * _INSERT_HEAD + + + + > * _INSERT_BEFORE - + - + > * _INSERT_AFTER + + + + > * _INSERT_TAIL - - + + > * _CONCAT - - + + > * _REMOVE_AFTER + - + - > * _REMOVE_HEAD + - + - > * _REMOVE + + + + > * _SWAP + + + + > * > */ >#ifdef QUEUE_MACRO_DEBUG >/* Store the last 2 places the queue element or head was altered */ >struct qm_trace { > unsigned long lastline; > unsigned long prevline; > const char *lastfile; > const char *prevfile; >}; > >#define TRACEBUF struct qm_trace trace; >#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } , >#define TRASHIT(x) do {(x) = (void *)-1;} while (0) >#define QMD_SAVELINK(name, link) void **name = (void *)&(link) > >#define QMD_TRACE_HEAD(head) do { \ > (head)->trace.prevline = (head)->trace.lastline; \ > (head)->trace.prevfile = (head)->trace.lastfile; \ > (head)->trace.lastline = __LINE__; \ > (head)->trace.lastfile = __FILE__; \ >} while (0) > >#define QMD_TRACE_ELEM(elem) do { \ > (elem)->trace.prevline = (elem)->trace.lastline; \ > (elem)->trace.prevfile = (elem)->trace.lastfile; \ > (elem)->trace.lastline = __LINE__; \ > (elem)->trace.lastfile = __FILE__; \ >} while (0) > >#else ># 138 "/usr/src/sys/sys/queue.h" >#define QMD_TRACE_ELEM(elem) >#define QMD_TRACE_HEAD(head) >#define QMD_SAVELINK(name, link) >#define TRACEBUF >#define TRACEBUF_INITIALIZER >#define TRASHIT(x) >#endif /* QUEUE_MACRO_DEBUG */ ># 145 "/usr/src/sys/sys/queue.h" > >/* > * Singly-linked List declarations. > */ >#define SLIST_HEAD(name, type) \ >struct name { \ > struct type *slh_first; /* first element */ \ >} > >#define SLIST_HEAD_INITIALIZER(head) \ > { NULL } > >#define SLIST_ENTRY(type) \ >struct { \ > struct type *sle_next; /* next element */ \ >} > >/* > * Singly-linked List functions. > */ >#define SLIST_EMPTY(head) ((head)->slh_first == NULL) > >#define SLIST_FIRST(head) ((head)->slh_first) > >#define SLIST_FOREACH(var, head, field) \ > for ((var) = SLIST_FIRST((head)); \ > (var); \ > (var) = SLIST_NEXT((var), field)) > >#define SLIST_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ > (var); \ > (var) = SLIST_NEXT((var), field)) > >#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = SLIST_FIRST((head)); \ > (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ > (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ > for ((varp) = &SLIST_FIRST((head)); \ > ((var) = *(varp)) != NULL; \ > (varp) = &SLIST_NEXT((var), field)) > >#define SLIST_INIT(head) do { \ > SLIST_FIRST((head)) = NULL; \ >} while (0) > >#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ > SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ > SLIST_NEXT((slistelm), field) = (elm); \ >} while (0) > >#define SLIST_INSERT_HEAD(head, elm, field) do { \ > SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ > SLIST_FIRST((head)) = (elm); \ >} while (0) > >#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) > >#define SLIST_REMOVE(head, elm, type, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ > if (SLIST_FIRST((head)) == (elm)) { \ > SLIST_REMOVE_HEAD((head), field); \ > } \ > else { \ > struct type *curelm = SLIST_FIRST((head)); \ > while (SLIST_NEXT(curelm, field) != (elm)) \ > curelm = SLIST_NEXT(curelm, field); \ > SLIST_REMOVE_AFTER(curelm, field); \ > } \ > TRASHIT(*oldnext); \ >} while (0) > >#define SLIST_REMOVE_AFTER(elm, field) do { \ > SLIST_NEXT(elm, field) = \ > SLIST_NEXT(SLIST_NEXT(elm, field), field); \ >} while (0) > >#define SLIST_REMOVE_HEAD(head, field) do { \ > SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ >} while (0) > >#define SLIST_SWAP(head1, head2, type) do { \ > struct type *swap_first = SLIST_FIRST(head1); \ > SLIST_FIRST(head1) = SLIST_FIRST(head2); \ > SLIST_FIRST(head2) = swap_first; \ >} while (0) > >/* > * Singly-linked Tail queue declarations. > */ >#define STAILQ_HEAD(name, type) \ >struct name { \ > struct type *stqh_first;/* first element */ \ > struct type **stqh_last;/* addr of last next element */ \ >} > >#define STAILQ_HEAD_INITIALIZER(head) \ > { NULL, &(head).stqh_first } > >#define STAILQ_ENTRY(type) \ >struct { \ > struct type *stqe_next; /* next element */ \ >} > >/* > * Singly-linked Tail queue functions. > */ >#define STAILQ_CONCAT(head1, head2) do { \ > if (!STAILQ_EMPTY((head2))) { \ > *(head1)->stqh_last = (head2)->stqh_first; \ > (head1)->stqh_last = (head2)->stqh_last; \ > STAILQ_INIT((head2)); \ > } \ >} while (0) > >#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) > >#define STAILQ_FIRST(head) ((head)->stqh_first) > >#define STAILQ_FOREACH(var, head, field) \ > for((var) = STAILQ_FIRST((head)); \ > (var); \ > (var) = STAILQ_NEXT((var), field)) > >#define STAILQ_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ > (var); \ > (var) = STAILQ_NEXT((var), field)) > >#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = STAILQ_FIRST((head)); \ > (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ > (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define STAILQ_INIT(head) do { \ > STAILQ_FIRST((head)) = NULL; \ > (head)->stqh_last = &STAILQ_FIRST((head)); \ >} while (0) > >#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ > if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ > STAILQ_NEXT((tqelm), field) = (elm); \ >} while (0) > >#define STAILQ_INSERT_HEAD(head, elm, field) do { \ > if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ > STAILQ_FIRST((head)) = (elm); \ >} while (0) > >#define STAILQ_INSERT_TAIL(head, elm, field) do { \ > STAILQ_NEXT((elm), field) = NULL; \ > *(head)->stqh_last = (elm); \ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ >} while (0) > >#define STAILQ_LAST(head, type, field) \ > (STAILQ_EMPTY((head)) ? NULL : \ > __containerof((head)->stqh_last, struct type, field.stqe_next)) > >#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) > >#define STAILQ_REMOVE(head, elm, type, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ > if (STAILQ_FIRST((head)) == (elm)) { \ > STAILQ_REMOVE_HEAD((head), field); \ > } \ > else { \ > struct type *curelm = STAILQ_FIRST((head)); \ > while (STAILQ_NEXT(curelm, field) != (elm)) \ > curelm = STAILQ_NEXT(curelm, field); \ > STAILQ_REMOVE_AFTER(head, curelm, field); \ > } \ > TRASHIT(*oldnext); \ >} while (0) > >#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ > if ((STAILQ_NEXT(elm, field) = \ > STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ >} while (0) > >#define STAILQ_REMOVE_HEAD(head, field) do { \ > if ((STAILQ_FIRST((head)) = \ > STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ > (head)->stqh_last = &STAILQ_FIRST((head)); \ >} while (0) > >#define STAILQ_SWAP(head1, head2, type) do { \ > struct type *swap_first = STAILQ_FIRST(head1); \ > struct type **swap_last = (head1)->stqh_last; \ > STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ > (head1)->stqh_last = (head2)->stqh_last; \ > STAILQ_FIRST(head2) = swap_first; \ > (head2)->stqh_last = swap_last; \ > if (STAILQ_EMPTY(head1)) \ > (head1)->stqh_last = &STAILQ_FIRST(head1); \ > if (STAILQ_EMPTY(head2)) \ > (head2)->stqh_last = &STAILQ_FIRST(head2); \ >} while (0) > > >/* > * List declarations. > */ >#define LIST_HEAD(name, type) \ >struct name { \ > struct type *lh_first; /* first element */ \ >} > >#define LIST_HEAD_INITIALIZER(head) \ > { NULL } > >#define LIST_ENTRY(type) \ >struct { \ > struct type *le_next; /* next element */ \ > struct type **le_prev; /* address of previous next element */ \ >} > >/* > * List functions. > */ > >#if (defined(_KERNEL) && defined(INVARIANTS)) >#define QMD_LIST_CHECK_HEAD(head, field) do { \ > if (LIST_FIRST((head)) != NULL && \ > LIST_FIRST((head))->field.le_prev != \ > &LIST_FIRST((head))) \ > panic("Bad list head %p first->prev != head", (head)); \ >} while (0) > >#define QMD_LIST_CHECK_NEXT(elm, field) do { \ > if (LIST_NEXT((elm), field) != NULL && \ > LIST_NEXT((elm), field)->field.le_prev != \ > &((elm)->field.le_next)) \ > panic("Bad link elm %p next->prev != elm", (elm)); \ >} while (0) > >#define QMD_LIST_CHECK_PREV(elm, field) do { \ > if (*(elm)->field.le_prev != (elm)) \ > panic("Bad link elm %p prev->next != elm", (elm)); \ >} while (0) >#else ># 401 "/usr/src/sys/sys/queue.h" >#define QMD_LIST_CHECK_HEAD(head, field) >#define QMD_LIST_CHECK_NEXT(elm, field) >#define QMD_LIST_CHECK_PREV(elm, field) >#endif /* (_KERNEL && INVARIANTS) */ ># 405 "/usr/src/sys/sys/queue.h" > >#define LIST_EMPTY(head) ((head)->lh_first == NULL) > >#define LIST_FIRST(head) ((head)->lh_first) > >#define LIST_FOREACH(var, head, field) \ > for ((var) = LIST_FIRST((head)); \ > (var); \ > (var) = LIST_NEXT((var), field)) > >#define LIST_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ > (var); \ > (var) = LIST_NEXT((var), field)) > >#define LIST_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = LIST_FIRST((head)); \ > (var) && ((tvar) = LIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ > (var) && ((tvar) = LIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define LIST_INIT(head) do { \ > LIST_FIRST((head)) = NULL; \ >} while (0) > >#define LIST_INSERT_AFTER(listelm, elm, field) do { \ > QMD_LIST_CHECK_NEXT(listelm, field); \ > if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ > LIST_NEXT((listelm), field)->field.le_prev = \ > &LIST_NEXT((elm), field); \ > LIST_NEXT((listelm), field) = (elm); \ > (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ >} while (0) > >#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ > QMD_LIST_CHECK_PREV(listelm, field); \ > (elm)->field.le_prev = (listelm)->field.le_prev; \ > LIST_NEXT((elm), field) = (listelm); \ > *(listelm)->field.le_prev = (elm); \ > (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ >} while (0) > >#define LIST_INSERT_HEAD(head, elm, field) do { \ > QMD_LIST_CHECK_HEAD((head), field); \ > if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ > LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ > LIST_FIRST((head)) = (elm); \ > (elm)->field.le_prev = &LIST_FIRST((head)); \ >} while (0) > >#define LIST_NEXT(elm, field) ((elm)->field.le_next) > >#define LIST_PREV(elm, head, type, field) \ > ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ > __containerof((elm)->field.le_prev, struct type, field.le_next)) > >#define LIST_REMOVE(elm, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.le_next); \ > QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ > QMD_LIST_CHECK_NEXT(elm, field); \ > QMD_LIST_CHECK_PREV(elm, field); \ > if (LIST_NEXT((elm), field) != NULL) \ > LIST_NEXT((elm), field)->field.le_prev = \ > (elm)->field.le_prev; \ > *(elm)->field.le_prev = LIST_NEXT((elm), field); \ > TRASHIT(*oldnext); \ > TRASHIT(*oldprev); \ >} while (0) > >#define LIST_SWAP(head1, head2, type, field) do { \ > struct type *swap_tmp = LIST_FIRST((head1)); \ > LIST_FIRST((head1)) = LIST_FIRST((head2)); \ > LIST_FIRST((head2)) = swap_tmp; \ > if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ > swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ > if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ > swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ >} while (0) > >/* > * Tail queue declarations. > */ >#define TAILQ_HEAD(name, type) \ >struct name { \ > struct type *tqh_first; /* first element */ \ > struct type **tqh_last; /* addr of last next element */ \ > TRACEBUF \ >} > >#define TAILQ_HEAD_INITIALIZER(head) \ > { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } > >#define TAILQ_ENTRY(type) \ >struct { \ > struct type *tqe_next; /* next element */ \ > struct type **tqe_prev; /* address of previous next element */ \ > TRACEBUF \ >} > >/* > * Tail queue functions. > */ >#if (defined(_KERNEL) && defined(INVARIANTS)) >#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ > if (!TAILQ_EMPTY(head) && \ > TAILQ_FIRST((head))->field.tqe_prev != \ > &TAILQ_FIRST((head))) \ > panic("Bad tailq head %p first->prev != head", (head)); \ >} while (0) > >#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ > if (*(head)->tqh_last != NULL) \ > panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ >} while (0) > >#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ > if (TAILQ_NEXT((elm), field) != NULL && \ > TAILQ_NEXT((elm), field)->field.tqe_prev != \ > &((elm)->field.tqe_next)) \ > panic("Bad link elm %p next->prev != elm", (elm)); \ >} while (0) > >#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ > if (*(elm)->field.tqe_prev != (elm)) \ > panic("Bad link elm %p prev->next != elm", (elm)); \ >} while (0) >#else ># 536 "/usr/src/sys/sys/queue.h" >#define QMD_TAILQ_CHECK_HEAD(head, field) >#define QMD_TAILQ_CHECK_TAIL(head, headname) >#define QMD_TAILQ_CHECK_NEXT(elm, field) >#define QMD_TAILQ_CHECK_PREV(elm, field) >#endif /* (_KERNEL && INVARIANTS) */ ># 541 "/usr/src/sys/sys/queue.h" > >#define TAILQ_CONCAT(head1, head2, field) do { \ > if (!TAILQ_EMPTY(head2)) { \ > *(head1)->tqh_last = (head2)->tqh_first; \ > (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ > (head1)->tqh_last = (head2)->tqh_last; \ > TAILQ_INIT((head2)); \ > QMD_TRACE_HEAD(head1); \ > QMD_TRACE_HEAD(head2); \ > } \ >} while (0) > >#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) > >#define TAILQ_FIRST(head) ((head)->tqh_first) > >#define TAILQ_FOREACH(var, head, field) \ > for ((var) = TAILQ_FIRST((head)); \ > (var); \ > (var) = TAILQ_NEXT((var), field)) > >#define TAILQ_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ > (var); \ > (var) = TAILQ_NEXT((var), field)) > >#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = TAILQ_FIRST((head)); \ > (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ > (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ > for ((var) = TAILQ_LAST((head), headname); \ > (var); \ > (var) = TAILQ_PREV((var), headname, field)) > >#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ > for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ > (var); \ > (var) = TAILQ_PREV((var), headname, field)) > >#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ > for ((var) = TAILQ_LAST((head), headname); \ > (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ > (var) = (tvar)) > >#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ > for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ > (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ > (var) = (tvar)) > >#define TAILQ_INIT(head) do { \ > TAILQ_FIRST((head)) = NULL; \ > (head)->tqh_last = &TAILQ_FIRST((head)); \ > QMD_TRACE_HEAD(head); \ >} while (0) > >#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ > QMD_TAILQ_CHECK_NEXT(listelm, field); \ > if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ > TAILQ_NEXT((elm), field)->field.tqe_prev = \ > &TAILQ_NEXT((elm), field); \ > else { \ > (head)->tqh_last = &TAILQ_NEXT((elm), field); \ > QMD_TRACE_HEAD(head); \ > } \ > TAILQ_NEXT((listelm), field) = (elm); \ > (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ > QMD_TRACE_ELEM(&(elm)->field); \ > QMD_TRACE_ELEM(&(listelm)->field); \ >} while (0) > >#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ > QMD_TAILQ_CHECK_PREV(listelm, field); \ > (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ > TAILQ_NEXT((elm), field) = (listelm); \ > *(listelm)->field.tqe_prev = (elm); \ > (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ > QMD_TRACE_ELEM(&(elm)->field); \ > QMD_TRACE_ELEM(&(listelm)->field); \ >} while (0) > >#define TAILQ_INSERT_HEAD(head, elm, field) do { \ > QMD_TAILQ_CHECK_HEAD(head, field); \ > if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ > TAILQ_FIRST((head))->field.tqe_prev = \ > &TAILQ_NEXT((elm), field); \ > else \ > (head)->tqh_last = &TAILQ_NEXT((elm), field); \ > TAILQ_FIRST((head)) = (elm); \ > (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ > QMD_TRACE_HEAD(head); \ > QMD_TRACE_ELEM(&(elm)->field); \ >} while (0) > >#define TAILQ_INSERT_TAIL(head, elm, field) do { \ > QMD_TAILQ_CHECK_TAIL(head, field); \ > TAILQ_NEXT((elm), field) = NULL; \ > (elm)->field.tqe_prev = (head)->tqh_last; \ > *(head)->tqh_last = (elm); \ > (head)->tqh_last = &TAILQ_NEXT((elm), field); \ > QMD_TRACE_HEAD(head); \ > QMD_TRACE_ELEM(&(elm)->field); \ >} while (0) > >#define TAILQ_LAST(head, headname) \ > (*(((struct headname *)((head)->tqh_last))->tqh_last)) > >#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) > >#define TAILQ_PREV(elm, headname, field) \ > (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) > >#define TAILQ_REMOVE(head, elm, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ > QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ > QMD_TAILQ_CHECK_NEXT(elm, field); \ > QMD_TAILQ_CHECK_PREV(elm, field); \ > if ((TAILQ_NEXT((elm), field)) != NULL) \ > TAILQ_NEXT((elm), field)->field.tqe_prev = \ > (elm)->field.tqe_prev; \ > else { \ > (head)->tqh_last = (elm)->field.tqe_prev; \ > QMD_TRACE_HEAD(head); \ > } \ > *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ > TRASHIT(*oldnext); \ > TRASHIT(*oldprev); \ > QMD_TRACE_ELEM(&(elm)->field); \ >} while (0) > >#define TAILQ_SWAP(head1, head2, type, field) do { \ > struct type *swap_first = (head1)->tqh_first; \ > struct type **swap_last = (head1)->tqh_last; \ > (head1)->tqh_first = (head2)->tqh_first; \ > (head1)->tqh_last = (head2)->tqh_last; \ > (head2)->tqh_first = swap_first; \ > (head2)->tqh_last = swap_last; \ > if ((swap_first = (head1)->tqh_first) != NULL) \ > swap_first->field.tqe_prev = &(head1)->tqh_first; \ > else \ > (head1)->tqh_last = &(head1)->tqh_first; \ > if ((swap_first = (head2)->tqh_first) != NULL) \ > swap_first->field.tqe_prev = &(head2)->tqh_first; \ > else \ > (head2)->tqh_last = &(head2)->tqh_first; \ >} while (0) > >#endif /* !_SYS_QUEUE_H_ */ ># 695 "/usr/src/sys/sys/queue.h" ># 42 "/usr/src/sys/sys/_callout.h" 2 > >struct lock_object; > >LIST_HEAD(callout_list, callout); >SLIST_HEAD(callout_slist, callout); >TAILQ_HEAD(callout_tailq, callout); > >struct callout { > union { > LIST_ENTRY(callout) le; > SLIST_ENTRY(callout) sle; > TAILQ_ENTRY(callout) tqe; > } c_links; > sbintime_t c_time; /* ticks to the event */ > sbintime_t c_precision; /* delta allowed wrt opt */ > void *c_arg; /* function argument */ > void (*c_func)(void *); /* function to call */ > struct lock_object *c_lock; /* lock to handle */ > int c_flags; /* state of this entry */ > volatile int c_cpu; /* CPU we're scheduled on */ >}; > >#endif ># 65 "/usr/src/sys/sys/_callout.h" ># 42 "/usr/src/sys/sys/callout.h" 2 > >#define CALLOUT_LOCAL_ALLOC 0x0001 /* was allocated from callfree */ >#define CALLOUT_ACTIVE 0x0002 /* callout is currently active */ >#define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */ >#define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */ >#define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */ >#define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */ >#define CALLOUT_DFRMIGRATION 0x0040 /* callout in deferred migration mode */ >#define CALLOUT_PROCESSED 0x0080 /* callout in wheel or processing list? */ >#define CALLOUT_DIRECT 0x0100 /* allow exec from hw int context */ > >#define C_DIRECT_EXEC 0x0001 /* direct execution of callout */ >#define C_PRELBITS 7 >#define C_PRELRANGE ((1 << C_PRELBITS) - 1) >#define C_PREL(x) (((x) + 1) << 1) >#define C_PRELGET(x) (int)((((x) >> 1) & C_PRELRANGE) - 1) >#define C_HARDCLOCK 0x0100 /* align to hardclock() calls */ >#define C_ABSOLUTE 0x0200 /* event time is absolute. */ > >struct callout_handle { > struct callout *callout; >}; > >#ifdef _KERNEL >#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) >#define callout_migrating(c) ((c)->c_flags & CALLOUT_DFRMIGRATION) >#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) >#define callout_drain(c) _callout_stop_safe(c, 1) >void callout_init(struct callout *, int); >void _callout_init_lock(struct callout *, struct lock_object *, int); >#define callout_init_mtx(c, mtx, flags) \ > _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \ > NULL, (flags)) >#define callout_init_rm(c, rm, flags) \ > _callout_init_lock((c), ((rm) != NULL) ? &(rm)->lock_object : \ > NULL, (flags)) >#define callout_init_rw(c, rw, flags) \ > _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ > NULL, (flags)) >#define callout_pending(c) ((c)->c_flags & CALLOUT_PENDING) >int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t, > void (*)(void *), void *, int, int); >#define callout_reset_sbt(c, sbt, pr, fn, arg, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), (c)->c_cpu, (flags)) >#define callout_reset_sbt_curcpu(c, sbt, pr, fn, arg, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), PCPU_GET(cpuid),\ > (flags)) >#define callout_reset_on(c, to_ticks, fn, arg, cpu) \ > callout_reset_sbt_on((c), tick_sbt * (to_ticks), 0, (fn), (arg), \ > (cpu), C_HARDCLOCK) >#define callout_reset(c, on_tick, fn, arg) \ > callout_reset_on((c), (on_tick), (fn), (arg), (c)->c_cpu) >#define callout_reset_curcpu(c, on_tick, fn, arg) \ > callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid)) >#define callout_schedule_sbt_on(c, sbt, pr, cpu, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (c)->c_func, (c)->c_arg, \ > (cpu), (flags)) >#define callout_schedule_sbt(c, sbt, pr, flags) \ > callout_schedule_sbt_on((c), (sbt), (pr), (c)->c_cpu, (flags)) >#define callout_schedule_sbt_curcpu(c, sbt, pr, flags) \ > callout_schedule_sbt_on((c), (sbt), (pr), PCPU_GET(cpuid), (flags)) >int callout_schedule(struct callout *, int); >int callout_schedule_on(struct callout *, int, int); >#define callout_schedule_curcpu(c, on_tick) \ > callout_schedule_on((c), (on_tick), PCPU_GET(cpuid)) >#define callout_stop(c) _callout_stop_safe(c, 0) >int _callout_stop_safe(struct callout *, int); >void callout_process(sbintime_t now); > >#endif ># 112 "/usr/src/sys/sys/callout.h" > >#endif /* _SYS_CALLOUT_H_ */ ># 114 "/usr/src/sys/sys/callout.h" ># 44 "/usr/src/sys/sys/systm.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/systm.h" ># 45 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/systm.h" ># 46 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/stdint.h> /* for people using printf mainly */ >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/sys/systm.h" ># 1 "/usr/src/sys/sys/stdint.h" 1 >/*- > * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/stdint.h 237517 2012-06-24 04:15:58Z andrew $ > */ > >#ifndef _SYS_STDINT_H_ >#define _SYS_STDINT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/stdint.h" ># 33 "/usr/src/sys/sys/stdint.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/sys/sys/stdint.h" ># 34 "/usr/src/sys/sys/stdint.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/stdint.h" ># 1 "./machine/_stdint.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/_stdint.h 232264 2012-02-28 18:38:33Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_stdint.h" ># 1 "./x86/_stdint.h" 1 >/*- > * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org> > * Copyright (c) 2001 The NetBSD Foundation, Inc. > * All rights reserved. > * > * This code is derived from software contributed to The NetBSD Foundation > * by Klaus Klein. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the NetBSD > * Foundation, Inc. and its contributors. > * 4. Neither the name of The NetBSD Foundation nor the names of its > * contributors may be used to endorse or promote products derived > * from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS > * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED > * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS > * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) > * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE > * POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/x86/include/_stdint.h 237517 2012-06-24 04:15:58Z andrew $ > */ > >#ifndef _MACHINE__STDINT_H_ >#define _MACHINE__STDINT_H_ > >#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) > >#define INT8_C(c) (c) >#define INT16_C(c) (c) >#define INT32_C(c) (c) > >#define UINT8_C(c) (c) >#define UINT16_C(c) (c) >#define UINT32_C(c) (c ## U) > >#ifdef __LP64__ >#define INT64_C(c) (c ## L) >#define UINT64_C(c) (c ## UL) >#else ># 57 "./x86/_stdint.h" >#define INT64_C(c) (c ## LL) >#define UINT64_C(c) (c ## ULL) >#endif ># 60 "./x86/_stdint.h" > >#define INTMAX_C(c) INT64_C(c) >#define UINTMAX_C(c) UINT64_C(c) > >#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ ># 65 "./x86/_stdint.h" > >#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) > >/* > * ISO/IEC 9899:1999 > * 7.18.2.1 Limits of exact-width integer types > */ >#define INT8_MIN (-0x7f-1) >#define INT16_MIN (-0x7fff-1) >#define INT32_MIN (-0x7fffffff-1) > >#define INT8_MAX 0x7f >#define INT16_MAX 0x7fff >#define INT32_MAX 0x7fffffff > >#define UINT8_MAX 0xff >#define UINT16_MAX 0xffff >#define UINT32_MAX 0xffffffffU > >#ifdef __LP64__ >#define INT64_MIN (-0x7fffffffffffffff-1) >#define INT64_MAX 0x7fffffffffffffff >#define UINT64_MAX 0xffffffffffffffff >#else ># 89 "./x86/_stdint.h" >#define INT64_MIN (-0x7fffffffffffffffLL-1) >#define INT64_MAX 0x7fffffffffffffffLL >#define UINT64_MAX 0xffffffffffffffffULL >#endif ># 93 "./x86/_stdint.h" > >/* > * ISO/IEC 9899:1999 > * 7.18.2.2 Limits of minimum-width integer types > */ >/* Minimum values of minimum-width signed integer types. */ >#define INT_LEAST8_MIN INT8_MIN >#define INT_LEAST16_MIN INT16_MIN >#define INT_LEAST32_MIN INT32_MIN >#define INT_LEAST64_MIN INT64_MIN > >/* Maximum values of minimum-width signed integer types. */ >#define INT_LEAST8_MAX INT8_MAX >#define INT_LEAST16_MAX INT16_MAX >#define INT_LEAST32_MAX INT32_MAX >#define INT_LEAST64_MAX INT64_MAX > >/* Maximum values of minimum-width unsigned integer types. */ >#define UINT_LEAST8_MAX UINT8_MAX >#define UINT_LEAST16_MAX UINT16_MAX >#define UINT_LEAST32_MAX UINT32_MAX >#define UINT_LEAST64_MAX UINT64_MAX > >/* > * ISO/IEC 9899:1999 > * 7.18.2.3 Limits of fastest minimum-width integer types > */ >/* Minimum values of fastest minimum-width signed integer types. */ >#define INT_FAST8_MIN INT32_MIN >#define INT_FAST16_MIN INT32_MIN >#define INT_FAST32_MIN INT32_MIN >#define INT_FAST64_MIN INT64_MIN > >/* Maximum values of fastest minimum-width signed integer types. */ >#define INT_FAST8_MAX INT32_MAX >#define INT_FAST16_MAX INT32_MAX >#define INT_FAST32_MAX INT32_MAX >#define INT_FAST64_MAX INT64_MAX > >/* Maximum values of fastest minimum-width unsigned integer types. */ >#define UINT_FAST8_MAX UINT32_MAX >#define UINT_FAST16_MAX UINT32_MAX >#define UINT_FAST32_MAX UINT32_MAX >#define UINT_FAST64_MAX UINT64_MAX > >/* > * ISO/IEC 9899:1999 > * 7.18.2.4 Limits of integer types capable of holding object pointers > */ >#ifdef __LP64__ >#define INTPTR_MIN INT64_MIN >#define INTPTR_MAX INT64_MAX >#define UINTPTR_MAX UINT64_MAX >#else ># 147 "./x86/_stdint.h" >#define INTPTR_MIN INT32_MIN >#define INTPTR_MAX INT32_MAX >#define UINTPTR_MAX UINT32_MAX >#endif ># 151 "./x86/_stdint.h" > >/* > * ISO/IEC 9899:1999 > * 7.18.2.5 Limits of greatest-width integer types > */ >#define INTMAX_MIN INT64_MIN >#define INTMAX_MAX INT64_MAX >#define UINTMAX_MAX UINT64_MAX > >/* > * ISO/IEC 9899:1999 > * 7.18.3 Limits of other integer types > */ >#ifdef __LP64__ >/* Limits of ptrdiff_t. */ >#define PTRDIFF_MIN INT64_MIN >#define PTRDIFF_MAX INT64_MAX > >/* Limits of sig_atomic_t. */ >#define SIG_ATOMIC_MIN LONG_MIN >#define SIG_ATOMIC_MAX LONG_MAX > >/* Limit of size_t. */ >#define SIZE_MAX UINT64_MAX >#else ># 176 "./x86/_stdint.h" >#define PTRDIFF_MIN INT32_MIN >#define PTRDIFF_MAX INT32_MAX >#define SIG_ATOMIC_MIN INT32_MIN >#define SIG_ATOMIC_MAX INT32_MAX >#define SIZE_MAX UINT32_MAX >#endif ># 182 "./x86/_stdint.h" > >/* Limits of wint_t. */ >#define WINT_MIN INT32_MIN >#define WINT_MAX INT32_MAX > >#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ ># 188 "./x86/_stdint.h" > >#endif /* !_MACHINE__STDINT_H_ */ ># 190 "./x86/_stdint.h" ># 7 "./machine/_stdint.h" 2 ># 36 "/usr/src/sys/sys/stdint.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/stdint.h" ># 37 "/usr/src/sys/sys/stdint.h" > >typedef __int_least8_t int_least8_t; >typedef __int_least16_t int_least16_t; >typedef __int_least32_t int_least32_t; >typedef __int_least64_t int_least64_t; > >typedef __uint_least8_t uint_least8_t; >typedef __uint_least16_t uint_least16_t; >typedef __uint_least32_t uint_least32_t; >typedef __uint_least64_t uint_least64_t; > >typedef __int_fast8_t int_fast8_t; >typedef __int_fast16_t int_fast16_t; >typedef __int_fast32_t int_fast32_t; >typedef __int_fast64_t int_fast64_t; > >typedef __uint_fast8_t uint_fast8_t; >typedef __uint_fast16_t uint_fast16_t; >typedef __uint_fast32_t uint_fast32_t; >typedef __uint_fast64_t uint_fast64_t; > >#ifndef _INTMAX_T_DECLARED >typedef __intmax_t intmax_t; >#define _INTMAX_T_DECLARED >#endif ># 62 "/usr/src/sys/sys/stdint.h" >#ifndef _UINTMAX_T_DECLARED >typedef __uintmax_t uintmax_t; >#define _UINTMAX_T_DECLARED >#endif ># 66 "/usr/src/sys/sys/stdint.h" > >/* GNU and Darwin define this and people seem to think it's portable */ >#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX) >#define __WORDSIZE 64 >#else ># 71 "/usr/src/sys/sys/stdint.h" >#define __WORDSIZE 32 >#endif ># 73 "/usr/src/sys/sys/stdint.h" > >/* Limits of wchar_t. */ >#define WCHAR_MIN __WCHAR_MIN >#define WCHAR_MAX __WCHAR_MAX > >#endif /* !_SYS_STDINT_H_ */ ># 79 "/usr/src/sys/sys/stdint.h" ># 47 "/usr/src/sys/sys/systm.h" 2 > >extern int cold; /* nonzero if we are doing a cold boot */ >extern int rebooting; /* kern_reboot() has been called. */ >extern const char *panicstr; /* panic message */ >extern char version[]; /* system version */ >extern char compiler_version[]; /* compiler version */ >extern char copyright[]; /* system copyright */ >extern int kstack_pages; /* number of kernel stack pages */ > >extern u_long pagesizes[]; /* supported page sizes */ >extern long physmem; /* physical memory */ >extern long realmem; /* 'real' memory */ > >extern char *rootdevnames[2]; /* names of possible root devices */ > >extern int boothowto; /* reboot flags, from console subsystem */ >extern int bootverbose; /* nonzero to print verbose messages */ > >extern int maxusers; /* system tune hint */ >extern int ngroups_max; /* max # of supplemental groups */ >extern int vm_guest; /* Running as virtual machine guest? */ > >/* > * Detected virtual machine guest types. The intention is to expand > * and/or add to the VM_GUEST_VM type if specific VM functionality is > * ever implemented (e.g. vendor-specific paravirtualization features). > * Keep in sync with vm_guest_sysctl_names[]. > */ >enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, > VM_GUEST_VMWARE, VM_LAST }; > >#if defined(WITNESS) || defined(INVARIANTS) >void kassert_panic(const char *fmt, ...) __printflike(1, 2); >#endif ># 81 "/usr/src/sys/sys/systm.h" > >#ifdef INVARIANTS /* The option is always available */ >#define KASSERT(exp,msg) do { \ > if (__predict_false(!(exp))) \ > kassert_panic msg; \ >} while (0) >#define VNASSERT(exp, vp, msg) do { \ > if (__predict_false(!(exp))) { \ > vn_printf(vp, "VNASSERT failed\n"); \ > kassert_panic msg; \ > } \ >} while (0) >#else ># 94 "/usr/src/sys/sys/systm.h" >#define KASSERT(exp,msg) do { \ >} while (0) > >#define VNASSERT(exp, vp, msg) do { \ >} while (0) >#endif ># 100 "/usr/src/sys/sys/systm.h" > >#ifndef CTASSERT /* Allow lint to override */ >#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") >#endif ># 104 "/usr/src/sys/sys/systm.h" > >/* > * Assert that a pointer can be loaded from memory atomically. > * > * This assertion enforces stronger alignment than necessary. For example, > * on some architectures, atomicity for unaligned loads will depend on > * whether or not the load spans multiple cache lines. > */ >#define ASSERT_ATOMIC_LOAD_PTR(var, msg) \ > KASSERT(sizeof(var) == sizeof(void *) && \ > ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg) > >/* > * Assert that a thread is in critical(9) section. > */ >#define CRITICAL_ASSERT(td) \ > KASSERT((td)->td_critnest >= 1, ("Not in critical section")); > >/* > * If we have already panic'd and this is the thread that called > * panic(), then don't block on any mutexes but silently succeed. > * Otherwise, the kernel will deadlock since the scheduler isn't > * going to run the thread that holds any lock we need. > */ >#define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched) > >/* > * XXX the hints declarations are even more misplaced than most declarations > * in this file, since they are needed in one file (per arch) and only used > * in two files. > * XXX most of these variables should be const. > */ >extern int osreldate; >extern int envmode; >extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */ >extern int dynamic_kenv; >extern struct mtx kenv_lock; >extern char *kern_envp; >extern char static_env[]; >extern char static_hints[]; /* by config for now */ > >extern char **kenvp; > >extern const void *zero_region; /* address space maps to a zeroed page */ > >extern int unmapped_buf_allowed; >extern int iosize_max_clamp; >extern int devfs_iosize_max_clamp; >#define IOSIZE_MAX (iosize_max_clamp ? INT_MAX : SSIZE_MAX) >#define DEVFS_IOSIZE_MAX (devfs_iosize_max_clamp ? INT_MAX : SSIZE_MAX) > >/* > * General function declarations. > */ > >struct inpcb; >struct lock_object; >struct malloc_type; >struct mtx; >struct proc; >struct socket; >struct thread; >struct tty; >struct ucred; >struct uio; >struct _jmp_buf; >struct trapframe; >struct eventtimer; > >int setjmp(struct _jmp_buf *) __returns_twice; >void longjmp(struct _jmp_buf *, int) __dead2; >int dumpstatus(vm_offset_t addr, off_t count); >int nullop(void); >int eopnotsupp(void); >int ureadc(int, struct uio *); >void hashdestroy(void *, struct malloc_type *, u_long); >void *hashinit(int count, struct malloc_type *type, u_long *hashmask); >void *hashinit_flags(int count, struct malloc_type *type, > u_long *hashmask, int flags); >#define HASH_NOWAIT 0x00000001 >#define HASH_WAITOK 0x00000002 > >void *phashinit(int count, struct malloc_type *type, u_long *nentries); >void g_waitidle(void); > >void panic(const char *, ...) __dead2 __printflike(1, 2); > >void cpu_boot(int); >void cpu_flush_dcache(void *, size_t); >void cpu_rootconf(void); >void critical_enter(void); >void critical_exit(void); >void init_param1(void); >void init_param2(long physpages); >void init_static_kenv(char *, size_t); >void tablefull(const char *); >#ifdef EARLY_PRINTF >typedef void early_putc_t(int ch); >extern early_putc_t *early_putc; >#endif ># 204 "/usr/src/sys/sys/systm.h" >int kvprintf(char const *, void (*)(int, void*), void *, int, > __va_list) __printflike(1, 0); >void log(int, const char *, ...) __printflike(2, 3); >void log_console(struct uio *); >int asprintf(char **ret, struct malloc_type *mtp, const char *format, > ...) __printflike(3, 4); >int printf(const char *, ...) __printflike(1, 2); >int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); >int sprintf(char *buf, const char *, ...) __printflike(2, 3); >int uprintf(const char *, ...) __printflike(1, 2); >int vprintf(const char *, __va_list) __printflike(1, 0); >int vasprintf(char **ret, struct malloc_type *mtp, const char *format, > __va_list ap) __printflike(3, 0); >int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0); >int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); >int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); >int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); >int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); >int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); >long strtol(const char *, char **, int) __nonnull(1); >u_long strtoul(const char *, char **, int) __nonnull(1); >quad_t strtoq(const char *, char **, int) __nonnull(1); >u_quad_t strtouq(const char *, char **, int) __nonnull(1); >void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4); >void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0); >void hexdump(const void *ptr, int length, const char *hdr, int flags); >#define HD_COLUMN_MASK 0xff >#define HD_DELIM_MASK 0xff00 >#define HD_OMIT_COUNT (1 << 16) >#define HD_OMIT_HEX (1 << 17) >#define HD_OMIT_CHARS (1 << 18) > >#define ovbcopy(f, t, l) bcopy((f), (t), (l)) >void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2); >void bzero(void *buf, size_t len) __nonnull(1); >void explicit_bzero(void *, size_t) __nonnull(1);; > >void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2); >void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2); > >int copystr(const void * __restrict kfaddr, void * __restrict kdaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyinstr(const void * __restrict udaddr, void * __restrict kaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyin(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); > >int fubyte(volatile const void *base); >long fuword(volatile const void *base); >int fuword16(volatile const void *base); >int32_t fuword32(volatile const void *base); >int64_t fuword64(volatile const void *base); >int fueword(volatile const void *base, long *val); >int fueword32(volatile const void *base, int32_t *val); >int fueword64(volatile const void *base, int64_t *val); >int subyte(volatile void *base, int byte); >int suword(volatile void *base, long word); >int suword16(volatile void *base, int word); >int suword32(volatile void *base, int32_t word); >int suword64(volatile void *base, int64_t word); >uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); >u_long casuword(volatile u_long *p, u_long oldval, u_long newval); >int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, > uint32_t newval); >int casueword(volatile u_long *p, u_long oldval, u_long *oldvalp, > u_long newval); > >void realitexpire(void *); > >int sysbeep(int hertz, int period); > >void hardclock(int usermode, uintfptr_t pc); >void hardclock_cnt(int cnt, int usermode); >void hardclock_cpu(int usermode); >void hardclock_sync(int cpu); >void softclock(void *); >void statclock(int usermode); >void statclock_cnt(int cnt, int usermode); >void profclock(int usermode, uintfptr_t pc); >void profclock_cnt(int cnt, int usermode, uintfptr_t pc); > >int hardclockintr(void); > >void startprofclock(struct proc *); >void stopprofclock(struct proc *); >void cpu_startprofclock(void); >void cpu_stopprofclock(void); >sbintime_t cpu_idleclock(void); >void cpu_activeclock(void); >void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt); >void cpu_et_frequency(struct eventtimer *et, uint64_t newfreq); >extern int cpu_deepest_sleep; >extern int cpu_disable_c2_sleep; >extern int cpu_disable_c3_sleep; > >int cr_cansee(struct ucred *u1, struct ucred *u2); >int cr_canseesocket(struct ucred *cred, struct socket *so); >int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); > >char *kern_getenv(const char *name); >void freeenv(char *env); >int getenv_int(const char *name, int *data); >int getenv_uint(const char *name, unsigned int *data); >int getenv_long(const char *name, long *data); >int getenv_ulong(const char *name, unsigned long *data); >int getenv_string(const char *name, char *data, int size); >int getenv_quad(const char *name, quad_t *data); >int kern_setenv(const char *name, const char *value); >int kern_unsetenv(const char *name); >int testenv(const char *name); > >typedef uint64_t (cpu_tick_f)(void); >void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var); >extern cpu_tick_f *cpu_ticks; >uint64_t cpu_tickrate(void); >uint64_t cputick2usec(uint64_t tick); > >#ifdef APM_FIXUP_CALLTODO >struct timeval; >void adjust_timeout_calltodo(struct timeval *time_change); >#endif /* APM_FIXUP_CALLTODO */ ># 333 "/usr/src/sys/sys/systm.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/libkern.h> >#endif /* expanded by -frewrite-includes */ ># 334 "/usr/src/sys/sys/systm.h" ># 1 "/usr/src/sys/sys/libkern.h" 1 >/*- > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)libkern.h 8.1 (Berkeley) 6/10/93 > * $FreeBSD: head/sys/sys/libkern.h 280279 2015-03-20 10:27:06Z jhb $ > */ > >#ifndef _SYS_LIBKERN_H_ >#define _SYS_LIBKERN_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/libkern.h" ># 37 "/usr/src/sys/sys/libkern.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/libkern.h" ># 38 "/usr/src/sys/sys/libkern.h" >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/systm.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/libkern.h" ># 1 "/usr/src/sys/sys/systm.h" 1 >/*- > * Copyright (c) 1982, 1988, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)systm.h 8.7 (Berkeley) 3/29/95 > * $FreeBSD: head/sys/sys/systm.h 280279 2015-03-20 10:27:06Z jhb $ > */ > >#ifndef _SYS_SYSTM_H_ >#define _SYS_SYSTM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/systm.h" ># 42 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/systm.h" ># 43 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/callout.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/systm.h" ># 44 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/systm.h" ># 45 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/systm.h" ># 46 "/usr/src/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/stdint.h> /* for people using printf mainly */ >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/sys/systm.h" ># 47 "/usr/src/sys/sys/systm.h" > >extern int cold; /* nonzero if we are doing a cold boot */ >extern int rebooting; /* kern_reboot() has been called. */ >extern const char *panicstr; /* panic message */ >extern char version[]; /* system version */ >extern char compiler_version[]; /* compiler version */ >extern char copyright[]; /* system copyright */ >extern int kstack_pages; /* number of kernel stack pages */ > >extern u_long pagesizes[]; /* supported page sizes */ >extern long physmem; /* physical memory */ >extern long realmem; /* 'real' memory */ > >extern char *rootdevnames[2]; /* names of possible root devices */ > >extern int boothowto; /* reboot flags, from console subsystem */ >extern int bootverbose; /* nonzero to print verbose messages */ > >extern int maxusers; /* system tune hint */ >extern int ngroups_max; /* max # of supplemental groups */ >extern int vm_guest; /* Running as virtual machine guest? */ > >/* > * Detected virtual machine guest types. The intention is to expand > * and/or add to the VM_GUEST_VM type if specific VM functionality is > * ever implemented (e.g. vendor-specific paravirtualization features). > * Keep in sync with vm_guest_sysctl_names[]. > */ >enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, > VM_GUEST_VMWARE, VM_LAST }; > >#if defined(WITNESS) || defined(INVARIANTS) >void kassert_panic(const char *fmt, ...) __printflike(1, 2); >#endif ># 81 "/usr/src/sys/sys/systm.h" > >#ifdef INVARIANTS /* The option is always available */ >#define KASSERT(exp,msg) do { \ > if (__predict_false(!(exp))) \ > kassert_panic msg; \ >} while (0) >#define VNASSERT(exp, vp, msg) do { \ > if (__predict_false(!(exp))) { \ > vn_printf(vp, "VNASSERT failed\n"); \ > kassert_panic msg; \ > } \ >} while (0) >#else ># 94 "/usr/src/sys/sys/systm.h" >#define KASSERT(exp,msg) do { \ >} while (0) > >#define VNASSERT(exp, vp, msg) do { \ >} while (0) >#endif ># 100 "/usr/src/sys/sys/systm.h" > >#ifndef CTASSERT /* Allow lint to override */ >#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") >#endif ># 104 "/usr/src/sys/sys/systm.h" > >/* > * Assert that a pointer can be loaded from memory atomically. > * > * This assertion enforces stronger alignment than necessary. For example, > * on some architectures, atomicity for unaligned loads will depend on > * whether or not the load spans multiple cache lines. > */ >#define ASSERT_ATOMIC_LOAD_PTR(var, msg) \ > KASSERT(sizeof(var) == sizeof(void *) && \ > ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg) > >/* > * Assert that a thread is in critical(9) section. > */ >#define CRITICAL_ASSERT(td) \ > KASSERT((td)->td_critnest >= 1, ("Not in critical section")); > >/* > * If we have already panic'd and this is the thread that called > * panic(), then don't block on any mutexes but silently succeed. > * Otherwise, the kernel will deadlock since the scheduler isn't > * going to run the thread that holds any lock we need. > */ >#define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched) > >/* > * XXX the hints declarations are even more misplaced than most declarations > * in this file, since they are needed in one file (per arch) and only used > * in two files. > * XXX most of these variables should be const. > */ >extern int osreldate; >extern int envmode; >extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */ >extern int dynamic_kenv; >extern struct mtx kenv_lock; >extern char *kern_envp; >extern char static_env[]; >extern char static_hints[]; /* by config for now */ > >extern char **kenvp; > >extern const void *zero_region; /* address space maps to a zeroed page */ > >extern int unmapped_buf_allowed; >extern int iosize_max_clamp; >extern int devfs_iosize_max_clamp; >#define IOSIZE_MAX (iosize_max_clamp ? INT_MAX : SSIZE_MAX) >#define DEVFS_IOSIZE_MAX (devfs_iosize_max_clamp ? INT_MAX : SSIZE_MAX) > >/* > * General function declarations. > */ > >struct inpcb; >struct lock_object; >struct malloc_type; >struct mtx; >struct proc; >struct socket; >struct thread; >struct tty; >struct ucred; >struct uio; >struct _jmp_buf; >struct trapframe; >struct eventtimer; > >int setjmp(struct _jmp_buf *) __returns_twice; >void longjmp(struct _jmp_buf *, int) __dead2; >int dumpstatus(vm_offset_t addr, off_t count); >int nullop(void); >int eopnotsupp(void); >int ureadc(int, struct uio *); >void hashdestroy(void *, struct malloc_type *, u_long); >void *hashinit(int count, struct malloc_type *type, u_long *hashmask); >void *hashinit_flags(int count, struct malloc_type *type, > u_long *hashmask, int flags); >#define HASH_NOWAIT 0x00000001 >#define HASH_WAITOK 0x00000002 > >void *phashinit(int count, struct malloc_type *type, u_long *nentries); >void g_waitidle(void); > >void panic(const char *, ...) __dead2 __printflike(1, 2); > >void cpu_boot(int); >void cpu_flush_dcache(void *, size_t); >void cpu_rootconf(void); >void critical_enter(void); >void critical_exit(void); >void init_param1(void); >void init_param2(long physpages); >void init_static_kenv(char *, size_t); >void tablefull(const char *); >#ifdef EARLY_PRINTF >typedef void early_putc_t(int ch); >extern early_putc_t *early_putc; >#endif ># 204 "/usr/src/sys/sys/systm.h" >int kvprintf(char const *, void (*)(int, void*), void *, int, > __va_list) __printflike(1, 0); >void log(int, const char *, ...) __printflike(2, 3); >void log_console(struct uio *); >int asprintf(char **ret, struct malloc_type *mtp, const char *format, > ...) __printflike(3, 4); >int printf(const char *, ...) __printflike(1, 2); >int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); >int sprintf(char *buf, const char *, ...) __printflike(2, 3); >int uprintf(const char *, ...) __printflike(1, 2); >int vprintf(const char *, __va_list) __printflike(1, 0); >int vasprintf(char **ret, struct malloc_type *mtp, const char *format, > __va_list ap) __printflike(3, 0); >int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0); >int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); >int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); >int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); >int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); >int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); >long strtol(const char *, char **, int) __nonnull(1); >u_long strtoul(const char *, char **, int) __nonnull(1); >quad_t strtoq(const char *, char **, int) __nonnull(1); >u_quad_t strtouq(const char *, char **, int) __nonnull(1); >void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4); >void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0); >void hexdump(const void *ptr, int length, const char *hdr, int flags); >#define HD_COLUMN_MASK 0xff >#define HD_DELIM_MASK 0xff00 >#define HD_OMIT_COUNT (1 << 16) >#define HD_OMIT_HEX (1 << 17) >#define HD_OMIT_CHARS (1 << 18) > >#define ovbcopy(f, t, l) bcopy((f), (t), (l)) >void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2); >void bzero(void *buf, size_t len) __nonnull(1); >void explicit_bzero(void *, size_t) __nonnull(1);; > >void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2); >void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2); > >int copystr(const void * __restrict kfaddr, void * __restrict kdaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyinstr(const void * __restrict udaddr, void * __restrict kaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyin(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); > >int fubyte(volatile const void *base); >long fuword(volatile const void *base); >int fuword16(volatile const void *base); >int32_t fuword32(volatile const void *base); >int64_t fuword64(volatile const void *base); >int fueword(volatile const void *base, long *val); >int fueword32(volatile const void *base, int32_t *val); >int fueword64(volatile const void *base, int64_t *val); >int subyte(volatile void *base, int byte); >int suword(volatile void *base, long word); >int suword16(volatile void *base, int word); >int suword32(volatile void *base, int32_t word); >int suword64(volatile void *base, int64_t word); >uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); >u_long casuword(volatile u_long *p, u_long oldval, u_long newval); >int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, > uint32_t newval); >int casueword(volatile u_long *p, u_long oldval, u_long *oldvalp, > u_long newval); > >void realitexpire(void *); > >int sysbeep(int hertz, int period); > >void hardclock(int usermode, uintfptr_t pc); >void hardclock_cnt(int cnt, int usermode); >void hardclock_cpu(int usermode); >void hardclock_sync(int cpu); >void softclock(void *); >void statclock(int usermode); >void statclock_cnt(int cnt, int usermode); >void profclock(int usermode, uintfptr_t pc); >void profclock_cnt(int cnt, int usermode, uintfptr_t pc); > >int hardclockintr(void); > >void startprofclock(struct proc *); >void stopprofclock(struct proc *); >void cpu_startprofclock(void); >void cpu_stopprofclock(void); >sbintime_t cpu_idleclock(void); >void cpu_activeclock(void); >void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt); >void cpu_et_frequency(struct eventtimer *et, uint64_t newfreq); >extern int cpu_deepest_sleep; >extern int cpu_disable_c2_sleep; >extern int cpu_disable_c3_sleep; > >int cr_cansee(struct ucred *u1, struct ucred *u2); >int cr_canseesocket(struct ucred *cred, struct socket *so); >int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); > >char *kern_getenv(const char *name); >void freeenv(char *env); >int getenv_int(const char *name, int *data); >int getenv_uint(const char *name, unsigned int *data); >int getenv_long(const char *name, long *data); >int getenv_ulong(const char *name, unsigned long *data); >int getenv_string(const char *name, char *data, int size); >int getenv_quad(const char *name, quad_t *data); >int kern_setenv(const char *name, const char *value); >int kern_unsetenv(const char *name); >int testenv(const char *name); > >typedef uint64_t (cpu_tick_f)(void); >void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var); >extern cpu_tick_f *cpu_ticks; >uint64_t cpu_tickrate(void); >uint64_t cputick2usec(uint64_t tick); > >#ifdef APM_FIXUP_CALLTODO >struct timeval; >void adjust_timeout_calltodo(struct timeval *time_change); >#endif /* APM_FIXUP_CALLTODO */ ># 333 "/usr/src/sys/sys/systm.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/libkern.h> >#endif /* expanded by -frewrite-includes */ ># 334 "/usr/src/sys/sys/systm.h" ># 335 "/usr/src/sys/sys/systm.h" > >/* Initialize the world */ >void consinit(void); >void cpu_initclocks(void); >void cpu_initclocks_bsp(void); >void cpu_initclocks_ap(void); >void usrinfoinit(void); > >/* Finalize the world */ >void kern_reboot(int) __dead2; >void shutdown_nice(int); > >/* Timeouts */ >typedef void timeout_t(void *); /* timeout function type */ >#define CALLOUT_HANDLE_INITIALIZER(handle) \ > { NULL } > >void callout_handle_init(struct callout_handle *); >struct callout_handle timeout(timeout_t *, void *, int); >void untimeout(timeout_t *, void *, struct callout_handle); > >/* Stubs for obsolete functions that used to be for interrupt management */ >static __inline intrmask_t splbio(void) { return 0; } >static __inline intrmask_t splcam(void) { return 0; } >static __inline intrmask_t splclock(void) { return 0; } >static __inline intrmask_t splhigh(void) { return 0; } >static __inline intrmask_t splimp(void) { return 0; } >static __inline intrmask_t splnet(void) { return 0; } >static __inline intrmask_t spltty(void) { return 0; } >static __inline void splx(intrmask_t ipl __unused) { return; } > >/* > * Common `proc' functions are declared here so that proc.h can be included > * less often. > */ >int _sleep(void *chan, struct lock_object *lock, int pri, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep(chan, mtx, pri, wmesg, timo) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) >#define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \ > (flags)) >int msleep_spin_sbt(void *chan, struct mtx *mtx, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep_spin(chan, mtx, wmesg, timo) \ > msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, > int flags); >#define pause(wmesg, timo) \ > pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) >#define tsleep(chan, pri, wmesg, timo) \ > _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >#define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \ > _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags)) >void wakeup(void *chan) __nonnull(1); >void wakeup_one(void *chan) __nonnull(1); > >/* > * Common `struct cdev *' stuff are declared here to avoid #include poisoning > */ > >struct cdev; >dev_t dev2udev(struct cdev *x); >const char *devtoname(struct cdev *cdev); > >int poll_no_poll(int events); > >/* XXX: Should be void nanodelay(u_int nsec); */ >void DELAY(int usec); > >/* Root mount holdback API */ >struct root_hold_token; > >struct root_hold_token *root_mount_hold(const char *identifier); >void root_mount_rel(struct root_hold_token *h); >void root_mount_wait(void); >int root_mounted(void); > > >/* > * Unit number allocation API. (kern/subr_unit.c) > */ >struct unrhdr; >struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex); >void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex); >void delete_unrhdr(struct unrhdr *uh); >void clean_unrhdr(struct unrhdr *uh); >void clean_unrhdrl(struct unrhdr *uh); >int alloc_unr(struct unrhdr *uh); >int alloc_unr_specific(struct unrhdr *uh, u_int item); >int alloc_unrl(struct unrhdr *uh); >void free_unr(struct unrhdr *uh, u_int item); > >void intr_prof_stack_use(struct thread *td, struct trapframe *frame); > >#endif /* !_SYS_SYSTM_H_ */ ># 434 "/usr/src/sys/sys/systm.h" ># 40 "/usr/src/sys/sys/libkern.h" 2 >#endif ># 41 "/usr/src/sys/sys/libkern.h" > >#ifndef LIBKERN_INLINE >#define LIBKERN_INLINE static __inline >#define LIBKERN_BODY >#endif ># 46 "/usr/src/sys/sys/libkern.h" > >/* BCD conversions. */ >extern u_char const bcd2bin_data[]; >extern u_char const bin2bcd_data[]; >extern char const hex2ascii_data[]; > >#define bcd2bin(bcd) (bcd2bin_data[bcd]) >#define bin2bcd(bin) (bin2bcd_data[bin]) >#define hex2ascii(hex) (hex2ascii_data[hex]) > >static __inline int imax(int a, int b) { return (a > b ? a : b); } >static __inline int imin(int a, int b) { return (a < b ? a : b); } >static __inline long lmax(long a, long b) { return (a > b ? a : b); } >static __inline long lmin(long a, long b) { return (a < b ? a : b); } >static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); } >static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); } >static __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); } >static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } >static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); } >static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); } >static __inline off_t omax(off_t a, off_t b) { return (a > b ? a : b); } >static __inline off_t omin(off_t a, off_t b) { return (a < b ? a : b); } > >static __inline int abs(int a) { return (a < 0 ? -a : a); } >static __inline long labs(long a) { return (a < 0 ? -a : a); } >static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); } > >#define ARC4_ENTR_NONE 0 /* Don't have entropy yet. */ >#define ARC4_ENTR_HAVE 1 /* Have entropy. */ >#define ARC4_ENTR_SEED 2 /* Reseeding. */ >extern int arc4rand_iniseed_state; > >/* Prototypes for non-quad routines. */ >struct malloc_type; >uint32_t arc4random(void); >void arc4rand(void *ptr, u_int len, int reseed); >int bcmp(const void *, const void *, size_t); >int timingsafe_bcmp(const void *, const void *, size_t); >void *bsearch(const void *, const void *, size_t, > size_t, int (*)(const void *, const void *)); >#ifndef HAVE_INLINE_FFS >int ffs(int); >#endif ># 89 "/usr/src/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FFSL >int ffsl(long); >#endif ># 92 "/usr/src/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FLS >int fls(int); >#endif ># 95 "/usr/src/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FLSL >int flsl(long); >#endif ># 98 "/usr/src/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FLSLL >int flsll(long long); >#endif ># 101 "/usr/src/sys/sys/libkern.h" >#define bitcount64(x) __bitcount64((uint64_t)(x)) >#define bitcount32(x) __bitcount32((uint32_t)(x)) >#define bitcount16(x) __bitcount16((uint16_t)(x)) >#define bitcountl(x) __bitcountl((u_long)(x)) >#define bitcount(x) __bitcount((u_int)(x)) > >int fnmatch(const char *, const char *, int); >int locc(int, char *, u_int); >void *memchr(const void *s, int c, size_t n); >void *memcchr(const void *s, int c, size_t n); >int memcmp(const void *b1, const void *b2, size_t len); >void *memmem(const void *l, size_t l_len, const void *s, size_t s_len); >void qsort(void *base, size_t nmemb, size_t size, > int (*compar)(const void *, const void *)); >void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, > int (*compar)(void *, const void *, const void *)); >u_long random(void); >int scanc(u_int, const u_char *, const u_char *, int); >void srandom(u_long); >int strcasecmp(const char *, const char *); >char *strcat(char * __restrict, const char * __restrict); >char *strchr(const char *, int); >int strcmp(const char *, const char *); >char *strcpy(char * __restrict, const char * __restrict); >size_t strcspn(const char * __restrict, const char * __restrict) __pure; >char *strdup(const char *__restrict, struct malloc_type *); >char *strndup(const char *__restrict, size_t, struct malloc_type *); >size_t strlcat(char *, const char *, size_t); >size_t strlcpy(char *, const char *, size_t); >size_t strlen(const char *); >int strncasecmp(const char *, const char *, size_t); >int strncmp(const char *, const char *, size_t); >char *strncpy(char * __restrict, const char * __restrict, size_t); >size_t strnlen(const char *, size_t); >char *strrchr(const char *, int); >char *strsep(char **, const char *delim); >size_t strspn(const char *, const char *); >char *strstr(const char *, const char *); >int strvalid(const char *, size_t); > >extern const uint32_t crc32_tab[]; > >static __inline uint32_t >crc32_raw(const void *buf, size_t size, uint32_t crc) >{ > const uint8_t *p = (const uint8_t *)buf; > > while (size--) > crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); > return (crc); >} > >static __inline uint32_t >crc32(const void *buf, size_t size) >{ > uint32_t crc; > > crc = crc32_raw(buf, size, ~0U); > return (crc ^ ~0U); >} > >uint32_t >calculate_crc32c(uint32_t crc32c, const unsigned char *buffer, > unsigned int length); > > >LIBKERN_INLINE void *memset(void *, int, size_t); >#ifdef LIBKERN_BODY >LIBKERN_INLINE void * >memset(void *b, int c, size_t len) >{ > char *bb; > > if (c == 0) > bzero(b, len); > else > for (bb = (char *)b; len--; ) > *bb++ = c; > return (b); >} >#endif ># 182 "/usr/src/sys/sys/libkern.h" > >static __inline char * >index(const char *p, int ch) >{ > > return (strchr(p, ch)); >} > >static __inline char * >rindex(const char *p, int ch) >{ > > return (strrchr(p, ch)); >} > >/* fnmatch() return values. */ >#define FNM_NOMATCH 1 /* Match failed. */ > >/* fnmatch() flags. */ >#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ >#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ >#define FNM_PERIOD 0x04 /* Period must be matched by period. */ >#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */ >#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ >#define FNM_IGNORECASE FNM_CASEFOLD >#define FNM_FILE_NAME FNM_PATHNAME > >#endif /* !_SYS_LIBKERN_H_ */ ># 210 "/usr/src/sys/sys/libkern.h" ># 335 "/usr/src/sys/sys/systm.h" 2 > >/* Initialize the world */ >void consinit(void); >void cpu_initclocks(void); >void cpu_initclocks_bsp(void); >void cpu_initclocks_ap(void); >void usrinfoinit(void); > >/* Finalize the world */ >void kern_reboot(int) __dead2; >void shutdown_nice(int); > >/* Timeouts */ >typedef void timeout_t(void *); /* timeout function type */ >#define CALLOUT_HANDLE_INITIALIZER(handle) \ > { NULL } > >void callout_handle_init(struct callout_handle *); >struct callout_handle timeout(timeout_t *, void *, int); >void untimeout(timeout_t *, void *, struct callout_handle); > >/* Stubs for obsolete functions that used to be for interrupt management */ >static __inline intrmask_t splbio(void) { return 0; } >static __inline intrmask_t splcam(void) { return 0; } >static __inline intrmask_t splclock(void) { return 0; } >static __inline intrmask_t splhigh(void) { return 0; } >static __inline intrmask_t splimp(void) { return 0; } >static __inline intrmask_t splnet(void) { return 0; } >static __inline intrmask_t spltty(void) { return 0; } >static __inline void splx(intrmask_t ipl __unused) { return; } > >/* > * Common `proc' functions are declared here so that proc.h can be included > * less often. > */ >int _sleep(void *chan, struct lock_object *lock, int pri, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep(chan, mtx, pri, wmesg, timo) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) >#define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \ > (flags)) >int msleep_spin_sbt(void *chan, struct mtx *mtx, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep_spin(chan, mtx, wmesg, timo) \ > msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, > int flags); >#define pause(wmesg, timo) \ > pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) >#define tsleep(chan, pri, wmesg, timo) \ > _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >#define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \ > _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags)) >void wakeup(void *chan) __nonnull(1); >void wakeup_one(void *chan) __nonnull(1); > >/* > * Common `struct cdev *' stuff are declared here to avoid #include poisoning > */ > >struct cdev; >dev_t dev2udev(struct cdev *x); >const char *devtoname(struct cdev *cdev); > >int poll_no_poll(int events); > >/* XXX: Should be void nanodelay(u_int nsec); */ >void DELAY(int usec); > >/* Root mount holdback API */ >struct root_hold_token; > >struct root_hold_token *root_mount_hold(const char *identifier); >void root_mount_rel(struct root_hold_token *h); >void root_mount_wait(void); >int root_mounted(void); > > >/* > * Unit number allocation API. (kern/subr_unit.c) > */ >struct unrhdr; >struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex); >void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex); >void delete_unrhdr(struct unrhdr *uh); >void clean_unrhdr(struct unrhdr *uh); >void clean_unrhdrl(struct unrhdr *uh); >int alloc_unr(struct unrhdr *uh); >int alloc_unr_specific(struct unrhdr *uh, u_int item); >int alloc_unrl(struct unrhdr *uh); >void free_unr(struct unrhdr *uh, u_int item); > >void intr_prof_stack_use(struct thread *td, struct trapframe *frame); > >#endif /* !_SYS_SYSTM_H_ */ ># 434 "/usr/src/sys/sys/systm.h" ># 48 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/lock.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp > * $FreeBSD: head/sys/sys/lock.h 275751 2014-12-13 21:00:10Z dchagin $ > */ > >#ifndef _SYS_LOCK_H_ >#define _SYS_LOCK_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/lock.h" ># 36 "/usr/src/sys/sys/lock.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/lock.h" ># 1 "/usr/src/sys/sys/_lock.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_lock.h 179025 2008-05-15 20:10:06Z attilio $ > */ > >#ifndef _SYS__LOCK_H_ >#define _SYS__LOCK_H_ > >struct lock_object { > const char *lo_name; /* Individual lock name. */ > u_int lo_flags; > u_int lo_data; /* General class specific data. */ > struct witness *lo_witness; /* Data for witness. */ >}; > >#endif /* !_SYS__LOCK_H_ */ ># 42 "/usr/src/sys/sys/_lock.h" ># 37 "/usr/src/sys/sys/lock.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ktr_class.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/lock.h" ># 1 "/usr/src/sys/sys/ktr_class.h" 1 >/*- > * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ > * $FreeBSD: head/sys/sys/ktr_class.h 279539 2015-03-02 20:05:16Z jmg $ > */ > >#ifndef _SYS_KTR_CLASS_H_ >#define _SYS_KTR_CLASS_H_ > >/* > * KTR trace classes > * > * Two of the trace classes (KTR_DEV and KTR_SUBSYS) are special in that > * they are really placeholders so that indvidual drivers and subsystems > * can map their internal tracing to the general class when they wish to > * have tracing enabled and map it to 0 when they don't. > */ >#define KTR_GEN 0x00000001 /* General (TR) */ >#define KTR_NET 0x00000002 /* Network */ >#define KTR_DEV 0x00000004 /* Device driver */ >#define KTR_LOCK 0x00000008 /* MP locking */ >#define KTR_SMP 0x00000010 /* MP general */ >#define KTR_SUBSYS 0x00000020 /* Subsystem. */ >#define KTR_PMAP 0x00000040 /* Pmap tracing */ >#define KTR_MALLOC 0x00000080 /* Malloc tracing */ >#define KTR_TRAP 0x00000100 /* Trap processing */ >#define KTR_INTR 0x00000200 /* Interrupt tracing */ >#define KTR_SIG 0x00000400 /* Signal processing */ >#define KTR_SPARE2 0x00000800 /* cxgb, amd64, xen, clk, &c */ >#define KTR_PROC 0x00001000 /* Process scheduling */ >#define KTR_SYSC 0x00002000 /* System call */ >#define KTR_INIT 0x00004000 /* System initialization */ >#define KTR_SPARE3 0x00008000 /* cxgb, drm2, ntb */ >#define KTR_SPARE4 0x00010000 /* geom_sched */ >#define KTR_EVH 0x00020000 /* Eventhandler */ >#define KTR_VFS 0x00040000 /* VFS events */ >#define KTR_VOP 0x00080000 /* Auto-generated vop events */ >#define KTR_VM 0x00100000 /* The virtual memory system */ >#define KTR_INET 0x00200000 /* IPv4 stack */ >#define KTR_RUNQ 0x00400000 /* Run queue */ >#define KTR_CONTENTION 0x00800000 /* Lock contention */ >#define KTR_UMA 0x01000000 /* UMA slab allocator */ >#define KTR_CALLOUT 0x02000000 /* Callouts and timeouts */ >#define KTR_GEOM 0x04000000 /* GEOM I/O events */ >#define KTR_BUSDMA 0x08000000 /* busdma(9) events */ >#define KTR_INET6 0x10000000 /* IPv6 stack */ >#define KTR_SCHED 0x20000000 /* Machine parsed sched info. */ >#define KTR_BUF 0x40000000 /* Buffer cache */ >#define KTR_ALL 0x7fffffff > >/* KTR trace classes to compile in */ >#ifdef KTR >#ifndef KTR_COMPILE >#define KTR_COMPILE (KTR_ALL) >#endif ># 81 "/usr/src/sys/sys/ktr_class.h" >#else /* !KTR */ ># 82 "/usr/src/sys/sys/ktr_class.h" >#undef KTR_COMPILE >#define KTR_COMPILE 0 >#endif /* KTR */ ># 85 "/usr/src/sys/sys/ktr_class.h" > >#endif /* !_SYS_KTR_CLASS_H_ */ ># 87 "/usr/src/sys/sys/ktr_class.h" ># 38 "/usr/src/sys/sys/lock.h" 2 > >struct lock_list_entry; >struct thread; > >/* > * Lock classes. Each lock has a class which describes characteristics > * common to all types of locks of a given class. > * > * Spin locks in general must always protect against preemption, as it is > * an error to perform any type of context switch while holding a spin lock. > * Also, for an individual lock to be recursable, its class must allow > * recursion and the lock itself must explicitly allow recursion. > * > * The 'lc_ddb_show' function pointer is used to dump class-specific > * data for the 'show lock' DDB command. The 'lc_lock' and > * 'lc_unlock' function pointers are used in sleep(9) and cv_wait(9) > * to lock and unlock locks while blocking on a sleep queue. The > * return value of 'lc_unlock' will be passed to 'lc_lock' on resume > * to allow communication of state between the two routines. > */ > >struct lock_class { > const char *lc_name; > u_int lc_flags; > void (*lc_assert)(const struct lock_object *lock, int what); > void (*lc_ddb_show)(const struct lock_object *lock); > void (*lc_lock)(struct lock_object *lock, uintptr_t how); > int (*lc_owner)(const struct lock_object *lock, > struct thread **owner); > uintptr_t (*lc_unlock)(struct lock_object *lock); >}; > >#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */ >#define LC_SPINLOCK 0x00000002 /* Spin lock. */ >#define LC_SLEEPABLE 0x00000004 /* Sleeping allowed with this lock. */ >#define LC_RECURSABLE 0x00000008 /* Locks of this type may recurse. */ >#define LC_UPGRADABLE 0x00000010 /* Upgrades and downgrades permitted. */ > >#define LO_CLASSFLAGS 0x0000ffff /* Class specific flags. */ >#define LO_INITIALIZED 0x00010000 /* Lock has been initialized. */ >#define LO_WITNESS 0x00020000 /* Should witness monitor this lock. */ >#define LO_QUIET 0x00040000 /* Don't log locking operations. */ >#define LO_RECURSABLE 0x00080000 /* Lock may recurse. */ >#define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */ >#define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */ >#define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */ >#define LO_IS_VNODE 0x00800000 /* Tell WITNESS about a VNODE lock */ >#define LO_CLASSMASK 0x0f000000 /* Class index bitmask. */ >#define LO_NOPROFILE 0x10000000 /* Don't profile this lock */ >#define LO_NEW 0x20000000 /* Don't check for double-init */ > >/* > * Lock classes are statically assigned an index into the gobal lock_classes > * array. Debugging code looks up the lock class for a given lock object > * by indexing the array. > */ >#define LO_CLASSSHIFT 24 >#define LO_CLASSINDEX(lock) ((((lock)->lo_flags) & LO_CLASSMASK) >> LO_CLASSSHIFT) >#define LOCK_CLASS(lock) (lock_classes[LO_CLASSINDEX((lock))]) >#define LOCK_CLASS_MAX (LO_CLASSMASK >> LO_CLASSSHIFT) > >/* > * Option flags passed to lock operations that witness also needs to know > * about or that are generic across all locks. > */ >#define LOP_NEWORDER 0x00000001 /* Define a new lock order. */ >#define LOP_QUIET 0x00000002 /* Don't log locking operations. */ >#define LOP_TRYLOCK 0x00000004 /* Don't check lock order. */ >#define LOP_EXCLUSIVE 0x00000008 /* Exclusive lock. */ >#define LOP_DUPOK 0x00000010 /* Don't check for duplicate acquires */ > >/* Flags passed to witness_assert. */ >#define LA_MASKASSERT 0x000000ff /* Mask for witness defined asserts. */ >#define LA_UNLOCKED 0x00000000 /* Lock is unlocked. */ >#define LA_LOCKED 0x00000001 /* Lock is at least share locked. */ >#define LA_SLOCKED 0x00000002 /* Lock is exactly share locked. */ >#define LA_XLOCKED 0x00000004 /* Lock is exclusively locked. */ >#define LA_RECURSED 0x00000008 /* Lock is recursed. */ >#define LA_NOTRECURSED 0x00000010 /* Lock is not recursed. */ > >#ifdef _KERNEL >/* > * If any of WITNESS, INVARIANTS, or KTR_LOCK KTR tracing has been enabled, > * then turn on LOCK_DEBUG. When this option is on, extra debugging > * facilities such as tracking the file and line number of lock operations > * are enabled. Also, mutex locking operations are not inlined to avoid > * bloat from all the extra debugging code. We also have to turn on all the > * calling conventions for this debugging code in modules so that modules can > * work with both debug and non-debug kernels. > */ >#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || defined(INVARIANT_SUPPORT) || defined(LOCK_PROFILING) || (defined(KTR) && (KTR_COMPILE & KTR_LOCK)) >#define LOCK_DEBUG 1 >#else ># 131 "/usr/src/sys/sys/lock.h" >#define LOCK_DEBUG 0 >#endif ># 133 "/usr/src/sys/sys/lock.h" > >/* > * In the LOCK_DEBUG case, use the filename and line numbers for debugging > * operations. Otherwise, use default values to avoid the unneeded bloat. > */ >#if LOCK_DEBUG > 0 >#define LOCK_FILE __FILE__ >#define LOCK_LINE __LINE__ >#else ># 142 "/usr/src/sys/sys/lock.h" >#define LOCK_FILE NULL >#define LOCK_LINE 0 >#endif ># 145 "/usr/src/sys/sys/lock.h" > >/* > * Macros for KTR_LOCK tracing. > * > * opname - name of this operation (LOCK/UNLOCK/SLOCK, etc.) > * lo - struct lock_object * for this lock > * flags - flags passed to the lock operation > * recurse - this locks recursion level (or 0 if class is not recursable) > * result - result of a try lock operation > * file - file name > * line - line number > */ >#define LOCK_LOG_TEST(lo, flags) \ > (((flags) & LOP_QUIET) == 0 && ((lo)->lo_flags & LO_QUIET) == 0) > >#define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do { \ > if (LOCK_LOG_TEST((lo), (flags))) \ > CTR6(KTR_LOCK, opname " (%s) %s %p r = %d at %s:%d", \ > LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ > (lo), (u_int)(recurse), (file), (line)); \ >} while (0) > >#define LOCK_LOG_TRY(opname, lo, flags, result, file, line) do { \ > if (LOCK_LOG_TEST((lo), (flags))) \ > CTR6(KTR_LOCK, "TRY_" opname " (%s) %s %p result=%d at %s:%d",\ > LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ > (lo), (u_int)(result), (file), (line)); \ >} while (0) > >#define LOCK_LOG_INIT(lo, flags) do { \ > if (LOCK_LOG_TEST((lo), (flags))) \ > CTR4(KTR_LOCK, "%s: %p (%s) %s", __func__, (lo), \ > LOCK_CLASS(lo)->lc_name, (lo)->lo_name); \ >} while (0) > >#define LOCK_LOG_DESTROY(lo, flags) LOCK_LOG_INIT(lo, flags) > >#define lock_initialized(lo) ((lo)->lo_flags & LO_INITIALIZED) > >/* > * Helpful macros for quickly coming up with assertions with informative > * panic messages. > */ >#define MPASS(ex) MPASS4(ex, #ex, __FILE__, __LINE__) >#define MPASS2(ex, what) MPASS4(ex, what, __FILE__, __LINE__) >#define MPASS3(ex, file, line) MPASS4(ex, #ex, file, line) >#define MPASS4(ex, what, file, line) \ > KASSERT((ex), ("Assertion %s failed at %s:%d", what, file, line)) > >extern struct lock_class lock_class_mtx_sleep; >extern struct lock_class lock_class_mtx_spin; >extern struct lock_class lock_class_sx; >extern struct lock_class lock_class_rw; >extern struct lock_class lock_class_rm; >extern struct lock_class lock_class_rm_sleepable; >extern struct lock_class lock_class_lockmgr; > >extern struct lock_class *lock_classes[]; > >void lock_init(struct lock_object *, struct lock_class *, > const char *, const char *, int); >void lock_destroy(struct lock_object *); >void spinlock_enter(void); >void spinlock_exit(void); >void witness_init(struct lock_object *, const char *); >void witness_destroy(struct lock_object *); >int witness_defineorder(struct lock_object *, struct lock_object *); >void witness_checkorder(struct lock_object *, int, const char *, int, > struct lock_object *); >void witness_lock(struct lock_object *, int, const char *, int); >void witness_upgrade(struct lock_object *, int, const char *, int); >void witness_downgrade(struct lock_object *, int, const char *, int); >void witness_unlock(struct lock_object *, int, const char *, int); >void witness_save(struct lock_object *, const char **, int *); >void witness_restore(struct lock_object *, const char *, int); >int witness_list_locks(struct lock_list_entry **, > int (*)(const char *, ...)); >int witness_warn(int, struct lock_object *, const char *, ...); >void witness_assert(const struct lock_object *, int, const char *, int); >void witness_display_spinlock(struct lock_object *, struct thread *, > int (*)(const char *, ...)); >int witness_line(struct lock_object *); >void witness_norelease(struct lock_object *); >void witness_releaseok(struct lock_object *); >const char *witness_file(struct lock_object *); >void witness_thread_exit(struct thread *); > >#ifdef WITNESS > >/* Flags for witness_warn(). */ >#define WARN_GIANTOK 0x01 /* Giant is exempt from this check. */ >#define WARN_PANIC 0x02 /* Panic if check fails. */ >#define WARN_SLEEPOK 0x04 /* Sleepable locks are exempt from check. */ > >#define WITNESS_INIT(lock, type) \ > witness_init((lock), (type)) > >#define WITNESS_DESTROY(lock) \ > witness_destroy(lock) > >#define WITNESS_CHECKORDER(lock, flags, file, line, interlock) \ > witness_checkorder((lock), (flags), (file), (line), (interlock)) > >#define WITNESS_DEFINEORDER(lock1, lock2) \ > witness_defineorder((struct lock_object *)(lock1), \ > (struct lock_object *)(lock2)) > >#define WITNESS_LOCK(lock, flags, file, line) \ > witness_lock((lock), (flags), (file), (line)) > >#define WITNESS_UPGRADE(lock, flags, file, line) \ > witness_upgrade((lock), (flags), (file), (line)) > >#define WITNESS_DOWNGRADE(lock, flags, file, line) \ > witness_downgrade((lock), (flags), (file), (line)) > >#define WITNESS_UNLOCK(lock, flags, file, line) \ > witness_unlock((lock), (flags), (file), (line)) > >#define WITNESS_CHECK(flags, lock, fmt, ...) \ > witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) > >#define WITNESS_WARN(flags, lock, fmt, ...) \ > witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) > >#define WITNESS_SAVE_DECL(n) \ > const char * __CONCAT(n, __wf); \ > int __CONCAT(n, __wl) > >#define WITNESS_SAVE(lock, n) \ > witness_save((lock), &__CONCAT(n, __wf), &__CONCAT(n, __wl)) > >#define WITNESS_RESTORE(lock, n) \ > witness_restore((lock), __CONCAT(n, __wf), __CONCAT(n, __wl)) > >#define WITNESS_NORELEASE(lock) \ > witness_norelease(&(lock)->lock_object) > >#define WITNESS_RELEASEOK(lock) \ > witness_releaseok(&(lock)->lock_object) > >#define WITNESS_FILE(lock) \ > witness_file(lock) > >#define WITNESS_LINE(lock) \ > witness_line(lock) > >#else /* WITNESS */ ># 293 "/usr/src/sys/sys/lock.h" >#define WITNESS_INIT(lock, type) (void)0 >#define WITNESS_DESTROY(lock) (void)0 >#define WITNESS_DEFINEORDER(lock1, lock2) 0 >#define WITNESS_CHECKORDER(lock, flags, file, line, interlock) (void)0 >#define WITNESS_LOCK(lock, flags, file, line) (void)0 >#define WITNESS_UPGRADE(lock, flags, file, line) (void)0 >#define WITNESS_DOWNGRADE(lock, flags, file, line) (void)0 >#define WITNESS_UNLOCK(lock, flags, file, line) (void)0 >#define WITNESS_CHECK(flags, lock, fmt, ...) 0 >#define WITNESS_WARN(flags, lock, fmt, ...) (void)0 >#define WITNESS_SAVE_DECL(n) (void)0 >#define WITNESS_SAVE(lock, n) (void)0 >#define WITNESS_RESTORE(lock, n) (void)0 >#define WITNESS_NORELEASE(lock) (void)0 >#define WITNESS_RELEASEOK(lock) (void)0 >#define WITNESS_FILE(lock) ("?") >#define WITNESS_LINE(lock) (0) >#endif /* WITNESS */ ># 311 "/usr/src/sys/sys/lock.h" > >#endif /* _KERNEL */ ># 313 "/usr/src/sys/sys/lock.h" >#endif /* _SYS_LOCK_H_ */ ># 314 "/usr/src/sys/sys/lock.h" ># 49 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> >#endif /* expanded by -frewrite-includes */ ># 49 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/mutex.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ > * $FreeBSD: head/sys/sys/mutex.h 275751 2014-12-13 21:00:10Z dchagin $ > */ > >#ifndef _SYS_MUTEX_H_ >#define _SYS_MUTEX_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/mutex.h" ># 36 "/usr/src/sys/sys/mutex.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/mutex.h" ># 37 "/usr/src/sys/sys/mutex.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/mutex.h" ># 1 "/usr/src/sys/sys/_mutex.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_mutex.h 242901 2012-11-11 23:25:47Z attilio $ > */ > >#ifndef _SYS__MUTEX_H_ >#define _SYS__MUTEX_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/param.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/sys/sys/_mutex.h" ># 35 "/usr/src/sys/sys/_mutex.h" > >/* > * Sleep/spin mutex. > * > * All mutex implementations must always have a member called mtx_lock. > * Other locking primitive structures are not allowed to use this name > * for their members. > * If this rule needs to change, the bits in the mutex implementation must > * be modified appropriately. > */ >struct mtx { > struct lock_object lock_object; /* Common lock properties. */ > volatile uintptr_t mtx_lock; /* Owner and flags. */ >}; > >/* > * Members of struct mtx_padalign must mirror members of struct mtx. > * mtx_padalign mutexes can use the mtx(9) API transparently without > * modification. > * Pad-aligned mutexes used within structures should generally be the > * first member of the struct. Otherwise, the compiler can generate > * additional padding for the struct to keep a correct alignment for > * the mutex. > */ >struct mtx_padalign { > struct lock_object lock_object; /* Common lock properties. */ > volatile uintptr_t mtx_lock; /* Owner and flags. */ >} __aligned(CACHE_LINE_SIZE); > >#endif /* !_SYS__MUTEX_H_ */ ># 65 "/usr/src/sys/sys/_mutex.h" ># 38 "/usr/src/sys/sys/mutex.h" 2 > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/mutex.h" ># 1 "/usr/src/sys/sys/pcpu.h" 1 >/*- > * Copyright (c) 2001 Wind River Systems, Inc. > * All rights reserved. > * Written by: John Baldwin <jhb@FreeBSD.org> > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the author nor the names of any co-contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/pcpu.h 261722 2014-02-10 19:47:14Z glebius $ > */ > >#ifndef _SYS_PCPU_H_ >#define _SYS_PCPU_H_ > >#ifdef LOCORE >#error "no assembler-serviceable parts inside" >#endif ># 39 "/usr/src/sys/sys/pcpu.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_cpuset.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/pcpu.h" ># 1 "/usr/src/sys/sys/_cpuset.h" 1 >/*- > * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> > * All rights reserved. > * > * Copyright (c) 2008 Nokia Corporation > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_cpuset.h 270222 2014-08-20 16:05:15Z jhb $ > */ > >#ifndef _SYS__CPUSET_H_ >#define _SYS__CPUSET_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_bitset.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/_cpuset.h" ># 1 "/usr/src/sys/sys/_bitset.h" 1 >/*- > * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> > * All rights reserved. > * > * Copyright (c) 2008 Nokia Corporation > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_bitset.h 250395 2013-05-09 00:04:59Z attilio $ > */ > >#ifndef _SYS__BITSET_H_ >#define _SYS__BITSET_H_ > >/* > * Macros addressing word and bit within it, tuned to make compiler > * optimize cases when SETSIZE fits into single machine word. > */ >#define _BITSET_BITS (sizeof(long) * NBBY) > >#define __bitset_words(_s) (howmany(_s, _BITSET_BITS)) > >#define __bitset_mask(_s, n) \ > (1L << ((__bitset_words((_s)) == 1) ? \ > (__size_t)(n) : ((n) % _BITSET_BITS))) > >#define __bitset_word(_s, n) \ > ((__bitset_words((_s)) == 1) ? 0 : ((n) / _BITSET_BITS)) > >#define BITSET_DEFINE(t, _s) \ >struct t { \ > long __bits[__bitset_words((_s))]; \ >}; > >#define BITSET_T_INITIALIZER(x) \ > { .__bits = { x } } > >#define BITSET_FSET(n) \ > [ 0 ... ((n) - 1) ] = (-1L) > >#endif /* !_SYS__BITSET_H_ */ ># 62 "/usr/src/sys/sys/_bitset.h" ># 36 "/usr/src/sys/sys/_cpuset.h" 2 > >#ifdef _KERNEL >#define CPU_SETSIZE MAXCPU >#endif ># 40 "/usr/src/sys/sys/_cpuset.h" > >#define CPU_MAXSIZE 256 > >#ifndef CPU_SETSIZE >#define CPU_SETSIZE CPU_MAXSIZE >#endif ># 46 "/usr/src/sys/sys/_cpuset.h" > >#define _NCPUBITS _BITSET_BITS >#define _NCPUWORDS __bitset_words(CPU_SETSIZE) > >BITSET_DEFINE(_cpuset, CPU_SETSIZE); >typedef struct _cpuset cpuset_t; > >#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) >#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER > >#endif /* !_SYS__CPUSET_H_ */ ># 57 "/usr/src/sys/sys/_cpuset.h" ># 41 "/usr/src/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/pcpu.h" ># 42 "/usr/src/sys/sys/pcpu.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/pcpu.h" ># 43 "/usr/src/sys/sys/pcpu.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sx.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/pcpu.h" ># 1 "/usr/src/sys/sys/_sx.h" 1 >/*- > * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice(s), this list of conditions and the following disclaimer as > * the first lines of this file unmodified other than the possible > * addition of one or more copyright notices. > * 2. Redistributions in binary form must reproduce the above copyright > * notice(s), this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > * DAMAGE. > * > * $FreeBSD: head/sys/sys/_sx.h 179025 2008-05-15 20:10:06Z attilio $ > */ > >#ifndef _SYS__SX_H_ >#define _SYS__SX_H_ > >/* > * Shared/exclusive lock main structure definition. > */ >struct sx { > struct lock_object lock_object; > volatile uintptr_t sx_lock; >}; > >#endif /* !_SYS__SX_H_ */ ># 43 "/usr/src/sys/sys/_sx.h" ># 44 "/usr/src/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/pcpu.h" ># 45 "/usr/src/sys/sys/pcpu.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_rmlock.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/pcpu.h" ># 1 "/usr/src/sys/sys/_rmlock.h" 1 >/*- > * Copyright (c) 2007 Stephan Uphoff <ups@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Neither the name of the author nor the names of any co-contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_rmlock.h 252209 2013-06-25 18:44:15Z jhb $ > */ > >#ifndef _SYS__RMLOCK_H_ >#define _SYS__RMLOCK_H_ > >/* > * Mostly reader/occasional writer lock. > */ > >LIST_HEAD(rmpriolist,rm_priotracker); > >struct rm_queue { > struct rm_queue *volatile rmq_next; > struct rm_queue *volatile rmq_prev; >}; > >struct rmlock { > struct lock_object lock_object; > volatile cpuset_t rm_writecpus; > LIST_HEAD(,rm_priotracker) rm_activeReaders; > union { > struct lock_object _rm_wlock_object; > struct mtx _rm_lock_mtx; > struct sx _rm_lock_sx; > } _rm_lock; >}; > >#define rm_wlock_object _rm_lock._rm_wlock_object >#define rm_lock_mtx _rm_lock._rm_lock_mtx >#define rm_lock_sx _rm_lock._rm_lock_sx > >struct rm_priotracker { > struct rm_queue rmp_cpuQueue; /* Must be first */ > struct rmlock *rmp_rmlock; > struct thread *rmp_thread; > int rmp_flags; > LIST_ENTRY(rm_priotracker) rmp_qentry; >}; > >#endif /* !_SYS__RMLOCK_H_ */ ># 70 "/usr/src/sys/sys/_rmlock.h" ># 46 "/usr/src/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/vmmeter.h> >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/sys/pcpu.h" ># 1 "/usr/src/sys/sys/vmmeter.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 > * $FreeBSD: head/sys/sys/vmmeter.h 263620 2014-03-22 10:26:09Z bdrewery $ > */ > >#ifndef _SYS_VMMETER_H_ >#define _SYS_VMMETER_H_ > >/* > * This value is used by ps(1) to change sleep state flag from 'S' to > * 'I' and by the sched process to set the alarm clock. > */ >#define MAXSLP 20 > >/* > * System wide statistics counters. > * Locking: > * a - locked by atomic operations > * c - constant after initialization > * f - locked by vm_page_queue_free_mtx > * p - locked by being in the PCPU and atomicity respect to interrupts > * q - changes are synchronized by the corresponding vm_pagequeue lock > */ >struct vmmeter { > /* > * General system activity. > */ > u_int v_swtch; /* (p) context switches */ > u_int v_trap; /* (p) calls to trap */ > u_int v_syscall; /* (p) calls to syscall() */ > u_int v_intr; /* (p) device interrupts */ > u_int v_soft; /* (p) software interrupts */ > /* > * Virtual memory activity. > */ > u_int v_vm_faults; /* (p) address memory faults */ > u_int v_io_faults; /* (p) page faults requiring I/O */ > u_int v_cow_faults; /* (p) copy-on-writes faults */ > u_int v_cow_optim; /* (p) optimized copy-on-writes faults */ > u_int v_zfod; /* (p) pages zero filled on demand */ > u_int v_ozfod; /* (p) optimized zero fill pages */ > u_int v_swapin; /* (p) swap pager pageins */ > u_int v_swapout; /* (p) swap pager pageouts */ > u_int v_swappgsin; /* (p) swap pager pages paged in */ > u_int v_swappgsout; /* (p) swap pager pages paged out */ > u_int v_vnodein; /* (p) vnode pager pageins */ > u_int v_vnodeout; /* (p) vnode pager pageouts */ > u_int v_vnodepgsin; /* (p) vnode_pager pages paged in */ > u_int v_vnodepgsout; /* (p) vnode pager pages paged out */ > u_int v_intrans; /* (p) intransit blocking page faults */ > u_int v_reactivated; /* (f) pages reactivated from free list */ > u_int v_pdwakeups; /* (f) times daemon has awaken from sleep */ > u_int v_pdpages; /* (p) pages analyzed by daemon */ > > u_int v_tcached; /* (p) total pages cached */ > u_int v_dfree; /* (p) pages freed by daemon */ > u_int v_pfree; /* (p) pages freed by exiting processes */ > u_int v_tfree; /* (p) total pages freed */ > /* > * Distribution of page usages. > */ > u_int v_page_size; /* (c) page size in bytes */ > u_int v_page_count; /* (c) total number of pages in system */ > u_int v_free_reserved; /* (c) pages reserved for deadlock */ > u_int v_free_target; /* (c) pages desired free */ > u_int v_free_min; /* (c) pages desired free */ > u_int v_free_count; /* (f) pages free */ > u_int v_wire_count; /* (a) pages wired down */ > u_int v_active_count; /* (q) pages active */ > u_int v_inactive_target; /* (c) pages desired inactive */ > u_int v_inactive_count; /* (q) pages inactive */ > u_int v_cache_count; /* (f) pages on cache queue */ > u_int v_cache_min; /* (c) min pages desired on cache queue */ > u_int v_cache_max; /* (c) max pages in cached obj (unused) */ > u_int v_pageout_free_min; /* (c) min pages reserved for kernel */ > u_int v_interrupt_free_min; /* (c) reserved pages for int code */ > u_int v_free_severe; /* (c) severe page depletion point */ > /* > * Fork/vfork/rfork activity. > */ > u_int v_forks; /* (p) fork() calls */ > u_int v_vforks; /* (p) vfork() calls */ > u_int v_rforks; /* (p) rfork() calls */ > u_int v_kthreads; /* (p) fork() calls by kernel */ > u_int v_forkpages; /* (p) VM pages affected by fork() */ > u_int v_vforkpages; /* (p) VM pages affected by vfork() */ > u_int v_rforkpages; /* (p) VM pages affected by rfork() */ > u_int v_kthreadpages; /* (p) VM pages affected by fork() by kernel */ >}; >#ifdef _KERNEL > >extern struct vmmeter vm_cnt; > >extern int vm_pageout_wakeup_thresh; > >/* > * Return TRUE if we are under our severe low-free-pages threshold > * > * This routine is typically used at the user<->system interface to determine > * whether we need to block in order to avoid a low memory deadlock. > */ > >static __inline >int >vm_page_count_severe(void) >{ > return (vm_cnt.v_free_severe > (vm_cnt.v_free_count + > vm_cnt.v_cache_count)); >} > >/* > * Return TRUE if we are under our minimum low-free-pages threshold. > * > * This routine is typically used within the system to determine whether > * we can execute potentially very expensive code in terms of memory. It > * is also used by the pageout daemon to calculate when to sleep, when > * to wake waiters up, and when (after making a pass) to become more > * desparate. > */ > >static __inline >int >vm_page_count_min(void) >{ > return (vm_cnt.v_free_min > (vm_cnt.v_free_count + vm_cnt.v_cache_count)); >} > >/* > * Return TRUE if we have not reached our free page target during > * free page recovery operations. > */ > >static __inline >int >vm_page_count_target(void) >{ > return (vm_cnt.v_free_target > (vm_cnt.v_free_count + > vm_cnt.v_cache_count)); >} > >/* > * Return the number of pages we need to free-up or cache > * A positive number indicates that we do not have enough free pages. > */ > >static __inline >int >vm_paging_target(void) >{ > return (vm_cnt.v_free_target - (vm_cnt.v_free_count + > vm_cnt.v_cache_count)); >} > >/* > * Returns TRUE if the pagedaemon needs to be woken up. > */ > >static __inline >int >vm_paging_needed(void) >{ > return (vm_cnt.v_free_count + vm_cnt.v_cache_count < > vm_pageout_wakeup_thresh); >} > >#endif ># 194 "/usr/src/sys/sys/vmmeter.h" > >/* systemwide totals computed every five seconds */ >struct vmtotal { > int16_t t_rq; /* length of the run queue */ > int16_t t_dw; /* jobs in ``disk wait'' (neg priority) */ > int16_t t_pw; /* jobs in page wait */ > int16_t t_sl; /* jobs sleeping in core */ > int16_t t_sw; /* swapped out runnable/short block jobs */ > int32_t t_vm; /* total virtual memory */ > int32_t t_avm; /* active virtual memory */ > int32_t t_rm; /* total real memory in use */ > int32_t t_arm; /* active real memory */ > int32_t t_vmshr; /* shared virtual memory */ > int32_t t_avmshr; /* active shared virtual memory */ > int32_t t_rmshr; /* shared real memory */ > int32_t t_armshr; /* active shared real memory */ > int32_t t_free; /* free memory pages */ >}; > >#endif ># 214 "/usr/src/sys/sys/vmmeter.h" ># 47 "/usr/src/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/resource.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/sys/sys/pcpu.h" ># 1 "/usr/src/sys/sys/resource.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)resource.h 8.4 (Berkeley) 1/9/95 > * $FreeBSD: head/sys/sys/resource.h 256849 2013-10-21 16:44:53Z kib $ > */ > >#ifndef _SYS_RESOURCE_H_ >#define _SYS_RESOURCE_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/resource.h" ># 37 "/usr/src/sys/sys/resource.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timeval.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/resource.h" ># 38 "/usr/src/sys/sys/resource.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/resource.h" ># 39 "/usr/src/sys/sys/resource.h" > >/* > * Process priority specifications to get/setpriority. > */ >#define PRIO_MIN -20 >#define PRIO_MAX 20 > >#define PRIO_PROCESS 0 >#define PRIO_PGRP 1 >#define PRIO_USER 2 > >/* > * Resource utilization information. > * > * All fields are only modified by curthread and > * no locks are required to read. > */ > >#define RUSAGE_SELF 0 >#define RUSAGE_CHILDREN -1 >#define RUSAGE_THREAD 1 > >struct rusage { > struct timeval ru_utime; /* user time used */ > struct timeval ru_stime; /* system time used */ > long ru_maxrss; /* max resident set size */ >#define ru_first ru_ixrss > long ru_ixrss; /* integral shared memory size */ > long ru_idrss; /* integral unshared data " */ > long ru_isrss; /* integral unshared stack " */ > long ru_minflt; /* page reclaims */ > long ru_majflt; /* page faults */ > long ru_nswap; /* swaps */ > long ru_inblock; /* block input operations */ > long ru_oublock; /* block output operations */ > long ru_msgsnd; /* messages sent */ > long ru_msgrcv; /* messages received */ > long ru_nsignals; /* signals received */ > long ru_nvcsw; /* voluntary context switches */ > long ru_nivcsw; /* involuntary " */ >#define ru_last ru_nivcsw >}; > >#if __BSD_VISIBLE >struct __wrusage { > struct rusage wru_self; > struct rusage wru_children; >}; >#endif ># 88 "/usr/src/sys/sys/resource.h" > >/* > * Resource limits > */ >#define RLIMIT_CPU 0 /* maximum cpu time in seconds */ >#define RLIMIT_FSIZE 1 /* maximum file size */ >#define RLIMIT_DATA 2 /* data size */ >#define RLIMIT_STACK 3 /* stack size */ >#define RLIMIT_CORE 4 /* core file size */ >#define RLIMIT_RSS 5 /* resident set size */ >#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ >#define RLIMIT_NPROC 7 /* number of processes */ >#define RLIMIT_NOFILE 8 /* number of open files */ >#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ >#define RLIMIT_VMEM 10 /* virtual process size (incl. mmap) */ >#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */ >#define RLIMIT_NPTS 11 /* pseudo-terminals */ >#define RLIMIT_SWAP 12 /* swap used */ >#define RLIMIT_KQUEUES 13 /* kqueues allocated */ > >#define RLIM_NLIMITS 14 /* number of resource limits */ > >#define RLIM_INFINITY ((rlim_t)(((uint64_t)1 << 63) - 1)) >/* XXX Missing: RLIM_SAVED_MAX, RLIM_SAVED_CUR */ > > >/* > * Resource limit string identifiers > */ > >#ifdef _RLIMIT_IDENT >static const char *rlimit_ident[RLIM_NLIMITS] = { > "cpu", > "fsize", > "data", > "stack", > "core", > "rss", > "memlock", > "nproc", > "nofile", > "sbsize", > "vmem", > "npts", > "swap", > "kqueues", >}; >#endif ># 136 "/usr/src/sys/sys/resource.h" > >#ifndef _RLIM_T_DECLARED >typedef __rlim_t rlim_t; >#define _RLIM_T_DECLARED >#endif ># 141 "/usr/src/sys/sys/resource.h" > >struct rlimit { > rlim_t rlim_cur; /* current (soft) limit */ > rlim_t rlim_max; /* maximum value for rlim_cur */ >}; > >#if __BSD_VISIBLE > >struct orlimit { > __int32_t rlim_cur; /* current (soft) limit */ > __int32_t rlim_max; /* maximum value for rlim_cur */ >}; > >struct loadavg { > __fixpt_t ldavg[3]; > long fscale; >}; > >#define CP_USER 0 >#define CP_NICE 1 >#define CP_SYS 2 >#define CP_INTR 3 >#define CP_IDLE 4 >#define CPUSTATES 5 > >#endif /* __BSD_VISIBLE */ ># 167 "/usr/src/sys/sys/resource.h" > >#ifdef _KERNEL > >extern struct loadavg averunnable; >void read_cpu_time(long *cp_time); /* Writes array of CPUSTATES */ > >#else ># 174 "/usr/src/sys/sys/resource.h" > >__BEGIN_DECLS >/* XXX 2nd arg to [gs]etpriority() should be an id_t */ >int getpriority(int, int); >int getrlimit(int, struct rlimit *); >int getrusage(int, struct rusage *); >int setpriority(int, int, int); >int setrlimit(int, const struct rlimit *); >__END_DECLS > >#endif /* _KERNEL */ ># 185 "/usr/src/sys/sys/resource.h" >#endif /* !_SYS_RESOURCE_H_ */ ># 186 "/usr/src/sys/sys/resource.h" ># 48 "/usr/src/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/sys/sys/pcpu.h" ># 1 "./machine/pcpu.h" 1 >/*- > * Copyright (c) Peter Wemm <peter@netplex.com.au> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/amd64/include/pcpu.h 256073 2013-10-05 23:11:01Z gibbs $ > */ > >#ifndef _MACHINE_PCPU_H_ >#define _MACHINE_PCPU_H_ > >#ifndef _SYS_CDEFS_H_ >#error "sys/cdefs.h is a prerequisite for this file" >#endif ># 35 "./machine/pcpu.h" > >/* > * The SMP parts are setup in pmap.c and locore.s for the BSP, and > * mp_machdep.c sets up the data for the AP's to "see" when they awake. > * The reason for doing it via a struct is so that an array of pointers > * to each CPU's data can be set up for things like "check curproc on all > * other processors" > */ >#define PCPU_MD_FIELDS \ > char pc_monitorbuf[128] __aligned(128); /* cache line */ \ > struct pcpu *pc_prvspace; /* Self-reference */ \ > struct pmap *pc_curpmap; \ > struct amd64tss *pc_tssp; /* TSS segment active on CPU */ \ > struct amd64tss *pc_commontssp;/* Common TSS for the CPU */ \ > register_t pc_rsp0; \ > register_t pc_scratch_rsp; /* User %rsp in syscall */ \ > u_int pc_apic_id; \ > u_int pc_acpi_id; /* ACPI CPU id */ \ > /* Pointer to the CPU %fs descriptor */ \ > struct user_segment_descriptor *pc_fs32p; \ > /* Pointer to the CPU %gs descriptor */ \ > struct user_segment_descriptor *pc_gs32p; \ > /* Pointer to the CPU LDT descriptor */ \ > struct system_segment_descriptor *pc_ldt; \ > /* Pointer to the CPU TSS descriptor */ \ > struct system_segment_descriptor *pc_tss; \ > uint64_t pc_pm_save_cnt; \ > u_int pc_cmci_mask; /* MCx banks for CMCI */ \ > uint64_t pc_dbreg[16]; /* ddb debugging regs */ \ > int pc_dbreg_cmd; /* ddb debugging reg cmd */ \ > u_int pc_vcpu_id; /* Xen vCPU ID */ \ > char __pad[157] /* be divisor of PAGE_SIZE \ > after cache alignment */ > >#define PC_DBREG_CMD_NONE 0 >#define PC_DBREG_CMD_LOAD 1 > >#ifdef _KERNEL > >#ifdef lint > >extern struct pcpu *pcpup; > >#define PCPU_GET(member) (pcpup->pc_ ## member) >#define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) >#define PCPU_INC(member) PCPU_ADD(member, 1) >#define PCPU_PTR(member) (&pcpup->pc_ ## member) >#define PCPU_SET(member, val) (pcpup->pc_ ## member = (val)) > >#elif defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) ># 85 "./machine/pcpu.h" > >/* > * Evaluates to the byte offset of the per-cpu variable name. > */ >#define __pcpu_offset(name) \ > __offsetof(struct pcpu, name) > >/* > * Evaluates to the type of the per-cpu variable name. > */ >#define __pcpu_type(name) \ > __typeof(((struct pcpu *)0)->name) > >/* > * Evaluates to the address of the per-cpu variable name. > */ >#define __PCPU_PTR(name) __extension__ ({ \ > __pcpu_type(name) *__p; \ > \ > __asm __volatile("movq %%gs:%1,%0; addq %2,%0" \ > : "=r" (__p) \ > : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \ > "i" (__pcpu_offset(name))); \ > \ > __p; \ >}) > >/* > * Evaluates to the value of the per-cpu variable name. > */ >#define __PCPU_GET(name) __extension__ ({ \ > __pcpu_type(name) __res; \ > struct __s { \ > u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ > } __s; \ > \ > if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ > sizeof(__res) == 4 || sizeof(__res) == 8) { \ > __asm __volatile("mov %%gs:%1,%0" \ > : "=r" (__s) \ > : "m" (*(struct __s *)(__pcpu_offset(name)))); \ > *(struct __s *)(void *)&__res = __s; \ > } else { \ > __res = *__PCPU_PTR(name); \ > } \ > __res; \ >}) > >/* > * Adds the value to the per-cpu counter name. The implementation > * must be atomic with respect to interrupts. > */ >#define __PCPU_ADD(name, val) do { \ > __pcpu_type(name) __val; \ > struct __s { \ > u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ > } __s; \ > \ > __val = (val); \ > if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ > sizeof(__val) == 4 || sizeof(__val) == 8) { \ > __s = *(struct __s *)(void *)&__val; \ > __asm __volatile("add %1,%%gs:%0" \ > : "=m" (*(struct __s *)(__pcpu_offset(name))) \ > : "r" (__s)); \ > } else \ > *__PCPU_PTR(name) += __val; \ >} while (0) > >/* > * Increments the value of the per-cpu counter name. The implementation > * must be atomic with respect to interrupts. > */ >#define __PCPU_INC(name) do { \ > CTASSERT(sizeof(__pcpu_type(name)) == 1 || \ > sizeof(__pcpu_type(name)) == 2 || \ > sizeof(__pcpu_type(name)) == 4 || \ > sizeof(__pcpu_type(name)) == 8); \ > if (sizeof(__pcpu_type(name)) == 1) { \ > __asm __volatile("incb %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } else if (sizeof(__pcpu_type(name)) == 2) { \ > __asm __volatile("incw %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } else if (sizeof(__pcpu_type(name)) == 4) { \ > __asm __volatile("incl %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } else if (sizeof(__pcpu_type(name)) == 8) { \ > __asm __volatile("incq %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } \ >} while (0) > >/* > * Sets the value of the per-cpu variable name to value val. > */ >#define __PCPU_SET(name, val) { \ > __pcpu_type(name) __val; \ > struct __s { \ > u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ > } __s; \ > \ > __val = (val); \ > if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ > sizeof(__val) == 4 || sizeof(__val) == 8) { \ > __s = *(struct __s *)(void *)&__val; \ > __asm __volatile("mov %1,%%gs:%0" \ > : "=m" (*(struct __s *)(__pcpu_offset(name))) \ > : "r" (__s)); \ > } else { \ > *__PCPU_PTR(name) = __val; \ > } \ >} > >#define PCPU_GET(member) __PCPU_GET(pc_ ## member) >#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) >#define PCPU_INC(member) __PCPU_INC(pc_ ## member) >#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) >#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) > >#define OFFSETOF_CURTHREAD 0 >#ifdef __clang__ >#pragma clang diagnostic push >#pragma clang diagnostic ignored "-Wnull-dereference" >#endif ># 214 "./machine/pcpu.h" >static __inline __pure2 struct thread * >__curthread(void) >{ > struct thread *td; > > __asm("movq %%gs:%1,%0" : "=r" (td) > : "m" (*(char *)OFFSETOF_CURTHREAD)); > return (td); >} >#ifdef __clang__ >#pragma clang diagnostic pop >#endif ># 226 "./machine/pcpu.h" >#define curthread (__curthread()) > >#define OFFSETOF_CURPCB 32 >static __inline __pure2 struct pcb * >__curpcb(void) >{ > struct pcb *pcb; > > __asm("movq %%gs:%1,%0" : "=r" (pcb) : "m" (*(char *)OFFSETOF_CURPCB)); > return (pcb); >} >#define curpcb (__curpcb()) > >#define IS_BSP() (PCPU_GET(cpuid) == 0) > >#else /* !lint || defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) */ ># 242 "./machine/pcpu.h" > >#error "this file needs to be ported to your compiler" > >#endif /* lint, etc. */ ># 246 "./machine/pcpu.h" > >#endif /* _KERNEL */ ># 248 "./machine/pcpu.h" > >#endif /* !_MACHINE_PCPU_H_ */ ># 250 "./machine/pcpu.h" ># 49 "/usr/src/sys/sys/pcpu.h" 2 > >#define DPCPU_SETNAME "set_pcpu" >#define DPCPU_SYMPREFIX "pcpu_entry_" > >#ifdef _KERNEL > >/* > * Define a set for pcpu data. > */ >extern uintptr_t *__start_set_pcpu; >__GLOBL(__start_set_pcpu); >extern uintptr_t *__stop_set_pcpu; >__GLOBL(__stop_set_pcpu); > >/* > * Array of dynamic pcpu base offsets. Indexed by id. > */ >extern uintptr_t dpcpu_off[]; > >/* > * Convenience defines. > */ >#define DPCPU_START ((uintptr_t)&__start_set_pcpu) >#define DPCPU_STOP ((uintptr_t)&__stop_set_pcpu) >#define DPCPU_BYTES (DPCPU_STOP - DPCPU_START) >#define DPCPU_MODMIN 2048 >#define DPCPU_SIZE roundup2(DPCPU_BYTES, PAGE_SIZE) >#define DPCPU_MODSIZE (DPCPU_SIZE - (DPCPU_BYTES - DPCPU_MODMIN)) > >/* > * Declaration and definition. > */ >#define DPCPU_NAME(n) pcpu_entry_##n >#define DPCPU_DECLARE(t, n) extern t DPCPU_NAME(n) >#define DPCPU_DEFINE(t, n) t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used > >/* > * Accessors with a given base. > */ >#define _DPCPU_PTR(b, n) \ > (__typeof(DPCPU_NAME(n))*)((b) + (uintptr_t)&DPCPU_NAME(n)) >#define _DPCPU_GET(b, n) (*_DPCPU_PTR(b, n)) >#define _DPCPU_SET(b, n, v) (*_DPCPU_PTR(b, n) = v) > >/* > * Accessors for the current cpu. > */ >#define DPCPU_PTR(n) _DPCPU_PTR(PCPU_GET(dynamic), n) >#define DPCPU_GET(n) (*DPCPU_PTR(n)) >#define DPCPU_SET(n, v) (*DPCPU_PTR(n) = v) > >/* > * Accessors for remote cpus. > */ >#define DPCPU_ID_PTR(i, n) _DPCPU_PTR(dpcpu_off[(i)], n) >#define DPCPU_ID_GET(i, n) (*DPCPU_ID_PTR(i, n)) >#define DPCPU_ID_SET(i, n, v) (*DPCPU_ID_PTR(i, n) = v) > >/* > * Utility macros. > */ >#define DPCPU_SUM(n) __extension__ \ >({ \ > u_int _i; \ > __typeof(*DPCPU_PTR(n)) sum; \ > \ > sum = 0; \ > CPU_FOREACH(_i) { \ > sum += *DPCPU_ID_PTR(_i, n); \ > } \ > sum; \ >}) > >#define DPCPU_VARSUM(n, var) __extension__ \ >({ \ > u_int _i; \ > __typeof((DPCPU_PTR(n))->var) sum; \ > \ > sum = 0; \ > CPU_FOREACH(_i) { \ > sum += (DPCPU_ID_PTR(_i, n))->var; \ > } \ > sum; \ >}) > >#define DPCPU_ZERO(n) do { \ > u_int _i; \ > \ > CPU_FOREACH(_i) { \ > bzero(DPCPU_ID_PTR(_i, n), sizeof(*DPCPU_PTR(n))); \ > } \ >} while(0) > >#endif /* _KERNEL */ ># 143 "/usr/src/sys/sys/pcpu.h" > >/* > * This structure maps out the global data that needs to be kept on a > * per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR > * macros defined in <machine/pcpu.h>. Machine dependent fields are > * defined in the PCPU_MD_FIELDS macro defined in <machine/pcpu.h>. > */ >struct pcpu { > struct thread *pc_curthread; /* Current thread */ > struct thread *pc_idlethread; /* Idle thread */ > struct thread *pc_fpcurthread; /* Fp state owner */ > struct thread *pc_deadthread; /* Zombie thread or NULL */ > struct pcb *pc_curpcb; /* Current pcb */ > uint64_t pc_switchtime; /* cpu_ticks() at last csw */ > int pc_switchticks; /* `ticks' at last csw */ > u_int pc_cpuid; /* This cpu number */ > STAILQ_ENTRY(pcpu) pc_allcpu; > struct lock_list_entry *pc_spinlocks; > struct vmmeter pc_cnt; /* VM stats counters */ > long pc_cp_time[CPUSTATES]; /* statclock ticks */ > struct device *pc_device; > void *pc_netisr; /* netisr SWI cookie */ > int pc_dnweight; /* vm_page_dontneed() */ > int pc_domain; /* Memory domain. */ > struct rm_queue pc_rm_queue; /* rmlock list of trackers */ > uintptr_t pc_dynamic; /* Dynamic per-cpu data area */ > > /* > * Keep MD fields last, so that CPU-specific variations on a > * single architecture don't result in offset variations of > * the machine-independent fields of the pcpu. Even though > * the pcpu structure is private to the kernel, some ports > * (e.g., lsof, part of gtop) define _KERNEL and include this > * header. While strictly speaking this is wrong, there's no > * reason not to keep the offsets of the MI fields constant > * if only to make kernel debugging easier. > */ > PCPU_MD_FIELDS; >} __aligned(CACHE_LINE_SIZE); > >#ifdef CTASSERT >/* > * To minimize memory waste in per-cpu UMA zones, size of struct pcpu > * should be denominator of PAGE_SIZE. > */ >CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE); >#endif ># 190 "/usr/src/sys/sys/pcpu.h" > >#ifdef _KERNEL > >STAILQ_HEAD(cpuhead, pcpu); > >extern struct cpuhead cpuhead; >extern struct pcpu *cpuid_to_pcpu[]; > >#define curcpu PCPU_GET(cpuid) >#define curproc (curthread->td_proc) >#ifndef curthread >#define curthread PCPU_GET(curthread) >#endif ># 203 "/usr/src/sys/sys/pcpu.h" >#define curvidata PCPU_GET(vidata) > >/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */ >static inline void * >zpcpu_get(void *base) >{ > > return ((char *)(base) + sizeof(struct pcpu) * curcpu); >} > >static inline void * >zpcpu_get_cpu(void *base, int cpu) >{ > > return ((char *)(base) + sizeof(struct pcpu) * cpu); >} > >/* > * Machine dependent callouts. cpu_pcpu_init() is responsible for > * initializing machine dependent fields of struct pcpu, and > * db_show_mdpcpu() is responsible for handling machine dependent > * fields for the DDB 'show pcpu' command. > */ >void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); >void db_show_mdpcpu(struct pcpu *pcpu); > >void *dpcpu_alloc(int size); >void dpcpu_copy(void *s, int size); >void dpcpu_free(void *s, int size); >void dpcpu_init(void *dpcpu, int cpuid); >void pcpu_destroy(struct pcpu *pcpu); >struct pcpu *pcpu_find(u_int cpuid); >void pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); > >#endif /* _KERNEL */ ># 238 "/usr/src/sys/sys/pcpu.h" > >#endif /* !_SYS_PCPU_H_ */ ># 240 "/usr/src/sys/sys/pcpu.h" ># 41 "/usr/src/sys/sys/mutex.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock_profile.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/mutex.h" ># 1 "/usr/src/sys/sys/lock_profile.h" 1 >/*- > * Copyright (c) 2006 Kip Macy kmacy@FreeBSD.org > * Copyright (c) 2006 Kris Kennaway kris@FreeBSD.org > * Copyright (c) 2006 Dag-Erling Smorgrav des@des.no > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHAL THE AUTHORS BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/lock_profile.h 194578 2009-06-21 09:01:12Z rdivacky $ > */ > > >#ifndef _SYS_LOCK_PROFILE_H_ >#define _SYS_LOCK_PROFILE_H_ > >struct lock_profile_object; >LIST_HEAD(lpohead, lock_profile_object); > >#ifdef _KERNEL >#ifdef LOCK_PROFILING >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/lock_profile.h" ># 40 "/usr/src/sys/sys/lock_profile.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/lock_profile.h" ># 41 "/usr/src/sys/sys/lock_profile.h" > >#ifndef USE_CPU_NANOSECONDS >u_int64_t nanoseconds(void); >#endif ># 45 "/usr/src/sys/sys/lock_profile.h" > >extern volatile int lock_prof_enable; > >void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, > uint64_t waittime, const char *file, int line); >void lock_profile_release_lock(struct lock_object *lo); >void lock_profile_thread_exit(struct thread *td); > > >static inline void >lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, > uint64_t *waittime) >{ > if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE) || *contested) > return; > *waittime = nanoseconds(); > *contested = 1; >} > >#else /* !LOCK_PROFILING */ ># 65 "/usr/src/sys/sys/lock_profile.h" > >#define lock_profile_release_lock(lo) (void)0 >#define lock_profile_obtain_lock_failed(lo, contested, waittime) (void)0 >#define lock_profile_obtain_lock_success(lo, contested, waittime, file, line) (void)0 >#define lock_profile_thread_exit(td) (void)0 > >#endif /* !LOCK_PROFILING */ ># 72 "/usr/src/sys/sys/lock_profile.h" > >#endif /* _KERNEL */ ># 74 "/usr/src/sys/sys/lock_profile.h" > >#endif /* _SYS_LOCK_PROFILE_H_ */ ># 76 "/usr/src/sys/sys/lock_profile.h" ># 42 "/usr/src/sys/sys/mutex.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lockstat.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/mutex.h" ># 1 "/usr/src/sys/sys/lockstat.h" 1 >/*- > * Copyright (c) 2008-2009 Stacey Son <sson@FreeBSD.org> > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/lockstat.h 228448 2011-12-12 23:29:32Z attilio $ > */ > >/* > * DTrace lockstat provider definitions > * > */ > >#ifndef _SYS_LOCKSTAT_H >#define _SYS_LOCKSTAT_H > >#ifdef _KERNEL > >/* > * Spin Locks > */ >#define LS_MTX_SPIN_LOCK_ACQUIRE 0 >#define LS_MTX_SPIN_UNLOCK_RELEASE 1 >#define LS_MTX_SPIN_LOCK_SPIN 2 > >/* > * Adaptive Locks > */ >#define LS_MTX_LOCK_ACQUIRE 3 >#define LS_MTX_UNLOCK_RELEASE 4 >#define LS_MTX_LOCK_SPIN 5 >#define LS_MTX_LOCK_BLOCK 6 >#define LS_MTX_TRYLOCK_ACQUIRE 7 > >/* > * Reader/Writer Locks > */ >#define LS_RW_RLOCK_ACQUIRE 8 >#define LS_RW_RUNLOCK_RELEASE 9 >#define LS_RW_WLOCK_ACQUIRE 10 >#define LS_RW_WUNLOCK_RELEASE 11 >#define LS_RW_RLOCK_SPIN 12 >#define LS_RW_RLOCK_BLOCK 13 >#define LS_RW_WLOCK_SPIN 14 >#define LS_RW_WLOCK_BLOCK 15 >#define LS_RW_TRYUPGRADE_UPGRADE 16 >#define LS_RW_DOWNGRADE_DOWNGRADE 17 > >/* > * Shared/Exclusive Locks > */ >#define LS_SX_SLOCK_ACQUIRE 18 >#define LS_SX_SUNLOCK_RELEASE 19 >#define LS_SX_XLOCK_ACQUIRE 20 >#define LS_SX_XUNLOCK_RELEASE 21 >#define LS_SX_SLOCK_SPIN 22 >#define LS_SX_SLOCK_BLOCK 23 >#define LS_SX_XLOCK_SPIN 24 >#define LS_SX_XLOCK_BLOCK 25 >#define LS_SX_TRYUPGRADE_UPGRADE 26 >#define LS_SX_DOWNGRADE_DOWNGRADE 27 > >/* > * Thread Locks > */ >#define LS_THREAD_LOCK_SPIN 28 > >/* > * Lockmanager Locks > * According to locking(9) Lockmgr locks are "Largely deprecated" > * so no support for these have been added in the lockstat provider. > */ > >#define LS_NPROBES 29 > >#define LS_MTX_LOCK "mtx_lock" >#define LS_MTX_UNLOCK "mtx_unlock" >#define LS_MTX_SPIN_LOCK "mtx_lock_spin" >#define LS_MTX_SPIN_UNLOCK "mtx_unlock_spin" >#define LS_MTX_TRYLOCK "mtx_trylock" >#define LS_RW_RLOCK "rw_rlock" >#define LS_RW_WLOCK "rw_wlock" >#define LS_RW_RUNLOCK "rw_runlock" >#define LS_RW_WUNLOCK "rw_wunlock" >#define LS_RW_TRYUPGRADE "rw_try_upgrade" >#define LS_RW_DOWNGRADE "rw_downgrade" >#define LS_SX_SLOCK "sx_slock" >#define LS_SX_XLOCK "sx_xlock" >#define LS_SX_SUNLOCK "sx_sunlock" >#define LS_SX_XUNLOCK "sx_xunlock" >#define LS_SX_TRYUPGRADE "sx_try_upgrade" >#define LS_SX_DOWNGRADE "sx_downgrade" >#define LS_THREAD_LOCK "thread_lock" > >#define LS_ACQUIRE "acquire" >#define LS_RELEASE "release" >#define LS_SPIN "spin" >#define LS_BLOCK "block" >#define LS_UPGRADE "upgrade" >#define LS_DOWNGRADE "downgrade" > >#define LS_TYPE_ADAPTIVE "adaptive" >#define LS_TYPE_SPIN "spin" >#define LS_TYPE_THREAD "thread" >#define LS_TYPE_RW "rw" >#define LS_TYPE_SX "sx" > >#define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE) >#define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE) >#define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN) >#define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK) >#define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE) >#define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE) >#define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN) >#define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE) >#define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE) >#define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK) >#define LSR_SPIN (LS_TYPE_RW "-" LS_SPIN) >#define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE) >#define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE) >#define LSX_ACQUIRE (LS_TYPE_SX "-" LS_ACQUIRE) >#define LSX_RELEASE (LS_TYPE_SX "-" LS_RELEASE) >#define LSX_BLOCK (LS_TYPE_SX "-" LS_BLOCK) >#define LSX_SPIN (LS_TYPE_SX "-" LS_SPIN) >#define LSX_UPGRADE (LS_TYPE_SX "-" LS_UPGRADE) >#define LSX_DOWNGRADE (LS_TYPE_SX "-" LS_DOWNGRADE) >#define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN) > >/* > * The following must match the type definition of dtrace_probe. It is > * defined this way to avoid having to rely on CDDL code. > */ >extern uint32_t lockstat_probemap[LS_NPROBES]; >typedef void (*lockstat_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1, > uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); >extern lockstat_probe_func_t lockstat_probe_func; >extern uint64_t lockstat_nsecs(void); > >#ifdef KDTRACE_HOOKS >/* > * Macros to record lockstat probes. > */ >#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) do { \ > uint32_t id; \ > \ > if ((id = lockstat_probemap[(probe)])) \ > (*lockstat_probe_func)(id, (uintptr_t)(lp), (arg1), (arg2), \ > (arg3), (arg4)); \ >} while (0) > >#define LOCKSTAT_RECORD(probe, lp, arg1) \ > LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0) > >#define LOCKSTAT_RECORD0(probe, lp) \ > LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0) > >#define LOCKSTAT_RECORD1(probe, lp, arg1) \ > LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0) > >#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \ > LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0) > >#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \ > LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, 0) > >#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \ > uint32_t id; \ > \ > lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ > if ((id = lockstat_probemap[(probe)])) \ > (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \ >} while (0) > >#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \ > uint32_t id; \ > \ > lock_profile_release_lock(&(lp)->lock_object); \ > if ((id = lockstat_probemap[(probe)])) \ > (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \ >} while (0) > >#else /* !KDTRACE_HOOKS */ ># 202 "/usr/src/sys/sys/lockstat.h" > >#define LOCKSTAT_RECORD(probe, lp, arg1) >#define LOCKSTAT_RECORD0(probe, lp) >#define LOCKSTAT_RECORD1(probe, lp, arg1) >#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) >#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) >#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) > >#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) \ > lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l) > >#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) \ > lock_profile_release_lock(&(lp)->lock_object) > >#endif /* !KDTRACE_HOOKS */ ># 217 "/usr/src/sys/sys/lockstat.h" > >#endif /* _KERNEL */ ># 219 "/usr/src/sys/sys/lockstat.h" > >#endif /* _SYS_LOCKSTAT_H */ ># 221 "/usr/src/sys/sys/lockstat.h" ># 43 "/usr/src/sys/sys/mutex.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/mutex.h" ># 44 "/usr/src/sys/sys/mutex.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/mutex.h" ># 45 "/usr/src/sys/sys/mutex.h" > >/* > * Mutex types and options passed to mtx_init(). MTX_QUIET and MTX_DUPOK > * can also be passed in. > */ >#define MTX_DEF 0x00000000 /* DEFAULT (sleep) lock */ >#define MTX_SPIN 0x00000001 /* Spin lock (disables interrupts) */ >#define MTX_RECURSE 0x00000004 /* Option: lock allowed to recurse */ >#define MTX_NOWITNESS 0x00000008 /* Don't do any witness checking. */ >#define MTX_NOPROFILE 0x00000020 /* Don't profile this lock */ >#define MTX_NEW 0x00000040 /* Don't check for double-init */ > >/* > * Option flags passed to certain lock/unlock routines, through the use > * of corresponding mtx_{lock,unlock}_flags() interface macros. > */ >#define MTX_QUIET LOP_QUIET /* Don't log a mutex event */ >#define MTX_DUPOK LOP_DUPOK /* Don't log a duplicate acquire */ > >/* > * State bits kept in mutex->mtx_lock, for the DEFAULT lock type. None of this, > * with the exception of MTX_UNOWNED, applies to spin locks. > */ >#define MTX_RECURSED 0x00000001 /* lock recursed (for MTX_DEF only) */ >#define MTX_CONTESTED 0x00000002 /* lock contested (for MTX_DEF only) */ >#define MTX_UNOWNED 0x00000004 /* Cookie for free mutex */ >#define MTX_FLAGMASK (MTX_RECURSED | MTX_CONTESTED | MTX_UNOWNED) > >/* > * Value stored in mutex->mtx_lock to denote a destroyed mutex. > */ >#define MTX_DESTROYED (MTX_CONTESTED | MTX_UNOWNED) > >/* > * Prototypes > * > * NOTE: Functions prepended with `_' (underscore) are exported to other parts > * of the kernel via macros, thus allowing us to use the cpp LOCK_FILE > * and LOCK_LINE or for hiding the lock cookie crunching to the > * consumers. These functions should not be called directly by any > * code using the API. Their macros cover their functionality. > * Functions with a `_' suffix are the entrypoint for the common > * KPI covering both compat shims and fast path case. These can be > * used by consumers willing to pass options, file and line > * informations, in an option-independent way. > * > * [See below for descriptions] > * > */ >void _mtx_init(volatile uintptr_t *c, const char *name, const char *type, > int opts); >void _mtx_destroy(volatile uintptr_t *c); >void mtx_sysinit(void *arg); >int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, > int line); >void mutex_init(void); >void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t tid, int opts, > const char *file, int line); >void __mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, > int line); >#ifdef SMP >void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t tid, int opts, > const char *file, int line); >#endif ># 109 "/usr/src/sys/sys/mutex.h" >void __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, > int line); >void __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, > int line); >void __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, > int line); >void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, > const char *file, int line); >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >void __mtx_assert(const volatile uintptr_t *c, int what, const char *file, > int line); >#endif ># 121 "/usr/src/sys/sys/mutex.h" >void thread_lock_flags_(struct thread *, int, const char *, int); > >#define thread_lock(tdp) \ > thread_lock_flags_((tdp), 0, __FILE__, __LINE__) >#define thread_lock_flags(tdp, opt) \ > thread_lock_flags_((tdp), (opt), __FILE__, __LINE__) >#define thread_unlock(tdp) \ > mtx_unlock_spin((tdp)->td_lock) > >/* > * Top-level macros to provide lock cookie once the actual mtx is passed. > * They will also prevent passing a malformed object to the mtx KPI by > * failing compilation as the mtx_lock reserved member will not be found. > */ >#define mtx_init(m, n, t, o) \ > _mtx_init(&(m)->mtx_lock, n, t, o) >#define mtx_destroy(m) \ > _mtx_destroy(&(m)->mtx_lock) >#define mtx_trylock_flags_(m, o, f, l) \ > _mtx_trylock_flags_(&(m)->mtx_lock, o, f, l) >#define _mtx_lock_sleep(m, t, o, f, l) \ > __mtx_lock_sleep(&(m)->mtx_lock, t, o, f, l) >#define _mtx_unlock_sleep(m, o, f, l) \ > __mtx_unlock_sleep(&(m)->mtx_lock, o, f, l) >#ifdef SMP >#define _mtx_lock_spin(m, t, o, f, l) \ > _mtx_lock_spin_cookie(&(m)->mtx_lock, t, o, f, l) >#endif ># 149 "/usr/src/sys/sys/mutex.h" >#define _mtx_lock_flags(m, o, f, l) \ > __mtx_lock_flags(&(m)->mtx_lock, o, f, l) >#define _mtx_unlock_flags(m, o, f, l) \ > __mtx_unlock_flags(&(m)->mtx_lock, o, f, l) >#define _mtx_lock_spin_flags(m, o, f, l) \ > __mtx_lock_spin_flags(&(m)->mtx_lock, o, f, l) >#define _mtx_unlock_spin_flags(m, o, f, l) \ > __mtx_unlock_spin_flags(&(m)->mtx_lock, o, f, l) >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define _mtx_assert(m, w, f, l) \ > __mtx_assert(&(m)->mtx_lock, w, f, l) >#endif ># 161 "/usr/src/sys/sys/mutex.h" > >#define mtx_recurse lock_object.lo_data > >/* Very simple operations on mtx_lock. */ > >/* Try to obtain mtx_lock once. */ >#define _mtx_obtain_lock(mp, tid) \ > atomic_cmpset_acq_ptr(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) > >/* Try to release mtx_lock if it is unrecursed and uncontested. */ >#define _mtx_release_lock(mp, tid) \ > atomic_cmpset_rel_ptr(&(mp)->mtx_lock, (tid), MTX_UNOWNED) > >/* Release mtx_lock quickly, assuming we own it. */ >#define _mtx_release_lock_quick(mp) \ > atomic_store_rel_ptr(&(mp)->mtx_lock, MTX_UNOWNED) > >/* > * Full lock operations that are suitable to be inlined in non-debug > * kernels. If the lock cannot be acquired or released trivially then > * the work is deferred to another function. > */ > >/* Lock a normal mutex. */ >#define __mtx_lock(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > if (!_mtx_obtain_lock((mp), _tid)) \ > _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ > else \ > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, \ > mp, 0, 0, (file), (line)); \ >} while (0) > >/* > * Lock a spin mutex. For spinlocks, we handle recursion inline (it > * turns out that function calls can be significantly expensive on > * some architectures). Since spin locks are not _too_ common, > * inlining this code is not too big a deal. > */ >#ifdef SMP >#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > spinlock_enter(); \ > if (!_mtx_obtain_lock((mp), _tid)) { \ > if ((mp)->mtx_lock == _tid) \ > (mp)->mtx_recurse++; \ > else \ > _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ > } else \ > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ > mp, 0, 0, (file), (line)); \ >} while (0) >#else /* SMP */ ># 216 "/usr/src/sys/sys/mutex.h" >#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > spinlock_enter(); \ > if ((mp)->mtx_lock == _tid) \ > (mp)->mtx_recurse++; \ > else { \ > KASSERT((mp)->mtx_lock == MTX_UNOWNED, ("corrupt spinlock")); \ > (mp)->mtx_lock = _tid; \ > } \ >} while (0) >#endif /* SMP */ ># 228 "/usr/src/sys/sys/mutex.h" > >/* Unlock a normal mutex. */ >#define __mtx_unlock(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > if ((mp)->mtx_recurse == 0) \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_UNLOCK_RELEASE, \ > (mp)); \ > if (!_mtx_release_lock((mp), _tid)) \ > _mtx_unlock_sleep((mp), (opts), (file), (line)); \ >} while (0) > >/* > * Unlock a spin mutex. For spinlocks, we can handle everything > * inline, as it's pretty simple and a function call would be too > * expensive (at least on some architectures). Since spin locks are > * not _too_ common, inlining this code is not too big a deal. > * > * Since we always perform a spinlock_enter() when attempting to acquire a > * spin lock, we need to always perform a matching spinlock_exit() when > * releasing a spin lock. This includes the recursion cases. > */ >#ifdef SMP >#define __mtx_unlock_spin(mp) do { \ > if (mtx_recursed((mp))) \ > (mp)->mtx_recurse--; \ > else { \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ > mp); \ > _mtx_release_lock_quick((mp)); \ > } \ > spinlock_exit(); \ >} while (0) >#else /* SMP */ ># 262 "/usr/src/sys/sys/mutex.h" >#define __mtx_unlock_spin(mp) do { \ > if (mtx_recursed((mp))) \ > (mp)->mtx_recurse--; \ > else { \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ > mp); \ > (mp)->mtx_lock = MTX_UNOWNED; \ > } \ > spinlock_exit(); \ >} while (0) >#endif /* SMP */ ># 273 "/usr/src/sys/sys/mutex.h" > >/* > * Exported lock manipulation interface. > * > * mtx_lock(m) locks MTX_DEF mutex `m' > * > * mtx_lock_spin(m) locks MTX_SPIN mutex `m' > * > * mtx_unlock(m) unlocks MTX_DEF mutex `m' > * > * mtx_unlock_spin(m) unlocks MTX_SPIN mutex `m' > * > * mtx_lock_spin_flags(m, opts) and mtx_lock_flags(m, opts) locks mutex `m' > * and passes option flags `opts' to the "hard" function, if required. > * With these routines, it is possible to pass flags such as MTX_QUIET > * to the appropriate lock manipulation routines. > * > * mtx_trylock(m) attempts to acquire MTX_DEF mutex `m' but doesn't sleep if > * it cannot. Rather, it returns 0 on failure and non-zero on success. > * It does NOT handle recursion as we assume that if a caller is properly > * using this part of the interface, he will know that the lock in question > * is _not_ recursed. > * > * mtx_trylock_flags(m, opts) is used the same way as mtx_trylock() but accepts > * relevant option flags `opts.' > * > * mtx_initialized(m) returns non-zero if the lock `m' has been initialized. > * > * mtx_owned(m) returns non-zero if the current thread owns the lock `m' > * > * mtx_recursed(m) returns non-zero if the lock `m' is presently recursed. > */ >#define mtx_lock(m) mtx_lock_flags((m), 0) >#define mtx_lock_spin(m) mtx_lock_spin_flags((m), 0) >#define mtx_trylock(m) mtx_trylock_flags((m), 0) >#define mtx_unlock(m) mtx_unlock_flags((m), 0) >#define mtx_unlock_spin(m) mtx_unlock_spin_flags((m), 0) > >struct mtx_pool; > >struct mtx_pool *mtx_pool_create(const char *mtx_name, int pool_size, int opts); >void mtx_pool_destroy(struct mtx_pool **poolp); >struct mtx *mtx_pool_find(struct mtx_pool *pool, void *ptr); >struct mtx *mtx_pool_alloc(struct mtx_pool *pool); >#define mtx_pool_lock(pool, ptr) \ > mtx_lock(mtx_pool_find((pool), (ptr))) >#define mtx_pool_lock_spin(pool, ptr) \ > mtx_lock_spin(mtx_pool_find((pool), (ptr))) >#define mtx_pool_unlock(pool, ptr) \ > mtx_unlock(mtx_pool_find((pool), (ptr))) >#define mtx_pool_unlock_spin(pool, ptr) \ > mtx_unlock_spin(mtx_pool_find((pool), (ptr))) > >/* > * mtxpool_sleep is a general purpose pool of sleep mutexes. > */ >extern struct mtx_pool *mtxpool_sleep; > >#ifndef LOCK_DEBUG >#error LOCK_DEBUG not defined, include <sys/lock.h> before <sys/mutex.h> >#endif ># 334 "/usr/src/sys/sys/mutex.h" >#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE) >#define mtx_lock_flags_(m, opts, file, line) \ > _mtx_lock_flags((m), (opts), (file), (line)) >#define mtx_unlock_flags_(m, opts, file, line) \ > _mtx_unlock_flags((m), (opts), (file), (line)) >#define mtx_lock_spin_flags_(m, opts, file, line) \ > _mtx_lock_spin_flags((m), (opts), (file), (line)) >#define mtx_unlock_spin_flags_(m, opts, file, line) \ > _mtx_unlock_spin_flags((m), (opts), (file), (line)) >#else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */ ># 344 "/usr/src/sys/sys/mutex.h" >#define mtx_lock_flags_(m, opts, file, line) \ > __mtx_lock((m), curthread, (opts), (file), (line)) >#define mtx_unlock_flags_(m, opts, file, line) \ > __mtx_unlock((m), curthread, (opts), (file), (line)) >#define mtx_lock_spin_flags_(m, opts, file, line) \ > __mtx_lock_spin((m), curthread, (opts), (file), (line)) >#define mtx_unlock_spin_flags_(m, opts, file, line) \ > __mtx_unlock_spin((m)) >#endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */ ># 353 "/usr/src/sys/sys/mutex.h" > >#ifdef INVARIANTS >#define mtx_assert_(m, what, file, line) \ > _mtx_assert((m), (what), (file), (line)) > >#define GIANT_REQUIRED mtx_assert_(&Giant, MA_OWNED, __FILE__, __LINE__) > >#else /* INVARIANTS */ ># 361 "/usr/src/sys/sys/mutex.h" >#define mtx_assert_(m, what, file, line) (void)0 >#define GIANT_REQUIRED >#endif /* INVARIANTS */ ># 364 "/usr/src/sys/sys/mutex.h" > >#define mtx_lock_flags(m, opts) \ > mtx_lock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_unlock_flags(m, opts) \ > mtx_unlock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_lock_spin_flags(m, opts) \ > mtx_lock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_unlock_spin_flags(m, opts) \ > mtx_unlock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_trylock_flags(m, opts) \ > mtx_trylock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_assert(m, what) \ > mtx_assert_((m), (what), __FILE__, __LINE__) > >#define mtx_sleep(chan, mtx, pri, wmesg, timo) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) > >#define mtx_initialized(m) lock_initialized(&(m)->lock_object) > >#define mtx_owned(m) (((m)->mtx_lock & ~MTX_FLAGMASK) == (uintptr_t)curthread) > >#define mtx_recursed(m) ((m)->mtx_recurse != 0) > >#define mtx_name(m) ((m)->lock_object.lo_name) > >/* > * Global locks. > */ >extern struct mtx Giant; >extern struct mtx blocked_lock; > >/* > * Giant lock manipulation and clean exit macros. > * Used to replace return with an exit Giant and return. > * > * Note that DROP_GIANT*() needs to be paired with PICKUP_GIANT() > * The #ifndef is to allow lint-like tools to redefine DROP_GIANT. > */ >#ifndef DROP_GIANT >#define DROP_GIANT() \ >do { \ > int _giantcnt = 0; \ > WITNESS_SAVE_DECL(Giant); \ > \ > if (mtx_owned(&Giant)) { \ > WITNESS_SAVE(&Giant.lock_object, Giant); \ > for (_giantcnt = 0; mtx_owned(&Giant) && \ > !SCHEDULER_STOPPED(); _giantcnt++) \ > mtx_unlock(&Giant); \ > } > >#define PICKUP_GIANT() \ > PARTIAL_PICKUP_GIANT(); \ >} while (0) > >#define PARTIAL_PICKUP_GIANT() \ > mtx_assert(&Giant, MA_NOTOWNED); \ > if (_giantcnt > 0) { \ > while (_giantcnt--) \ > mtx_lock(&Giant); \ > WITNESS_RESTORE(&Giant.lock_object, Giant); \ > } >#endif ># 428 "/usr/src/sys/sys/mutex.h" > >struct mtx_args { > void *ma_mtx; > const char *ma_desc; > int ma_opts; >}; > >#define MTX_SYSINIT(name, mtx, desc, opts) \ > static struct mtx_args name##_args = { \ > (mtx), \ > (desc), \ > (opts) \ > }; \ > SYSINIT(name##_mtx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > mtx_sysinit, &name##_args); \ > SYSUNINIT(name##_mtx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > _mtx_destroy, __DEVOLATILE(void *, &(mtx)->mtx_lock)) > >/* > * The INVARIANTS-enabled mtx_assert() functionality. > * > * The constants need to be defined for INVARIANT_SUPPORT infrastructure > * support as _mtx_assert() itself uses them and the latter implies that > * _mtx_assert() must build. > */ >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define MA_OWNED LA_XLOCKED >#define MA_NOTOWNED LA_UNLOCKED >#define MA_RECURSED LA_RECURSED >#define MA_NOTRECURSED LA_NOTRECURSED >#endif ># 459 "/usr/src/sys/sys/mutex.h" > >/* > * Common lock type names. > */ >#define MTX_NETWORK_LOCK "network driver" > >#endif /* _KERNEL */ ># 466 "/usr/src/sys/sys/mutex.h" >#endif /* _SYS_MUTEX_H_ */ ># 467 "/usr/src/sys/sys/mutex.h" ># 50 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/conf.h> >#endif /* expanded by -frewrite-includes */ ># 50 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/conf.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * Copyright (c) 2000 > * Poul-Henning Kamp. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)conf.h 8.5 (Berkeley) 1/9/95 > * $FreeBSD: head/sys/sys/conf.h 277897 2015-01-29 19:55:33Z jhb $ > */ > >#ifndef _SYS_CONF_H_ >#define _SYS_CONF_H_ > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/eventhandler.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/conf.h" ># 1 "/usr/src/sys/sys/eventhandler.h" 1 >/*- > * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/eventhandler.h 277796 2015-01-27 17:33:18Z avg $ > */ > >#ifndef _SYS_EVENTHANDLER_H_ >#define _SYS_EVENTHANDLER_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/eventhandler.h" ># 33 "/usr/src/sys/sys/eventhandler.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ktr.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/sys/sys/eventhandler.h" ># 1 "/usr/src/sys/sys/ktr.h" 1 >/*- > * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ > * $FreeBSD: head/sys/sys/ktr.h 258858 2013-12-02 22:34:47Z attilio $ > */ > >/* > * Wraparound kernel trace buffer support. > */ > >#ifndef _SYS_KTR_H_ >#define _SYS_KTR_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ktr_class.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/ktr.h" ># 40 "/usr/src/sys/sys/ktr.h" > >/* > * Version number for ktr_entry struct. Increment this when you break binary > * compatibility. > */ >#define KTR_VERSION 2 > >#define KTR_PARMS 6 > >#ifndef LOCORE > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 51 "/usr/src/sys/sys/ktr.h" ># 52 "/usr/src/sys/sys/ktr.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_cpuset.h> >#endif /* expanded by -frewrite-includes */ ># 52 "/usr/src/sys/sys/ktr.h" ># 53 "/usr/src/sys/sys/ktr.h" > >struct ktr_entry { > u_int64_t ktr_timestamp; > int ktr_cpu; > int ktr_line; > const char *ktr_file; > const char *ktr_desc; > struct thread *ktr_thread; > u_long ktr_parms[KTR_PARMS]; >}; > >extern cpuset_t ktr_cpumask; >extern int ktr_mask; >extern int ktr_entries; >extern int ktr_verbose; > >extern volatile int ktr_idx; >extern struct ktr_entry *ktr_buf; > >#ifdef KTR > >void ktr_tracepoint(u_int mask, const char *file, int line, > const char *format, u_long arg1, u_long arg2, u_long arg3, > u_long arg4, u_long arg5, u_long arg6); > >#define CTR6(m, format, p1, p2, p3, p4, p5, p6) do { \ > if (KTR_COMPILE & (m)) \ > ktr_tracepoint((m), __FILE__, __LINE__, format, \ > (u_long)(p1), (u_long)(p2), (u_long)(p3), \ > (u_long)(p4), (u_long)(p5), (u_long)(p6)); \ > } while(0) >#define CTR0(m, format) CTR6(m, format, 0, 0, 0, 0, 0, 0) >#define CTR1(m, format, p1) CTR6(m, format, p1, 0, 0, 0, 0, 0) >#define CTR2(m, format, p1, p2) CTR6(m, format, p1, p2, 0, 0, 0, 0) >#define CTR3(m, format, p1, p2, p3) CTR6(m, format, p1, p2, p3, 0, 0, 0) >#define CTR4(m, format, p1, p2, p3, p4) CTR6(m, format, p1, p2, p3, p4, 0, 0) >#define CTR5(m, format, p1, p2, p3, p4, p5) CTR6(m, format, p1, p2, p3, p4, p5, 0) >#else /* KTR */ ># 91 "/usr/src/sys/sys/ktr.h" >#define CTR0(m, d) (void)0 >#define CTR1(m, d, p1) (void)0 >#define CTR2(m, d, p1, p2) (void)0 >#define CTR3(m, d, p1, p2, p3) (void)0 >#define CTR4(m, d, p1, p2, p3, p4) (void)0 >#define CTR5(m, d, p1, p2, p3, p4, p5) (void)0 >#define CTR6(m, d, p1, p2, p3, p4, p5, p6) (void)0 >#endif /* KTR */ ># 99 "/usr/src/sys/sys/ktr.h" > >#define TR0(d) CTR0(KTR_GEN, d) >#define TR1(d, p1) CTR1(KTR_GEN, d, p1) >#define TR2(d, p1, p2) CTR2(KTR_GEN, d, p1, p2) >#define TR3(d, p1, p2, p3) CTR3(KTR_GEN, d, p1, p2, p3) >#define TR4(d, p1, p2, p3, p4) CTR4(KTR_GEN, d, p1, p2, p3, p4) >#define TR5(d, p1, p2, p3, p4, p5) CTR5(KTR_GEN, d, p1, p2, p3, p4, p5) >#define TR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6) > >/* > * The event macros implement KTR graphic plotting facilities provided > * by src/tools/sched/schedgraph.py. Three generic types of events are > * supported: states, counters, and points. > * > * m is the ktr class for ktr_mask. > * ident is the string identifier that owns the event (ie: "thread 10001") > * etype is the type of event to plot (state, counter, point) > * edat is the event specific data (state name, counter value, point name) > * up to four attributes may be supplied as a name, value pair of arguments. > * > * etype and attribute names must be string constants. This minimizes the > * number of ktr slots required by construction the final format strings > * at compile time. Both must also include a colon and format specifier > * (ie. "prio:%d", prio). It is recommended that string arguments be > * contained within escaped quotes if they may contain ',' or ':' characters. > * > * The special attribute (KTR_ATTR_LINKED, ident) creates a reference to another > * id on the graph for easy traversal of related graph elements. > */ > >#define KTR_ATTR_LINKED "linkedto:\"%s\"" >#define KTR_EFMT(egroup, ident, etype) \ > "KTRGRAPH group:\"" egroup "\", id:\"%s\", " etype ", attributes: " > >#define KTR_EVENT0(m, egroup, ident, etype, edat) \ > CTR2(m, KTR_EFMT(egroup, ident, etype) "none", ident, edat) >#define KTR_EVENT1(m, egroup, ident, etype, edat, a0, v0) \ > CTR3(m, KTR_EFMT(egroup, ident, etype) a0, ident, edat, (v0)) >#define KTR_EVENT2(m, egroup, ident, etype, edat, a0, v0, a1, v1) \ > CTR4(m, KTR_EFMT(egroup, ident, etype) a0 ", " a1, \ > ident, edat, (v0), (v1)) >#define KTR_EVENT3(m, egroup, ident, etype, edat, a0, v0, a1, v1, a2, v2)\ > CTR5(m,KTR_EFMT(egroup, ident, etype) a0 ", " a1 ", " a2, \ > ident, edat, (v0), (v1), (v2)) >#define KTR_EVENT4(m, egroup, ident, etype, edat, \ > a0, v0, a1, v1, a2, v2, a3, v3) \ > CTR6(m,KTR_EFMT(egroup, ident, etype) a0 ", " a1 ", " a2 ", " a3,\ > ident, edat, (v0), (v1), (v2), (v3)) > >/* > * State functions graph state changes on an ident. > */ >#define KTR_STATE0(m, egroup, ident, state) \ > KTR_EVENT0(m, egroup, ident, "state:\"%s\"", state) >#define KTR_STATE1(m, egroup, ident, state, a0, v0) \ > KTR_EVENT1(m, egroup, ident, "state:\"%s\"", state, a0, (v0)) >#define KTR_STATE2(m, egroup, ident, state, a0, v0, a1, v1) \ > KTR_EVENT2(m, egroup, ident, "state:\"%s\"", state, a0, (v0), a1, (v1)) >#define KTR_STATE3(m, egroup, ident, state, a0, v0, a1, v1, a2, v2) \ > KTR_EVENT3(m, egroup, ident, "state:\"%s\"", \ > state, a0, (v0), a1, (v1), a2, (v2)) >#define KTR_STATE4(m, egroup, ident, state, a0, v0, a1, v1, a2, v2, a3, v3)\ > KTR_EVENT4(m, egroup, ident, "state:\"%s\"", \ > state, a0, (v0), a1, (v1), a2, (v2), a3, (v3)) > >/* > * Counter functions graph counter values. The counter id > * must not be intermixed with a state id. > */ >#define KTR_COUNTER0(m, egroup, ident, counter) \ > KTR_EVENT0(m, egroup, ident, "counter:%d", counter) >#define KTR_COUNTER1(m, egroup, ident, edat, a0, v0) \ > KTR_EVENT1(m, egroup, ident, "counter:%d", counter, a0, (v0)) >#define KTR_COUNTER2(m, egroup, ident, counter, a0, v0, a1, v1) \ > KTR_EVENT2(m, egroup, ident, "counter:%d", counter, a0, (v0), a1, (v1)) >#define KTR_COUNTER3(m, egroup, ident, counter, a0, v0, a1, v1, a2, v2) \ > KTR_EVENT3(m, egroup, ident, "counter:%d", \ > counter, a0, (v0), a1, (v1), a2, (v2)) >#define KTR_COUNTER4(m, egroup, ident, counter, a0, v0, a1, v1, a2, v2, a3, v3)\ > KTR_EVENT4(m, egroup, ident, "counter:%d", \ > counter, a0, (v0), a1, (v1), a2, (v2), a3, (v3)) > >/* > * Point functions plot points of interest on counter or state graphs. > */ >#define KTR_POINT0(m, egroup, ident, point) \ > KTR_EVENT0(m, egroup, ident, "point:\"%s\"", point) >#define KTR_POINT1(m, egroup, ident, point, a0, v0) \ > KTR_EVENT1(m, egroup, ident, "point:\"%s\"", point, a0, (v0)) >#define KTR_POINT2(m, egroup, ident, point, a0, v0, a1, v1) \ > KTR_EVENT2(m, egroup, ident, "point:\"%s\"", point, a0, (v0), a1, (v1)) >#define KTR_POINT3(m, egroup, ident, point, a0, v0, a1, v1, a2, v2) \ > KTR_EVENT3(m, egroup, ident, "point:\"%s\"", point, \ > a0, (v0), a1, (v1), a2, (v2)) >#define KTR_POINT4(m, egroup, ident, point, a0, v0, a1, v1, a2, v2, a3, v3)\ > KTR_EVENT4(m, egroup, ident, "point:\"%s\"", \ > point, a0, (v0), a1, (v1), a2, (v2), a3, (v3)) > >/* > * Start functions denote the start of a region of code or operation > * and should be paired with stop functions for timing of nested > * sequences. > * > * Specifying extra attributes with the name "key" will result in > * multi-part keys. For example a block device and offset pair > * might be used to describe a buf undergoing I/O. > */ >#define KTR_START0(m, egroup, ident, key) \ > KTR_EVENT0(m, egroup, ident, "start:0x%jX", (uintmax_t)key) >#define KTR_START1(m, egroup, ident, key, a0, v0) \ > KTR_EVENT1(m, egroup, ident, "start:0x%jX", (uintmax_t)key, a0, (v0)) >#define KTR_START2(m, egroup, ident, key, a0, v0, a1, v1) \ > KTR_EVENT2(m, egroup, ident, "start:0x%jX", (uintmax_t)key, \ > a0, (v0), a1, (v1)) >#define KTR_START3(m, egroup, ident, key, a0, v0, a1, v1, a2, v2)\ > KTR_EVENT3(m, egroup, ident, "start:0x%jX", (uintmax_t)key, \ > a0, (v0), a1, (v1), a2, (v2)) >#define KTR_START4(m, egroup, ident, key, \ > a0, v0, a1, v1, a2, v2, a3, v3) \ > KTR_EVENT4(m, egroup, ident, "start:0x%jX", (uintmax_t)key, \ > a0, (v0), a1, (v1), a2, (v2), a3, (v3)) > >/* > * Stop functions denote the end of a region of code or operation > * and should be paired with start functions for timing of nested > * sequences. > */ >#define KTR_STOP0(m, egroup, ident, key) \ > KTR_EVENT0(m, egroup, ident, "stop:0x%jX", (uintmax_t)key) >#define KTR_STOP1(m, egroup, ident, key, a0, v0) \ > KTR_EVENT1(m, egroup, ident, "stop:0x%jX", (uintmax_t)key, a0, (v0)) >#define KTR_STOP2(m, egroup, ident, key, a0, v0, a1, v1) \ > KTR_EVENT2(m, egroup, ident, "stop:0x%jX", (uintmax_t)key, \ > a0, (v0), a1, (v1)) >#define KTR_STOP3(m, egroup, ident, key, a0, v0, a1, v1, a2, v2)\ > KTR_EVENT3(m, egroup, ident, "stop:0x%jX", (uintmax_t)key, \ > a0, (v0), a1, (v1), a2, (v2)) >#define KTR_STOP4(m, egroup, ident, \ > key, a0, v0, a1, v1, a2, v2, a3, v3) \ > KTR_EVENT4(m, egroup, ident, "stop:0x%jX", (uintmax_t)key, \ > a0, (v0), a1, (v1), a2, (v2), a3, (v3)) > >/* > * Trace initialization events, similar to CTR with KTR_INIT, but > * completely ifdef'ed out if KTR_INIT isn't in KTR_COMPILE (to > * save string space, the compiler doesn't optimize out strings > * for the conditional ones above). > */ >#if (KTR_COMPILE & KTR_INIT) != 0 >#define ITR0(d) CTR0(KTR_INIT, d) >#define ITR1(d, p1) CTR1(KTR_INIT, d, p1) >#define ITR2(d, p1, p2) CTR2(KTR_INIT, d, p1, p2) >#define ITR3(d, p1, p2, p3) CTR3(KTR_INIT, d, p1, p2, p3) >#define ITR4(d, p1, p2, p3, p4) CTR4(KTR_INIT, d, p1, p2, p3, p4) >#define ITR5(d, p1, p2, p3, p4, p5) CTR5(KTR_INIT, d, p1, p2, p3, p4, p5) >#define ITR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_INIT, d, p1, p2, p3, p4, p5, p6) >#else ># 256 "/usr/src/sys/sys/ktr.h" >#define ITR0(d) >#define ITR1(d, p1) >#define ITR2(d, p1, p2) >#define ITR3(d, p1, p2, p3) >#define ITR4(d, p1, p2, p3, p4) >#define ITR5(d, p1, p2, p3, p4, p5) >#define ITR6(d, p1, p2, p3, p4, p5, p6) >#endif ># 264 "/usr/src/sys/sys/ktr.h" > >#endif /* !LOCORE */ ># 266 "/usr/src/sys/sys/ktr.h" > >#endif /* !_SYS_KTR_H_ */ ># 268 "/usr/src/sys/sys/ktr.h" ># 34 "/usr/src/sys/sys/eventhandler.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/sys/sys/eventhandler.h" ># 35 "/usr/src/sys/sys/eventhandler.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/eventhandler.h" ># 36 "/usr/src/sys/sys/eventhandler.h" > >struct eventhandler_entry { > TAILQ_ENTRY(eventhandler_entry) ee_link; > int ee_priority; >#define EHE_DEAD_PRIORITY (-1) > void *ee_arg; >}; > >#ifdef VIMAGE >struct eventhandler_entry_vimage { > void (* func)(void); /* Original function registered. */ > void *ee_arg; /* Original argument registered. */ > void *sparep[2]; >}; >#endif ># 51 "/usr/src/sys/sys/eventhandler.h" > >struct eventhandler_list { > char *el_name; > int el_flags; >#define EHL_INITTED (1<<0) > u_int el_runcount; > struct mtx el_lock; > TAILQ_ENTRY(eventhandler_list) el_link; > TAILQ_HEAD(,eventhandler_entry) el_entries; >}; > >typedef struct eventhandler_entry *eventhandler_tag; > >#define EHL_LOCK(p) mtx_lock(&(p)->el_lock) >#define EHL_UNLOCK(p) mtx_unlock(&(p)->el_lock) >#define EHL_LOCK_ASSERT(p, x) mtx_assert(&(p)->el_lock, x) > >/* > * Macro to invoke the handlers for a given event. > */ >#define _EVENTHANDLER_INVOKE(name, list, ...) do { \ > struct eventhandler_entry *_ep; \ > struct eventhandler_entry_ ## name *_t; \ > \ > KASSERT((list)->el_flags & EHL_INITTED, \ > ("eventhandler_invoke: running non-inited list")); \ > EHL_LOCK_ASSERT((list), MA_OWNED); \ > (list)->el_runcount++; \ > KASSERT((list)->el_runcount > 0, \ > ("eventhandler_invoke: runcount overflow")); \ > CTR0(KTR_EVH, "eventhandler_invoke(\"" __STRING(name) "\")"); \ > TAILQ_FOREACH(_ep, &((list)->el_entries), ee_link) { \ > if (_ep->ee_priority != EHE_DEAD_PRIORITY) { \ > EHL_UNLOCK((list)); \ > _t = (struct eventhandler_entry_ ## name *)_ep; \ > CTR1(KTR_EVH, "eventhandler_invoke: executing %p", \ > (void *)_t->eh_func); \ > _t->eh_func(_ep->ee_arg , ## __VA_ARGS__); \ > EHL_LOCK((list)); \ > } \ > } \ > KASSERT((list)->el_runcount > 0, \ > ("eventhandler_invoke: runcount underflow")); \ > (list)->el_runcount--; \ > if ((list)->el_runcount == 0) \ > eventhandler_prune_list(list); \ > EHL_UNLOCK((list)); \ >} while (0) > >/* > * Slow handlers are entirely dynamic; lists are created > * when entries are added to them, and thus have no concept of "owner", > * > * Slow handlers need to be declared, but do not need to be defined. The > * declaration must be in scope wherever the handler is to be invoked. > */ >#define EVENTHANDLER_DECLARE(name, type) \ >struct eventhandler_entry_ ## name \ >{ \ > struct eventhandler_entry ee; \ > type eh_func; \ >}; \ >struct __hack > >#define EVENTHANDLER_DEFINE(name, func, arg, priority) \ > static eventhandler_tag name ## _tag; \ > static void name ## _evh_init(void *ctx) \ > { \ > name ## _tag = EVENTHANDLER_REGISTER(name, func, ctx, \ > priority); \ > } \ > SYSINIT(name ## _evh_init, SI_SUB_CONFIGURE, SI_ORDER_ANY, \ > name ## _evh_init, arg); \ > struct __hack > >#define EVENTHANDLER_INVOKE(name, ...) \ >do { \ > struct eventhandler_list *_el; \ > \ > if ((_el = eventhandler_find_list(#name)) != NULL) \ > _EVENTHANDLER_INVOKE(name, _el , ## __VA_ARGS__); \ >} while (0) > >#define EVENTHANDLER_REGISTER(name, func, arg, priority) \ > eventhandler_register(NULL, #name, func, arg, priority) > >#define EVENTHANDLER_DEREGISTER(name, tag) \ >do { \ > struct eventhandler_list *_el; \ > \ > if ((_el = eventhandler_find_list(#name)) != NULL) \ > eventhandler_deregister(_el, tag); \ >} while(0) > > >eventhandler_tag eventhandler_register(struct eventhandler_list *list, > const char *name, void *func, void *arg, int priority); >void eventhandler_deregister(struct eventhandler_list *list, > eventhandler_tag tag); >struct eventhandler_list *eventhandler_find_list(const char *name); >void eventhandler_prune_list(struct eventhandler_list *list); > >#ifdef VIMAGE >typedef void (*vimage_iterator_func_t)(void *, ...); > >eventhandler_tag vimage_eventhandler_register(struct eventhandler_list *list, > const char *name, void *func, void *arg, int priority, > vimage_iterator_func_t); >#endif ># 160 "/usr/src/sys/sys/eventhandler.h" > >/* > * Standard system event queues. > */ > >/* Generic priority levels */ >#define EVENTHANDLER_PRI_FIRST 0 >#define EVENTHANDLER_PRI_ANY 10000 >#define EVENTHANDLER_PRI_LAST 20000 > >/* Shutdown events */ >typedef void (*shutdown_fn)(void *, int); > >#define SHUTDOWN_PRI_FIRST EVENTHANDLER_PRI_FIRST >#define SHUTDOWN_PRI_DEFAULT EVENTHANDLER_PRI_ANY >#define SHUTDOWN_PRI_LAST EVENTHANDLER_PRI_LAST > >EVENTHANDLER_DECLARE(shutdown_pre_sync, shutdown_fn); /* before fs sync */ >EVENTHANDLER_DECLARE(shutdown_post_sync, shutdown_fn); /* after fs sync */ >EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn); > >/* Power state change events */ >typedef void (*power_change_fn)(void *); >EVENTHANDLER_DECLARE(power_resume, power_change_fn); >EVENTHANDLER_DECLARE(power_suspend, power_change_fn); >EVENTHANDLER_DECLARE(power_suspend_early, power_change_fn); > >/* Low memory event */ >typedef void (*vm_lowmem_handler_t)(void *, int); >#define LOWMEM_PRI_DEFAULT EVENTHANDLER_PRI_FIRST >EVENTHANDLER_DECLARE(vm_lowmem, vm_lowmem_handler_t); > >/* Root mounted event */ >typedef void (*mountroot_handler_t)(void *); >EVENTHANDLER_DECLARE(mountroot, mountroot_handler_t); > >/* File system mount events */ >struct mount; >struct vnode; >struct thread; >typedef void (*vfs_mounted_notify_fn)(void *, struct mount *, struct vnode *, > struct thread *); >typedef void (*vfs_unmounted_notify_fn)(void *, struct mount *, > struct thread *); >EVENTHANDLER_DECLARE(vfs_mounted, vfs_mounted_notify_fn); >EVENTHANDLER_DECLARE(vfs_unmounted, vfs_unmounted_notify_fn); > >/* > * Process events > * process_fork and exit handlers are called without Giant. > * exec handlers are called with Giant, but that is by accident. > */ >struct proc; >struct image_params; > >typedef void (*exitlist_fn)(void *, struct proc *); >typedef void (*forklist_fn)(void *, struct proc *, struct proc *, int); >typedef void (*execlist_fn)(void *, struct proc *, struct image_params *); >typedef void (*proc_ctor_fn)(void *, struct proc *); >typedef void (*proc_dtor_fn)(void *, struct proc *); >typedef void (*proc_init_fn)(void *, struct proc *); >typedef void (*proc_fini_fn)(void *, struct proc *); >EVENTHANDLER_DECLARE(process_ctor, proc_ctor_fn); >EVENTHANDLER_DECLARE(process_dtor, proc_dtor_fn); >EVENTHANDLER_DECLARE(process_init, proc_init_fn); >EVENTHANDLER_DECLARE(process_fini, proc_fini_fn); >EVENTHANDLER_DECLARE(process_exit, exitlist_fn); >EVENTHANDLER_DECLARE(process_fork, forklist_fn); >EVENTHANDLER_DECLARE(process_exec, execlist_fn); > >/* > * application dump event > */ >typedef void (*app_coredump_start_fn)(void *, struct thread *, char *name); >typedef void (*app_coredump_progress_fn)(void *, struct thread *td, int byte_count); >typedef void (*app_coredump_finish_fn)(void *, struct thread *td); >typedef void (*app_coredump_error_fn)(void *, struct thread *td, char *msg, ...); > >EVENTHANDLER_DECLARE(app_coredump_start, app_coredump_start_fn); >EVENTHANDLER_DECLARE(app_coredump_progress, app_coredump_progress_fn); >EVENTHANDLER_DECLARE(app_coredump_finish, app_coredump_finish_fn); >EVENTHANDLER_DECLARE(app_coredump_error, app_coredump_error_fn); > >typedef void (*thread_ctor_fn)(void *, struct thread *); >typedef void (*thread_dtor_fn)(void *, struct thread *); >typedef void (*thread_fini_fn)(void *, struct thread *); >typedef void (*thread_init_fn)(void *, struct thread *); >EVENTHANDLER_DECLARE(thread_ctor, thread_ctor_fn); >EVENTHANDLER_DECLARE(thread_dtor, thread_dtor_fn); >EVENTHANDLER_DECLARE(thread_init, thread_init_fn); >EVENTHANDLER_DECLARE(thread_fini, thread_fini_fn); > >typedef void (*uma_zone_chfn)(void *); >EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn); >EVENTHANDLER_DECLARE(nmbufs_change, uma_zone_chfn); >EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn); > >/* Kernel linker file load and unload events */ >struct linker_file; >typedef void (*kld_load_fn)(void *, struct linker_file *); >typedef void (*kld_unload_fn)(void *, const char *, caddr_t, size_t); >typedef void (*kld_unload_try_fn)(void *, struct linker_file *, int *); >EVENTHANDLER_DECLARE(kld_load, kld_load_fn); >EVENTHANDLER_DECLARE(kld_unload, kld_unload_fn); >EVENTHANDLER_DECLARE(kld_unload_try, kld_unload_try_fn); > >/* Generic graphics framebuffer interface */ >struct fb_info; >typedef void (*register_framebuffer_fn)(void *, struct fb_info *); >typedef void (*unregister_framebuffer_fn)(void *, struct fb_info *); >EVENTHANDLER_DECLARE(register_framebuffer, register_framebuffer_fn); >EVENTHANDLER_DECLARE(unregister_framebuffer, unregister_framebuffer_fn); > >#endif /* _SYS_EVENTHANDLER_H_ */ ># 274 "/usr/src/sys/sys/eventhandler.h" ># 45 "/usr/src/sys/sys/conf.h" 2 >#else ># 46 "/usr/src/sys/sys/conf.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/sys/conf.h" ># 47 "/usr/src/sys/sys/conf.h" >#endif ># 48 "/usr/src/sys/sys/conf.h" > >struct snapdata; >struct devfs_dirent; >struct cdevsw; >struct file; > >struct cdev { > void *si_spare0; > u_int si_flags; >#define SI_ETERNAL 0x0001 /* never destroyed */ >#define SI_ALIAS 0x0002 /* carrier of alias name */ >#define SI_NAMED 0x0004 /* make_dev{_alias} has been called */ >#define SI_CHEAPCLONE 0x0008 /* can be removed_dev'ed when vnode reclaims */ >#define SI_CHILD 0x0010 /* child of another struct cdev **/ >#define SI_DUMPDEV 0x0080 /* is kernel dumpdev */ >#define SI_CLONELIST 0x0200 /* on a clone list */ >#define SI_UNMAPPED 0x0400 /* can handle unmapped I/O */ >#define SI_NOSPLIT 0x0800 /* I/O should not be split up */ > struct timespec si_atime; > struct timespec si_ctime; > struct timespec si_mtime; > uid_t si_uid; > gid_t si_gid; > mode_t si_mode; > struct ucred *si_cred; /* cached clone-time credential */ > int si_drv0; > int si_refcount; > LIST_ENTRY(cdev) si_list; > LIST_ENTRY(cdev) si_clone; > LIST_HEAD(, cdev) si_children; > LIST_ENTRY(cdev) si_siblings; > struct cdev *si_parent; > struct mount *si_mountpt; > void *si_drv1, *si_drv2; > struct cdevsw *si_devsw; > int si_iosize_max; /* maximum I/O size (for physio &al) */ > u_long si_usecount; > u_long si_threadcount; > union { > struct snapdata *__sid_snapdata; > } __si_u; > char si_name[SPECNAMELEN + 1]; >}; > >#define si_snapdata __si_u.__sid_snapdata > >#ifdef _KERNEL > >/* > * Definitions of device driver entry switches > */ > >struct bio; >struct buf; >struct thread; >struct uio; >struct knote; >struct clonedevs; >struct vm_object; >struct vnode; > >typedef int d_open_t(struct cdev *dev, int oflags, int devtype, struct thread *td); >typedef int d_fdopen_t(struct cdev *dev, int oflags, struct thread *td, struct file *fp); >typedef int d_close_t(struct cdev *dev, int fflag, int devtype, struct thread *td); >typedef void d_strategy_t(struct bio *bp); >typedef int d_ioctl_t(struct cdev *dev, u_long cmd, caddr_t data, > int fflag, struct thread *td); > >typedef int d_read_t(struct cdev *dev, struct uio *uio, int ioflag); >typedef int d_write_t(struct cdev *dev, struct uio *uio, int ioflag); >typedef int d_poll_t(struct cdev *dev, int events, struct thread *td); >typedef int d_kqfilter_t(struct cdev *dev, struct knote *kn); >typedef int d_mmap_t(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, > int nprot, vm_memattr_t *memattr); >typedef int d_mmap_single_t(struct cdev *cdev, vm_ooffset_t *offset, > vm_size_t size, struct vm_object **object, int nprot); >typedef void d_purge_t(struct cdev *dev); > >typedef int dumper_t( > void *_priv, /* Private to the driver. */ > void *_virtual, /* Virtual (mapped) address. */ > vm_offset_t _physical, /* Physical address of virtual. */ > off_t _offset, /* Byte-offset to write at. */ > size_t _length); /* Number of bytes to dump. */ > >#endif /* _KERNEL */ ># 134 "/usr/src/sys/sys/conf.h" > >/* > * Types for d_flags. > */ >#define D_TAPE 0x0001 >#define D_DISK 0x0002 >#define D_TTY 0x0004 >#define D_MEM 0x0008 > >#ifdef _KERNEL > >#define D_TYPEMASK 0xffff > >/* > * Flags for d_flags which the drivers can set. > */ >#define D_TRACKCLOSE 0x00080000 /* track all closes */ >#define D_MMAP_ANON 0x00100000 /* special treatment in vm_mmap.c */ >#define D_NEEDGIANT 0x00400000 /* driver want Giant */ >#define D_NEEDMINOR 0x00800000 /* driver uses clone_create() */ > >/* > * Version numbers. > */ >#define D_VERSION_00 0x20011966 >#define D_VERSION_01 0x17032005 /* Add d_uid,gid,mode & kind */ >#define D_VERSION_02 0x28042009 /* Add d_mmap_single */ >#define D_VERSION_03 0x17122009 /* d_mmap takes memattr,vm_ooffset_t */ >#define D_VERSION D_VERSION_03 > >/* > * Flags used for internal housekeeping > */ >#define D_INIT 0x80000000 /* cdevsw initialized */ > >/* > * Character device switch table > */ >struct cdevsw { > int d_version; > u_int d_flags; > const char *d_name; > d_open_t *d_open; > d_fdopen_t *d_fdopen; > d_close_t *d_close; > d_read_t *d_read; > d_write_t *d_write; > d_ioctl_t *d_ioctl; > d_poll_t *d_poll; > d_mmap_t *d_mmap; > d_strategy_t *d_strategy; > dumper_t *d_dump; > d_kqfilter_t *d_kqfilter; > d_purge_t *d_purge; > d_mmap_single_t *d_mmap_single; > > int32_t d_spare0[3]; > void *d_spare1[3]; > > /* These fields should not be messed with by drivers */ > LIST_HEAD(, cdev) d_devs; > int d_spare2; > union { > struct cdevsw *gianttrick; > SLIST_ENTRY(cdevsw) postfree_list; > } __d_giant; >}; >#define d_gianttrick __d_giant.gianttrick >#define d_postfree_list __d_giant.postfree_list > >struct module; > >struct devsw_module_data { > int (*chainevh)(struct module *, int, void *); /* next handler */ > void *chainarg; /* arg for next event handler */ > /* Do not initialize fields hereafter */ >}; > >#define DEV_MODULE_ORDERED(name, evh, arg, ord) \ >static moduledata_t name##_mod = { \ > #name, \ > evh, \ > arg \ >}; \ >DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, ord) > >#define DEV_MODULE(name, evh, arg) \ > DEV_MODULE_ORDERED(name, evh, arg, SI_ORDER_MIDDLE) > >void clone_setup(struct clonedevs **cdp); >void clone_cleanup(struct clonedevs **); >#define CLONE_UNITMASK 0xfffff >#define CLONE_FLAG0 (CLONE_UNITMASK + 1) >int clone_create(struct clonedevs **, struct cdevsw *, int *unit, struct cdev **dev, int extra); > >int count_dev(struct cdev *_dev); >void delist_dev(struct cdev *_dev); >void destroy_dev(struct cdev *_dev); >int destroy_dev_sched(struct cdev *dev); >int destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg); >void destroy_dev_drain(struct cdevsw *csw); >void drain_dev_clone_events(void); >struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref); >struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref); >void dev_relthread(struct cdev *_dev, int _ref); >void dev_depends(struct cdev *_pdev, struct cdev *_cdev); >void dev_ref(struct cdev *dev); >void dev_refl(struct cdev *dev); >void dev_rel(struct cdev *dev); >void dev_strategy(struct cdev *dev, struct buf *bp); >void dev_strategy_csw(struct cdev *dev, struct cdevsw *csw, struct buf *bp); >struct cdev *make_dev(struct cdevsw *_devsw, int _unit, uid_t _uid, gid_t _gid, > int _perms, const char *_fmt, ...) __printflike(6, 7); >struct cdev *make_dev_cred(struct cdevsw *_devsw, int _unit, > struct ucred *_cr, uid_t _uid, gid_t _gid, int _perms, > const char *_fmt, ...) __printflike(7, 8); >#define MAKEDEV_REF 0x01 >#define MAKEDEV_WHTOUT 0x02 >#define MAKEDEV_NOWAIT 0x04 >#define MAKEDEV_WAITOK 0x08 >#define MAKEDEV_ETERNAL 0x10 >#define MAKEDEV_CHECKNAME 0x20 >struct cdev *make_dev_credf(int _flags, > struct cdevsw *_devsw, int _unit, > struct ucred *_cr, uid_t _uid, gid_t _gid, int _mode, > const char *_fmt, ...) __printflike(8, 9); >int make_dev_p(int _flags, struct cdev **_cdev, struct cdevsw *_devsw, > struct ucred *_cr, uid_t _uid, gid_t _gid, int _mode, > const char *_fmt, ...) __printflike(8, 9); >struct cdev *make_dev_alias(struct cdev *_pdev, const char *_fmt, ...) > __printflike(2, 3); >int make_dev_alias_p(int _flags, struct cdev **_cdev, struct cdev *_pdev, > const char *_fmt, ...) __printflike(4, 5); >int make_dev_physpath_alias(int _flags, struct cdev **_cdev, > struct cdev *_pdev, struct cdev *_old_alias, > const char *_physpath); >void dev_lock(void); >void dev_unlock(void); >void setconf(void); > >#ifdef KLD_MODULE >#define MAKEDEV_ETERNAL_KLD 0 >#else ># 277 "/usr/src/sys/sys/conf.h" >#define MAKEDEV_ETERNAL_KLD MAKEDEV_ETERNAL >#endif ># 279 "/usr/src/sys/sys/conf.h" > >#define dev2unit(d) ((d)->si_drv0) > >typedef void (*cdevpriv_dtr_t)(void *data); >int devfs_get_cdevpriv(void **datap); >int devfs_set_cdevpriv(void *priv, cdevpriv_dtr_t dtr); >void devfs_clear_cdevpriv(void); >void devfs_fpdrop(struct file *fp); /* XXX This is not public KPI */ > >ino_t devfs_alloc_cdp_inode(void); >void devfs_free_cdp_inode(ino_t ino); > >#define UID_ROOT 0 >#define UID_BIN 3 >#define UID_UUCP 66 >#define UID_NOBODY 65534 > >#define GID_WHEEL 0 >#define GID_KMEM 2 >#define GID_TTY 4 >#define GID_OPERATOR 5 >#define GID_BIN 7 >#define GID_GAMES 13 >#define GID_DIALER 68 >#define GID_NOBODY 65534 > >typedef void (*dev_clone_fn)(void *arg, struct ucred *cred, char *name, > int namelen, struct cdev **result); > >int dev_stdclone(char *_name, char **_namep, const char *_stem, int *_unit); >EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); > >/* Stuff relating to kernel-dump */ > >struct dumperinfo { > dumper_t *dumper; /* Dumping function. */ > void *priv; /* Private parts. */ > u_int blocksize; /* Size of block in bytes. */ > u_int maxiosize; /* Max size allowed for an individual I/O */ > off_t mediaoffset; /* Initial offset in bytes. */ > off_t mediasize; /* Space available in bytes. */ >}; > >int set_dumper(struct dumperinfo *, const char *_devname, struct thread *td); >int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); >int doadump(boolean_t); >extern int dumping; /* system is dumping */ > >#endif /* _KERNEL */ ># 328 "/usr/src/sys/sys/conf.h" > >#endif /* !_SYS_CONF_H_ */ ># 330 "/usr/src/sys/sys/conf.h" ># 51 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cons.h> >#endif /* expanded by -frewrite-includes */ ># 51 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/cons.h" 1 >/*- > * Copyright (c) 1988 University of Utah. > * Copyright (c) 1991 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * the Systems Programming Group of the University of Utah Computer > * Science Department. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)cons.h 7.2 (Berkeley) 5/9/91 > * $FreeBSD: head/sys/sys/cons.h 268158 2014-07-02 13:24:21Z emaste $ > */ > >#ifndef _MACHINE_CONS_H_ >#define _MACHINE_CONS_H_ > >struct consdev; >struct tty; > >typedef void cn_probe_t(struct consdev *); >typedef void cn_init_t(struct consdev *); >typedef void cn_term_t(struct consdev *); >typedef void cn_grab_t(struct consdev *); >typedef void cn_ungrab_t(struct consdev *); >typedef int cn_getc_t(struct consdev *); >typedef void cn_putc_t(struct consdev *, int); > >struct consdev_ops { > cn_probe_t *cn_probe; > /* probe hardware and fill in consdev info */ > cn_init_t *cn_init; > /* turn on as console */ > cn_term_t *cn_term; > /* turn off as console */ > cn_getc_t *cn_getc; > /* kernel getchar interface */ > cn_putc_t *cn_putc; > /* kernel putchar interface */ > cn_grab_t *cn_grab; > /* grab console for exclusive kernel use */ > cn_ungrab_t *cn_ungrab; > /* ungrab console */ >}; > >struct consdev { > const struct consdev_ops *cn_ops; > /* console device operations. */ > short cn_pri; /* pecking order; the higher the better */ > void *cn_arg; /* drivers method argument */ > int cn_flags; /* capabilities of this console */ > char cn_name[SPECNAMELEN + 1]; /* console (device) name */ >}; > >/* values for cn_pri - reflect our policy for console selection */ >#define CN_DEAD 0 /* device doesn't exist */ >#define CN_LOW 1 /* device is a last restort only */ >#define CN_NORMAL 2 /* device exists but is nothing special */ >#define CN_INTERNAL 3 /* "internal" bit-mapped display */ >#define CN_REMOTE 4 /* serial interface with remote bit set */ > >/* Values for cn_flags. */ >#define CN_FLAG_NODEBUG 0x00000001 /* Not supported with debugger. */ >#define CN_FLAG_NOAVAIL 0x00000002 /* Temporarily not available. */ > >/* Visibility of characters in cngets() */ >#define GETS_NOECHO 0 /* Disable echoing of characters. */ >#define GETS_ECHO 1 /* Enable echoing of characters. */ >#define GETS_ECHOPASS 2 /* Print a * for every character. */ > >#ifdef _KERNEL > >extern struct msgbuf consmsgbuf; /* Message buffer for constty. */ >extern struct tty *constty; /* Temporary virtual console. */ > >#define CONSOLE_DEVICE(name, ops, arg) \ > static struct consdev name = { \ > .cn_ops = &ops, \ > .cn_arg = (arg), \ > }; \ > DATA_SET(cons_set, name) > >#define CONSOLE_DRIVER(name) \ > static const struct consdev_ops name##_consdev_ops = { \ > .cn_probe = name##_cnprobe, \ > .cn_init = name##_cninit, \ > .cn_term = name##_cnterm, \ > .cn_getc = name##_cngetc, \ > .cn_putc = name##_cnputc, \ > .cn_grab = name##_cngrab, \ > .cn_ungrab = name##_cnungrab, \ > }; \ > CONSOLE_DEVICE(name##_consdev, name##_consdev_ops, NULL) > >/* Other kernel entry points. */ >void cninit(void); >void cninit_finish(void); >int cnadd(struct consdev *); >void cnavailable(struct consdev *, int); >void cnremove(struct consdev *); >void cnselect(struct consdev *); >void cngrab(void); >void cnungrab(void); >int cncheckc(void); >int cngetc(void); >void cngets(char *, size_t, int); >void cnputc(int); >void cnputs(char *); >int cnunavailable(void); >void constty_set(struct tty *tp); >void constty_clear(void); > >/* sc(4) / vt(4) coexistence shim */ >#define VTY_SC 0x01 >#define VTY_VT 0x02 >int vty_enabled(unsigned int); >void vty_set_preferred(unsigned int); > >#endif /* _KERNEL */ ># 143 "/usr/src/sys/sys/cons.h" > >#endif /* !_MACHINE_CONS_H_ */ ># 145 "/usr/src/sys/sys/cons.h" ># 52 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/fcntl.h> >#endif /* expanded by -frewrite-includes */ ># 52 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/fcntl.h" 1 >/*- > * Copyright (c) 1983, 1990, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 > * $FreeBSD: head/sys/sys/fcntl.h 264628 2014-04-17 21:29:22Z jilles $ > */ > >#ifndef _SYS_FCNTL_H_ >#define _SYS_FCNTL_H_ > >/* > * This file includes the definitions for open and fcntl > * described by POSIX for <fcntl.h>; it also includes > * related kernel definitions. > */ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/sys/sys/fcntl.h" ># 48 "/usr/src/sys/sys/fcntl.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/sys/sys/fcntl.h" ># 49 "/usr/src/sys/sys/fcntl.h" > >#ifndef _MODE_T_DECLARED >typedef __mode_t mode_t; >#define _MODE_T_DECLARED >#endif ># 54 "/usr/src/sys/sys/fcntl.h" > >#ifndef _OFF_T_DECLARED >typedef __off_t off_t; >#define _OFF_T_DECLARED >#endif ># 59 "/usr/src/sys/sys/fcntl.h" > >#ifndef _PID_T_DECLARED >typedef __pid_t pid_t; >#define _PID_T_DECLARED >#endif ># 64 "/usr/src/sys/sys/fcntl.h" > >/* > * File status flags: these are used by open(2), fcntl(2). > * They are also used (indirectly) in the kernel file structure f_flags, > * which is a superset of the open/fcntl flags. Open flags and f_flags > * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). > * Open/fcntl flags begin with O_; kernel-internal flags begin with F. > */ >/* open-only flags */ >#define O_RDONLY 0x0000 /* open for reading only */ >#define O_WRONLY 0x0001 /* open for writing only */ >#define O_RDWR 0x0002 /* open for reading and writing */ >#define O_ACCMODE 0x0003 /* mask for above modes */ > >/* > * Kernel encoding of open mode; separate read and write bits that are > * independently testable: 1 greater than the above. > * > * XXX > * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH, > * which was documented to use FREAD/FWRITE, continues to work. > */ >#if __BSD_VISIBLE >#define FREAD 0x0001 >#define FWRITE 0x0002 >#endif ># 90 "/usr/src/sys/sys/fcntl.h" >#define O_NONBLOCK 0x0004 /* no delay */ >#define O_APPEND 0x0008 /* set append mode */ >#if __BSD_VISIBLE >#define O_SHLOCK 0x0010 /* open with shared file lock */ >#define O_EXLOCK 0x0020 /* open with exclusive file lock */ >#define O_ASYNC 0x0040 /* signal pgrp when data ready */ >#define O_FSYNC 0x0080 /* synchronous writes */ >#endif ># 98 "/usr/src/sys/sys/fcntl.h" >#define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ >#if __POSIX_VISIBLE >= 200809 >#define O_NOFOLLOW 0x0100 /* don't follow symlinks */ >#endif ># 102 "/usr/src/sys/sys/fcntl.h" >#define O_CREAT 0x0200 /* create if nonexistent */ >#define O_TRUNC 0x0400 /* truncate to zero length */ >#define O_EXCL 0x0800 /* error if already exists */ >#ifdef _KERNEL >#define FHASLOCK 0x4000 /* descriptor holds advisory lock */ >#endif ># 108 "/usr/src/sys/sys/fcntl.h" > >/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */ >#define O_NOCTTY 0x8000 /* don't assign controlling terminal */ > >#if __BSD_VISIBLE >/* Attempt to bypass buffer cache */ >#define O_DIRECT 0x00010000 >#endif ># 116 "/usr/src/sys/sys/fcntl.h" > >#if __POSIX_VISIBLE >= 200809 >#define O_DIRECTORY 0x00020000 /* Fail if not directory */ >#define O_EXEC 0x00040000 /* Open for execute only */ >#endif ># 121 "/usr/src/sys/sys/fcntl.h" >#ifdef _KERNEL >#define FEXEC O_EXEC >#endif ># 124 "/usr/src/sys/sys/fcntl.h" > >#if __POSIX_VISIBLE >= 200809 >/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ >#define O_TTY_INIT 0x00080000 /* Restore default termios attributes */ > >#define O_CLOEXEC 0x00100000 >#endif ># 131 "/usr/src/sys/sys/fcntl.h" > >/* > * XXX missing O_DSYNC, O_RSYNC. > */ > >#ifdef _KERNEL >/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ >#define FFLAGS(oflags) ((oflags) & O_EXEC ? (oflags) : (oflags) + 1) >#define OFLAGS(fflags) ((fflags) & O_EXEC ? (fflags) : (fflags) - 1) > >/* bits to save after open */ >#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT|FEXEC) >/* bits settable by fcntl(F_SETFL, ...) */ >#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FRDAHEAD|O_DIRECT) > >#if defined(COMPAT_FREEBSD7) || defined(COMPAT_FREEBSD6) || \ > defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) >/* > * Set by shm_open(3) in older libc's to get automatic MAP_ASYNC > * behavior for POSIX shared memory objects (which are otherwise > * implemented as plain files). > */ >#define FPOSIXSHM O_NOFOLLOW >#undef FCNTLFLAGS >#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|FRDAHEAD| \ > O_DIRECT) >#endif ># 158 "/usr/src/sys/sys/fcntl.h" >#endif ># 159 "/usr/src/sys/sys/fcntl.h" > >/* > * The O_* flags used to have only F* names, which were used in the kernel > * and by fcntl. We retain the F* names for the kernel f_flag field > * and for backward compatibility for fcntl. These flags are deprecated. > */ >#if __BSD_VISIBLE >#define FAPPEND O_APPEND /* kernel/compat */ >#define FASYNC O_ASYNC /* kernel/compat */ >#define FFSYNC O_FSYNC /* kernel */ >#define FNONBLOCK O_NONBLOCK /* kernel */ >#define FNDELAY O_NONBLOCK /* compat */ >#define O_NDELAY O_NONBLOCK /* compat */ >#endif ># 173 "/usr/src/sys/sys/fcntl.h" > >/* > * We are out of bits in f_flag (which is a short). However, > * the flag bits not set in FMASK are only meaningful in the > * initial open syscall. Those bits can thus be given a > * different meaning for fcntl(2). > */ >#if __BSD_VISIBLE >/* Read ahead */ >#define FRDAHEAD O_CREAT >#endif ># 184 "/usr/src/sys/sys/fcntl.h" > >#if __POSIX_VISIBLE >= 200809 >/* > * Magic value that specify the use of the current working directory > * to determine the target of relative file paths in the openat() and > * similar syscalls. > */ >#define AT_FDCWD -100 > >/* > * Miscellaneous flags for the *at() syscalls. > */ >#define AT_EACCESS 0x100 /* Check access using effective user and group ID */ >#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symbolic links */ >#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic link */ >#define AT_REMOVEDIR 0x800 /* Remove directory instead of file */ >#endif ># 201 "/usr/src/sys/sys/fcntl.h" > >/* > * Constants used for fcntl(2) > */ > >/* command values */ >#define F_DUPFD 0 /* duplicate file descriptor */ >#define F_GETFD 1 /* get file descriptor flags */ >#define F_SETFD 2 /* set file descriptor flags */ >#define F_GETFL 3 /* get file status flags */ >#define F_SETFL 4 /* set file status flags */ >#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 >#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ >#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ >#endif ># 216 "/usr/src/sys/sys/fcntl.h" >#if __BSD_VISIBLE >#define F_OGETLK 7 /* get record locking information */ >#define F_OSETLK 8 /* set record locking information */ >#define F_OSETLKW 9 /* F_SETLK; wait if blocked */ >#define F_DUP2FD 10 /* duplicate file descriptor to arg */ >#endif ># 222 "/usr/src/sys/sys/fcntl.h" >#define F_GETLK 11 /* get record locking information */ >#define F_SETLK 12 /* set record locking information */ >#define F_SETLKW 13 /* F_SETLK; wait if blocked */ >#if __BSD_VISIBLE >#define F_SETLK_REMOTE 14 /* debugging support for remote locks */ >#define F_READAHEAD 15 /* read ahead */ >#define F_RDAHEAD 16 /* Darwin compatible read ahead */ >#endif ># 230 "/usr/src/sys/sys/fcntl.h" >#if __POSIX_VISIBLE >= 200809 >#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ >#endif ># 233 "/usr/src/sys/sys/fcntl.h" >#if __BSD_VISIBLE >#define F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */ >#endif ># 236 "/usr/src/sys/sys/fcntl.h" > >/* file descriptor flags (F_GETFD, F_SETFD) */ >#define FD_CLOEXEC 1 /* close-on-exec flag */ > >/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ >#define F_RDLCK 1 /* shared or read lock */ >#define F_UNLCK 2 /* unlock */ >#define F_WRLCK 3 /* exclusive or write lock */ >#if __BSD_VISIBLE >#define F_UNLCKSYS 4 /* purge locks for a given system ID */ >#define F_CANCEL 5 /* cancel an async lock request */ >#endif ># 248 "/usr/src/sys/sys/fcntl.h" >#ifdef _KERNEL >#define F_WAIT 0x010 /* Wait until lock is granted */ >#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */ >#define F_POSIX 0x040 /* Use POSIX semantics for lock */ >#define F_REMOTE 0x080 /* Lock owner is remote NFS client */ >#define F_NOINTR 0x100 /* Ignore signals when waiting */ >#endif ># 255 "/usr/src/sys/sys/fcntl.h" > >/* > * Advisory file segment locking data type - > * information passed to system by user > */ >struct flock { > off_t l_start; /* starting offset */ > off_t l_len; /* len = 0 means until end of file */ > pid_t l_pid; /* lock owner */ > short l_type; /* lock type: read/write, etc. */ > short l_whence; /* type of l_start */ > int l_sysid; /* remote system id or zero for local */ >}; > >#if __BSD_VISIBLE >/* > * Old advisory file segment locking data type, > * before adding l_sysid. > */ >struct __oflock { > off_t l_start; /* starting offset */ > off_t l_len; /* len = 0 means until end of file */ > pid_t l_pid; /* lock owner */ > short l_type; /* lock type: read/write, etc. */ > short l_whence; /* type of l_start */ >}; >#endif ># 282 "/usr/src/sys/sys/fcntl.h" > >#if __BSD_VISIBLE >/* lock operations for flock(2) */ >#define LOCK_SH 0x01 /* shared file lock */ >#define LOCK_EX 0x02 /* exclusive file lock */ >#define LOCK_NB 0x04 /* don't block when locking */ >#define LOCK_UN 0x08 /* unlock file */ >#endif ># 290 "/usr/src/sys/sys/fcntl.h" > >#if __POSIX_VISIBLE >= 200112 >/* > * Advice to posix_fadvise > */ >#define POSIX_FADV_NORMAL 0 /* no special treatment */ >#define POSIX_FADV_RANDOM 1 /* expect random page references */ >#define POSIX_FADV_SEQUENTIAL 2 /* expect sequential page references */ >#define POSIX_FADV_WILLNEED 3 /* will need these pages */ >#define POSIX_FADV_DONTNEED 4 /* dont need these pages */ >#define POSIX_FADV_NOREUSE 5 /* access data only once */ >#endif ># 302 "/usr/src/sys/sys/fcntl.h" > >#ifndef _KERNEL >__BEGIN_DECLS >int open(const char *, int, ...); >int creat(const char *, mode_t); >int fcntl(int, int, ...); >#if __BSD_VISIBLE >int flock(int, int); >#endif ># 311 "/usr/src/sys/sys/fcntl.h" >#if __POSIX_VISIBLE >= 200809 >int openat(int, const char *, int, ...); >#endif ># 314 "/usr/src/sys/sys/fcntl.h" >#if __POSIX_VISIBLE >= 200112 >int posix_fadvise(int, off_t, off_t, int); >int posix_fallocate(int, off_t, off_t); >#endif ># 318 "/usr/src/sys/sys/fcntl.h" >__END_DECLS >#endif ># 320 "/usr/src/sys/sys/fcntl.h" > >#endif /* !_SYS_FCNTL_H_ */ ># 322 "/usr/src/sys/sys/fcntl.h" ># 53 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/kdb.h> >#endif /* expanded by -frewrite-includes */ ># 53 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/kdb.h" 1 >/*- > * Copyright (c) 2004 Marcel Moolenaar > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/kdb.h 244100 2012-12-10 23:12:51Z alfred $ > */ > >#ifndef _SYS_KDB_H_ >#define _SYS_KDB_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/setjmp.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/kdb.h" ># 1 "./machine/setjmp.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/setjmp.h 232275 2012-02-28 22:17:52Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/setjmp.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/setjmp.h" ># 1 "./x86/setjmp.h" 1 >/*- > * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Neither the name of the author nor the names of any co-contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/x86/include/setjmp.h 232275 2012-02-28 22:17:52Z tijl $ > */ > >#ifndef _MACHINE_SETJMP_H_ >#define _MACHINE_SETJMP_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 35 "./x86/setjmp.h" ># 36 "./x86/setjmp.h" > >#define _JBLEN 12 /* Size of the jmp_buf on AMD64. */ > >/* > * jmp_buf and sigjmp_buf are encapsulated in different structs to force > * compile-time diagnostics for mismatches. The structs are the same > * internally to avoid some run-time errors for mismatches. > */ >#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE >typedef struct _sigjmp_buf { long _sjb[_JBLEN]; } sigjmp_buf[1]; >#endif ># 47 "./x86/setjmp.h" > >typedef struct _jmp_buf { long _jb[_JBLEN]; } jmp_buf[1]; > >#endif /* !_MACHINE_SETJMP_H_ */ ># 51 "./x86/setjmp.h" ># 7 "./machine/setjmp.h" 2 ># 33 "/usr/src/sys/sys/kdb.h" 2 > >struct pcb; >struct thread; >struct trapframe; > >typedef int dbbe_init_f(void); >typedef void dbbe_trace_f(void); >typedef void dbbe_trace_thread_f(struct thread *); >typedef int dbbe_trap_f(int, int); > >struct kdb_dbbe { > const char *dbbe_name; > dbbe_init_f *dbbe_init; > dbbe_trace_f *dbbe_trace; > dbbe_trace_thread_f *dbbe_trace_thread; > dbbe_trap_f *dbbe_trap; > int dbbe_active; >}; > >#define KDB_BACKEND(name, init, trace, trace_thread, trap) \ > static struct kdb_dbbe name##_dbbe = { \ > .dbbe_name = #name, \ > .dbbe_init = init, \ > .dbbe_trace = trace, \ > .dbbe_trace_thread = trace_thread, \ > .dbbe_trap = trap \ > }; \ > DATA_SET(kdb_dbbe_set, name##_dbbe) > >extern int kdb_active; /* Non-zero while in debugger. */ >extern int debugger_on_panic; /* enter the debugger on panic. */ >extern struct kdb_dbbe *kdb_dbbe; /* Default debugger backend or NULL. */ >extern struct trapframe *kdb_frame; /* Frame to kdb_trap(). */ >extern struct pcb *kdb_thrctx; /* Current context. */ >extern struct thread *kdb_thread; /* Current thread. */ > >int kdb_alt_break(int, int *); >int kdb_alt_break_gdb(int, int *); >int kdb_break(void); >void kdb_backtrace(void); >void kdb_backtrace_thread(struct thread *); >int kdb_dbbe_select(const char *); >void kdb_enter(const char *, const char *); >void kdb_init(void); >void * kdb_jmpbuf(jmp_buf); >void kdb_panic(const char *); >void kdb_reboot(void); >void kdb_reenter(void); >struct pcb *kdb_thr_ctx(struct thread *); >struct thread *kdb_thr_first(void); >struct thread *kdb_thr_from_pid(pid_t); >struct thread *kdb_thr_lookup(lwpid_t); >struct thread *kdb_thr_next(struct thread *); >int kdb_thr_select(struct thread *); >int kdb_trap(int, int, struct trapframe *); > >/* > * KDB enters the debugger via breakpoint(), which leaves the debugger without > * a lot of information about why it was entered. This simple enumerated set > * captures some basic information. > * > * It is recommended that values here be short (<16 character) alpha-numeric > * strings, as they will be used to construct DDB(4) script names. > */ >extern const char * volatile kdb_why; >#define KDB_WHY_UNSET NULL /* No reason set. */ >#define KDB_WHY_PANIC "panic" /* panic() was called. */ >#define KDB_WHY_KASSERT "kassert" /* kassert failed. */ >#define KDB_WHY_SYSCTL "sysctl" /* Sysctl entered debugger. */ >#define KDB_WHY_BOOTFLAGS "bootflags" /* Boot flags were set. */ >#define KDB_WHY_WITNESS "witness" /* Witness entered debugger. */ >#define KDB_WHY_VFSLOCK "vfslock" /* VFS detected lock problem. */ >#define KDB_WHY_NETGRAPH "netgraph" /* Netgraph entered debugger. */ >#define KDB_WHY_BREAK "break" /* Console or serial break. */ >#define KDB_WHY_WATCHDOG "watchdog" /* Watchdog entered debugger. */ >#define KDB_WHY_CAM "cam" /* CAM has entered debugger. */ >#define KDB_WHY_NDIS "ndis" /* NDIS entered debugger. */ >#define KDB_WHY_ACPI "acpi" /* ACPI entered debugger. */ >#define KDB_WHY_TRAPSIG "trapsig" /* Sparc fault. */ >#define KDB_WHY_POWERFAIL "powerfail" /* Powerfail NMI. */ >#define KDB_WHY_MAC "mac" /* MAC Framework. */ >#define KDB_WHY_POWERPC "powerpc" /* Unhandled powerpc intr. */ >#define KDB_WHY_UNIONFS "unionfs" /* Unionfs bug. */ >#define KDB_WHY_DTRACE "dtrace" /* DTrace action entered debugger. */ > >/* Return values for kdb_alt_break */ >#define KDB_REQ_DEBUGGER 1 /* User requested Debugger */ >#define KDB_REQ_PANIC 2 /* User requested a panic */ >#define KDB_REQ_REBOOT 3 /* User requested a clean reboot */ > >#endif /* !_SYS_KDB_H_ */ ># 124 "/usr/src/sys/sys/kdb.h" ># 54 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/kernel.h> >#endif /* expanded by -frewrite-includes */ ># 54 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/kernel.h" 1 >/*- > * Copyright (c) 1995 Terrence R. Lambert > * All rights reserved. > * > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)kernel.h 8.3 (Berkeley) 1/21/94 > * $FreeBSD: head/sys/sys/kernel.h 265432 2014-05-06 10:53:51Z rwatson $ > */ > >#ifndef _SYS_KERNEL_H_ >#define _SYS_KERNEL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/linker_set.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/sys/sys/kernel.h" ># 1 "/usr/src/sys/sys/linker_set.h" 1 >/*- > * Copyright (c) 1999 John D. Polstra > * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/linker_set.h 268138 2014-07-02 08:49:06Z hselasky $ > */ > >#ifndef _SYS_LINKER_SET_H_ >#define _SYS_LINKER_SET_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 36 "/usr/src/sys/sys/linker_set.h" > >/* > * The following macros are used to declare global sets of objects, which > * are collected by the linker into a `linker_set' as defined below. > * For ELF, this is done by constructing a separate segment for each set. > */ > >#if defined(__powerpc64__) >/* > * Move the symbol pointer from ".text" to ".data" segment, to make > * the GCC compiler happy: > */ >#define __MAKE_SET_CONST >#else ># 50 "/usr/src/sys/sys/linker_set.h" >#define __MAKE_SET_CONST const >#endif ># 52 "/usr/src/sys/sys/linker_set.h" > >/* > * Private macros, not to be used outside this header file. > */ >#ifdef __GNUCLIKE___SECTION >#define __MAKE_SET(set, sym) \ > __GLOBL(__CONCAT(__start_set_,set)); \ > __GLOBL(__CONCAT(__stop_set_,set)); \ > static void const * __MAKE_SET_CONST \ > __set_##set##_sym_##sym __section("set_" #set) \ > __used = &(sym) >#else /* !__GNUCLIKE___SECTION */ ># 64 "/usr/src/sys/sys/linker_set.h" >#ifndef lint >#error this file needs to be ported to your compiler >#endif /* lint */ ># 67 "/usr/src/sys/sys/linker_set.h" >#define __MAKE_SET(set, sym) extern void const * const (__set_##set##_sym_##sym) >#endif /* __GNUCLIKE___SECTION */ ># 69 "/usr/src/sys/sys/linker_set.h" > >/* > * Public macros. > */ >#define TEXT_SET(set, sym) __MAKE_SET(set, sym) >#define DATA_SET(set, sym) __MAKE_SET(set, sym) >#define BSS_SET(set, sym) __MAKE_SET(set, sym) >#define ABS_SET(set, sym) __MAKE_SET(set, sym) >#define SET_ENTRY(set, sym) __MAKE_SET(set, sym) > >/* > * Initialize before referring to a given linker set. > */ >#define SET_DECLARE(set, ptype) \ > extern ptype __weak *__CONCAT(__start_set_,set); \ > extern ptype __weak *__CONCAT(__stop_set_,set) > >#define SET_BEGIN(set) \ > (&__CONCAT(__start_set_,set)) >#define SET_LIMIT(set) \ > (&__CONCAT(__stop_set_,set)) > >/* > * Iterate over all the elements of a set. > * > * Sets always contain addresses of things, and "pvar" points to words > * containing those addresses. Thus is must be declared as "type **pvar", > * and the address of each set item is obtained inside the loop by "*pvar". > */ >#define SET_FOREACH(pvar, set) \ > for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++) > >#define SET_ITEM(set, i) \ > ((SET_BEGIN(set))[i]) > >/* > * Provide a count of the items in a set. > */ >#define SET_COUNT(set) \ > (SET_LIMIT(set) - SET_BEGIN(set)) > >#endif /* _SYS_LINKER_SET_H_ */ ># 111 "/usr/src/sys/sys/linker_set.h" ># 49 "/usr/src/sys/sys/kernel.h" 2 > >#ifdef _KERNEL > >/* for intrhook below */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 53 "/usr/src/sys/sys/kernel.h" ># 54 "/usr/src/sys/sys/kernel.h" > >/* Global variables for the kernel. */ > >/* 1.1 */ >extern char kernelname[MAXPATHLEN]; > >extern int tick; /* usec per tick (1000000 / hz) */ >extern int hz; /* system clock's frequency */ >extern int psratio; /* ratio: prof / stat */ >extern int stathz; /* statistics clock's frequency */ >extern int profhz; /* profiling clock's frequency */ >extern int profprocs; /* number of process's profiling */ >extern volatile int ticks; > >#endif /* _KERNEL */ ># 69 "/usr/src/sys/sys/kernel.h" > >/* > * Enumerated types for known system startup interfaces. > * > * Startup occurs in ascending numeric order; the list entries are > * sorted prior to attempting startup to guarantee order. Items > * of the same level are arbitrated for order based on the 'order' > * element. > * > * These numbers are arbitrary and are chosen ONLY for ordering; the > * enumeration values are explicit rather than implicit to provide > * for binary compatibility with inserted elements. > * > * The SI_SUB_LAST value must have the highest lexical value. > * > * The SI_SUB_SWAP values represent a value used by > * the BSD 4.4Lite but not by FreeBSD; it is maintained in dependent > * order to support porting. > */ >enum sysinit_sub_id { > SI_SUB_DUMMY = 0x0000000, /* not executed; for linker*/ > SI_SUB_DONE = 0x0000001, /* processed*/ > SI_SUB_TUNABLES = 0x0700000, /* establish tunable values */ > SI_SUB_COPYRIGHT = 0x0800001, /* first use of console*/ > SI_SUB_SETTINGS = 0x0880000, /* check and recheck settings */ > SI_SUB_MTX_POOL_STATIC = 0x0900000, /* static mutex pool */ > SI_SUB_VM = 0x1000000, /* virtual memory system init*/ > SI_SUB_KMEM = 0x1800000, /* kernel memory*/ > SI_SUB_HYPERVISOR = 0x1A40000, /* > * Hypervisor detection and > * virtualization support > * setup. > */ > SI_SUB_WITNESS = 0x1A80000, /* witness initialization */ > SI_SUB_MTX_POOL_DYNAMIC = 0x1AC0000, /* dynamic mutex pool */ > SI_SUB_LOCK = 0x1B00000, /* various locks */ > SI_SUB_EVENTHANDLER = 0x1C00000, /* eventhandler init */ > SI_SUB_VNET_PRELINK = 0x1E00000, /* vnet init before modules */ > SI_SUB_KLD = 0x2000000, /* KLD and module setup */ > SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/ > SI_SUB_RACCT = 0x2110000, /* resource accounting */ > SI_SUB_RANDOM = 0x2120000, /* random number generator */ > SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */ > SI_SUB_MAC = 0x2180000, /* TrustedBSD MAC subsystem */ > SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */ > SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */ > SI_SUB_VNET = 0x21E0000, /* vnet 0 */ > SI_SUB_INTRINSIC = 0x2200000, /* proc 0*/ > SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits*/ > SI_SUB_DDB_SERVICES = 0x2380000, /* capture, scripting, etc. */ > SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue*/ > SI_SUB_KTRACE = 0x2480000, /* ktrace */ > SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */ > SI_SUB_CYCLIC = 0x24A0000, /* Cyclic timers */ > SI_SUB_AUDIT = 0x24C0000, /* audit */ > SI_SUB_CREATE_INIT = 0x2500000, /* create init process*/ > SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */ > SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ > SI_SUB_INTR = 0x2800000, /* interrupt threads */ > SI_SUB_SOFTINTR = 0x2800001, /* start soft interrupt thread */ > SI_SUB_ACL = 0x2900000, /* start for filesystem ACLs */ > SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ > SI_SUB_INIT_IF = 0x3000000, /* prep for net interfaces */ > SI_SUB_NETGRAPH = 0x3010000, /* Let Netgraph initialize */ > SI_SUB_DTRACE = 0x3020000, /* DTrace subsystem */ > SI_SUB_DTRACE_PROVIDER = 0x3048000, /* DTrace providers */ > SI_SUB_DTRACE_ANON = 0x308C000, /* DTrace anon enabling */ > SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */ > SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */ > SI_SUB_VFS = 0x4000000, /* virtual filesystem*/ > SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks*/ > SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory*/ > SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores*/ > SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues*/ > SI_SUB_P1003_1B = 0x6E00000, /* P1003.1B realtime */ > SI_SUB_PSEUDO = 0x7000000, /* pseudo devices*/ > SI_SUB_EXEC = 0x7400000, /* execve() handlers */ > SI_SUB_PROTO_BEGIN = 0x8000000, /* VNET initialization */ > SI_SUB_PROTO_IF = 0x8400000, /* interfaces*/ > SI_SUB_PROTO_DOMAININIT = 0x8600000, /* domain registration system */ > SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?)*/ > SI_SUB_PROTO_IFATTACHDOMAIN = 0x8800001, /* domain dependent data init*/ > SI_SUB_PROTO_END = 0x8ffffff, /* VNET helper functions */ > SI_SUB_KPROF = 0x9000000, /* kernel profiling*/ > SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events*/ > SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */ > SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */ > SI_SUB_DUMP_CONF = 0xb200000, /* Find dump devices */ > SI_SUB_RAID = 0xb380000, /* Configure GEOM classes */ > SI_SUB_SWAP = 0xc000000, /* swap */ > SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup*/ > SI_SUB_SYSCALLS = 0xd800000, /* register system calls */ > SI_SUB_VNET_DONE = 0xdc00000, /* vnet registration complete */ > SI_SUB_KTHREAD_INIT = 0xe000000, /* init process*/ > SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon*/ > SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon*/ > SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon*/ > SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon*/ > SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/ > SI_SUB_SMP = 0xf000000, /* start the APs*/ > SI_SUB_RACCTD = 0xf100000, /* start racctd*/ > SI_SUB_LAST = 0xfffffff /* final initialization */ >}; > > >/* > * Some enumerated orders; "ANY" sorts last. > */ >enum sysinit_elem_order { > SI_ORDER_FIRST = 0x0000000, /* first*/ > SI_ORDER_SECOND = 0x0000001, /* second*/ > SI_ORDER_THIRD = 0x0000002, /* third*/ > SI_ORDER_FOURTH = 0x0000003, /* fourth*/ > SI_ORDER_MIDDLE = 0x1000000, /* somewhere in the middle */ > SI_ORDER_ANY = 0xfffffff /* last*/ >}; > > >/* > * A system initialization call instance > * > * At the moment there is one instance of sysinit. We probably do not > * want two which is why this code is if'd out, but we definitely want > * to discern SYSINIT's which take non-constant data pointers and > * SYSINIT's which take constant data pointers, > * > * The C_* macros take functions expecting const void * arguments > * while the non-C_* macros take functions expecting just void * arguments. > * > * With -Wcast-qual on, the compiler issues warnings: > * - if we pass non-const data or functions taking non-const data > * to a C_* macro. > * > * - if we pass const data to the normal macros > * > * However, no warning is issued if we pass a function taking const data > * through a normal non-const macro. This is ok because the function is > * saying it won't modify the data so we don't care whether the data is > * modifiable or not. > */ > >typedef void (*sysinit_nfunc_t)(void *); >typedef void (*sysinit_cfunc_t)(const void *); > >struct sysinit { > enum sysinit_sub_id subsystem; /* subsystem identifier*/ > enum sysinit_elem_order order; /* init order within subsystem*/ > sysinit_cfunc_t func; /* function */ > const void *udata; /* multiplexer/argument */ >}; > >/* > * Default: no special processing > * > * The C_ version of SYSINIT is for data pointers to const > * data ( and functions taking data pointers to const data ). > * At the moment it is no different from SYSINIT and thus > * still results in warnings. > * > * The casts are necessary to have the compiler produce the > * correct warnings when -Wcast-qual is used. > * > */ >#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ > static struct sysinit uniquifier ## _sys_init = { \ > subsystem, \ > order, \ > func, \ > (ident) \ > }; \ > DATA_SET(sysinit_set,uniquifier ## _sys_init) > >#define SYSINIT(uniquifier, subsystem, order, func, ident) \ > C_SYSINIT(uniquifier, subsystem, order, \ > (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(ident)) > >/* > * Called on module unload: no special processing > */ >#define C_SYSUNINIT(uniquifier, subsystem, order, func, ident) \ > static struct sysinit uniquifier ## _sys_uninit = { \ > subsystem, \ > order, \ > func, \ > (ident) \ > }; \ > DATA_SET(sysuninit_set,uniquifier ## _sys_uninit) > >#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \ > C_SYSUNINIT(uniquifier, subsystem, order, \ > (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)(ident)) > >void sysinit_add(struct sysinit **set, struct sysinit **set_end); > >/* > * Infrastructure for tunable 'constants'. Value may be specified at compile > * time or kernel load time. Rules relating tunables together can be placed > * in a SYSINIT function at SI_SUB_TUNABLES with SI_ORDER_ANY. > * > * WARNING: developers should never use the reserved suffixes specified in > * loader.conf(5) for any tunables or conflicts will result. > */ > >/* > * int > * please avoid using for new tunables! > */ >extern void tunable_int_init(void *); >struct tunable_int { > const char *path; > int *var; >}; >#define TUNABLE_INT(path, var) \ > static struct tunable_int __CONCAT(__tunable_int_, __LINE__) = { \ > (path), \ > (var), \ > }; \ > SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ > SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_int_init, \ > &__CONCAT(__tunable_int_, __LINE__)) > >#define TUNABLE_INT_FETCH(path, var) getenv_int((path), (var)) > >/* > * long > */ >extern void tunable_long_init(void *); >struct tunable_long { > const char *path; > long *var; >}; >#define TUNABLE_LONG(path, var) \ > static struct tunable_long __CONCAT(__tunable_long_, __LINE__) = { \ > (path), \ > (var), \ > }; \ > SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ > SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_long_init,\ > &__CONCAT(__tunable_long_, __LINE__)) > >#define TUNABLE_LONG_FETCH(path, var) getenv_long((path), (var)) > >/* > * unsigned long > */ >extern void tunable_ulong_init(void *); >struct tunable_ulong { > const char *path; > unsigned long *var; >}; >#define TUNABLE_ULONG(path, var) \ > static struct tunable_ulong __CONCAT(__tunable_ulong_, __LINE__) = { \ > (path), \ > (var), \ > }; \ > SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ > SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_ulong_init, \ > &__CONCAT(__tunable_ulong_, __LINE__)) > >#define TUNABLE_ULONG_FETCH(path, var) getenv_ulong((path), (var)) > >/* > * quad > */ >extern void tunable_quad_init(void *); >struct tunable_quad { > const char *path; > quad_t *var; >}; >#define TUNABLE_QUAD(path, var) \ > static struct tunable_quad __CONCAT(__tunable_quad_, __LINE__) = { \ > (path), \ > (var), \ > }; \ > SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ > SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_quad_init, \ > &__CONCAT(__tunable_quad_, __LINE__)) > >#define TUNABLE_QUAD_FETCH(path, var) getenv_quad((path), (var)) > >extern void tunable_str_init(void *); >struct tunable_str { > const char *path; > char *var; > int size; >}; >#define TUNABLE_STR(path, var, size) \ > static struct tunable_str __CONCAT(__tunable_str_, __LINE__) = { \ > (path), \ > (var), \ > (size), \ > }; \ > SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ > SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_str_init, \ > &__CONCAT(__tunable_str_, __LINE__)) > >#define TUNABLE_STR_FETCH(path, var, size) \ > getenv_string((path), (var), (size)) > >struct intr_config_hook { > TAILQ_ENTRY(intr_config_hook) ich_links; > void (*ich_func)(void *arg); > void *ich_arg; >}; > >int config_intrhook_establish(struct intr_config_hook *hook); >void config_intrhook_disestablish(struct intr_config_hook *hook); > >#endif /* !_SYS_KERNEL_H_*/ ># 378 "/usr/src/sys/sys/kernel.h" ># 55 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/malloc.h> >#endif /* expanded by -frewrite-includes */ ># 55 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/malloc.h" 1 >/*- > * Copyright (c) 1987, 1993 > * The Regents of the University of California. > * Copyright (c) 2005, 2009 Robert N. M. Watson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)malloc.h 8.5 (Berkeley) 5/3/95 > * $FreeBSD: head/sys/sys/malloc.h 267992 2014-06-28 03:56:17Z hselasky $ > */ > >#ifndef _SYS_MALLOC_H_ >#define _SYS_MALLOC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/malloc.h" ># 39 "/usr/src/sys/sys/malloc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/malloc.h" ># 40 "/usr/src/sys/sys/malloc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/malloc.h" ># 41 "/usr/src/sys/sys/malloc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/malloc.h" ># 42 "/usr/src/sys/sys/malloc.h" > >#define MINALLOCSIZE UMA_SMALLEST_UNIT > >/* > * flags to malloc. > */ >#define M_NOWAIT 0x0001 /* do not block */ >#define M_WAITOK 0x0002 /* ok to block */ >#define M_ZERO 0x0100 /* bzero the allocation */ >#define M_NOVM 0x0200 /* don't ask VM for pages */ >#define M_USE_RESERVE 0x0400 /* can alloc out of reserve memory */ >#define M_NODUMP 0x0800 /* don't dump pages in this allocation */ >#define M_FIRSTFIT 0x1000 /* Only for vmem, fast fit. */ >#define M_BESTFIT 0x2000 /* Only for vmem, low fragmentation. */ > >#define M_MAGIC 877983977 /* time when first defined :-) */ > >/* > * Two malloc type structures are present: malloc_type, which is used by a > * type owner to declare the type, and malloc_type_internal, which holds > * malloc-owned statistics and other ABI-sensitive fields, such as the set of > * malloc statistics indexed by the compile-time MAXCPU constant. > * Applications should avoid introducing dependence on the allocator private > * data layout and size. > * > * The malloc_type ks_next field is protected by malloc_mtx. Other fields in > * malloc_type are static after initialization so unsynchronized. > * > * Statistics in malloc_type_stats are written only when holding a critical > * section and running on the CPU associated with the index into the stat > * array, but read lock-free resulting in possible (minor) races, which the > * monitoring app should take into account. > */ >struct malloc_type_stats { > uint64_t mts_memalloced; /* Bytes allocated on CPU. */ > uint64_t mts_memfreed; /* Bytes freed on CPU. */ > uint64_t mts_numallocs; /* Number of allocates on CPU. */ > uint64_t mts_numfrees; /* number of frees on CPU. */ > uint64_t mts_size; /* Bitmask of sizes allocated on CPU. */ > uint64_t _mts_reserved1; /* Reserved field. */ > uint64_t _mts_reserved2; /* Reserved field. */ > uint64_t _mts_reserved3; /* Reserved field. */ >}; > >/* > * Index definitions for the mti_probes[] array. > */ >#define DTMALLOC_PROBE_MALLOC 0 >#define DTMALLOC_PROBE_FREE 1 >#define DTMALLOC_PROBE_MAX 2 > >struct malloc_type_internal { > uint32_t mti_probes[DTMALLOC_PROBE_MAX]; > /* DTrace probe ID array. */ > u_char mti_zone; > struct malloc_type_stats mti_stats[MAXCPU]; >}; > >/* > * Public data structure describing a malloc type. Private data is hung off > * of ks_handle to avoid encoding internal malloc(9) data structures in > * modules, which will statically allocate struct malloc_type. > */ >struct malloc_type { > struct malloc_type *ks_next; /* Next in global chain. */ > u_long ks_magic; /* Detect programmer error. */ > const char *ks_shortdesc; /* Printable type name. */ > void *ks_handle; /* Priv. data, was lo_class. */ >}; > >/* > * Statistics structure headers for user space. The kern.malloc sysctl > * exposes a structure stream consisting of a stream header, then a series of > * malloc type headers and statistics structures (quantity maxcpus). For > * convenience, the kernel will provide the current value of maxcpus at the > * head of the stream. > */ >#define MALLOC_TYPE_STREAM_VERSION 0x00000001 >struct malloc_type_stream_header { > uint32_t mtsh_version; /* Stream format version. */ > uint32_t mtsh_maxcpus; /* Value of MAXCPU for stream. */ > uint32_t mtsh_count; /* Number of records. */ > uint32_t _mtsh_pad; /* Pad/reserved field. */ >}; > >#define MALLOC_MAX_NAME 32 >struct malloc_type_header { > char mth_name[MALLOC_MAX_NAME]; >}; > >#ifdef _KERNEL >#define MALLOC_DEFINE(type, shortdesc, longdesc) \ > struct malloc_type type[1] = { \ > { NULL, M_MAGIC, shortdesc, NULL } \ > }; \ > SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_THIRD, malloc_init, \ > type); \ > SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ > malloc_uninit, type) > >#define MALLOC_DECLARE(type) \ > extern struct malloc_type type[1] > >MALLOC_DECLARE(M_CACHE); >MALLOC_DECLARE(M_DEVBUF); >MALLOC_DECLARE(M_TEMP); > >MALLOC_DECLARE(M_IP6OPT); /* for INET6 */ >MALLOC_DECLARE(M_IP6NDP); /* for INET6 */ > >/* > * Deprecated macro versions of not-quite-malloc() and free(). > */ >#define MALLOC(space, cast, size, type, flags) \ > ((space) = (cast)malloc((u_long)(size), (type), (flags))) >#define FREE(addr, type) free((addr), (type)) > >/* > * XXX this should be declared in <sys/uio.h>, but that tends to fail > * because <sys/uio.h> is included in a header before the source file > * has a chance to include <sys/malloc.h> to get MALLOC_DECLARE() defined. > */ >MALLOC_DECLARE(M_IOV); > >extern struct mtx malloc_mtx; > >/* > * Function type used when iterating over the list of malloc types. > */ >typedef void malloc_type_list_func_t(struct malloc_type *, void *); > >void contigfree(void *addr, unsigned long size, struct malloc_type *type); >void *contigmalloc(unsigned long size, struct malloc_type *type, int flags, > vm_paddr_t low, vm_paddr_t high, unsigned long alignment, > vm_paddr_t boundary) __malloc_like; >void free(void *addr, struct malloc_type *type); >void *malloc(unsigned long size, struct malloc_type *type, int flags) __malloc_like; >void malloc_init(void *); >int malloc_last_fail(void); >void malloc_type_allocated(struct malloc_type *type, unsigned long size); >void malloc_type_freed(struct malloc_type *type, unsigned long size); >void malloc_type_list(malloc_type_list_func_t *, void *); >void malloc_uninit(void *); >void *realloc(void *addr, unsigned long size, struct malloc_type *type, > int flags); >void *reallocf(void *addr, unsigned long size, struct malloc_type *type, > int flags); > >struct malloc_type *malloc_desc2type(const char *desc); >#endif /* _KERNEL */ ># 192 "/usr/src/sys/sys/malloc.h" > >#endif /* !_SYS_MALLOC_H_ */ ># 194 "/usr/src/sys/sys/malloc.h" ># 56 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/msgbuf.h> >#endif /* expanded by -frewrite-includes */ ># 56 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/msgbuf.h" 1 >/*- > * Copyright (c) 1981, 1984, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: head/sys/sys/msgbuf.h 233135 2012-03-19 00:36:32Z eadler $ > */ > >#ifndef _SYS_MSGBUF_H_ >#define _SYS_MSGBUF_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/msgbuf.h" ># 37 "/usr/src/sys/sys/msgbuf.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/msgbuf.h" ># 38 "/usr/src/sys/sys/msgbuf.h" > >struct msgbuf { > char *msg_ptr; /* pointer to buffer */ >#define MSG_MAGIC 0x063062 > u_int msg_magic; > u_int msg_size; /* size of buffer area */ > u_int msg_wseq; /* write sequence number */ > u_int msg_rseq; /* read sequence number */ > u_int msg_cksum; /* checksum of contents */ > u_int msg_seqmod; /* range for sequence numbers */ > int msg_lastpri; /* saved priority value */ > u_int msg_flags; >#define MSGBUF_NEEDNL 0x01 /* set when newline needed */ > struct mtx msg_lock; /* mutex to protect the buffer */ >}; > >/* Normalise a sequence number or a difference between sequence numbers. */ >#define MSGBUF_SEQNORM(mbp, seq) (((seq) + (mbp)->msg_seqmod) % \ > (mbp)->msg_seqmod) >#define MSGBUF_SEQ_TO_POS(mbp, seq) ((seq) % (mbp)->msg_size) >/* Subtract sequence numbers. Note that only positive values result. */ >#define MSGBUF_SEQSUB(mbp, seq1, seq2) (MSGBUF_SEQNORM((mbp), (seq1) - (seq2))) > >#ifdef _KERNEL >extern int msgbufsize; >extern int msgbuftrigger; >extern struct msgbuf *msgbufp; >extern struct mtx msgbuf_lock; > >void msgbufinit(void *ptr, int size); >void msgbuf_addchar(struct msgbuf *mbp, int c); >void msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int filter_cr); >void msgbuf_clear(struct msgbuf *mbp); >void msgbuf_copy(struct msgbuf *src, struct msgbuf *dst); >int msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen); >int msgbuf_getchar(struct msgbuf *mbp); >int msgbuf_getcount(struct msgbuf *mbp); >void msgbuf_init(struct msgbuf *mbp, void *ptr, int size); >int msgbuf_peekbytes(struct msgbuf *mbp, char *buf, int buflen, > u_int *seqp); >void msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size); > >#ifndef MSGBUF_SIZE >#define MSGBUF_SIZE (32768 * 3) >#endif ># 83 "/usr/src/sys/sys/msgbuf.h" >#endif /* KERNEL */ ># 84 "/usr/src/sys/sys/msgbuf.h" > >#endif /* !_SYS_MSGBUF_H_ */ ># 86 "/usr/src/sys/sys/msgbuf.h" ># 57 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/namei.h> >#endif /* expanded by -frewrite-includes */ ># 57 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/namei.h" 1 >/*- > * Copyright (c) 1985, 1989, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)namei.h 8.5 (Berkeley) 1/9/95 > * $FreeBSD: head/sys/sys/namei.h 255219 2013-09-05 00:09:56Z pjd $ > */ > >#ifndef _SYS_NAMEI_H_ >#define _SYS_NAMEI_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/caprights.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/namei.h" ># 1 "/usr/src/sys/sys/caprights.h" 1 >/*- > * Copyright (c) 2013 FreeBSD Foundation > * All rights reserved. > * > * This software was developed by Pawel Jakub Dawidek under sponsorship from > * the FreeBSD Foundation. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/caprights.h 255219 2013-09-05 00:09:56Z pjd $ > */ > >#ifndef _SYS_CAPRIGHTS_H_ >#define _SYS_CAPRIGHTS_H_ > >/* > * The top two bits in the first element of the cr_rights[] array contain > * total number of elements in the array - 2. This means if those two bits are > * equal to 0, we have 2 array elements. > * The top two bits in all remaining array elements should be 0. > * The next five bits contain array index. Only one bit is used and bit position > * in this five-bits range defines array index. This means there can be at most > * five array elements. > */ >#define CAP_RIGHTS_VERSION_00 0 >/* >#define CAP_RIGHTS_VERSION_01 1 >#define CAP_RIGHTS_VERSION_02 2 >#define CAP_RIGHTS_VERSION_03 3 >*/ >#define CAP_RIGHTS_VERSION CAP_RIGHTS_VERSION_00 > >struct cap_rights { > uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; >}; > >#ifndef _CAP_RIGHTS_T_DECLARED >#define _CAP_RIGHTS_T_DECLARED >typedef struct cap_rights cap_rights_t; >#endif ># 60 "/usr/src/sys/sys/caprights.h" > >#endif /* !_SYS_CAPRIGHTS_H_ */ ># 62 "/usr/src/sys/sys/caprights.h" ># 37 "/usr/src/sys/sys/namei.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/filedesc.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/namei.h" ># 1 "/usr/src/sys/sys/filedesc.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: head/sys/sys/filedesc.h 278930 2015-02-17 23:54:06Z mjg $ > */ > >#ifndef _SYS_FILEDESC_H_ >#define _SYS_FILEDESC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/caprights.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/filedesc.h" ># 37 "/usr/src/sys/sys/filedesc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/filedesc.h" ># 38 "/usr/src/sys/sys/filedesc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/event.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/filedesc.h" ># 1 "/usr/src/sys/sys/event.h" 1 >/*- > * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/event.h 274560 2014-11-16 01:18:41Z jmg $ > */ > >#ifndef _SYS_EVENT_H_ >#define _SYS_EVENT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/event.h" ># 33 "/usr/src/sys/sys/event.h" > >#define EVFILT_READ (-1) >#define EVFILT_WRITE (-2) >#define EVFILT_AIO (-3) /* attached to aio requests */ >#define EVFILT_VNODE (-4) /* attached to vnodes */ >#define EVFILT_PROC (-5) /* attached to struct proc */ >#define EVFILT_SIGNAL (-6) /* attached to struct proc */ >#define EVFILT_TIMER (-7) /* timers */ >#define EVFILT_PROCDESC (-8) /* attached to process descriptors */ >#define EVFILT_FS (-9) /* filesystem events */ >#define EVFILT_LIO (-10) /* attached to lio requests */ >#define EVFILT_USER (-11) /* User events */ >#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ >#define EVFILT_SYSCOUNT 12 > >#define EV_SET(kevp_, a, b, c, d, e, f) do { \ > struct kevent *kevp = (kevp_); \ > (kevp)->ident = (a); \ > (kevp)->filter = (b); \ > (kevp)->flags = (c); \ > (kevp)->fflags = (d); \ > (kevp)->data = (e); \ > (kevp)->udata = (f); \ >} while(0) > >struct kevent { > uintptr_t ident; /* identifier for this event */ > short filter; /* filter for event */ > u_short flags; > u_int fflags; > intptr_t data; > void *udata; /* opaque user data identifier */ >}; > >/* actions */ >#define EV_ADD 0x0001 /* add event to kq (implies enable) */ >#define EV_DELETE 0x0002 /* delete event from kq */ >#define EV_ENABLE 0x0004 /* enable event */ >#define EV_DISABLE 0x0008 /* disable event (not reported) */ >#define EV_FORCEONESHOT 0x0100 /* enable _ONESHOT and force trigger */ > >/* flags */ >#define EV_ONESHOT 0x0010 /* only report one occurrence */ >#define EV_CLEAR 0x0020 /* clear event state after reporting */ >#define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data=0 */ >#define EV_DISPATCH 0x0080 /* disable event after reporting */ > >#define EV_SYSFLAGS 0xF000 /* reserved by system */ >#define EV_DROP 0x1000 /* note should be dropped */ >#define EV_FLAG1 0x2000 /* filter-specific flag */ > >/* returned values */ >#define EV_EOF 0x8000 /* EOF detected */ >#define EV_ERROR 0x4000 /* error, data contains errno */ > > /* > * data/hint flags/masks for EVFILT_USER, shared with userspace > * > * On input, the top two bits of fflags specifies how the lower twenty four > * bits should be applied to the stored value of fflags. > * > * On output, the top two bits will always be set to NOTE_FFNOP and the > * remaining twenty four bits will contain the stored fflags value. > */ >#define NOTE_FFNOP 0x00000000 /* ignore input fflags */ >#define NOTE_FFAND 0x40000000 /* AND fflags */ >#define NOTE_FFOR 0x80000000 /* OR fflags */ >#define NOTE_FFCOPY 0xc0000000 /* copy fflags */ >#define NOTE_FFCTRLMASK 0xc0000000 /* masks for operations */ >#define NOTE_FFLAGSMASK 0x00ffffff > >#define NOTE_TRIGGER 0x01000000 /* Cause the event to be > triggered for output. */ > >/* > * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace > */ >#define NOTE_LOWAT 0x0001 /* low water mark */ > >/* > * data/hint flags for EVFILT_VNODE, shared with userspace > */ >#define NOTE_DELETE 0x0001 /* vnode was removed */ >#define NOTE_WRITE 0x0002 /* data contents changed */ >#define NOTE_EXTEND 0x0004 /* size increased */ >#define NOTE_ATTRIB 0x0008 /* attributes changed */ >#define NOTE_LINK 0x0010 /* link count changed */ >#define NOTE_RENAME 0x0020 /* vnode was renamed */ >#define NOTE_REVOKE 0x0040 /* vnode access was revoked */ > >/* > * data/hint flags for EVFILT_PROC and EVFILT_PROCDESC, shared with userspace > */ >#define NOTE_EXIT 0x80000000 /* process exited */ >#define NOTE_FORK 0x40000000 /* process forked */ >#define NOTE_EXEC 0x20000000 /* process exec'd */ >#define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */ >#define NOTE_PDATAMASK 0x000fffff /* mask for pid */ > >/* additional flags for EVFILT_PROC */ >#define NOTE_TRACK 0x00000001 /* follow across forks */ >#define NOTE_TRACKERR 0x00000002 /* could not track child */ >#define NOTE_CHILD 0x00000004 /* am a child process */ > >/* additional flags for EVFILT_TIMER */ >#define NOTE_SECONDS 0x00000001 /* data is seconds */ >#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */ >#define NOTE_USECONDS 0x00000004 /* data is microseconds */ >#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */ > >struct knote; >SLIST_HEAD(klist, knote); >struct kqueue; >TAILQ_HEAD(kqlist, kqueue); >struct knlist { > struct klist kl_list; > void (*kl_lock)(void *); /* lock function */ > void (*kl_unlock)(void *); > void (*kl_assert_locked)(void *); > void (*kl_assert_unlocked)(void *); > void *kl_lockarg; /* argument passed to kl_lockf() */ >}; > > >#ifdef _KERNEL > >/* > * Flags for knote call > */ >#define KNF_LISTLOCKED 0x0001 /* knlist is locked */ >#define KNF_NOKQLOCK 0x0002 /* do not keep KQ_LOCK */ > >#define KNOTE(list, hist, flags) knote(list, hist, flags) >#define KNOTE_LOCKED(list, hint) knote(list, hint, KNF_LISTLOCKED) >#define KNOTE_UNLOCKED(list, hint) knote(list, hint, 0) > >#define KNLIST_EMPTY(list) SLIST_EMPTY(&(list)->kl_list) > >/* > * Flag indicating hint is a signal. Used by EVFILT_SIGNAL, and also > * shared by EVFILT_PROC (all knotes attached to p->p_klist) > */ >#define NOTE_SIGNAL 0x08000000 > >/* > * Hint values for the optional f_touch event filter. If f_touch is not set > * to NULL and f_isfd is zero the f_touch filter will be called with the type > * argument set to EVENT_REGISTER during a kevent() system call. It is also > * called under the same conditions with the type argument set to EVENT_PROCESS > * when the event has been triggered. > */ >#define EVENT_REGISTER 1 >#define EVENT_PROCESS 2 > >struct filterops { > int f_isfd; /* true if ident == filedescriptor */ > int (*f_attach)(struct knote *kn); > void (*f_detach)(struct knote *kn); > int (*f_event)(struct knote *kn, long hint); > void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type); >}; > >/* > * Setting the KN_INFLUX flag enables you to unlock the kq that this knote > * is on, and modify kn_status as if you had the KQ lock. > * > * kn_sfflags, kn_sdata, and kn_kevent are protected by the knlist lock. > */ >struct knote { > SLIST_ENTRY(knote) kn_link; /* for kq */ > SLIST_ENTRY(knote) kn_selnext; /* for struct selinfo */ > struct knlist *kn_knlist; /* f_attach populated */ > TAILQ_ENTRY(knote) kn_tqe; > struct kqueue *kn_kq; /* which queue we are on */ > struct kevent kn_kevent; > int kn_status; /* protected by kq lock */ >#define KN_ACTIVE 0x01 /* event has been triggered */ >#define KN_QUEUED 0x02 /* event is on queue */ >#define KN_DISABLED 0x04 /* event is disabled */ >#define KN_DETACHED 0x08 /* knote is detached */ >#define KN_INFLUX 0x10 /* knote is in flux */ >#define KN_MARKER 0x20 /* ignore this knote */ >#define KN_KQUEUE 0x40 /* this knote belongs to a kq */ >#define KN_HASKQLOCK 0x80 /* for _inevent */ >#define KN_SCAN 0x100 /* flux set in kqueue_scan() */ > int kn_sfflags; /* saved filter flags */ > intptr_t kn_sdata; /* saved data field */ > union { > struct file *p_fp; /* file data pointer */ > struct proc *p_proc; /* proc pointer */ > struct aiocblist *p_aio; /* AIO job pointer */ > struct aioliojob *p_lio; /* LIO job pointer */ > sbintime_t *p_nexttime; /* next timer event fires at */ > void *p_v; /* generic other pointer */ > } kn_ptr; > struct filterops *kn_fop; > void *kn_hook; > int kn_hookid; > >#define kn_id kn_kevent.ident >#define kn_filter kn_kevent.filter >#define kn_flags kn_kevent.flags >#define kn_fflags kn_kevent.fflags >#define kn_data kn_kevent.data >#define kn_fp kn_ptr.p_fp >}; >struct kevent_copyops { > void *arg; > int (*k_copyout)(void *arg, struct kevent *kevp, int count); > int (*k_copyin)(void *arg, struct kevent *kevp, int count); >}; > >struct thread; >struct proc; >struct knlist; >struct mtx; >struct rwlock; > >extern void knote(struct knlist *list, long hint, int lockflags); >extern void knote_fork(struct knlist *list, int pid); >extern void knlist_add(struct knlist *knl, struct knote *kn, int islocked); >extern void knlist_remove(struct knlist *knl, struct knote *kn, int islocked); >extern void knlist_remove_inevent(struct knlist *knl, struct knote *kn); >extern int knlist_empty(struct knlist *knl); >extern void knlist_init(struct knlist *knl, void *lock, > void (*kl_lock)(void *), void (*kl_unlock)(void *), > void (*kl_assert_locked)(void *), void (*kl_assert_unlocked)(void *)); >extern void knlist_init_mtx(struct knlist *knl, struct mtx *lock); >extern void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock); >extern void knlist_destroy(struct knlist *knl); >extern void knlist_cleardel(struct knlist *knl, struct thread *td, > int islocked, int killkn); >#define knlist_clear(knl, islocked) \ > knlist_cleardel((knl), NULL, (islocked), 0) >#define knlist_delete(knl, td, islocked) \ > knlist_cleardel((knl), (td), (islocked), 1) >extern void knote_fdclose(struct thread *p, int fd); >extern int kqfd_register(int fd, struct kevent *kev, struct thread *p, > int waitok); >extern int kqueue_add_filteropts(int filt, struct filterops *filtops); >extern int kqueue_del_filteropts(int filt); > >#else /* !_KERNEL */ ># 276 "/usr/src/sys/sys/event.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 277 "/usr/src/sys/sys/event.h" ># 278 "/usr/src/sys/sys/event.h" >struct timespec; > >__BEGIN_DECLS >int kqueue(void); >int kevent(int kq, const struct kevent *changelist, int nchanges, > struct kevent *eventlist, int nevents, > const struct timespec *timeout); >__END_DECLS > >#endif /* !_KERNEL */ ># 288 "/usr/src/sys/sys/event.h" > >#endif /* !_SYS_EVENT_H_ */ ># 290 "/usr/src/sys/sys/event.h" ># 39 "/usr/src/sys/sys/filedesc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/filedesc.h" ># 40 "/usr/src/sys/sys/filedesc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/priority.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/filedesc.h" ># 41 "/usr/src/sys/sys/filedesc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/seq.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/filedesc.h" ># 1 "/usr/src/sys/sys/seq.h" 1 >/*- > * Copyright (c) 2014 Mateusz Guzik <mjg@FreeBSD.org> > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/seq.h 274048 2014-11-03 13:14:34Z mjg $ > */ > >#ifndef _SYS_SEQ_H_ >#define _SYS_SEQ_H_ > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/systm.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/seq.h" ># 33 "/usr/src/sys/sys/seq.h" >#endif ># 34 "/usr/src/sys/sys/seq.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/sys/sys/seq.h" ># 35 "/usr/src/sys/sys/seq.h" > >/* > * seq_t may be included in structs visible to userspace > */ >typedef uint32_t seq_t; > >#ifdef _KERNEL > >/* > * Typical usage: > * > * writers: > * lock_exclusive(&obj->lock); > * seq_write_begin(&obj->seq); > * ..... > * seq_write_end(&obj->seq); > * unlock_exclusive(&obj->unlock); > * > * readers: > * obj_t lobj; > * seq_t seq; > * > * for (;;) { > * seq = seq_read(&gobj->seq); > * lobj = gobj; > * if (seq_consistent(&gobj->seq, seq)) > * break; > * cpu_spinwait(); > * } > * foo(lobj); > */ > >/* A hack to get MPASS macro */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 68 "/usr/src/sys/sys/seq.h" ># 69 "/usr/src/sys/sys/seq.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpu.h> >#endif /* expanded by -frewrite-includes */ ># 70 "/usr/src/sys/sys/seq.h" ># 1 "./machine/cpu.h" 1 >/*- > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 > * $FreeBSD: head/sys/amd64/include/cpu.h 267526 2014-06-16 08:43:03Z royger $ > */ > >#ifndef _MACHINE_CPU_H_ >#define _MACHINE_CPU_H_ > >/* > * Definitions unique to i386 cpu support. > */ >#if 0 /* expanded by -frewrite-includes */ >#include <machine/psl.h> >#endif /* expanded by -frewrite-includes */ ># 42 "./machine/cpu.h" ># 1 "./machine/psl.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/psl.h 233204 2012-03-19 21:29:57Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/psl.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/psl.h" ># 1 "./x86/psl.h" 1 >/*- > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)psl.h 5.2 (Berkeley) 1/18/91 > * $FreeBSD: head/sys/x86/include/psl.h 258135 2013-11-14 15:37:20Z emaste $ > */ > >#ifndef _MACHINE_PSL_H_ >#define _MACHINE_PSL_H_ > >/* > * 386 processor status longword. > */ >#define PSL_C 0x00000001 /* carry bit */ >#define PSL_PF 0x00000004 /* parity bit */ >#define PSL_AF 0x00000010 /* bcd carry bit */ >#define PSL_Z 0x00000040 /* zero bit */ >#define PSL_N 0x00000080 /* negative bit */ >#define PSL_T 0x00000100 /* trace enable bit */ >#define PSL_I 0x00000200 /* interrupt enable bit */ >#define PSL_D 0x00000400 /* string instruction direction bit */ >#define PSL_V 0x00000800 /* overflow bit */ >#define PSL_IOPL 0x00003000 /* i/o privilege level */ >#define PSL_NT 0x00004000 /* nested task bit */ >#define PSL_RF 0x00010000 /* resume flag bit */ >#define PSL_VM 0x00020000 /* virtual 8086 mode bit */ >#define PSL_AC 0x00040000 /* alignment checking */ >#define PSL_VIF 0x00080000 /* virtual interrupt enable */ >#define PSL_VIP 0x00100000 /* virtual interrupt pending */ >#define PSL_ID 0x00200000 /* identification bit */ > >/* > * The i486 manual says that we are not supposed to change reserved flags, > * but this is too much trouble since the reserved flags depend on the cpu > * and setting them to their historical values works in practice. > */ >#define PSL_RESERVED_DEFAULT 0x00000002 > >/* > * Initial flags for kernel and user mode. The kernel later inherits > * PSL_I and some other flags from user mode. > */ >#define PSL_KERNEL PSL_RESERVED_DEFAULT >#define PSL_USER (PSL_RESERVED_DEFAULT | PSL_I) > >/* > * Bits that can be changed in user mode on 486's. We allow these bits > * to be changed using ptrace(), sigreturn() and procfs. Setting PS_NT > * is undesirable but it may as well be allowed since users can inflict > * it on the kernel directly. Changes to PSL_AC are silently ignored on > * 386's. > * > * Users are allowed to change the privileged flag PSL_RF. The cpu sets PSL_RF > * in tf_eflags for faults. Debuggers should sometimes set it there too. > * tf_eflags is kept in the signal context during signal handling and there is > * no other place to remember it, so the PSL_RF bit may be corrupted by the > * signal handler without us knowing. Corruption of the PSL_RF bit at worst > * causes one more or one less debugger trap, so allowing it is fairly > * harmless. > */ >#define PSL_USERCHANGE (PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | PSL_T \ > | PSL_D | PSL_V | PSL_NT | PSL_RF | PSL_AC | PSL_ID) > >#endif /* !_MACHINE_PSL_H_ */ ># 93 "./x86/psl.h" ># 7 "./machine/psl.h" 2 ># 43 "./machine/cpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/frame.h> >#endif /* expanded by -frewrite-includes */ ># 43 "./machine/cpu.h" ># 1 "./machine/frame.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/frame.h 247047 2013-02-20 17:39:52Z kib $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/frame.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/frame.h" ># 1 "./x86/frame.h" 1 >/*- > * Copyright (c) 2003 Peter Wemm. > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 > * $FreeBSD: head/sys/x86/include/frame.h 247047 2013-02-20 17:39:52Z kib $ > */ > >#ifndef _MACHINE_FRAME_H_ >#define _MACHINE_FRAME_H_ 1 > >/* > * System stack frames. > */ > >#ifdef __i386__ >/* > * Exception/Trap Stack Frame > */ > >struct trapframe { > int tf_fs; > int tf_es; > int tf_ds; > int tf_edi; > int tf_esi; > int tf_ebp; > int tf_isp; > int tf_ebx; > int tf_edx; > int tf_ecx; > int tf_eax; > int tf_trapno; > /* below portion defined in 386 hardware */ > int tf_err; > int tf_eip; > int tf_cs; > int tf_eflags; > /* below only when crossing rings (e.g. user to kernel) */ > int tf_esp; > int tf_ss; >}; > >/* Superset of trap frame, for traps from virtual-8086 mode */ > >struct trapframe_vm86 { > int tf_fs; > int tf_es; > int tf_ds; > int tf_edi; > int tf_esi; > int tf_ebp; > int tf_isp; > int tf_ebx; > int tf_edx; > int tf_ecx; > int tf_eax; > int tf_trapno; > /* below portion defined in 386 hardware */ > int tf_err; > int tf_eip; > int tf_cs; > int tf_eflags; > /* below only when crossing rings (e.g. user to kernel) */ > int tf_esp; > int tf_ss; > /* below only when switching out of VM86 mode */ > int tf_vm86_es; > int tf_vm86_ds; > int tf_vm86_fs; > int tf_vm86_gs; >}; >#endif /* __i386__ */ ># 102 "./x86/frame.h" > >#ifdef __amd64__ >/* > * Exception/Trap Stack Frame > * > * The ordering of this is specifically so that we can take first 6 > * the syscall arguments directly from the beginning of the frame. > */ > >struct trapframe { > register_t tf_rdi; > register_t tf_rsi; > register_t tf_rdx; > register_t tf_rcx; > register_t tf_r8; > register_t tf_r9; > register_t tf_rax; > register_t tf_rbx; > register_t tf_rbp; > register_t tf_r10; > register_t tf_r11; > register_t tf_r12; > register_t tf_r13; > register_t tf_r14; > register_t tf_r15; > uint32_t tf_trapno; > uint16_t tf_fs; > uint16_t tf_gs; > register_t tf_addr; > uint32_t tf_flags; > uint16_t tf_es; > uint16_t tf_ds; > /* below portion defined in hardware */ > register_t tf_err; > register_t tf_rip; > register_t tf_cs; > register_t tf_rflags; > register_t tf_rsp; > register_t tf_ss; >}; > >#define TF_HASSEGS 0x1 >#define TF_HASBASES 0x2 >#define TF_HASFPXSTATE 0x4 >#endif /* __amd64__ */ ># 147 "./x86/frame.h" > >#endif /* _MACHINE_FRAME_H_ */ ># 149 "./x86/frame.h" ># 7 "./machine/frame.h" 2 ># 44 "./machine/cpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/segments.h> >#endif /* expanded by -frewrite-includes */ ># 44 "./machine/cpu.h" ># 1 "./machine/segments.h" 1 >/*- > * Copyright (c) 1989, 1990 William F. Jolitz > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 > * $FreeBSD: head/sys/amd64/include/segments.h 258660 2013-11-26 19:38:42Z kib $ > */ > >#ifndef _MACHINE_SEGMENTS_H_ >#define _MACHINE_SEGMENTS_H_ > >/* > * AMD64 Segmentation Data Structures and definitions > */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/segments.h> >#endif /* expanded by -frewrite-includes */ ># 44 "./machine/segments.h" ># 1 "./x86/segments.h" 1 >/*- > * Copyright (c) 1989, 1990 William F. Jolitz > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 > * $FreeBSD: head/sys/x86/include/segments.h 268351 2014-07-07 00:27:09Z marcel $ > */ > >#ifndef _X86_SEGMENTS_H_ >#define _X86_SEGMENTS_H_ > >/* > * X86 Segmentation Data Structures and definitions > */ > >/* > * Selectors > */ >#define SEL_RPL_MASK 3 /* requester priv level */ >#define ISPL(s) ((s)&3) /* priority level of a selector */ >#ifdef XEN >#define SEL_KPL 1 /* kernel priority level */ >#else ># 52 "./x86/segments.h" >#define SEL_KPL 0 /* kernel priority level */ >#endif ># 54 "./x86/segments.h" >#define SEL_UPL 3 /* user priority level */ >#define ISLDT(s) ((s)&SEL_LDT) /* is it local or global */ >#define SEL_LDT 4 /* local descriptor table */ >#define IDXSEL(s) (((s)>>3) & 0x1fff) /* index of selector */ >#define LSEL(s,r) (((s)<<3) | SEL_LDT | r) /* a local selector */ >#define GSEL(s,r) (((s)<<3) | r) /* a global selector */ > >/* > * User segment descriptors (%cs, %ds etc for i386 apps. 64 bit wide) > * For long-mode apps, %cs only has the conforming bit in sd_type, the sd_dpl, > * sd_p, sd_l and sd_def32 which must be zero). %ds only has sd_p. > */ >struct segment_descriptor { > unsigned sd_lolimit:16; /* segment extent (lsb) */ > unsigned sd_lobase:24; /* segment base address (lsb) */ > unsigned sd_type:5; /* segment type */ > unsigned sd_dpl:2; /* segment descriptor priority level */ > unsigned sd_p:1; /* segment descriptor present */ > unsigned sd_hilimit:4; /* segment extent (msb) */ > unsigned sd_xx:2; /* unused */ > unsigned sd_def32:1; /* default 32 vs 16 bit size */ > unsigned sd_gran:1; /* limit granularity (byte/page units)*/ > unsigned sd_hibase:8; /* segment base address (msb) */ >} __packed; > >struct user_segment_descriptor { > unsigned sd_lolimit:16; /* segment extent (lsb) */ > unsigned sd_lobase:24; /* segment base address (lsb) */ > unsigned sd_type:5; /* segment type */ > unsigned sd_dpl:2; /* segment descriptor priority level */ > unsigned sd_p:1; /* segment descriptor present */ > unsigned sd_hilimit:4; /* segment extent (msb) */ > unsigned sd_xx:1; /* unused */ > unsigned sd_long:1; /* long mode (cs only) */ > unsigned sd_def32:1; /* default 32 vs 16 bit size */ > unsigned sd_gran:1; /* limit granularity (byte/page units)*/ > unsigned sd_hibase:8; /* segment base address (msb) */ >} __packed; > >#define USD_GETBASE(sd) (((sd)->sd_lobase) | (sd)->sd_hibase << 24) >#define USD_SETBASE(sd, b) (sd)->sd_lobase = (b); \ > (sd)->sd_hibase = ((b) >> 24); >#define USD_GETLIMIT(sd) (((sd)->sd_lolimit) | (sd)->sd_hilimit << 16) >#define USD_SETLIMIT(sd, l) (sd)->sd_lolimit = (l); \ > (sd)->sd_hilimit = ((l) >> 16); > >#ifdef __i386__ >/* > * Gate descriptors (e.g. indirect descriptors) > */ >struct gate_descriptor { > unsigned gd_looffset:16; /* gate offset (lsb) */ > unsigned gd_selector:16; /* gate segment selector */ > unsigned gd_stkcpy:5; /* number of stack wds to cpy */ > unsigned gd_xx:3; /* unused */ > unsigned gd_type:5; /* segment type */ > unsigned gd_dpl:2; /* segment descriptor priority level */ > unsigned gd_p:1; /* segment descriptor present */ > unsigned gd_hioffset:16; /* gate offset (msb) */ >} __packed; > >/* > * Generic descriptor > */ >union descriptor { > struct segment_descriptor sd; > struct gate_descriptor gd; >}; >#else ># 123 "./x86/segments.h" >/* > * Gate descriptors (e.g. indirect descriptors, trap, interrupt etc. 128 bit) > * Only interrupt and trap gates have gd_ist. > */ >struct gate_descriptor { > uint64_t gd_looffset:16; /* gate offset (lsb) */ > uint64_t gd_selector:16; /* gate segment selector */ > uint64_t gd_ist:3; /* IST table index */ > uint64_t gd_xx:5; /* unused */ > uint64_t gd_type:5; /* segment type */ > uint64_t gd_dpl:2; /* segment descriptor priority level */ > uint64_t gd_p:1; /* segment descriptor present */ > uint64_t gd_hioffset:48; /* gate offset (msb) */ > uint64_t sd_xx1:32; >} __packed; > >/* > * Generic descriptor > */ >union descriptor { > struct user_segment_descriptor sd; > struct gate_descriptor gd; >}; >#endif ># 147 "./x86/segments.h" > > /* system segments and gate types */ >#define SDT_SYSNULL 0 /* system null */ >#define SDT_SYS286TSS 1 /* system 286 TSS available */ >#define SDT_SYSLDT 2 /* system local descriptor table */ >#define SDT_SYS286BSY 3 /* system 286 TSS busy */ >#define SDT_SYS286CGT 4 /* system 286 call gate */ >#define SDT_SYSTASKGT 5 /* system task gate */ >#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ >#define SDT_SYS286TGT 7 /* system 286 trap gate */ >#define SDT_SYSNULL2 8 /* system null again */ >#define SDT_SYS386TSS 9 /* system 386 TSS available */ >#define SDT_SYSTSS 9 /* system available 64 bit TSS */ >#define SDT_SYSNULL3 10 /* system null again */ >#define SDT_SYS386BSY 11 /* system 386 TSS busy */ >#define SDT_SYSBSY 11 /* system busy 64 bit TSS */ >#define SDT_SYS386CGT 12 /* system 386 call gate */ >#define SDT_SYSCGT 12 /* system 64 bit call gate */ >#define SDT_SYSNULL4 13 /* system null again */ >#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ >#define SDT_SYSIGT 14 /* system 64 bit interrupt gate */ >#define SDT_SYS386TGT 15 /* system 386 trap gate */ >#define SDT_SYSTGT 15 /* system 64 bit trap gate */ > > /* memory segment types */ >#define SDT_MEMRO 16 /* memory read only */ >#define SDT_MEMROA 17 /* memory read only accessed */ >#define SDT_MEMRW 18 /* memory read write */ >#define SDT_MEMRWA 19 /* memory read write accessed */ >#define SDT_MEMROD 20 /* memory read only expand dwn limit */ >#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ >#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ >#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed*/ >#define SDT_MEME 24 /* memory execute only */ >#define SDT_MEMEA 25 /* memory execute only accessed */ >#define SDT_MEMER 26 /* memory execute read */ >#define SDT_MEMERA 27 /* memory execute read accessed */ >#define SDT_MEMEC 28 /* memory execute only conforming */ >#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ >#define SDT_MEMERC 30 /* memory execute read conforming */ >#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ > >/* > * Size of IDT table > */ >#define NIDT 256 /* 32 reserved, 0x80 syscall, most are h/w */ >#define NRSVIDT 32 /* reserved entries for cpu exceptions */ > >/* > * Entries in the Interrupt Descriptor Table (IDT) > */ >#define IDT_DE 0 /* #DE: Divide Error */ >#define IDT_DB 1 /* #DB: Debug */ >#define IDT_NMI 2 /* Nonmaskable External Interrupt */ >#define IDT_BP 3 /* #BP: Breakpoint */ >#define IDT_OF 4 /* #OF: Overflow */ >#define IDT_BR 5 /* #BR: Bound Range Exceeded */ >#define IDT_UD 6 /* #UD: Undefined/Invalid Opcode */ >#define IDT_NM 7 /* #NM: No Math Coprocessor */ >#define IDT_DF 8 /* #DF: Double Fault */ >#define IDT_FPUGP 9 /* Coprocessor Segment Overrun */ >#define IDT_TS 10 /* #TS: Invalid TSS */ >#define IDT_NP 11 /* #NP: Segment Not Present */ >#define IDT_SS 12 /* #SS: Stack Segment Fault */ >#define IDT_GP 13 /* #GP: General Protection Fault */ >#define IDT_PF 14 /* #PF: Page Fault */ >#define IDT_MF 16 /* #MF: FPU Floating-Point Error */ >#define IDT_AC 17 /* #AC: Alignment Check */ >#define IDT_MC 18 /* #MC: Machine Check */ >#define IDT_XF 19 /* #XF: SIMD Floating-Point Exception */ >#define IDT_IO_INTS NRSVIDT /* Base of IDT entries for I/O interrupts. */ >#define IDT_SYSCALL 0x80 /* System Call Interrupt Vector */ >#define IDT_DTRACE_RET 0x92 /* DTrace pid provider Interrupt Vector */ >#define IDT_EVTCHN 0x93 /* Xen HVM Event Channel Interrupt Vector */ > >#if defined(__i386__) >/* > * Entries in the Global Descriptor Table (GDT) > * Note that each 4 entries share a single 32 byte L1 cache line. > * Some of the fast syscall instructions require a specific order here. > */ >#define GNULL_SEL 0 /* Null Descriptor */ >#define GPRIV_SEL 1 /* SMP Per-Processor Private Data */ >#define GUFS_SEL 2 /* User %fs Descriptor (order critical: 1) */ >#define GUGS_SEL 3 /* User %gs Descriptor (order critical: 2) */ >#define GCODE_SEL 4 /* Kernel Code Descriptor (order critical: 1) */ >#define GDATA_SEL 5 /* Kernel Data Descriptor (order critical: 2) */ >#define GUCODE_SEL 6 /* User Code Descriptor (order critical: 3) */ >#define GUDATA_SEL 7 /* User Data Descriptor (order critical: 4) */ >#define GBIOSLOWMEM_SEL 8 /* BIOS low memory access (must be entry 8) */ >#define GPROC0_SEL 9 /* Task state process slot zero and up */ >#define GLDT_SEL 10 /* Default User LDT */ >#define GUSERLDT_SEL 11 /* User LDT */ >#define GPANIC_SEL 12 /* Task state to consider panic from */ >#define GBIOSCODE32_SEL 13 /* BIOS interface (32bit Code) */ >#define GBIOSCODE16_SEL 14 /* BIOS interface (16bit Code) */ >#define GBIOSDATA_SEL 15 /* BIOS interface (Data) */ >#define GBIOSUTIL_SEL 16 /* BIOS interface (Utility) */ >#define GBIOSARGS_SEL 17 /* BIOS interface (Arguments) */ >#define GNDIS_SEL 18 /* For the NDIS layer */ >#ifdef XEN >#define NGDT 9 >#else ># 250 "./x86/segments.h" >#define NGDT 19 >#endif ># 252 "./x86/segments.h" > >/* > * Entries in the Local Descriptor Table (LDT) > */ >#define LSYS5CALLS_SEL 0 /* forced by intel BCS */ >#define LSYS5SIGR_SEL 1 >#define L43BSDCALLS_SEL 2 /* notyet */ >#define LUCODE_SEL 3 >#define LSOL26CALLS_SEL 4 /* Solaris >= 2.6 system call gate */ >#define LUDATA_SEL 5 >/* separate stack, es,fs,gs sels ? */ >/* #define LPOSIXCALLS_SEL 5*/ /* notyet */ >#define LBSDICALLS_SEL 16 /* BSDI system call gate */ >#define NLDT (LBSDICALLS_SEL + 1) > >#else /* !__i386__ */ ># 268 "./x86/segments.h" >/* > * Entries in the Global Descriptor Table (GDT) > */ >#define GNULL_SEL 0 /* Null Descriptor */ >#define GNULL2_SEL 1 /* Null Descriptor */ >#define GUFS32_SEL 2 /* User 32 bit %fs Descriptor */ >#define GUGS32_SEL 3 /* User 32 bit %gs Descriptor */ >#define GCODE_SEL 4 /* Kernel Code Descriptor */ >#define GDATA_SEL 5 /* Kernel Data Descriptor */ >#define GUCODE32_SEL 6 /* User 32 bit code Descriptor */ >#define GUDATA_SEL 7 /* User 32/64 bit Data Descriptor */ >#define GUCODE_SEL 8 /* User 64 bit Code Descriptor */ >#define GPROC0_SEL 9 /* TSS for entering kernel etc */ >/* slot 10 is second half of GPROC0_SEL */ >#define GUSERLDT_SEL 11 /* LDT */ >/* slot 12 is second half of GUSERLDT_SEL */ >#define NGDT 13 >#endif /* __i386__ */ ># 286 "./x86/segments.h" > >#endif /* !_X86_SEGMENTS_H_ */ ># 288 "./x86/segments.h" ># 45 "./machine/segments.h" 2 > >/* > * System segment descriptors (128 bit wide) > */ >struct system_segment_descriptor { > u_int64_t sd_lolimit:16; /* segment extent (lsb) */ > u_int64_t sd_lobase:24; /* segment base address (lsb) */ > u_int64_t sd_type:5; /* segment type */ > u_int64_t sd_dpl:2; /* segment descriptor priority level */ > u_int64_t sd_p:1; /* segment descriptor present */ > u_int64_t sd_hilimit:4; /* segment extent (msb) */ > u_int64_t sd_xx0:3; /* unused */ > u_int64_t sd_gran:1; /* limit granularity (byte/page units)*/ > u_int64_t sd_hibase:40 __packed;/* segment base address (msb) */ > u_int64_t sd_xx1:8; > u_int64_t sd_mbz:5; /* MUST be zero */ > u_int64_t sd_xx2:19; >} __packed; > >/* > * Software definitions are in this convenient format, > * which are translated into inconvenient segment descriptors > * when needed to be used by the 386 hardware > */ > >struct soft_segment_descriptor { > unsigned long ssd_base; /* segment base address */ > unsigned long ssd_limit; /* segment extent */ > unsigned long ssd_type:5; /* segment type */ > unsigned long ssd_dpl:2; /* segment descriptor priority level */ > unsigned long ssd_p:1; /* segment descriptor present */ > unsigned long ssd_long:1; /* long mode (for %cs) */ > unsigned long ssd_def32:1; /* default 32 vs 16 bit size */ > unsigned long ssd_gran:1; /* limit granularity (byte/page units)*/ >} __packed; > >/* > * region descriptors, used to load gdt/idt tables before segments yet exist. > */ >struct region_descriptor { > uint64_t rd_limit:16; /* segment extent */ > uint64_t rd_base:64 __packed; /* base address */ >} __packed; > >#ifdef _KERNEL >extern struct user_segment_descriptor gdt[]; >extern struct soft_segment_descriptor gdt_segs[]; >extern struct gate_descriptor *idt; >extern struct region_descriptor r_gdt, r_idt; > >void lgdt(struct region_descriptor *rdp); >void sdtossd(struct user_segment_descriptor *sdp, > struct soft_segment_descriptor *ssdp); >void ssdtosd(struct soft_segment_descriptor *ssdp, > struct user_segment_descriptor *sdp); >void ssdtosyssd(struct soft_segment_descriptor *ssdp, > struct system_segment_descriptor *sdp); >void update_gdt_gsbase(struct thread *td, uint32_t base); >void update_gdt_fsbase(struct thread *td, uint32_t base); >#endif /* _KERNEL */ ># 105 "./machine/segments.h" > >#endif /* !_MACHINE_SEGMENTS_H_ */ ># 107 "./machine/segments.h" ># 45 "./machine/cpu.h" 2 > >#define cpu_exec(p) /* nothing */ >#define cpu_swapin(p) /* nothing */ >#define cpu_getstack(td) ((td)->td_frame->tf_rsp) >#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap)) >#define cpu_spinwait() ia32_pause() > >#define TRAPF_USERMODE(framep) \ > (ISPL((framep)->tf_cs) == SEL_UPL) >#define TRAPF_PC(framep) ((framep)->tf_rip) > >#ifdef _KERNEL >/* > * Struct containing pointers to CPU management functions whose > * implementation is run time selectable. Selection can be made, > * for example, based on detection of a particular CPU variant or > * hypervisor environment. > */ >struct cpu_ops { > void (*cpu_init)(void); > void (*cpu_resume)(void); >}; > >extern struct cpu_ops cpu_ops; >extern char btext[]; >extern char etext[]; > >/* Resume hook for VMM. */ >extern void (*vmm_resume_p)(void); > >void cpu_halt(void); >void cpu_reset(void); >void fork_trampoline(void); >void swi_vm(void *); > >/* > * Return contents of in-cpu fast counter as a sort of "bogo-time" > * for random-harvesting purposes. > */ >static __inline u_int64_t >get_cyclecount(void) >{ > > return (rdtsc()); >} > >#endif ># 92 "./machine/cpu.h" > >#endif /* !_MACHINE_CPU_H_ */ ># 94 "./machine/cpu.h" ># 71 "/usr/src/sys/sys/seq.h" 2 > >/* > * Stuff below is going away when we gain suitable memory barriers. > * > * atomic_load_acq_int at least on amd64 provides a full memory barrier, > * in a way which affects performance. > * > * Hack below covers all architectures and avoids most of the penalty at least > * on amd64 but still has unnecessary cost. > */ >static __inline int >atomic_load_rmb_int(volatile u_int *p) >{ > volatile u_int v; > > v = *p; > atomic_load_acq_int(&v); > return (v); >} > >static __inline int >atomic_rmb_load_int(volatile u_int *p) >{ > volatile u_int v = 0; > > atomic_load_acq_int(&v); > v = *p; > return (v); >} > >static __inline bool >seq_in_modify(seq_t seqp) >{ > > return (seqp & 1); >} > >static __inline void >seq_write_begin(seq_t *seqp) >{ > > MPASS(!seq_in_modify(*seqp)); > atomic_add_acq_int(seqp, 1); >} > >static __inline void >seq_write_end(seq_t *seqp) >{ > > atomic_add_rel_int(seqp, 1); > MPASS(!seq_in_modify(*seqp)); >} > >static __inline seq_t >seq_read(seq_t *seqp) >{ > seq_t ret; > > for (;;) { > ret = atomic_load_rmb_int(seqp); > if (seq_in_modify(ret)) { > cpu_spinwait(); > continue; > } > break; > } > > return (ret); >} > >static __inline seq_t >seq_consistent(seq_t *seqp, seq_t oldseq) >{ > > return (atomic_rmb_load_int(seqp) == oldseq); >} > >static __inline seq_t >seq_consistent_nomb(seq_t *seqp, seq_t oldseq) >{ > > return (*seqp == oldseq); >} > >#endif /* _KERNEL */ ># 156 "/usr/src/sys/sys/seq.h" >#endif /* _SYS_SEQ_H_ */ ># 157 "/usr/src/sys/sys/seq.h" ># 42 "/usr/src/sys/sys/filedesc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sx.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/filedesc.h" ># 1 "/usr/src/sys/sys/sx.h" 1 >/*- > * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> > * Copyright (c) 2001 Jason Evans <jasone@freebsd.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice(s), this list of conditions and the following disclaimer as > * the first lines of this file unmodified other than the possible > * addition of one or more copyright notices. > * 2. Redistributions in binary form must reproduce the above copyright > * notice(s), this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > * DAMAGE. > * > * $FreeBSD: head/sys/sys/sx.h 275751 2014-12-13 21:00:10Z dchagin $ > */ > >#ifndef _SYS_SX_H_ >#define _SYS_SX_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/sx.h" ># 36 "/usr/src/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sx.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/sx.h" ># 37 "/usr/src/sys/sys/sx.h" > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/sx.h" ># 40 "/usr/src/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock_profile.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/sx.h" ># 41 "/usr/src/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lockstat.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/sx.h" ># 42 "/usr/src/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/sx.h" ># 43 "/usr/src/sys/sys/sx.h" >#endif ># 44 "/usr/src/sys/sys/sx.h" > >/* > * In general, the sx locks and rwlocks use very similar algorithms. > * The main difference in the implementations is how threads are > * blocked when a lock is unavailable. For this, sx locks use sleep > * queues which do not support priority propagation, and rwlocks use > * turnstiles which do. > * > * The sx_lock field consists of several fields. The low bit > * indicates if the lock is locked with a shared or exclusive lock. A > * value of 0 indicates an exclusive lock, and a value of 1 indicates > * a shared lock. Bit 1 is a boolean indicating if there are any > * threads waiting for a shared lock. Bit 2 is a boolean indicating > * if there are any threads waiting for an exclusive lock. Bit 3 is a > * boolean indicating if an exclusive lock is recursively held. The > * rest of the variable's definition is dependent on the value of the > * first bit. For an exclusive lock, it is a pointer to the thread > * holding the lock, similar to the mtx_lock field of mutexes. For > * shared locks, it is a count of read locks that are held. > * > * When the lock is not locked by any thread, it is encoded as a > * shared lock with zero waiters. > */ > >#define SX_LOCK_SHARED 0x01 >#define SX_LOCK_SHARED_WAITERS 0x02 >#define SX_LOCK_EXCLUSIVE_WAITERS 0x04 >#define SX_LOCK_RECURSED 0x08 >#define SX_LOCK_FLAGMASK \ > (SX_LOCK_SHARED | SX_LOCK_SHARED_WAITERS | \ > SX_LOCK_EXCLUSIVE_WAITERS | SX_LOCK_RECURSED) > >#define SX_OWNER(x) ((x) & ~SX_LOCK_FLAGMASK) >#define SX_SHARERS_SHIFT 4 >#define SX_SHARERS(x) (SX_OWNER(x) >> SX_SHARERS_SHIFT) >#define SX_SHARERS_LOCK(x) \ > ((x) << SX_SHARERS_SHIFT | SX_LOCK_SHARED) >#define SX_ONE_SHARER (1 << SX_SHARERS_SHIFT) > >#define SX_LOCK_UNLOCKED SX_SHARERS_LOCK(0) >#define SX_LOCK_DESTROYED \ > (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS) > >#ifdef _KERNEL > >#define sx_recurse lock_object.lo_data > >/* > * Function prototipes. Routines that start with an underscore are not part > * of the public interface and are wrappered with a macro. > */ >void sx_sysinit(void *arg); >#define sx_init(sx, desc) sx_init_flags((sx), (desc), 0) >void sx_init_flags(struct sx *sx, const char *description, int opts); >void sx_destroy(struct sx *sx); >int sx_try_slock_(struct sx *sx, const char *file, int line); >int sx_try_xlock_(struct sx *sx, const char *file, int line); >int sx_try_upgrade_(struct sx *sx, const char *file, int line); >void sx_downgrade_(struct sx *sx, const char *file, int line); >int _sx_slock(struct sx *sx, int opts, const char *file, int line); >int _sx_xlock(struct sx *sx, int opts, const char *file, int line); >void _sx_sunlock(struct sx *sx, const char *file, int line); >void _sx_xunlock(struct sx *sx, const char *file, int line); >int _sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, > const char *file, int line); >int _sx_slock_hard(struct sx *sx, int opts, const char *file, int line); >void _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int > line); >void _sx_sunlock_hard(struct sx *sx, const char *file, int line); >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >void _sx_assert(const struct sx *sx, int what, const char *file, int line); >#endif ># 116 "/usr/src/sys/sys/sx.h" >#ifdef DDB >int sx_chain(struct thread *td, struct thread **ownerp); >#endif ># 119 "/usr/src/sys/sys/sx.h" > >struct sx_args { > struct sx *sa_sx; > const char *sa_desc; > int sa_flags; >}; > >#define SX_SYSINIT_FLAGS(name, sxa, desc, flags) \ > static struct sx_args name##_args = { \ > (sxa), \ > (desc), \ > (flags) \ > }; \ > SYSINIT(name##_sx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > sx_sysinit, &name##_args); \ > SYSUNINIT(name##_sx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > sx_destroy, (sxa)) > >#define SX_SYSINIT(name, sxa, desc) SX_SYSINIT_FLAGS(name, sxa, desc, 0) > >/* > * Full lock operations that are suitable to be inlined in non-debug kernels. > * If the lock can't be acquired or released trivially then the work is > * deferred to 'tougher' functions. > */ > >/* Acquire an exclusive lock. */ >static __inline int >__sx_xlock(struct sx *sx, struct thread *td, int opts, const char *file, > int line) >{ > uintptr_t tid = (uintptr_t)td; > int error = 0; > > if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) > error = _sx_xlock_hard(sx, tid, opts, file, line); > else > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_XLOCK_ACQUIRE, > sx, 0, 0, file, line); > > return (error); >} > >/* Release an exclusive lock. */ >static __inline void >__sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) >{ > uintptr_t tid = (uintptr_t)td; > > if (sx->sx_recurse == 0) > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_SX_XUNLOCK_RELEASE, sx); > if (!atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED)) > _sx_xunlock_hard(sx, tid, file, line); >} > >/* Acquire a shared lock. */ >static __inline int >__sx_slock(struct sx *sx, int opts, const char *file, int line) >{ > uintptr_t x = sx->sx_lock; > int error = 0; > > if (!(x & SX_LOCK_SHARED) || > !atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER)) > error = _sx_slock_hard(sx, opts, file, line); > else > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_SLOCK_ACQUIRE, sx, 0, > 0, file, line); > > return (error); >} > >/* > * Release a shared lock. We can just drop a single shared lock so > * long as we aren't trying to drop the last shared lock when other > * threads are waiting for an exclusive lock. This takes advantage of > * the fact that an unlocked lock is encoded as a shared lock with a > * count of 0. > */ >static __inline void >__sx_sunlock(struct sx *sx, const char *file, int line) >{ > uintptr_t x = sx->sx_lock; > > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_SX_SUNLOCK_RELEASE, sx); > if (x == (SX_SHARERS_LOCK(1) | SX_LOCK_EXCLUSIVE_WAITERS) || > !atomic_cmpset_rel_ptr(&sx->sx_lock, x, x - SX_ONE_SHARER)) > _sx_sunlock_hard(sx, file, line); >} > >/* > * Public interface for lock operations. > */ >#ifndef LOCK_DEBUG >#error "LOCK_DEBUG not defined, include <sys/lock.h> before <sys/sx.h>" >#endif ># 215 "/usr/src/sys/sys/sx.h" >#if (LOCK_DEBUG > 0) || defined(SX_NOINLINE) >#define sx_xlock_(sx, file, line) \ > (void)_sx_xlock((sx), 0, (file), (line)) >#define sx_xlock_sig_(sx, file, line) \ > _sx_xlock((sx), SX_INTERRUPTIBLE, (file), (line)) >#define sx_xunlock_(sx, file, line) \ > _sx_xunlock((sx), (file), (line)) >#define sx_slock_(sx, file, line) \ > (void)_sx_slock((sx), 0, (file), (line)) >#define sx_slock_sig_(sx, file, line) \ > _sx_slock((sx), SX_INTERRUPTIBLE, (file) , (line)) >#define sx_sunlock_(sx, file, line) \ > _sx_sunlock((sx), (file), (line)) >#else ># 229 "/usr/src/sys/sys/sx.h" >#define sx_xlock_(sx, file, line) \ > (void)__sx_xlock((sx), curthread, 0, (file), (line)) >#define sx_xlock_sig_(sx, file, line) \ > __sx_xlock((sx), curthread, SX_INTERRUPTIBLE, (file), (line)) >#define sx_xunlock_(sx, file, line) \ > __sx_xunlock((sx), curthread, (file), (line)) >#define sx_slock_(sx, file, line) \ > (void)__sx_slock((sx), 0, (file), (line)) >#define sx_slock_sig_(sx, file, line) \ > __sx_slock((sx), SX_INTERRUPTIBLE, (file), (line)) >#define sx_sunlock_(sx, file, line) \ > __sx_sunlock((sx), (file), (line)) >#endif /* LOCK_DEBUG > 0 || SX_NOINLINE */ ># 242 "/usr/src/sys/sys/sx.h" >#define sx_try_slock(sx) sx_try_slock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_try_xlock(sx) sx_try_xlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_try_upgrade(sx) sx_try_upgrade_((sx), LOCK_FILE, LOCK_LINE) >#define sx_downgrade(sx) sx_downgrade_((sx), LOCK_FILE, LOCK_LINE) >#ifdef INVARIANTS >#define sx_assert_(sx, what, file, line) \ > _sx_assert((sx), (what), (file), (line)) >#else ># 250 "/usr/src/sys/sys/sx.h" >#define sx_assert_(sx, what, file, line) (void)0 >#endif ># 252 "/usr/src/sys/sys/sx.h" > >#define sx_xlock(sx) sx_xlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_xlock_sig(sx) sx_xlock_sig_((sx), LOCK_FILE, LOCK_LINE) >#define sx_xunlock(sx) sx_xunlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_slock(sx) sx_slock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_slock_sig(sx) sx_slock_sig_((sx), LOCK_FILE, LOCK_LINE) >#define sx_sunlock(sx) sx_sunlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_assert(sx, what) sx_assert_((sx), (what), __FILE__, __LINE__) > >/* > * Return a pointer to the owning thread if the lock is exclusively > * locked. > */ >#define sx_xholder(sx) \ > ((sx)->sx_lock & SX_LOCK_SHARED ? NULL : \ > (struct thread *)SX_OWNER((sx)->sx_lock)) > >#define sx_xlocked(sx) \ > (((sx)->sx_lock & ~(SX_LOCK_FLAGMASK & ~SX_LOCK_SHARED)) == \ > (uintptr_t)curthread) > >#define sx_unlock_(sx, file, line) do { \ > if (sx_xlocked(sx)) \ > sx_xunlock_(sx, file, line); \ > else \ > sx_sunlock_(sx, file, line); \ >} while (0) > >#define sx_unlock(sx) sx_unlock_((sx), LOCK_FILE, LOCK_LINE) > >#define sx_sleep(chan, sx, pri, wmesg, timo) \ > _sleep((chan), &(sx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) > >/* > * Options passed to sx_init_flags(). > */ >#define SX_DUPOK 0x01 >#define SX_NOPROFILE 0x02 >#define SX_NOWITNESS 0x04 >#define SX_QUIET 0x08 >#define SX_NOADAPTIVE 0x10 >#define SX_RECURSE 0x20 >#define SX_NEW 0x40 > >/* > * Options passed to sx_*lock_hard(). > */ >#define SX_INTERRUPTIBLE 0x40 > >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define SA_LOCKED LA_LOCKED >#define SA_SLOCKED LA_SLOCKED >#define SA_XLOCKED LA_XLOCKED >#define SA_UNLOCKED LA_UNLOCKED >#define SA_RECURSED LA_RECURSED >#define SA_NOTRECURSED LA_NOTRECURSED > >/* Backwards compatability. */ >#define SX_LOCKED LA_LOCKED >#define SX_SLOCKED LA_SLOCKED >#define SX_XLOCKED LA_XLOCKED >#define SX_UNLOCKED LA_UNLOCKED >#define SX_RECURSED LA_RECURSED >#define SX_NOTRECURSED LA_NOTRECURSED >#endif ># 318 "/usr/src/sys/sys/sx.h" > >#endif /* _KERNEL */ ># 320 "/usr/src/sys/sys/sx.h" > >#endif /* !_SYS_SX_H_ */ ># 322 "/usr/src/sys/sys/sx.h" ># 43 "/usr/src/sys/sys/filedesc.h" 2 > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_limits.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/filedesc.h" ># 1 "./machine/_limits.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/_limits.h 232262 2012-02-28 18:24:28Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_limits.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_limits.h" ># 1 "./x86/_limits.h" 1 >/*- > * Copyright (c) 1988, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)limits.h 8.3 (Berkeley) 1/4/94 > * $FreeBSD: head/sys/x86/include/_limits.h 235939 2012-05-24 21:44:46Z obrien $ > */ > >#ifndef _MACHINE__LIMITS_H_ >#define _MACHINE__LIMITS_H_ > >/* > * According to ANSI (section 2.2.4.2), the values below must be usable by > * #if preprocessing directives. Additionally, the expression must have the > * same type as would an expression that is an object of the corresponding > * type converted according to the integral promotions. The subtraction for > * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an > * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). > */ > >#define __CHAR_BIT 8 /* number of bits in a char */ > >#define __SCHAR_MAX 0x7f /* max value for a signed char */ >#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ > >#define __UCHAR_MAX 0xff /* max value for an unsigned char */ > >#define __USHRT_MAX 0xffff /* max value for an unsigned short */ >#define __SHRT_MAX 0x7fff /* max value for a short */ >#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */ > >#define __UINT_MAX 0xffffffff /* max value for an unsigned int */ >#define __INT_MAX 0x7fffffff /* max value for an int */ >#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */ > >#ifdef __LP64__ >#define __ULONG_MAX 0xffffffffffffffff /* max for an unsigned long */ >#define __LONG_MAX 0x7fffffffffffffff /* max for a long */ >#define __LONG_MIN (-0x7fffffffffffffff - 1) /* min for a long */ >#else ># 65 "./x86/_limits.h" >#define __ULONG_MAX 0xffffffffUL >#define __LONG_MAX 0x7fffffffL >#define __LONG_MIN (-0x7fffffffL - 1) >#endif ># 69 "./x86/_limits.h" > > /* max value for an unsigned long long */ >#define __ULLONG_MAX 0xffffffffffffffffULL >#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */ >#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ > >#ifdef __LP64__ >#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ >#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ >#define __OFF_MAX __LONG_MAX /* max value for an off_t */ >#define __OFF_MIN __LONG_MIN /* min value for an off_t */ >/* Quads and longs are the same on the amd64. Ensure they stay in sync. */ >#define __UQUAD_MAX __ULONG_MAX /* max value for a uquad_t */ >#define __QUAD_MAX __LONG_MAX /* max value for a quad_t */ >#define __QUAD_MIN __LONG_MIN /* min value for a quad_t */ >#define __LONG_BIT 64 >#else ># 86 "./x86/_limits.h" >#define __SSIZE_MAX __INT_MAX >#define __SIZE_T_MAX __UINT_MAX >#define __OFF_MAX __LLONG_MAX >#define __OFF_MIN __LLONG_MIN >#define __UQUAD_MAX __ULLONG_MAX >#define __QUAD_MAX __LLONG_MAX >#define __QUAD_MIN __LLONG_MIN >#define __LONG_BIT 32 >#endif ># 95 "./x86/_limits.h" > >#define __WORD_BIT 32 > >/* Minimum signal stack size. */ >#define __MINSIGSTKSZ (512 * 4) > >#endif /* !_MACHINE__LIMITS_H_ */ ># 102 "./x86/_limits.h" ># 7 "./machine/_limits.h" 2 ># 45 "/usr/src/sys/sys/filedesc.h" 2 > >struct filecaps { > cap_rights_t fc_rights; /* per-descriptor capability rights */ > u_long *fc_ioctls; /* per-descriptor allowed ioctls */ > int16_t fc_nioctls; /* fc_ioctls array size */ > uint32_t fc_fcntls; /* per-descriptor allowed fcntls */ >}; > >struct filedescent { > struct file *fde_file; /* file structure for open file */ > struct filecaps fde_caps; /* per-descriptor rights */ > uint8_t fde_flags; /* per-process open file flags */ > seq_t fde_seq; /* keep file and caps in sync */ >}; >#define fde_rights fde_caps.fc_rights >#define fde_fcntls fde_caps.fc_fcntls >#define fde_ioctls fde_caps.fc_ioctls >#define fde_nioctls fde_caps.fc_nioctls >#define fde_change_size (offsetof(struct filedescent, fde_seq)) > >struct fdescenttbl { > int fdt_nfiles; /* number of open files allocated */ > struct filedescent fdt_ofiles[0]; /* open files */ >}; >#define fd_seq(fdt, fd) (&(fdt)->fdt_ofiles[(fd)].fde_seq) > >/* > * This structure is used for the management of descriptors. It may be > * shared by multiple processes. > */ >#define NDSLOTTYPE u_long > >struct filedesc { > struct fdescenttbl *fd_files; /* open files table */ > struct vnode *fd_cdir; /* current directory */ > struct vnode *fd_rdir; /* root directory */ > struct vnode *fd_jdir; /* jail root directory */ > NDSLOTTYPE *fd_map; /* bitmap of free fds */ > int fd_lastfile; /* high-water mark of fd_ofiles */ > int fd_freefile; /* approx. next free file */ > u_short fd_cmask; /* mask for file creation */ > u_short fd_refcnt; /* thread reference count */ > u_short fd_holdcnt; /* hold count on structure + mutex */ > struct sx fd_sx; /* protects members of this struct */ > struct kqlist fd_kqlist; /* list of kqueues on this filedesc */ > int fd_holdleaderscount; /* block fdfree() for shared close() */ > int fd_holdleaderswakeup; /* fdfree() needs wakeup */ >}; > >/* > * Structure to keep track of (process leader, struct fildedesc) tuples. > * Each process has a pointer to such a structure when detailed tracking > * is needed, e.g., when rfork(RFPROC | RFMEM) causes a file descriptor > * table to be shared by processes having different "p_leader" pointers > * and thus distinct POSIX style locks. > * > * fdl_refcount and fdl_holdcount are protected by struct filedesc mtx. > */ >struct filedesc_to_leader { > int fdl_refcount; /* references from struct proc */ > int fdl_holdcount; /* temporary hold during closef */ > int fdl_wakeup; /* fdfree() waits on closef() */ > struct proc *fdl_leader; /* owner of POSIX locks */ > /* Circular list: */ > struct filedesc_to_leader *fdl_prev; > struct filedesc_to_leader *fdl_next; >}; >#define fd_nfiles fd_files->fdt_nfiles >#define fd_ofiles fd_files->fdt_ofiles > >/* > * Per-process open flags. > */ >#define UF_EXCLOSE 0x01 /* auto-close on exec */ > >#ifdef _KERNEL > >/* Lock a file descriptor table. */ >#define FILEDESC_LOCK_INIT(fdp) sx_init(&(fdp)->fd_sx, "filedesc structure") >#define FILEDESC_LOCK_DESTROY(fdp) sx_destroy(&(fdp)->fd_sx) >#define FILEDESC_LOCK(fdp) (&(fdp)->fd_sx) >#define FILEDESC_XLOCK(fdp) sx_xlock(&(fdp)->fd_sx) >#define FILEDESC_XUNLOCK(fdp) sx_xunlock(&(fdp)->fd_sx) >#define FILEDESC_SLOCK(fdp) sx_slock(&(fdp)->fd_sx) >#define FILEDESC_SUNLOCK(fdp) sx_sunlock(&(fdp)->fd_sx) > >#define FILEDESC_LOCK_ASSERT(fdp) sx_assert(&(fdp)->fd_sx, SX_LOCKED | \ > SX_NOTRECURSED) >#define FILEDESC_XLOCK_ASSERT(fdp) sx_assert(&(fdp)->fd_sx, SX_XLOCKED | \ > SX_NOTRECURSED) >#define FILEDESC_UNLOCK_ASSERT(fdp) sx_assert(&(fdp)->fd_sx, SX_UNLOCKED) > >struct thread; > >void filecaps_init(struct filecaps *fcaps); >void filecaps_copy(const struct filecaps *src, struct filecaps *dst); >void filecaps_move(struct filecaps *src, struct filecaps *dst); >void filecaps_free(struct filecaps *fcaps); > >int closef(struct file *fp, struct thread *td); >int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, > int openerror, int *indxp); >int falloc(struct thread *td, struct file **resultfp, int *resultfd, > int flags); >int falloc_noinstall(struct thread *td, struct file **resultfp); >int finstall(struct thread *td, struct file *fp, int *resultfp, int flags, > struct filecaps *fcaps); >int fdalloc(struct thread *td, int minfd, int *result); >int fdallocn(struct thread *td, int minfd, int *fds, int n); >int fdcheckstd(struct thread *td); >void fdclose(struct filedesc *fdp, struct file *fp, int idx, struct thread *td); >void fdcloseexec(struct thread *td); >void fdsetugidsafety(struct thread *td); >struct filedesc *fdcopy(struct filedesc *fdp); >void fdunshare(struct thread *td); >void fdescfree(struct thread *td); >struct filedesc *fdinit(struct filedesc *fdp, bool prepfiles); >struct filedesc *fdshare(struct filedesc *fdp); >struct filedesc_to_leader * > filedesc_to_leader_alloc(struct filedesc_to_leader *old, > struct filedesc *fdp, struct proc *leader); >int getvnode(struct filedesc *fdp, int fd, cap_rights_t *rightsp, > struct file **fpp); >void mountcheckdirs(struct vnode *olddp, struct vnode *newdp); > >/* Return a referenced file from an unlocked descriptor. */ >int fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, > struct file **fpp, seq_t *seqp); > >/* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */ >static __inline struct file * >fget_locked(struct filedesc *fdp, int fd) >{ > > FILEDESC_LOCK_ASSERT(fdp); > > if (fd < 0 || fd > fdp->fd_lastfile) > return (NULL); > > return (fdp->fd_ofiles[fd].fde_file); >} > >static __inline bool >fd_modified(struct filedesc *fdp, int fd, seq_t seq) >{ > > return (!seq_consistent(fd_seq(fdp->fd_files, fd), seq)); >} > >#endif /* _KERNEL */ ># 195 "/usr/src/sys/sys/filedesc.h" > >#endif /* !_SYS_FILEDESC_H_ */ ># 197 "/usr/src/sys/sys/filedesc.h" ># 38 "/usr/src/sys/sys/namei.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/namei.h" ># 39 "/usr/src/sys/sys/namei.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/uio.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/namei.h" ># 1 "/usr/src/sys/sys/uio.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)uio.h 8.5 (Berkeley) 2/22/94 > * $FreeBSD: head/sys/sys/uio.h 255608 2013-09-16 06:25:54Z kib $ > */ > >#ifndef _SYS_UIO_H_ >#define _SYS_UIO_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/uio.h" ># 37 "/usr/src/sys/sys/uio.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/uio.h" ># 38 "/usr/src/sys/sys/uio.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_iovec.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/uio.h" ># 1 "/usr/src/sys/sys/_iovec.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)uio.h 8.5 (Berkeley) 2/22/94 > * $FreeBSD: head/sys/sys/_iovec.h 139825 2005-01-07 02:29:27Z imp $ > */ > >#ifndef _SYS__IOVEC_H_ >#define _SYS__IOVEC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/_iovec.h" ># 37 "/usr/src/sys/sys/_iovec.h" > >#ifndef _SIZE_T_DECLARED >typedef __size_t size_t; >#define _SIZE_T_DECLARED >#endif ># 42 "/usr/src/sys/sys/_iovec.h" > >struct iovec { > void *iov_base; /* Base address. */ > size_t iov_len; /* Length. */ >}; > >#endif /* !_SYS__IOVEC_H_ */ ># 49 "/usr/src/sys/sys/_iovec.h" ># 39 "/usr/src/sys/sys/uio.h" 2 > >#ifndef _SSIZE_T_DECLARED >typedef __ssize_t ssize_t; >#define _SSIZE_T_DECLARED >#endif ># 44 "/usr/src/sys/sys/uio.h" > >#ifndef _OFF_T_DECLARED >typedef __off_t off_t; >#define _OFF_T_DECLARED >#endif ># 49 "/usr/src/sys/sys/uio.h" > >#if __BSD_VISIBLE >enum uio_rw { UIO_READ, UIO_WRITE }; > >/* Segment flag values. */ >enum uio_seg { > UIO_USERSPACE, /* from user data space */ > UIO_SYSSPACE, /* from system space */ > UIO_NOCOPY /* don't copy, already in object */ >}; >#endif ># 60 "/usr/src/sys/sys/uio.h" > >#ifdef _KERNEL > >struct uio { > struct iovec *uio_iov; /* scatter/gather list */ > int uio_iovcnt; /* length of scatter/gather list */ > off_t uio_offset; /* offset in target object */ > ssize_t uio_resid; /* remaining bytes to process */ > enum uio_seg uio_segflg; /* address space */ > enum uio_rw uio_rw; /* operation */ > struct thread *uio_td; /* owner */ >}; > >/* > * Limits > * > * N.B.: UIO_MAXIOV must be no less than IOV_MAX from <sys/syslimits.h> > * which in turn must be no less than _XOPEN_IOV_MAX from <limits.h>. If > * we ever make this tunable (probably pointless), then IOV_MAX should be > * removed from <sys/syslimits.h> and applications would be expected to use > * sysconf(3) to find out the correct value, or else assume the worst > * (_XOPEN_IOV_MAX). Perhaps UIO_MAXIOV should be simply defined as > * IOV_MAX. > */ >#define UIO_MAXIOV 1024 /* max 1K of iov's */ > >struct vm_object; >struct vm_page; > >struct uio *cloneuio(struct uio *uiop); >int copyinfrom(const void * __restrict src, void * __restrict dst, > size_t len, int seg); >int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, > int error); >int copyinstrfrom(const void * __restrict src, void * __restrict dst, > size_t len, size_t * __restrict copied, int seg); >int copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop); >int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz); >int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz); >int physcopyin(void *src, vm_paddr_t dst, size_t len); >int physcopyout(vm_paddr_t src, void *dst, size_t len); >int uiomove(void *cp, int n, struct uio *uio); >int uiomove_frombuf(void *buf, int buflen, struct uio *uio); >int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, > struct uio *uio); >int uiomove_nofault(void *cp, int n, struct uio *uio); >int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio); > >#else /* !_KERNEL */ ># 109 "/usr/src/sys/sys/uio.h" > >__BEGIN_DECLS >ssize_t readv(int, const struct iovec *, int); >ssize_t writev(int, const struct iovec *, int); >#if __BSD_VISIBLE >ssize_t preadv(int, const struct iovec *, int, off_t); >ssize_t pwritev(int, const struct iovec *, int, off_t); >#endif ># 117 "/usr/src/sys/sys/uio.h" >__END_DECLS > >#endif /* _KERNEL */ ># 120 "/usr/src/sys/sys/uio.h" > >#endif /* !_SYS_UIO_H_ */ ># 122 "/usr/src/sys/sys/uio.h" ># 40 "/usr/src/sys/sys/namei.h" 2 > >struct componentname { > /* > * Arguments to lookup. > */ > u_long cn_nameiop; /* namei operation */ > u_int64_t cn_flags; /* flags to namei */ > struct thread *cn_thread;/* thread requesting lookup */ > struct ucred *cn_cred; /* credentials */ > int cn_lkflags; /* Lock flags LK_EXCLUSIVE or LK_SHARED */ > /* > * Shared between lookup and commit routines. > */ > char *cn_pnbuf; /* pathname buffer */ > char *cn_nameptr; /* pointer to looked up name */ > long cn_namelen; /* length of looked up component */ > long cn_consume; /* chars to consume in lookup() */ >}; > >/* > * Encapsulation of namei parameters. > */ >struct nameidata { > /* > * Arguments to namei/lookup. > */ > const char *ni_dirp; /* pathname pointer */ > enum uio_seg ni_segflg; /* location of pathname */ > cap_rights_t ni_rightsneeded; /* rights required to look up vnode */ > /* > * Arguments to lookup. > */ > struct vnode *ni_startdir; /* starting directory */ > struct vnode *ni_rootdir; /* logical root directory */ > struct vnode *ni_topdir; /* logical top directory */ > int ni_dirfd; /* starting directory for *at functions */ > int ni_strictrelative; /* relative lookup only; no '..' */ > /* > * Results: returned from namei > */ > struct filecaps ni_filecaps; /* rights the *at base has */ > /* > * Results: returned from/manipulated by lookup > */ > struct vnode *ni_vp; /* vnode of result */ > struct vnode *ni_dvp; /* vnode of intermediate directory */ > /* > * Shared between namei and lookup/commit routines. > */ > size_t ni_pathlen; /* remaining chars in path */ > char *ni_next; /* next location in pathname */ > u_int ni_loopcnt; /* count of symlinks encountered */ > /* > * Lookup parameters: this structure describes the subset of > * information from the nameidata structure that is passed > * through the VOP interface. > */ > struct componentname ni_cnd; >}; > >#ifdef _KERNEL >/* > * namei operations > */ >#define LOOKUP 0 /* perform name lookup only */ >#define CREATE 1 /* setup for file creation */ >#define DELETE 2 /* setup for file deletion */ >#define RENAME 3 /* setup for file renaming */ >#define OPMASK 3 /* mask for operation */ >/* > * namei operational modifier flags, stored in ni_cnd.flags > */ >#define LOCKLEAF 0x0004 /* lock vnode on return */ >#define LOCKPARENT 0x0008 /* want parent vnode returned locked */ >#define WANTPARENT 0x0010 /* want parent vnode returned unlocked */ >#define NOCACHE 0x0020 /* name must not be left in cache */ >#define FOLLOW 0x0040 /* follow symbolic links */ >#define LOCKSHARED 0x0100 /* Shared lock leaf */ >#define NOFOLLOW 0x0000 /* do not follow symbolic links (pseudo) */ >#define MODMASK 0x01fc /* mask of operational modifiers */ >/* > * Namei parameter descriptors. > * > * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP. > * If the caller of namei sets the flag (for example execve wants to > * know the name of the program that is being executed), then it must > * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must > * be freed by either the commit routine or the VOP_ABORT routine. > * SAVESTART is set only by the callers of namei. It implies SAVENAME > * plus the addition of saving the parent directory that contains the > * name in ni_startdir. It allows repeated calls to lookup for the > * name being sought. The caller is responsible for releasing the > * buffer and for vrele'ing ni_startdir. > */ >#define RDONLY 0x00000200 /* lookup with read-only semantics */ >#define HASBUF 0x00000400 /* has allocated pathname buffer */ >#define SAVENAME 0x00000800 /* save pathname buffer */ >#define SAVESTART 0x00001000 /* save starting directory */ >#define ISDOTDOT 0x00002000 /* current component name is .. */ >#define MAKEENTRY 0x00004000 /* entry is to be added to name cache */ >#define ISLASTCN 0x00008000 /* this is last component of pathname */ >#define ISSYMLINK 0x00010000 /* symlink needs interpretation */ >#define ISWHITEOUT 0x00020000 /* found whiteout */ >#define DOWHITEOUT 0x00040000 /* do whiteouts */ >#define WILLBEDIR 0x00080000 /* new files will be dirs; allow trailing / */ >#define ISUNICODE 0x00100000 /* current component name is unicode*/ >#define ISOPEN 0x00200000 /* caller is opening; return a real vnode. */ >#define NOCROSSMOUNT 0x00400000 /* do not cross mount points */ >#define NOMACCHECK 0x00800000 /* do not perform MAC checks */ >#define AUDITVNODE1 0x04000000 /* audit the looked up vnode information */ >#define AUDITVNODE2 0x08000000 /* audit the looked up vnode information */ >#define TRAILINGSLASH 0x10000000 /* path ended in a slash */ >#define NOCAPCHECK 0x20000000 /* do not perform capability checks */ >#define PARAMASK 0x3ffffe00 /* mask of parameter descriptors */ > >/* > * Initialization of a nameidata structure. > */ >#define NDINIT(ndp, op, flags, segflg, namep, td) \ > NDINIT_ALL(ndp, op, flags, segflg, namep, AT_FDCWD, NULL, 0, td) >#define NDINIT_AT(ndp, op, flags, segflg, namep, dirfd, td) \ > NDINIT_ALL(ndp, op, flags, segflg, namep, dirfd, NULL, 0, td) >#define NDINIT_ATRIGHTS(ndp, op, flags, segflg, namep, dirfd, rightsp, td) \ > NDINIT_ALL(ndp, op, flags, segflg, namep, dirfd, NULL, rightsp, td) >#define NDINIT_ATVP(ndp, op, flags, segflg, namep, vp, td) \ > NDINIT_ALL(ndp, op, flags, segflg, namep, AT_FDCWD, vp, 0, td) > >void NDINIT_ALL(struct nameidata *ndp, u_long op, u_long flags, > enum uio_seg segflg, const char *namep, int dirfd, struct vnode *startdir, > cap_rights_t *rightsp, struct thread *td); > >#define NDF_NO_DVP_RELE 0x00000001 >#define NDF_NO_DVP_UNLOCK 0x00000002 >#define NDF_NO_DVP_PUT 0x00000003 >#define NDF_NO_VP_RELE 0x00000004 >#define NDF_NO_VP_UNLOCK 0x00000008 >#define NDF_NO_VP_PUT 0x0000000c >#define NDF_NO_STARTDIR_RELE 0x00000010 >#define NDF_NO_FREE_PNBUF 0x00000020 >#define NDF_ONLY_PNBUF (~NDF_NO_FREE_PNBUF) > >void NDFREE(struct nameidata *, const u_int); > >int namei(struct nameidata *ndp); >int lookup(struct nameidata *ndp); >int relookup(struct vnode *dvp, struct vnode **vpp, > struct componentname *cnp); >#endif ># 188 "/usr/src/sys/sys/namei.h" > >/* > * Stats on usefulness of namei caches. > */ >struct nchstats { > long ncs_goodhits; /* hits that we can really use */ > long ncs_neghits; /* negative hits that we can use */ > long ncs_badhits; /* hits we must drop */ > long ncs_falsehits; /* hits with id mismatch */ > long ncs_miss; /* misses */ > long ncs_long; /* long names that ignore cache */ > long ncs_pass2; /* names found with passes == 2 */ > long ncs_2passes; /* number of times we attempt it */ >}; > >extern struct nchstats nchstats; > >#endif /* !_SYS_NAMEI_H_ */ ># 206 "/usr/src/sys/sys/namei.h" ># 58 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/priv.h> >#endif /* expanded by -frewrite-includes */ ># 58 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/priv.h" 1 >/*- > * Copyright (c) 2006 nCircle Network Security, Inc. > * All rights reserved. > * > * This software was developed by Robert N. M. Watson for the TrustedBSD > * Project under contract to nCircle Network Security, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY, > * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED > * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR > * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF > * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING > * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS > * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/priv.h 277322 2015-01-18 15:13:11Z kib $ > */ > >/* > * Privilege checking interface for BSD kernel. > */ >#ifndef _SYS_PRIV_H_ >#define _SYS_PRIV_H_ > >/* > * Privilege list, sorted loosely by kernel subsystem. > * > * Think carefully before adding or reusing one of these privileges -- are > * there existing instances referring to the same privilege? Third party > * vendors may request the assignment of privileges to be used in loadable > * modules. Particular numeric privilege assignments are part of the > * loadable kernel module ABI, and should not be changed across minor > * releases. > * > * When adding a new privilege, remember to determine if it's appropriate for > * use in jail, and update the privilege switch in kern_jail.c as necessary. > */ > >/* > * Track beginning of privilege list. > */ >#define _PRIV_LOWEST 1 > >/* > * The remaining privileges typically correspond to one or a small > * number of specific privilege checks, and have (relatively) precise > * meanings. They are loosely sorted into a set of base system > * privileges, such as the ability to reboot, and then loosely by > * subsystem, indicated by a subsystem name. > */ >#define _PRIV_ROOT 1 /* Removed. */ >#define PRIV_ACCT 2 /* Manage process accounting. */ >#define PRIV_MAXFILES 3 /* Exceed system open files limit. */ >#define PRIV_MAXPROC 4 /* Exceed system processes limit. */ >#define PRIV_KTRACE 5 /* Set/clear KTRFAC_ROOT on ktrace. */ >#define PRIV_SETDUMPER 6 /* Configure dump device. */ >#define PRIV_REBOOT 8 /* Can reboot system. */ >#define PRIV_SWAPON 9 /* Can swapon(). */ >#define PRIV_SWAPOFF 10 /* Can swapoff(). */ >#define PRIV_MSGBUF 11 /* Can read kernel message buffer. */ >#define PRIV_IO 12 /* Can perform low-level I/O. */ >#define PRIV_KEYBOARD 13 /* Reprogram keyboard. */ >#define PRIV_DRIVER 14 /* Low-level driver privilege. */ >#define PRIV_ADJTIME 15 /* Set time adjustment. */ >#define PRIV_NTP_ADJTIME 16 /* Set NTP time adjustment. */ >#define PRIV_CLOCK_SETTIME 17 /* Can call clock_settime. */ >#define PRIV_SETTIMEOFDAY 18 /* Can call settimeofday. */ >#define _PRIV_SETHOSTID 19 /* Removed. */ >#define _PRIV_SETDOMAINNAME 20 /* Removed. */ > >/* > * Audit subsystem privileges. > */ >#define PRIV_AUDIT_CONTROL 40 /* Can configure audit. */ >#define PRIV_AUDIT_FAILSTOP 41 /* Can run during audit fail stop. */ >#define PRIV_AUDIT_GETAUDIT 42 /* Can get proc audit properties. */ >#define PRIV_AUDIT_SETAUDIT 43 /* Can set proc audit properties. */ >#define PRIV_AUDIT_SUBMIT 44 /* Can submit an audit record. */ > >/* > * Credential management privileges. > */ >#define PRIV_CRED_SETUID 50 /* setuid. */ >#define PRIV_CRED_SETEUID 51 /* seteuid to !ruid and !svuid. */ >#define PRIV_CRED_SETGID 52 /* setgid. */ >#define PRIV_CRED_SETEGID 53 /* setgid to !rgid and !svgid. */ >#define PRIV_CRED_SETGROUPS 54 /* Set process additional groups. */ >#define PRIV_CRED_SETREUID 55 /* setreuid. */ >#define PRIV_CRED_SETREGID 56 /* setregid. */ >#define PRIV_CRED_SETRESUID 57 /* setresuid. */ >#define PRIV_CRED_SETRESGID 58 /* setresgid. */ >#define PRIV_SEEOTHERGIDS 59 /* Exempt bsd.seeothergids. */ >#define PRIV_SEEOTHERUIDS 60 /* Exempt bsd.seeotheruids. */ > >/* > * Debugging privileges. > */ >#define PRIV_DEBUG_DIFFCRED 80 /* Exempt debugging other users. */ >#define PRIV_DEBUG_SUGID 81 /* Exempt debugging setuid proc. */ >#define PRIV_DEBUG_UNPRIV 82 /* Exempt unprivileged debug limit. */ >#define PRIV_DEBUG_DENIED 83 /* Exempt P2_NOTRACE. */ > >/* > * Dtrace privileges. > */ >#define PRIV_DTRACE_KERNEL 90 /* Allow use of DTrace on the kernel. */ >#define PRIV_DTRACE_PROC 91 /* Allow attaching DTrace to process. */ >#define PRIV_DTRACE_USER 92 /* Process may submit DTrace events. */ > >/* > * Firmware privilegs. > */ >#define PRIV_FIRMWARE_LOAD 100 /* Can load firmware. */ > >/* > * Jail privileges. > */ >#define PRIV_JAIL_ATTACH 110 /* Attach to a jail. */ >#define PRIV_JAIL_SET 111 /* Set jail parameters. */ >#define PRIV_JAIL_REMOVE 112 /* Remove a jail. */ > >/* > * Kernel environment priveleges. > */ >#define PRIV_KENV_SET 120 /* Set kernel env. variables. */ >#define PRIV_KENV_UNSET 121 /* Unset kernel env. variables. */ > >/* > * Loadable kernel module privileges. > */ >#define PRIV_KLD_LOAD 130 /* Load a kernel module. */ >#define PRIV_KLD_UNLOAD 131 /* Unload a kernel module. */ > >/* > * Privileges associated with the MAC Framework and specific MAC policy > * modules. > */ >#define PRIV_MAC_PARTITION 140 /* Privilege in mac_partition policy. */ >#define PRIV_MAC_PRIVS 141 /* Privilege in the mac_privs policy. */ > >/* > * Process-related privileges. > */ >#define PRIV_PROC_LIMIT 160 /* Exceed user process limit. */ >#define PRIV_PROC_SETLOGIN 161 /* Can call setlogin. */ >#define PRIV_PROC_SETRLIMIT 162 /* Can raise resources limits. */ >#define PRIV_PROC_SETLOGINCLASS 163 /* Can call setloginclass(2). */ > >/* > * System V IPC privileges. > */ >#define PRIV_IPC_READ 170 /* Can override IPC read perm. */ >#define PRIV_IPC_WRITE 171 /* Can override IPC write perm. */ >#define PRIV_IPC_ADMIN 172 /* Can override IPC owner-only perm. */ >#define PRIV_IPC_MSGSIZE 173 /* Exempt IPC message queue limit. */ > >/* > * POSIX message queue privileges. > */ >#define PRIV_MQ_ADMIN 180 /* Can override msgq owner-only perm. */ > >/* > * Performance monitoring counter privileges. > */ >#define PRIV_PMC_MANAGE 190 /* Can administer PMC. */ >#define PRIV_PMC_SYSTEM 191 /* Can allocate a system-wide PMC. */ > >/* > * Scheduling privileges. > */ >#define PRIV_SCHED_DIFFCRED 200 /* Exempt scheduling other users. */ >#define PRIV_SCHED_SETPRIORITY 201 /* Can set lower nice value for proc. */ >#define PRIV_SCHED_RTPRIO 202 /* Can set real time scheduling. */ >#define PRIV_SCHED_SETPOLICY 203 /* Can set scheduler policy. */ >#define PRIV_SCHED_SET 204 /* Can set thread scheduler. */ >#define PRIV_SCHED_SETPARAM 205 /* Can set thread scheduler params. */ >#define PRIV_SCHED_CPUSET 206 /* Can manipulate cpusets. */ >#define PRIV_SCHED_CPUSET_INTR 207 /* Can adjust IRQ to CPU binding. */ > >/* > * POSIX semaphore privileges. > */ >#define PRIV_SEM_WRITE 220 /* Can override sem write perm. */ > >/* > * Signal privileges. > */ >#define PRIV_SIGNAL_DIFFCRED 230 /* Exempt signalling other users. */ >#define PRIV_SIGNAL_SUGID 231 /* Non-conserv signal setuid proc. */ > >/* > * Sysctl privileges. > */ >#define PRIV_SYSCTL_DEBUG 240 /* Can invoke sysctl.debug. */ >#define PRIV_SYSCTL_WRITE 241 /* Can write sysctls. */ >#define PRIV_SYSCTL_WRITEJAIL 242 /* Can write sysctls, jail permitted. */ > >/* > * TTY privileges. > */ >#define PRIV_TTY_CONSOLE 250 /* Set console to tty. */ >#define PRIV_TTY_DRAINWAIT 251 /* Set tty drain wait time. */ >#define PRIV_TTY_DTRWAIT 252 /* Set DTR wait on tty. */ >#define PRIV_TTY_EXCLUSIVE 253 /* Override tty exclusive flag. */ >#define _PRIV_TTY_PRISON 254 /* Removed. */ >#define PRIV_TTY_STI 255 /* Simulate input on another tty. */ >#define PRIV_TTY_SETA 256 /* Set tty termios structure. */ > >/* > * UFS-specific privileges. > */ >#define PRIV_UFS_EXTATTRCTL 270 /* Can configure EAs on UFS1. */ >#define PRIV_UFS_QUOTAOFF 271 /* quotaoff(). */ >#define PRIV_UFS_QUOTAON 272 /* quotaon(). */ >#define PRIV_UFS_SETUSE 273 /* setuse(). */ > >/* > * ZFS-specific privileges. > */ >#define PRIV_ZFS_POOL_CONFIG 280 /* Can configure ZFS pools. */ >#define PRIV_ZFS_INJECT 281 /* Can inject faults in the ZFS fault > injection framework. */ >#define PRIV_ZFS_JAIL 282 /* Can attach/detach ZFS file systems > to/from jails. */ > >/* > * NFS-specific privileges. > */ >#define PRIV_NFS_DAEMON 290 /* Can become the NFS daemon. */ >#define PRIV_NFS_LOCKD 291 /* Can become NFS lock daemon. */ > >/* > * VFS privileges. > */ >#define PRIV_VFS_READ 310 /* Override vnode DAC read perm. */ >#define PRIV_VFS_WRITE 311 /* Override vnode DAC write perm. */ >#define PRIV_VFS_ADMIN 312 /* Override vnode DAC admin perm. */ >#define PRIV_VFS_EXEC 313 /* Override vnode DAC exec perm. */ >#define PRIV_VFS_LOOKUP 314 /* Override vnode DAC lookup perm. */ >#define PRIV_VFS_BLOCKRESERVE 315 /* Can use free block reserve. */ >#define PRIV_VFS_CHFLAGS_DEV 316 /* Can chflags() a device node. */ >#define PRIV_VFS_CHOWN 317 /* Can set user; group to non-member. */ >#define PRIV_VFS_CHROOT 318 /* chroot(). */ >#define PRIV_VFS_RETAINSUGID 319 /* Can retain sugid bits on change. */ >#define PRIV_VFS_EXCEEDQUOTA 320 /* Exempt from quota restrictions. */ >#define PRIV_VFS_EXTATTR_SYSTEM 321 /* Operate on system EA namespace. */ >#define PRIV_VFS_FCHROOT 322 /* fchroot(). */ >#define PRIV_VFS_FHOPEN 323 /* Can fhopen(). */ >#define PRIV_VFS_FHSTAT 324 /* Can fhstat(). */ >#define PRIV_VFS_FHSTATFS 325 /* Can fhstatfs(). */ >#define PRIV_VFS_GENERATION 326 /* stat() returns generation number. */ >#define PRIV_VFS_GETFH 327 /* Can retrieve file handles. */ >#define PRIV_VFS_GETQUOTA 328 /* getquota(). */ >#define PRIV_VFS_LINK 329 /* bsd.hardlink_check_uid */ >#define PRIV_VFS_MKNOD_BAD 330 /* Can mknod() to mark bad inodes. */ >#define PRIV_VFS_MKNOD_DEV 331 /* Can mknod() to create dev nodes. */ >#define PRIV_VFS_MKNOD_WHT 332 /* Can mknod() to create whiteout. */ >#define PRIV_VFS_MOUNT 333 /* Can mount(). */ >#define PRIV_VFS_MOUNT_OWNER 334 /* Can manage other users' file systems. */ >#define PRIV_VFS_MOUNT_EXPORTED 335 /* Can set MNT_EXPORTED on mount. */ >#define PRIV_VFS_MOUNT_PERM 336 /* Override dev node perms at mount. */ >#define PRIV_VFS_MOUNT_SUIDDIR 337 /* Can set MNT_SUIDDIR on mount. */ >#define PRIV_VFS_MOUNT_NONUSER 338 /* Can perform a non-user mount. */ >#define PRIV_VFS_SETGID 339 /* Can setgid if not in group. */ >#define PRIV_VFS_SETQUOTA 340 /* setquota(). */ >#define PRIV_VFS_STICKYFILE 341 /* Can set sticky bit on file. */ >#define PRIV_VFS_SYSFLAGS 342 /* Can modify system flags. */ >#define PRIV_VFS_UNMOUNT 343 /* Can unmount(). */ >#define PRIV_VFS_STAT 344 /* Override vnode MAC stat perm. */ > >/* > * Virtual memory privileges. > */ >#define PRIV_VM_MADV_PROTECT 360 /* Can set MADV_PROTECT. */ >#define PRIV_VM_MLOCK 361 /* Can mlock(), mlockall(). */ >#define PRIV_VM_MUNLOCK 362 /* Can munlock(), munlockall(). */ >#define PRIV_VM_SWAP_NOQUOTA 363 /* > * Can override the global > * swap reservation limits. > */ >#define PRIV_VM_SWAP_NORLIMIT 364 /* > * Can override the per-uid > * swap reservation limits. > */ > >/* > * Device file system privileges. > */ >#define PRIV_DEVFS_RULE 370 /* Can manage devfs rules. */ >#define PRIV_DEVFS_SYMLINK 371 /* Can create symlinks in devfs. */ > >/* > * Random number generator privileges. > */ >#define PRIV_RANDOM_RESEED 380 /* Closing /dev/random reseeds. */ > >/* > * Network stack privileges. > */ >#define PRIV_NET_BRIDGE 390 /* Administer bridge. */ >#define PRIV_NET_GRE 391 /* Administer GRE. */ >#define _PRIV_NET_PPP 392 /* Removed. */ >#define _PRIV_NET_SLIP 393 /* Removed. */ >#define PRIV_NET_BPF 394 /* Monitor BPF. */ >#define PRIV_NET_RAW 395 /* Open raw socket. */ >#define PRIV_NET_ROUTE 396 /* Administer routing. */ >#define PRIV_NET_TAP 397 /* Can open tap device. */ >#define PRIV_NET_SETIFMTU 398 /* Set interface MTU. */ >#define PRIV_NET_SETIFFLAGS 399 /* Set interface flags. */ >#define PRIV_NET_SETIFCAP 400 /* Set interface capabilities. */ >#define PRIV_NET_SETIFNAME 401 /* Set interface name. */ >#define PRIV_NET_SETIFMETRIC 402 /* Set interface metrics. */ >#define PRIV_NET_SETIFPHYS 403 /* Set interface physical layer prop. */ >#define PRIV_NET_SETIFMAC 404 /* Set interface MAC label. */ >#define PRIV_NET_ADDMULTI 405 /* Add multicast addr. to ifnet. */ >#define PRIV_NET_DELMULTI 406 /* Delete multicast addr. from ifnet. */ >#define PRIV_NET_HWIOCTL 407 /* Issue hardware ioctl on ifnet. */ >#define PRIV_NET_SETLLADDR 408 /* Set interface link-level address. */ >#define PRIV_NET_ADDIFGROUP 409 /* Add new interface group. */ >#define PRIV_NET_DELIFGROUP 410 /* Delete interface group. */ >#define PRIV_NET_IFCREATE 411 /* Create cloned interface. */ >#define PRIV_NET_IFDESTROY 412 /* Destroy cloned interface. */ >#define PRIV_NET_ADDIFADDR 413 /* Add protocol addr to interface. */ >#define PRIV_NET_DELIFADDR 414 /* Delete protocol addr on interface. */ >#define PRIV_NET_LAGG 415 /* Administer lagg interface. */ >#define PRIV_NET_GIF 416 /* Administer gif interface. */ >#define PRIV_NET_SETIFVNET 417 /* Move interface to vnet. */ >#define PRIV_NET_SETIFDESCR 418 /* Set interface description. */ >#define PRIV_NET_SETIFFIB 419 /* Set interface fib. */ >#define PRIV_NET_VXLAN 420 /* Administer vxlan. */ > >/* > * 802.11-related privileges. > */ >#define PRIV_NET80211_GETKEY 440 /* Query 802.11 keys. */ >#define PRIV_NET80211_MANAGE 441 /* Administer 802.11. */ > >/* > * Placeholder for AppleTalk privileges, not supported anymore. > */ >#define _PRIV_NETATALK_RESERVEDPORT 450 /* Bind low port number. */ > >/* > * ATM privileges. > */ >#define PRIV_NETATM_CFG 460 >#define PRIV_NETATM_ADD 461 >#define PRIV_NETATM_DEL 462 >#define PRIV_NETATM_SET 463 > >/* > * Bluetooth privileges. > */ >#define PRIV_NETBLUETOOTH_RAW 470 /* Open raw bluetooth socket. */ > >/* > * Netgraph and netgraph module privileges. > */ >#define PRIV_NETGRAPH_CONTROL 480 /* Open netgraph control socket. */ >#define PRIV_NETGRAPH_TTY 481 /* Configure tty for netgraph. */ > >/* > * IPv4 and IPv6 privileges. > */ >#define PRIV_NETINET_RESERVEDPORT 490 /* Bind low port number. */ >#define PRIV_NETINET_IPFW 491 /* Administer IPFW firewall. */ >#define PRIV_NETINET_DIVERT 492 /* Open IP divert socket. */ >#define PRIV_NETINET_PF 493 /* Administer pf firewall. */ >#define PRIV_NETINET_DUMMYNET 494 /* Administer DUMMYNET. */ >#define PRIV_NETINET_CARP 495 /* Administer CARP. */ >#define PRIV_NETINET_MROUTE 496 /* Administer multicast routing. */ >#define PRIV_NETINET_RAW 497 /* Open netinet raw socket. */ >#define PRIV_NETINET_GETCRED 498 /* Query netinet pcb credentials. */ >#define PRIV_NETINET_ADDRCTRL6 499 /* Administer IPv6 address scopes. */ >#define PRIV_NETINET_ND6 500 /* Administer IPv6 neighbor disc. */ >#define PRIV_NETINET_SCOPE6 501 /* Administer IPv6 address scopes. */ >#define PRIV_NETINET_ALIFETIME6 502 /* Administer IPv6 address lifetimes. */ >#define PRIV_NETINET_IPSEC 503 /* Administer IPSEC. */ >#define PRIV_NETINET_REUSEPORT 504 /* Allow [rapid] port/address reuse. */ >#define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */ >#define PRIV_NETINET_BINDANY 506 /* Allow bind to any address. */ >#define PRIV_NETINET_HASHKEY 507 /* Get and set hash keys for IPv4/6. */ > >/* > * Placeholders for IPX/SPX privileges, not supported any more. > */ >#define _PRIV_NETIPX_RESERVEDPORT 520 /* Bind low port number. */ >#define _PRIV_NETIPX_RAW 521 /* Open netipx raw socket. */ > >/* > * NCP privileges. > */ >#define PRIV_NETNCP 530 /* Use another user's connection. */ > >/* > * SMB privileges. > */ >#define PRIV_NETSMB 540 /* Use another user's connection. */ > >/* > * VM86 privileges. > */ >#define PRIV_VM86_INTCALL 550 /* Allow invoking vm86 int handlers. */ > >/* > * Set of reserved privilege values, which will be allocated to code as > * needed, in order to avoid renumbering later privileges due to insertion. > */ >#define _PRIV_RESERVED0 560 >#define _PRIV_RESERVED1 561 >#define _PRIV_RESERVED2 562 >#define _PRIV_RESERVED3 563 >#define _PRIV_RESERVED4 564 >#define _PRIV_RESERVED5 565 >#define _PRIV_RESERVED6 566 >#define _PRIV_RESERVED7 567 >#define _PRIV_RESERVED8 568 >#define _PRIV_RESERVED9 569 >#define _PRIV_RESERVED10 570 >#define _PRIV_RESERVED11 571 >#define _PRIV_RESERVED12 572 >#define _PRIV_RESERVED13 573 >#define _PRIV_RESERVED14 574 >#define _PRIV_RESERVED15 575 > >/* > * Define a set of valid privilege numbers that can be used by loadable > * modules that don't yet have privilege reservations. Ideally, these should > * not be used, since their meaning is opaque to any policies that are aware > * of specific privileges, such as jail, and as such may be arbitrarily > * denied. > */ >#define PRIV_MODULE0 600 >#define PRIV_MODULE1 601 >#define PRIV_MODULE2 602 >#define PRIV_MODULE3 603 >#define PRIV_MODULE4 604 >#define PRIV_MODULE5 605 >#define PRIV_MODULE6 606 >#define PRIV_MODULE7 607 >#define PRIV_MODULE8 608 >#define PRIV_MODULE9 609 >#define PRIV_MODULE10 610 >#define PRIV_MODULE11 611 >#define PRIV_MODULE12 612 >#define PRIV_MODULE13 613 >#define PRIV_MODULE14 614 >#define PRIV_MODULE15 615 > >/* > * DDB(4) privileges. > */ >#define PRIV_DDB_CAPTURE 620 /* Allow reading of DDB capture log. */ > >/* > * Arla/nnpfs privileges. > */ >#define PRIV_NNPFS_DEBUG 630 /* Perforn ARLA_VIOC_NNPFSDEBUG. */ > >/* > * cpuctl(4) privileges. > */ >#define PRIV_CPUCTL_WRMSR 640 /* Write model-specific register. */ >#define PRIV_CPUCTL_UPDATE 641 /* Update cpu microcode. */ > >/* > * Capi4BSD privileges. > */ >#define PRIV_C4B_RESET_CTLR 650 /* Load firmware, reset controller. */ >#define PRIV_C4B_TRACE 651 /* Unrestricted CAPI message tracing. */ > >/* > * OpenAFS privileges. > */ >#define PRIV_AFS_ADMIN 660 /* Can change AFS client settings. */ >#define PRIV_AFS_DAEMON 661 /* Can become the AFS daemon. */ > >/* > * Resource Limits privileges. > */ >#define PRIV_RCTL_GET_RACCT 670 >#define PRIV_RCTL_GET_RULES 671 >#define PRIV_RCTL_GET_LIMITS 672 >#define PRIV_RCTL_ADD_RULE 673 >#define PRIV_RCTL_REMOVE_RULE 674 > >/* > * mem(4) privileges. > */ >#define PRIV_KMEM_READ 680 /* Open mem/kmem for reading. */ >#define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */ > >/* > * Track end of privilege list. > */ >#define _PRIV_HIGHEST 682 > >/* > * Validate that a named privilege is known by the privilege system. Invalid > * privileges presented to the privilege system by a priv_check interface > * will result in a panic. This is only approximate due to sparse allocation > * of the privilege space. > */ >#define PRIV_VALID(x) ((x) > _PRIV_LOWEST && (x) < _PRIV_HIGHEST) > >#ifdef _KERNEL >/* > * Privilege check interfaces, modeled after historic suser() interfaces, but > * with the addition of a specific privilege name. No flags are currently > * defined for the API. Historically, flags specified using the real uid > * instead of the effective uid, and whether or not the check should be > * allowed in jail. > */ >struct thread; >struct ucred; >int priv_check(struct thread *td, int priv); >int priv_check_cred(struct ucred *cred, int priv, int flags); >#endif ># 532 "/usr/src/sys/sys/priv.h" > >#endif /* !_SYS_PRIV_H_ */ ># 534 "/usr/src/sys/sys/priv.h" ># 59 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/proc.h> >#endif /* expanded by -frewrite-includes */ ># 59 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/proc.h" 1 >/*- > * Copyright (c) 1986, 1989, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)proc.h 8.15 (Berkeley) 5/19/95 > * $FreeBSD: head/sys/sys/proc.h 277960 2015-01-31 02:15:16Z jhb $ > */ > >#ifndef _SYS_PROC_H_ >#define _SYS_PROC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/callout.h> /* For struct callout. */ >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/proc.h" ># 42 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/event.h> /* For struct klist. */ >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/proc.h" ># 43 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/condvar.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/condvar.h" 1 >/*- > * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/condvar.h 247785 2013-03-04 12:20:48Z davide $ > */ > >#ifndef _SYS_CONDVAR_H_ >#define _SYS_CONDVAR_H_ > >#ifndef LOCORE >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/sys/sys/condvar.h" ># 34 "/usr/src/sys/sys/condvar.h" > >struct lock_object; >struct thread; > >TAILQ_HEAD(cv_waitq, thread); > >/* > * Condition variable. The waiters count is protected by the mutex that > * protects the condition; that is, the mutex that is passed to cv_wait*() > * and is held across calls to cv_signal() and cv_broadcast(). It is an > * optimization to avoid looking up the sleep queue if there are no waiters. > */ >struct cv { > const char *cv_description; > int cv_waiters; >}; > >#ifdef _KERNEL >void cv_init(struct cv *cvp, const char *desc); >void cv_destroy(struct cv *cvp); > >void _cv_wait(struct cv *cvp, struct lock_object *lock); >void _cv_wait_unlock(struct cv *cvp, struct lock_object *lock); >int _cv_wait_sig(struct cv *cvp, struct lock_object *lock); >int _cv_timedwait_sbt(struct cv *cvp, struct lock_object *lock, > sbintime_t sbt, sbintime_t pr, int flags); >int _cv_timedwait_sig_sbt(struct cv *cvp, struct lock_object *lock, > sbintime_t sbt, sbintime_t pr, int flags); > >void cv_signal(struct cv *cvp); >void cv_broadcastpri(struct cv *cvp, int pri); > >#define cv_wait(cvp, lock) \ > _cv_wait((cvp), &(lock)->lock_object) >#define cv_wait_unlock(cvp, lock) \ > _cv_wait_unlock((cvp), &(lock)->lock_object) >#define cv_wait_sig(cvp, lock) \ > _cv_wait_sig((cvp), &(lock)->lock_object) >#define cv_timedwait(cvp, lock, timo) \ > _cv_timedwait_sbt((cvp), &(lock)->lock_object, \ > tick_sbt * (timo), 0, C_HARDCLOCK) >#define cv_timedwait_sbt(cvp, lock, sbt, pr, flags) \ > _cv_timedwait_sbt((cvp), &(lock)->lock_object, (sbt), (pr), (flags)) >#define cv_timedwait_sig(cvp, lock, timo) \ > _cv_timedwait_sig_sbt((cvp), &(lock)->lock_object, \ > tick_sbt * (timo), 0, C_HARDCLOCK) >#define cv_timedwait_sig_sbt(cvp, lock, sbt, pr, flags) \ > _cv_timedwait_sig_sbt((cvp), &(lock)->lock_object, (sbt), (pr), (flags)) > >#define cv_broadcast(cvp) cv_broadcastpri(cvp, 0) > >#define cv_wmesg(cvp) ((cvp)->cv_description) > >#endif /* _KERNEL */ ># 88 "/usr/src/sys/sys/condvar.h" >#endif /* !LOCORE */ ># 89 "/usr/src/sys/sys/condvar.h" >#endif /* _SYS_CONDVAR_H_ */ ># 90 "/usr/src/sys/sys/condvar.h" ># 44 "/usr/src/sys/sys/proc.h" 2 >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/filedesc.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/proc.h" ># 46 "/usr/src/sys/sys/proc.h" >#endif ># 47 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/sys/sys/proc.h" ># 48 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/sys/sys/proc.h" ># 49 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock_profile.h> >#endif /* expanded by -frewrite-includes */ ># 49 "/usr/src/sys/sys/proc.h" ># 50 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 50 "/usr/src/sys/sys/proc.h" ># 51 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/osd.h> >#endif /* expanded by -frewrite-includes */ ># 51 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/osd.h" 1 >/*- > * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/osd.h 216615 2010-12-21 13:45:29Z lstewart $ > */ > >#ifndef _SYS_OSD_H_ >#define _SYS_OSD_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/osd.h" ># 33 "/usr/src/sys/sys/osd.h" > >/* > * Lock key: > * (c) container lock (e.g. jail's pr_mtx) and/or osd_object_lock > * (l) osd_list_lock > */ >struct osd { > u_int osd_nslots; /* (c) */ > void **osd_slots; /* (c) */ > LIST_ENTRY(osd) osd_next; /* (l) */ >}; > >#ifdef _KERNEL > >#define OSD_THREAD 0 >#define OSD_JAIL 1 >#define OSD_KHELP 2 > >#define OSD_FIRST OSD_THREAD >#define OSD_LAST OSD_KHELP > >typedef void (*osd_destructor_t)(void *value); >typedef int (*osd_method_t)(void *obj, void *data); > >int osd_register(u_int type, osd_destructor_t destructor, > osd_method_t *methods); >void osd_deregister(u_int type, u_int slot); > >int osd_set(u_int type, struct osd *osd, u_int slot, void *value); >void *osd_get(u_int type, struct osd *osd, u_int slot); >void osd_del(u_int type, struct osd *osd, u_int slot); >int osd_call(u_int type, u_int method, void *obj, void *data); > >void osd_exit(u_int type, struct osd *osd); > >#define osd_thread_register(destructor) \ > osd_register(OSD_THREAD, (destructor), NULL) >#define osd_thread_deregister(slot) \ > osd_deregister(OSD_THREAD, (slot)) >#define osd_thread_set(td, slot, value) \ > osd_set(OSD_THREAD, &(td)->td_osd, (slot), (value)) >#define osd_thread_get(td, slot) \ > osd_get(OSD_THREAD, &(td)->td_osd, (slot)) >#define osd_thread_del(td, slot) do { \ > KASSERT((td) == curthread, ("Not curthread.")); \ > osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \ >} while (0) >#define osd_thread_call(td, method, data) \ > osd_call(OSD_THREAD, (method), (td), (data)) >#define osd_thread_exit(td) \ > osd_exit(OSD_THREAD, &(td)->td_osd) > >#define osd_jail_register(destructor, methods) \ > osd_register(OSD_JAIL, (destructor), (methods)) >#define osd_jail_deregister(slot) \ > osd_deregister(OSD_JAIL, (slot)) >#define osd_jail_set(pr, slot, value) \ > osd_set(OSD_JAIL, &(pr)->pr_osd, (slot), (value)) >#define osd_jail_get(pr, slot) \ > osd_get(OSD_JAIL, &(pr)->pr_osd, (slot)) >#define osd_jail_del(pr, slot) \ > osd_del(OSD_JAIL, &(pr)->pr_osd, (slot)) >#define osd_jail_call(pr, method, data) \ > osd_call(OSD_JAIL, (method), (pr), (data)) >#define osd_jail_exit(pr) \ > osd_exit(OSD_JAIL, &(pr)->pr_osd) > >#endif /* _KERNEL */ ># 101 "/usr/src/sys/sys/osd.h" > >#endif /* !_SYS_OSD_H_ */ ># 103 "/usr/src/sys/sys/osd.h" ># 52 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/priority.h> >#endif /* expanded by -frewrite-includes */ ># 52 "/usr/src/sys/sys/proc.h" ># 53 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/rtprio.h> /* XXX. */ >#endif /* expanded by -frewrite-includes */ ># 53 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/rtprio.h" 1 >/*- > * Copyright (c) 1994, Henrik Vestergaard Draboel > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Henrik Vestergaard Draboel. > * 4. The name of the author may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/rtprio.h 165898 2007-01-08 21:21:45Z imp $ > */ > >#ifndef _SYS_RTPRIO_H_ >#define _SYS_RTPRIO_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/priority.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/rtprio.h" ># 38 "/usr/src/sys/sys/rtprio.h" > >/* > * Process realtime-priority specifications to rtprio. > */ > >/* priority types. Start at 1 to catch uninitialized fields. */ > >#define RTP_PRIO_REALTIME PRI_REALTIME /* real time process */ >#define RTP_PRIO_NORMAL PRI_TIMESHARE /* time sharing process */ >#define RTP_PRIO_IDLE PRI_IDLE /* idle process */ > >/* RTP_PRIO_FIFO is POSIX.1B SCHED_FIFO. > */ > >#define RTP_PRIO_FIFO_BIT PRI_FIFO_BIT >#define RTP_PRIO_FIFO PRI_FIFO >#define RTP_PRIO_BASE(P) PRI_BASE(P) >#define RTP_PRIO_IS_REALTIME(P) PRI_IS_REALTIME(P) >#define RTP_PRIO_NEED_RR(P) PRI_NEED_RR(P) > >/* priority range */ >#define RTP_PRIO_MIN 0 /* Highest priority */ >#define RTP_PRIO_MAX 31 /* Lowest priority */ > >/* > * rtprio() syscall functions > */ >#define RTP_LOOKUP 0 >#define RTP_SET 1 > >#ifndef LOCORE >/* > * Scheduling class information. > */ >struct rtprio { > u_short type; /* scheduling class */ > u_short prio; >}; > >#ifdef _KERNEL >struct thread; >int rtp_to_pri(struct rtprio *, struct thread *); >void pri_to_rtp(struct thread *, struct rtprio *); >#endif ># 82 "/usr/src/sys/sys/rtprio.h" >#endif ># 83 "/usr/src/sys/sys/rtprio.h" > >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 85 "/usr/src/sys/sys/rtprio.h" ># 86 "/usr/src/sys/sys/rtprio.h" > >__BEGIN_DECLS >int rtprio(int, pid_t, struct rtprio *); >int rtprio_thread(int, lwpid_t, struct rtprio *); >__END_DECLS >#endif /* !_KERNEL */ ># 92 "/usr/src/sys/sys/rtprio.h" >#endif /* !_SYS_RTPRIO_H_ */ ># 93 "/usr/src/sys/sys/rtprio.h" ># 54 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/runq.h> >#endif /* expanded by -frewrite-includes */ ># 54 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/runq.h" 1 >/*- > * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/runq.h 177435 2008-03-20 05:51:16Z jeff $ > */ > >#ifndef _RUNQ_H_ >#define _RUNQ_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/runq.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/runq.h" ># 1 "./machine/runq.h" 1 >/*- > * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/amd64/include/runq.h 139731 2005-01-05 20:17:21Z imp $ > */ > >#ifndef _MACHINE_RUNQ_H_ >#define _MACHINE_RUNQ_H_ > >#define RQB_LEN (1) /* Number of priority status words. */ >#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */ >#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */ > >#define RQB_BIT(pri) (1ul << ((pri) & (RQB_BPW - 1))) >#define RQB_WORD(pri) ((pri) >> RQB_L2BPW) > >#define RQB_FFS(word) (bsfq(word)) > >/* > * Type of run queue status word. > */ >typedef u_int64_t rqb_word_t; > >#endif ># 47 "./machine/runq.h" ># 33 "/usr/src/sys/sys/runq.h" 2 > >struct thread; > >/* > * Run queue parameters. > */ > >#define RQ_NQS (64) /* Number of run queues. */ >#define RQ_PPQ (4) /* Priorities per queue. */ > >/* > * Head of run queues. > */ >TAILQ_HEAD(rqhead, thread); > >/* > * Bit array which maintains the status of a run queue. When a queue is > * non-empty the bit corresponding to the queue number will be set. > */ >struct rqbits { > rqb_word_t rqb_bits[RQB_LEN]; >}; > >/* > * Run queue structure. Contains an array of run queues on which processes > * are placed, and a structure to maintain the status of each queue. > */ >struct runq { > struct rqbits rq_status; > struct rqhead rq_queues[RQ_NQS]; >}; > >void runq_add(struct runq *, struct thread *, int); >void runq_add_pri(struct runq *, struct thread *, u_char, int); >int runq_check(struct runq *); >struct thread *runq_choose(struct runq *); >struct thread *runq_choose_from(struct runq *, u_char); >struct thread *runq_choose_fuzz(struct runq *, int); >void runq_init(struct runq *); >void runq_remove(struct runq *, struct thread *); >void runq_remove_idx(struct runq *, struct thread *, u_char *); > >#endif ># 76 "/usr/src/sys/sys/runq.h" ># 55 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/resource.h> >#endif /* expanded by -frewrite-includes */ ># 55 "/usr/src/sys/sys/proc.h" ># 56 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sigio.h> >#endif /* expanded by -frewrite-includes */ ># 56 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/sigio.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: head/sys/sys/sigio.h 139825 2005-01-07 02:29:27Z imp $ > */ > >#ifndef _SYS_SIGIO_H_ >#define _SYS_SIGIO_H_ > >/* > * This structure holds the information needed to send a SIGIO or > * a SIGURG signal to a process or process group when new data arrives > * on a device or socket. The structure is placed on an SLIST belonging > * to the proc or pgrp so that the entire list may be revoked when the > * process exits or the process group disappears. > * > * (c) const > * (pg) locked by either the process or process group lock > */ >struct sigio { > union { > struct proc *siu_proc; /* (c) process to receive SIGIO/SIGURG */ > struct pgrp *siu_pgrp; /* (c) process group to receive ... */ > } sio_u; > SLIST_ENTRY(sigio) sio_pgsigio; /* (pg) sigio's for process or group */ > struct sigio **sio_myref; /* (c) location of the pointer that holds > * the reference to this structure */ > struct ucred *sio_ucred; /* (c) current credentials */ > pid_t sio_pgid; /* (c) pgid for signals */ >}; >#define sio_proc sio_u.siu_proc >#define sio_pgrp sio_u.siu_pgrp > >SLIST_HEAD(sigiolst, sigio); > >pid_t fgetown(struct sigio **sigiop); >int fsetown(pid_t pgid, struct sigio **sigiop); >void funsetown(struct sigio **sigiop); >void funsetownlst(struct sigiolst *sigiolst); > >#endif /* _SYS_SIGIO_H_ */ ># 68 "/usr/src/sys/sys/sigio.h" ># 57 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/signal.h> >#endif /* expanded by -frewrite-includes */ ># 57 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/signal.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)signal.h 8.4 (Berkeley) 5/4/95 > * $FreeBSD: head/sys/sys/signal.h 233519 2012-03-26 19:12:09Z rmh $ > */ > >#ifndef _SYS_SIGNAL_H_ >#define _SYS_SIGNAL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/signal.h" ># 42 "/usr/src/sys/sys/signal.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/signal.h" ># 43 "/usr/src/sys/sys/signal.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sigset.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/signal.h" ># 44 "/usr/src/sys/sys/signal.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_limits.h> /* __MINSIGSTKSZ */ >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/signal.h" ># 1 "./machine/_limits.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/_limits.h 232262 2012-02-28 18:24:28Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_limits.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_limits.h" ># 7 "./machine/_limits.h" ># 46 "/usr/src/sys/sys/signal.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */ >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/sys/signal.h" ># 1 "./machine/signal.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/signal.h 247047 2013-02-20 17:39:52Z kib $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/signal.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/signal.h" ># 1 "./x86/signal.h" 1 >/*- > * Copyright (c) 1986, 1989, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * Copyright (c) 2003 Peter Wemm. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)signal.h 8.1 (Berkeley) 6/11/93 > * $FreeBSD: head/sys/x86/include/signal.h 247047 2013-02-20 17:39:52Z kib $ > */ > >#ifndef _X86_SIGNAL_H >#define _X86_SIGNAL_H 1 > >/* > * Machine-dependent signal definitions > */ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 41 "./x86/signal.h" ># 42 "./x86/signal.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sigset.h> >#endif /* expanded by -frewrite-includes */ ># 42 "./x86/signal.h" ># 43 "./x86/signal.h" > >#if __BSD_VISIBLE >#if 0 /* expanded by -frewrite-includes */ >#include <machine/trap.h> /* codes for SIGILL, SIGFPE */ >#endif /* expanded by -frewrite-includes */ ># 45 "./x86/signal.h" ># 1 "./machine/trap.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/trap.h 232492 2012-03-04 14:12:57Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/trap.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/trap.h" ># 1 "./x86/trap.h" 1 >/*- > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)trap.h 5.4 (Berkeley) 5/9/91 > * $FreeBSD: head/sys/x86/include/trap.h 257417 2013-10-31 02:35:00Z markj $ > */ > >#ifndef _MACHINE_TRAP_H_ >#define _MACHINE_TRAP_H_ > >/* > * Trap type values > * also known in trap.c for name strings > */ > >#define T_PRIVINFLT 1 /* privileged instruction */ >#define T_BPTFLT 3 /* breakpoint instruction */ >#define T_ARITHTRAP 6 /* arithmetic trap */ >#define T_PROTFLT 9 /* protection fault */ >#define T_TRCTRAP 10 /* debug exception (sic) */ >#define T_PAGEFLT 12 /* page fault */ >#define T_ALIGNFLT 14 /* alignment fault */ > >#define T_DIVIDE 18 /* integer divide fault */ >#define T_NMI 19 /* non-maskable trap */ >#define T_OFLOW 20 /* overflow trap */ >#define T_BOUND 21 /* bound instruction fault */ >#define T_DNA 22 /* device not available fault */ >#define T_DOUBLEFLT 23 /* double fault */ >#define T_FPOPFLT 24 /* fp coprocessor operand fetch fault */ >#define T_TSSFLT 25 /* invalid tss fault */ >#define T_SEGNPFLT 26 /* segment not present fault */ >#define T_STKFLT 27 /* stack fault */ >#define T_MCHK 28 /* machine check trap */ >#define T_XMMFLT 29 /* SIMD floating-point exception */ >#define T_RESERVED 30 /* reserved (unknown) */ >#define T_DTRACE_RET 32 /* DTrace pid return */ > >/* XXX most of the following codes aren't used, but could be. */ > >/* definitions for <sys/signal.h> */ >#define ILL_RESAD_FAULT T_RESADFLT >#define ILL_PRIVIN_FAULT T_PRIVINFLT >#define ILL_RESOP_FAULT T_RESOPFLT >#define ILL_ALIGN_FAULT T_ALIGNFLT >#define ILL_FPOP_FAULT T_FPOPFLT /* coprocessor operand fault */ > >/* old FreeBSD macros, deprecated */ >#define FPE_INTOVF_TRAP 0x1 /* integer overflow */ >#define FPE_INTDIV_TRAP 0x2 /* integer divide by zero */ >#define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */ >#define FPE_FLTOVF_TRAP 0x4 /* floating overflow */ >#define FPE_FLTUND_TRAP 0x5 /* floating underflow */ >#define FPE_FPU_NP_TRAP 0x6 /* floating point unit not present */ >#define FPE_SUBRNG_TRAP 0x7 /* subrange out of bounds */ > >/* codes for SIGBUS */ >#define BUS_PAGE_FAULT T_PAGEFLT /* page fault protection base */ >#define BUS_SEGNP_FAULT T_SEGNPFLT /* segment not present */ >#define BUS_STK_FAULT T_STKFLT /* stack segment */ >#define BUS_SEGM_FAULT T_RESERVED /* segment protection base */ > >/* Trap's coming from user mode */ >#define T_USER 0x100 > >#endif /* !_MACHINE_TRAP_H_ */ ># 95 "./x86/trap.h" ># 7 "./machine/trap.h" 2 ># 46 "./x86/signal.h" 2 >#endif ># 47 "./x86/signal.h" > >#ifdef __i386__ >typedef int sig_atomic_t; > >#if __BSD_VISIBLE >struct sigcontext { > struct __sigset sc_mask; /* signal mask to restore */ > int sc_onstack; /* sigstack state to restore */ > int sc_gs; /* machine state (struct trapframe) */ > int sc_fs; > int sc_es; > int sc_ds; > int sc_edi; > int sc_esi; > int sc_ebp; > int sc_isp; > int sc_ebx; > int sc_edx; > int sc_ecx; > int sc_eax; > int sc_trapno; > int sc_err; > int sc_eip; > int sc_cs; > int sc_efl; > int sc_esp; > int sc_ss; > int sc_len; /* sizeof(mcontext_t) */ > /* > * See <machine/ucontext.h> and <machine/npx.h> for > * the following fields. > */ > int sc_fpformat; > int sc_ownedfp; > int sc_flags; > int sc_fpstate[128] __aligned(16); > > int sc_fsbase; > int sc_gsbase; > > int sc_xfpustate; > int sc_xfpustate_len; > > int sc_spare2[4]; >}; > >#define sc_sp sc_esp >#define sc_fp sc_ebp >#define sc_pc sc_eip >#define sc_ps sc_efl >#define sc_eflags sc_efl > >#endif /* __BSD_VISIBLE */ ># 100 "./x86/signal.h" >#endif /* __i386__ */ ># 101 "./x86/signal.h" > >#ifdef __amd64__ >typedef long sig_atomic_t; > >#if __BSD_VISIBLE >/* > * Information pushed on stack when a signal is delivered. > * This is used by the kernel to restore state following > * execution of the signal handler. It is also made available > * to the handler to allow it to restore state properly if > * a non-standard exit is performed. > * > * The sequence of the fields/registers after sc_mask in struct > * sigcontext must match those in mcontext_t and struct trapframe. > */ >struct sigcontext { > struct __sigset sc_mask; /* signal mask to restore */ > long sc_onstack; /* sigstack state to restore */ > long sc_rdi; /* machine state (struct trapframe) */ > long sc_rsi; > long sc_rdx; > long sc_rcx; > long sc_r8; > long sc_r9; > long sc_rax; > long sc_rbx; > long sc_rbp; > long sc_r10; > long sc_r11; > long sc_r12; > long sc_r13; > long sc_r14; > long sc_r15; > int sc_trapno; > short sc_fs; > short sc_gs; > long sc_addr; > int sc_flags; > short sc_es; > short sc_ds; > long sc_err; > long sc_rip; > long sc_cs; > long sc_rflags; > long sc_rsp; > long sc_ss; > long sc_len; /* sizeof(mcontext_t) */ > /* > * See <machine/ucontext.h> and <machine/fpu.h> for the following > * fields. > */ > long sc_fpformat; > long sc_ownedfp; > long sc_fpstate[64] __aligned(16); > > long sc_fsbase; > long sc_gsbase; > > long sc_xfpustate; > long sc_xfpustate_len; > > long sc_spare[4]; >}; >#endif /* __BSD_VISIBLE */ ># 165 "./x86/signal.h" >#endif /* __amd64__ */ ># 166 "./x86/signal.h" > >#endif ># 168 "./x86/signal.h" ># 7 "./machine/signal.h" 2 ># 47 "/usr/src/sys/sys/signal.h" 2 > >/* > * System defined signals. > */ >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SIGHUP 1 /* hangup */ >#endif ># 54 "/usr/src/sys/sys/signal.h" >#define SIGINT 2 /* interrupt */ >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SIGQUIT 3 /* quit */ >#endif ># 58 "/usr/src/sys/sys/signal.h" >#define SIGILL 4 /* illegal instr. (not reset when caught) */ >#if __XSI_VISIBLE >#define SIGTRAP 5 /* trace trap (not reset when caught) */ >#endif ># 62 "/usr/src/sys/sys/signal.h" >#define SIGABRT 6 /* abort() */ >#if __BSD_VISIBLE >#define SIGIOT SIGABRT /* compatibility */ >#define SIGEMT 7 /* EMT instruction */ >#endif ># 67 "/usr/src/sys/sys/signal.h" >#define SIGFPE 8 /* floating point exception */ >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SIGKILL 9 /* kill (cannot be caught or ignored) */ >#endif ># 71 "/usr/src/sys/sys/signal.h" >#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >#define SIGBUS 10 /* bus error */ >#endif ># 74 "/usr/src/sys/sys/signal.h" >#define SIGSEGV 11 /* segmentation violation */ >#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >#define SIGSYS 12 /* non-existent system call invoked */ >#endif ># 78 "/usr/src/sys/sys/signal.h" >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SIGPIPE 13 /* write on a pipe with no one to read it */ >#define SIGALRM 14 /* alarm clock */ >#endif ># 82 "/usr/src/sys/sys/signal.h" >#define SIGTERM 15 /* software termination signal from kill */ >#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >#define SIGURG 16 /* urgent condition on IO channel */ >#endif ># 86 "/usr/src/sys/sys/signal.h" >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SIGSTOP 17 /* sendable stop signal not from tty */ >#define SIGTSTP 18 /* stop signal from tty */ >#define SIGCONT 19 /* continue a stopped process */ >#define SIGCHLD 20 /* to parent on child stop or exit */ >#define SIGTTIN 21 /* to readers pgrp upon background tty read */ >#define SIGTTOU 22 /* like TTIN if (tp->t_local<OSTOP) */ >#endif ># 94 "/usr/src/sys/sys/signal.h" >#if __BSD_VISIBLE >#define SIGIO 23 /* input/output possible signal */ >#endif ># 97 "/usr/src/sys/sys/signal.h" >#if __XSI_VISIBLE >#define SIGXCPU 24 /* exceeded CPU time limit */ >#define SIGXFSZ 25 /* exceeded file size limit */ >#define SIGVTALRM 26 /* virtual time alarm */ >#define SIGPROF 27 /* profiling time alarm */ >#endif ># 103 "/usr/src/sys/sys/signal.h" >#if __BSD_VISIBLE >#define SIGWINCH 28 /* window size changes */ >#define SIGINFO 29 /* information request */ >#endif ># 107 "/usr/src/sys/sys/signal.h" >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SIGUSR1 30 /* user defined signal 1 */ >#define SIGUSR2 31 /* user defined signal 2 */ >#endif ># 111 "/usr/src/sys/sys/signal.h" >#if __BSD_VISIBLE >#define SIGTHR 32 /* reserved by thread library. */ >#define SIGLWP SIGTHR >#define SIGLIBRT 33 /* reserved by real-time library. */ >#endif ># 116 "/usr/src/sys/sys/signal.h" > >#define SIGRTMIN 65 >#define SIGRTMAX 126 > >#define SIG_DFL ((__sighandler_t *)0) >#define SIG_IGN ((__sighandler_t *)1) >#define SIG_ERR ((__sighandler_t *)-1) >/* #define SIG_CATCH ((__sighandler_t *)2) See signalvar.h */ >#define SIG_HOLD ((__sighandler_t *)3) > >/* > * Type of a signal handling function. > * > * Language spec sez signal handlers take exactly one arg, even though we > * actually supply three. Ugh! > * > * We don't try to hide the difference by leaving out the args because > * that would cause warnings about conformant programs. Nonconformant > * programs can avoid the warnings by casting to (__sighandler_t *) or > * sig_t before calling signal() or assigning to sa_handler or sv_handler. > * > * The kernel should reverse the cast before calling the function. It > * has no way to do this, but on most machines 1-arg and 3-arg functions > * have the same calling protocol so there is no problem in practice. > * A bit in sa_flags could be used to specify the number of args. > */ >typedef void __sighandler_t(int); > >#if __POSIX_VISIBLE || __XSI_VISIBLE >#ifndef _SIGSET_T_DECLARED >#define _SIGSET_T_DECLARED >typedef __sigset_t sigset_t; >#endif ># 149 "/usr/src/sys/sys/signal.h" >#endif ># 150 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500 >union sigval { > /* Members as suggested by Annex C of POSIX 1003.1b. */ > int sival_int; > void *sival_ptr; > /* 6.0 compatibility */ > int sigval_int; > void *sigval_ptr; >}; >#endif ># 161 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE >= 199309 >struct sigevent { > int sigev_notify; /* Notification type */ > int sigev_signo; /* Signal number */ > union sigval sigev_value; /* Signal value */ > union { > __lwpid_t _threadid; > struct { > void (*_function)(union sigval); > void *_attribute; /* pthread_attr_t * */ > } _sigev_thread; > unsigned short _kevent_flags; > long __spare__[8]; > } _sigev_un; >}; > >#if __BSD_VISIBLE >#define sigev_notify_kqueue sigev_signo >#define sigev_notify_kevent_flags _sigev_un._kevent_flags >#define sigev_notify_thread_id _sigev_un._threadid >#endif ># 183 "/usr/src/sys/sys/signal.h" >#define sigev_notify_function _sigev_un._sigev_thread._function >#define sigev_notify_attributes _sigev_un._sigev_thread._attribute > >#define SIGEV_NONE 0 /* No async notification. */ >#define SIGEV_SIGNAL 1 /* Generate a queued signal. */ >#define SIGEV_THREAD 2 /* Call back from another pthread. */ >#if __BSD_VISIBLE >#define SIGEV_KEVENT 3 /* Generate a kevent. */ >#define SIGEV_THREAD_ID 4 /* Send signal to a kernel thread. */ >#endif ># 193 "/usr/src/sys/sys/signal.h" >#endif /* __POSIX_VISIBLE >= 199309 */ ># 194 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >typedef struct __siginfo { > int si_signo; /* signal number */ > int si_errno; /* errno association */ > /* > * Cause of signal, one of the SI_ macros or signal-specific > * values, i.e. one of the FPE_... values for SIGFPE. This > * value is equivalent to the second argument to an old-style > * FreeBSD signal handler. > */ > int si_code; /* signal code */ > __pid_t si_pid; /* sending process */ > __uid_t si_uid; /* sender's ruid */ > int si_status; /* exit value */ > void *si_addr; /* faulting instruction */ > union sigval si_value; /* signal value */ > union { > struct { > int _trapno;/* machine specific trap code */ > } _fault; > struct { > int _timerid; > int _overrun; > } _timer; > struct { > int _mqd; > } _mesgq; > struct { > long _band; /* band event for SIGPOLL */ > } _poll; /* was this ever used ? */ > struct { > long __spare1__; > int __spare2__[7]; > } __spare__; > } _reason; >} siginfo_t; > >#define si_trapno _reason._fault._trapno >#define si_timerid _reason._timer._timerid >#define si_overrun _reason._timer._overrun >#define si_mqd _reason._mesgq._mqd >#define si_band _reason._poll._band > >/** si_code **/ >/* codes for SIGILL */ >#define ILL_ILLOPC 1 /* Illegal opcode. */ >#define ILL_ILLOPN 2 /* Illegal operand. */ >#define ILL_ILLADR 3 /* Illegal addressing mode. */ >#define ILL_ILLTRP 4 /* Illegal trap. */ >#define ILL_PRVOPC 5 /* Privileged opcode. */ >#define ILL_PRVREG 6 /* Privileged register. */ >#define ILL_COPROC 7 /* Coprocessor error. */ >#define ILL_BADSTK 8 /* Internal stack error. */ > >/* codes for SIGBUS */ >#define BUS_ADRALN 1 /* Invalid address alignment. */ >#define BUS_ADRERR 2 /* Nonexistent physical address. */ >#define BUS_OBJERR 3 /* Object-specific hardware error. */ > >/* codes for SIGSEGV */ >#define SEGV_MAPERR 1 /* Address not mapped to object. */ >#define SEGV_ACCERR 2 /* Invalid permissions for mapped */ > /* object. */ > >/* codes for SIGFPE */ >#define FPE_INTOVF 1 /* Integer overflow. */ >#define FPE_INTDIV 2 /* Integer divide by zero. */ >#define FPE_FLTDIV 3 /* Floating point divide by zero. */ >#define FPE_FLTOVF 4 /* Floating point overflow. */ >#define FPE_FLTUND 5 /* Floating point underflow. */ >#define FPE_FLTRES 6 /* Floating point inexact result. */ >#define FPE_FLTINV 7 /* Invalid floating point operation. */ >#define FPE_FLTSUB 8 /* Subscript out of range. */ > >/* codes for SIGTRAP */ >#define TRAP_BRKPT 1 /* Process breakpoint. */ >#define TRAP_TRACE 2 /* Process trace trap. */ >#define TRAP_DTRACE 3 /* DTrace induced trap. */ > >/* codes for SIGCHLD */ >#define CLD_EXITED 1 /* Child has exited */ >#define CLD_KILLED 2 /* Child has terminated abnormally but */ > /* did not create a core file */ >#define CLD_DUMPED 3 /* Child has terminated abnormally and */ > /* created a core file */ >#define CLD_TRAPPED 4 /* Traced child has trapped */ >#define CLD_STOPPED 5 /* Child has stopped */ >#define CLD_CONTINUED 6 /* Stopped child has continued */ > >/* codes for SIGPOLL */ >#define POLL_IN 1 /* Data input available */ >#define POLL_OUT 2 /* Output buffers available */ >#define POLL_MSG 3 /* Input message available */ >#define POLL_ERR 4 /* I/O Error */ >#define POLL_PRI 5 /* High priority input available */ >#define POLL_HUP 6 /* Device disconnected */ > >#endif ># 293 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE || __XSI_VISIBLE >struct __siginfo; > >/* > * Signal vector "template" used in sigaction call. > */ >struct sigaction { > union { > void (*__sa_handler)(int); > void (*__sa_sigaction)(int, struct __siginfo *, void *); > } __sigaction_u; /* signal handler */ > int sa_flags; /* see signal options below */ > sigset_t sa_mask; /* signal mask to apply */ >}; > >#define sa_handler __sigaction_u.__sa_handler >#endif ># 311 "/usr/src/sys/sys/signal.h" > >#if __XSI_VISIBLE >/* If SA_SIGINFO is set, sa_sigaction must be used instead of sa_handler. */ >#define sa_sigaction __sigaction_u.__sa_sigaction >#endif ># 316 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ >#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */ ># 320 "/usr/src/sys/sys/signal.h" > >#if __XSI_VISIBLE >#define SA_ONSTACK 0x0001 /* take signal on signal stack */ >#define SA_RESTART 0x0002 /* restart system call on signal return */ >#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ >#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ >#define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */ >#define SA_SIGINFO 0x0040 /* signal handler with SA_SIGINFO args */ >#endif ># 329 "/usr/src/sys/sys/signal.h" > >#if __BSD_VISIBLE >#define NSIG 32 /* number of old signals (counting 0) */ >#endif ># 333 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE || __XSI_VISIBLE >#define SI_NOINFO 0 /* No signal info besides si_signo. */ >#define SI_USER 0x10001 /* Signal sent by kill(). */ >#define SI_QUEUE 0x10002 /* Signal sent by the sigqueue(). */ >#define SI_TIMER 0x10003 /* Signal generated by expiration of */ > /* a timer set by timer_settime(). */ >#define SI_ASYNCIO 0x10004 /* Signal generated by completion of */ > /* an asynchronous I/O request.*/ >#define SI_MESGQ 0x10005 /* Signal generated by arrival of a */ > /* message on an empty message queue. */ >#define SI_KERNEL 0x10006 >#define SI_LWP 0x10007 /* Signal sent by thr_kill */ >#endif ># 347 "/usr/src/sys/sys/signal.h" >#if __BSD_VISIBLE >#define SI_UNDEFINED 0 >#endif ># 350 "/usr/src/sys/sys/signal.h" > >#if __BSD_VISIBLE >typedef __sighandler_t *sig_t; /* type of pointer to a signal function */ >typedef void __siginfohandler_t(int, struct __siginfo *, void *); >#endif ># 355 "/usr/src/sys/sys/signal.h" > >#if __XSI_VISIBLE >/* > * Structure used in sigaltstack call. > */ >#if __BSD_VISIBLE >typedef struct sigaltstack { >#else ># 363 "/usr/src/sys/sys/signal.h" >typedef struct { >#endif ># 365 "/usr/src/sys/sys/signal.h" > char *ss_sp; /* signal stack base */ > __size_t ss_size; /* signal stack length */ > int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ >} stack_t; > >#define SS_ONSTACK 0x0001 /* take signal on alternate stack */ >#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ >#define MINSIGSTKSZ __MINSIGSTKSZ /* minimum stack size */ >#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ >#endif ># 375 "/usr/src/sys/sys/signal.h" > >#if __BSD_VISIBLE >/* > * 4.3 compatibility: > * Signal vector "template" used in sigvec call. > */ >struct sigvec { > __sighandler_t *sv_handler; /* signal handler */ > int sv_mask; /* signal mask to apply */ > int sv_flags; /* see signal options below */ >}; > >#define SV_ONSTACK SA_ONSTACK >#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ >#define SV_RESETHAND SA_RESETHAND >#define SV_NODEFER SA_NODEFER >#define SV_NOCLDSTOP SA_NOCLDSTOP >#define SV_SIGINFO SA_SIGINFO >#define sv_onstack sv_flags /* isn't compatibility wonderful! */ >#endif ># 395 "/usr/src/sys/sys/signal.h" > >/* Keep this in one place only */ >#if defined(_KERNEL) && defined(COMPAT_43) && \ > !defined(__i386__) >struct osigcontext { > int _not_used; >}; >#endif ># 403 "/usr/src/sys/sys/signal.h" > >#if __XSI_VISIBLE >/* > * Structure used in sigstack call. > */ >struct sigstack { > /* XXX ss_sp's type should be `void *'. */ > char *ss_sp; /* signal stack pointer */ > int ss_onstack; /* current status */ >}; >#endif ># 414 "/usr/src/sys/sys/signal.h" > >#if __BSD_VISIBLE || __POSIX_VISIBLE > 0 && __POSIX_VISIBLE <= 200112 >/* > * Macro for converting signal number to a mask suitable for > * sigblock(). > */ >#define sigmask(m) (1 << ((m)-1)) >#endif ># 422 "/usr/src/sys/sys/signal.h" > >#if __BSD_VISIBLE >#define BADSIG SIG_ERR >#endif ># 426 "/usr/src/sys/sys/signal.h" > >#if __POSIX_VISIBLE || __XSI_VISIBLE >/* > * Flags for sigprocmask: > */ >#define SIG_BLOCK 1 /* block specified signal set */ >#define SIG_UNBLOCK 2 /* unblock specified signal set */ >#define SIG_SETMASK 3 /* set specified signal set */ >#endif ># 435 "/usr/src/sys/sys/signal.h" > >/* > * For historical reasons; programs expect signal's return value to be > * defined by <sys/signal.h>. > */ >__BEGIN_DECLS >__sighandler_t *signal(int, __sighandler_t *); >__END_DECLS > >#endif /* !_SYS_SIGNAL_H_ */ ># 445 "/usr/src/sys/sys/signal.h" ># 58 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/signalvar.h> >#endif /* expanded by -frewrite-includes */ ># 58 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/signalvar.h" 1 >/*- > * Copyright (c) 1991, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 > * $FreeBSD: head/sys/sys/signalvar.h 277321 2015-01-18 15:03:26Z kib $ > */ > >#ifndef _SYS_SIGNALVAR_H_ >#define _SYS_SIGNALVAR_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/signalvar.h" ># 37 "/usr/src/sys/sys/signalvar.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/signalvar.h" ># 38 "/usr/src/sys/sys/signalvar.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/signalvar.h" ># 39 "/usr/src/sys/sys/signalvar.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/signal.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/signalvar.h" ># 40 "/usr/src/sys/sys/signalvar.h" > >/* > * Kernel signal definitions and data structures. > */ > >/* > * Logical process signal actions and state, needed only within the process > * The mapping between sigacts and proc structures is 1:1 except for rfork() > * processes masquerading as threads which use one structure for the whole > * group. All members are locked by the included mutex. The reference count > * and mutex must be last for the bcopy in sigacts_copy() to work. > */ >struct sigacts { > sig_t ps_sigact[_SIG_MAXSIG]; /* Disposition of signals. */ > sigset_t ps_catchmask[_SIG_MAXSIG]; /* Signals to be blocked. */ > sigset_t ps_sigonstack; /* Signals to take on sigstack. */ > sigset_t ps_sigintr; /* Signals that interrupt syscalls. */ > sigset_t ps_sigreset; /* Signals that reset when caught. */ > sigset_t ps_signodefer; /* Signals not masked while handled. */ > sigset_t ps_siginfo; /* Signals that want SA_SIGINFO args. */ > sigset_t ps_sigignore; /* Signals being ignored. */ > sigset_t ps_sigcatch; /* Signals being caught by user. */ > sigset_t ps_freebsd4; /* Signals using freebsd4 ucontext. */ > sigset_t ps_osigset; /* Signals using <= 3.x osigset_t. */ > sigset_t ps_usertramp; /* SunOS compat; libc sigtramp. XXX */ > int ps_flag; > u_int ps_refcnt; > struct mtx ps_mtx; >}; > >#define PS_NOCLDWAIT 0x0001 /* No zombies if child dies */ >#define PS_NOCLDSTOP 0x0002 /* No SIGCHLD when children stop. */ >#define PS_CLDSIGIGN 0x0004 /* The SIGCHLD handler is SIG_IGN. */ > >#ifdef _KERNEL > >#ifdef COMPAT_43 >typedef struct { > struct osigcontext si_sc; > int si_signo; > int si_code; > union sigval si_value; >} osiginfo_t; > >struct osigaction { > union { > void (*__sa_handler)(int); > void (*__sa_sigaction)(int, osiginfo_t *, void *); > } __sigaction_u; /* signal handler */ > osigset_t sa_mask; /* signal mask to apply */ > int sa_flags; /* see signal options below */ >}; > >typedef void __osiginfohandler_t(int, osiginfo_t *, void *); >#endif /* COMPAT_43 */ ># 95 "/usr/src/sys/sys/signalvar.h" > >/* additional signal action values, used only temporarily/internally */ >#define SIG_CATCH ((__sighandler_t *)2) >/* #define SIG_HOLD ((__sighandler_t *)3) See signal.h */ > >/* > * get signal action for process and signal; currently only for current process > */ >#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) > >#endif /* _KERNEL */ ># 106 "/usr/src/sys/sys/signalvar.h" > >/* > * sigset_t manipulation macros. > */ >#define SIGADDSET(set, signo) \ > ((set).__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo)) > >#define SIGDELSET(set, signo) \ > ((set).__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo)) > >#define SIGEMPTYSET(set) \ > do { \ > int __i; \ > for (__i = 0; __i < _SIG_WORDS; __i++) \ > (set).__bits[__i] = 0; \ > } while (0) > >#define SIGFILLSET(set) \ > do { \ > int __i; \ > for (__i = 0; __i < _SIG_WORDS; __i++) \ > (set).__bits[__i] = ~0U; \ > } while (0) > >#define SIGISMEMBER(set, signo) \ > ((set).__bits[_SIG_WORD(signo)] & _SIG_BIT(signo)) > >#define SIGISEMPTY(set) (__sigisempty(&(set))) >#define SIGNOTEMPTY(set) (!__sigisempty(&(set))) > >#define SIGSETEQ(set1, set2) (__sigseteq(&(set1), &(set2))) >#define SIGSETNEQ(set1, set2) (!__sigseteq(&(set1), &(set2))) > >#define SIGSETOR(set1, set2) \ > do { \ > int __i; \ > for (__i = 0; __i < _SIG_WORDS; __i++) \ > (set1).__bits[__i] |= (set2).__bits[__i]; \ > } while (0) > >#define SIGSETAND(set1, set2) \ > do { \ > int __i; \ > for (__i = 0; __i < _SIG_WORDS; __i++) \ > (set1).__bits[__i] &= (set2).__bits[__i]; \ > } while (0) > >#define SIGSETNAND(set1, set2) \ > do { \ > int __i; \ > for (__i = 0; __i < _SIG_WORDS; __i++) \ > (set1).__bits[__i] &= ~(set2).__bits[__i]; \ > } while (0) > >#define SIGSETLO(set1, set2) ((set1).__bits[0] = (set2).__bits[0]) >#define SIGSETOLD(set, oset) ((set).__bits[0] = (oset)) > >#define SIG_CANTMASK(set) \ > SIGDELSET(set, SIGKILL), SIGDELSET(set, SIGSTOP) > >#define SIG_STOPSIGMASK(set) \ > SIGDELSET(set, SIGSTOP), SIGDELSET(set, SIGTSTP), \ > SIGDELSET(set, SIGTTIN), SIGDELSET(set, SIGTTOU) > >#define SIG_CONTSIGMASK(set) \ > SIGDELSET(set, SIGCONT) > >#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) > >#define SIG2OSIG(sig, osig) (osig = (sig).__bits[0]) >#define OSIG2SIG(osig, sig) SIGEMPTYSET(sig); (sig).__bits[0] = osig > >static __inline int >__sigisempty(sigset_t *set) >{ > int i; > > for (i = 0; i < _SIG_WORDS; i++) { > if (set->__bits[i]) > return (0); > } > return (1); >} > >static __inline int >__sigseteq(sigset_t *set1, sigset_t *set2) >{ > int i; > > for (i = 0; i < _SIG_WORDS; i++) { > if (set1->__bits[i] != set2->__bits[i]) > return (0); > } > return (1); >} > >struct osigevent { > int sigev_notify; /* Notification type */ > union { > int __sigev_signo; /* Signal number */ > int __sigev_notify_kqueue; > } __sigev_u; > union sigval sigev_value; /* Signal value */ >}; > >typedef struct ksiginfo { > TAILQ_ENTRY(ksiginfo) ksi_link; > siginfo_t ksi_info; > int ksi_flags; > struct sigqueue *ksi_sigq; >} ksiginfo_t; > >#define ksi_signo ksi_info.si_signo >#define ksi_errno ksi_info.si_errno >#define ksi_code ksi_info.si_code >#define ksi_pid ksi_info.si_pid >#define ksi_uid ksi_info.si_uid >#define ksi_status ksi_info.si_status >#define ksi_addr ksi_info.si_addr >#define ksi_value ksi_info.si_value >#define ksi_band ksi_info.si_band >#define ksi_trapno ksi_info.si_trapno >#define ksi_overrun ksi_info.si_overrun >#define ksi_timerid ksi_info.si_timerid >#define ksi_mqd ksi_info.si_mqd > >/* bits for ksi_flags */ >#define KSI_TRAP 0x01 /* Generated by trap. */ >#define KSI_EXT 0x02 /* Externally managed ksi. */ >#define KSI_INS 0x04 /* Directly insert ksi, not the copy */ >#define KSI_SIGQ 0x08 /* Generated by sigqueue, might ret EGAIN. */ >#define KSI_HEAD 0x10 /* Insert into head, not tail. */ >#define KSI_COPYMASK (KSI_TRAP|KSI_SIGQ) > >#define KSI_ONQ(ksi) ((ksi)->ksi_sigq != NULL) > >typedef struct sigqueue { > sigset_t sq_signals; /* All pending signals. */ > sigset_t sq_kill; /* Legacy depth 1 queue. */ > TAILQ_HEAD(, ksiginfo) sq_list;/* Queued signal info. */ > struct proc *sq_proc; > int sq_flags; >} sigqueue_t; > >/* Flags for ksi_flags */ >#define SQ_INIT 0x01 > >#ifdef _KERNEL > >/* Return nonzero if process p has an unmasked pending signal. */ >#define SIGPENDING(td) \ > ((!SIGISEMPTY((td)->td_siglist) && \ > !sigsetmasked(&(td)->td_siglist, &(td)->td_sigmask)) || \ > (!SIGISEMPTY((td)->td_proc->p_siglist) && \ > !sigsetmasked(&(td)->td_proc->p_siglist, &(td)->td_sigmask))) >/* > * Return the value of the pseudo-expression ((*set & ~*mask) != 0). This > * is an optimized version of SIGISEMPTY() on a temporary variable > * containing SIGSETNAND(*set, *mask). > */ >static __inline int >sigsetmasked(sigset_t *set, sigset_t *mask) >{ > int i; > > for (i = 0; i < _SIG_WORDS; i++) { > if (set->__bits[i] & ~mask->__bits[i]) > return (0); > } > return (1); >} > >#define ksiginfo_init(ksi) \ >do { \ > bzero(ksi, sizeof(ksiginfo_t)); \ >} while(0) > >#define ksiginfo_init_trap(ksi) \ >do { \ > ksiginfo_t *kp = ksi; \ > bzero(kp, sizeof(ksiginfo_t)); \ > kp->ksi_flags |= KSI_TRAP; \ >} while(0) > >static __inline void >ksiginfo_copy(ksiginfo_t *src, ksiginfo_t *dst) >{ > (dst)->ksi_info = src->ksi_info; > (dst)->ksi_flags = (src->ksi_flags & KSI_COPYMASK); >} > >static __inline void >ksiginfo_set_sigev(ksiginfo_t *dst, struct sigevent *sigev) >{ > dst->ksi_signo = sigev->sigev_signo; > dst->ksi_value = sigev->sigev_value; >} > >struct pgrp; >struct proc; >struct sigio; >struct thread; > >/* > * Lock the pointers for a sigio object in the underlying objects of > * a file descriptor. > */ >#define SIGIO_LOCK() mtx_lock(&sigio_lock) >#define SIGIO_TRYLOCK() mtx_trylock(&sigio_lock) >#define SIGIO_UNLOCK() mtx_unlock(&sigio_lock) >#define SIGIO_LOCKED() mtx_owned(&sigio_lock) >#define SIGIO_ASSERT(type) mtx_assert(&sigio_lock, type) > >extern struct mtx sigio_lock; > >/* Flags for kern_sigprocmask(). */ >#define SIGPROCMASK_OLD 0x0001 >#define SIGPROCMASK_PROC_LOCKED 0x0002 >#define SIGPROCMASK_PS_LOCKED 0x0004 > >int cursig(struct thread *td); >int sigdeferstop(void); >int sigallowstop(void); >void execsigs(struct proc *p); >void gsignal(int pgid, int sig, ksiginfo_t *ksi); >void killproc(struct proc *p, char *why); >ksiginfo_t * ksiginfo_alloc(int wait); >void ksiginfo_free(ksiginfo_t *ksi); >int pksignal(struct proc *p, int sig, ksiginfo_t *ksi); >void pgsigio(struct sigio **sigiop, int sig, int checkctty); >void pgsignal(struct pgrp *pgrp, int sig, int checkctty, ksiginfo_t *ksi); >int postsig(int sig); >void kern_psignal(struct proc *p, int sig); >int ptracestop(struct thread *td, int sig); >void sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *retmask); >struct sigacts *sigacts_alloc(void); >void sigacts_copy(struct sigacts *dest, struct sigacts *src); >void sigacts_free(struct sigacts *ps); >struct sigacts *sigacts_hold(struct sigacts *ps); >int sigacts_shared(struct sigacts *ps); >void sigexit(struct thread *td, int sig) __dead2; >int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **); >int sig_ffs(sigset_t *set); >void siginit(struct proc *p); >void signotify(struct thread *td); >void sigqueue_delete(struct sigqueue *queue, int sig); >void sigqueue_delete_proc(struct proc *p, int sig); >void sigqueue_flush(struct sigqueue *queue); >void sigqueue_init(struct sigqueue *queue, struct proc *p); >void sigqueue_take(ksiginfo_t *ksi); >void tdksignal(struct thread *td, int sig, ksiginfo_t *ksi); >int tdsendsignal(struct proc *p, struct thread *td, int sig, > ksiginfo_t *ksi); >void tdsigcleanup(struct thread *td); >void tdsignal(struct thread *td, int sig); >void trapsignal(struct thread *td, ksiginfo_t *ksi); > >#endif /* _KERNEL */ ># 364 "/usr/src/sys/sys/signalvar.h" > >#endif /* !_SYS_SIGNALVAR_H_ */ ># 366 "/usr/src/sys/sys/signalvar.h" ># 59 "/usr/src/sys/sys/proc.h" 2 >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/time.h> /* For structs itimerval, timeval. */ >#endif /* expanded by -frewrite-includes */ ># 60 "/usr/src/sys/sys/proc.h" ># 61 "/usr/src/sys/sys/proc.h" >#else ># 62 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 62 "/usr/src/sys/sys/proc.h" ># 63 "/usr/src/sys/sys/proc.h" >#endif ># 64 "/usr/src/sys/sys/proc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ucontext.h> >#endif /* expanded by -frewrite-includes */ ># 64 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/ucontext.h" 1 >/*- > * Copyright (c) 1999 Marcel Moolenaar > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer > * in this position and unchanged. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. The name of the author may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/ucontext.h 278001 2015-01-31 21:43:46Z kib $ > */ > >#ifndef _SYS_UCONTEXT_H_ >#define _SYS_UCONTEXT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/signal.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/sys/sys/ucontext.h" ># 35 "/usr/src/sys/sys/ucontext.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/ucontext.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/ucontext.h" ># 1 "./machine/ucontext.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/ucontext.h 247047 2013-02-20 17:39:52Z kib $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/ucontext.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/ucontext.h" ># 1 "./x86/ucontext.h" 1 >/*- > * Copyright (c) 2003 Peter Wemm > * Copyright (c) 1999 Marcel Moolenaar > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer > * in this position and unchanged. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. The name of the author may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/x86/include/ucontext.h 247047 2013-02-20 17:39:52Z kib $ > */ > >#ifndef _X86_UCONTEXT_H_ >#define _X86_UCONTEXT_H_ > >#ifdef __i386__ >/* Keep _MC_* values similar to amd64 */ >#define _MC_HASSEGS 0x1 >#define _MC_HASBASES 0x2 >#define _MC_HASFPXSTATE 0x4 >#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE) > >typedef struct __mcontext { > /* > * The definition of mcontext_t must match the layout of > * struct sigcontext after the sc_mask member. This is so > * that we can support sigcontext and ucontext_t at the same > * time. > */ > __register_t mc_onstack; /* XXX - sigcontext compat. */ > __register_t mc_gs; /* machine state (struct trapframe) */ > __register_t mc_fs; > __register_t mc_es; > __register_t mc_ds; > __register_t mc_edi; > __register_t mc_esi; > __register_t mc_ebp; > __register_t mc_isp; > __register_t mc_ebx; > __register_t mc_edx; > __register_t mc_ecx; > __register_t mc_eax; > __register_t mc_trapno; > __register_t mc_err; > __register_t mc_eip; > __register_t mc_cs; > __register_t mc_eflags; > __register_t mc_esp; > __register_t mc_ss; > > int mc_len; /* sizeof(mcontext_t) */ >#define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */ >#define _MC_FPFMT_387 0x10001 >#define _MC_FPFMT_XMM 0x10002 > int mc_fpformat; >#define _MC_FPOWNED_NONE 0x20000 /* FP state not used */ >#define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */ >#define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */ > int mc_ownedfp; > __register_t mc_flags; > /* > * See <machine/npx.h> for the internals of mc_fpstate[]. > */ > int mc_fpstate[128] __aligned(16); > > __register_t mc_fsbase; > __register_t mc_gsbase; > > __register_t mc_xfpustate; > __register_t mc_xfpustate_len; > > int mc_spare2[4]; >} mcontext_t; >#endif /* __i386__ */ ># 94 "./x86/ucontext.h" > >#ifdef __amd64__ >/* > * mc_trapno bits. Shall be in sync with TF_XXX. > */ >#define _MC_HASSEGS 0x1 >#define _MC_HASBASES 0x2 >#define _MC_HASFPXSTATE 0x4 >#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE) > >typedef struct __mcontext { > /* > * The definition of mcontext_t must match the layout of > * struct sigcontext after the sc_mask member. This is so > * that we can support sigcontext and ucontext_t at the same > * time. > */ > __register_t mc_onstack; /* XXX - sigcontext compat. */ > __register_t mc_rdi; /* machine state (struct trapframe) */ > __register_t mc_rsi; > __register_t mc_rdx; > __register_t mc_rcx; > __register_t mc_r8; > __register_t mc_r9; > __register_t mc_rax; > __register_t mc_rbx; > __register_t mc_rbp; > __register_t mc_r10; > __register_t mc_r11; > __register_t mc_r12; > __register_t mc_r13; > __register_t mc_r14; > __register_t mc_r15; > __uint32_t mc_trapno; > __uint16_t mc_fs; > __uint16_t mc_gs; > __register_t mc_addr; > __uint32_t mc_flags; > __uint16_t mc_es; > __uint16_t mc_ds; > __register_t mc_err; > __register_t mc_rip; > __register_t mc_cs; > __register_t mc_rflags; > __register_t mc_rsp; > __register_t mc_ss; > > long mc_len; /* sizeof(mcontext_t) */ > >#define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */ >#define _MC_FPFMT_XMM 0x10002 > long mc_fpformat; >#define _MC_FPOWNED_NONE 0x20000 /* FP state not used */ >#define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */ >#define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */ > long mc_ownedfp; > /* > * See <machine/fpu.h> for the internals of mc_fpstate[]. > */ > long mc_fpstate[64] __aligned(16); > > __register_t mc_fsbase; > __register_t mc_gsbase; > > __register_t mc_xfpustate; > __register_t mc_xfpustate_len; > > long mc_spare[4]; >} mcontext_t; >#endif /* __amd64__ */ ># 164 "./x86/ucontext.h" > >#endif /* !_X86_UCONTEXT_H_ */ ># 166 "./x86/ucontext.h" ># 7 "./machine/ucontext.h" 2 ># 36 "/usr/src/sys/sys/ucontext.h" 2 > >typedef struct __ucontext { > /* > * Keep the order of the first two fields. Also, > * keep them the first two fields in the structure. > * This way we can have a union with struct > * sigcontext and ucontext_t. This allows us to > * support them both at the same time. > * note: the union is not defined, though. > */ > sigset_t uc_sigmask; > mcontext_t uc_mcontext; > > struct __ucontext *uc_link; > stack_t uc_stack; > int uc_flags; >#define UCF_SWAPPED 0x00000001 /* Used by swapcontext(3). */ > int __spare__[4]; >} ucontext_t; > >#if defined(_KERNEL) && defined(COMPAT_FREEBSD4) >#if defined(__i386__) >struct ucontext4 { > sigset_t uc_sigmask; > struct mcontext4 uc_mcontext; > struct ucontext4 *uc_link; > stack_t uc_stack; > int __spare__[8]; >}; >#else /* __i386__ */ ># 66 "/usr/src/sys/sys/ucontext.h" >#define ucontext4 ucontext >#endif /* __i386__ */ ># 68 "/usr/src/sys/sys/ucontext.h" >#endif /* _KERNEL */ ># 69 "/usr/src/sys/sys/ucontext.h" > >#ifndef _KERNEL > >__BEGIN_DECLS > >int getcontext(ucontext_t *) __returns_twice; >ucontext_t *getcontextx(void); >int setcontext(const ucontext_t *); >void makecontext(ucontext_t *, void (*)(void), int, ...); >int signalcontext(ucontext_t *, int, __sighandler_t *); >int swapcontext(ucontext_t *, const ucontext_t *); > >#if __BSD_VISIBLE >int __getcontextx_size(void); >int __fillcontextx(char *ctx) __returns_twice; >int __fillcontextx2(char *ctx); >#endif ># 86 "/usr/src/sys/sys/ucontext.h" > >__END_DECLS > >#else /* _KERNEL */ ># 90 "/usr/src/sys/sys/ucontext.h" > >struct thread; > >/* > * Flags for get_mcontext(). The low order 4 bits (i.e a mask of 0x0f) are > * reserved for use by machine independent code. All other bits are for use > * by machine dependent code. > */ >#define GET_MC_CLEAR_RET 1 > >/* Machine-dependent functions: */ >int get_mcontext(struct thread *, mcontext_t *, int); >int set_mcontext(struct thread *, mcontext_t *); > >#endif /* !_KERNEL */ ># 105 "/usr/src/sys/sys/ucontext.h" > >#endif /* !_SYS_UCONTEXT_H_ */ ># 107 "/usr/src/sys/sys/ucontext.h" ># 65 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ucred.h> >#endif /* expanded by -frewrite-includes */ ># 65 "/usr/src/sys/sys/proc.h" ># 1 "/usr/src/sys/sys/ucred.h" 1 >/*- > * Copyright (c) 1989, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)ucred.h 8.4 (Berkeley) 1/9/95 > * $FreeBSD: head/sys/sys/ucred.h 280331 2015-03-21 20:24:54Z mjg $ > */ > >#ifndef _SYS_UCRED_H_ >#define _SYS_UCRED_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <bsm/audit.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/ucred.h" ># 1 "/usr/src/sys/bsm/audit.h" 1 >/*- > * Copyright (c) 2005-2009 Apple Inc. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Neither the name of Apple Inc. ("Apple") nor the names of > * its contributors may be used to endorse or promote products derived > * from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit.h#10 > * $FreeBSD: head/sys/bsm/audit.h 195740 2009-07-17 14:02:20Z rwatson $ > */ > >#ifndef _BSM_AUDIT_H >#define _BSM_AUDIT_H > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/bsm/audit.h" ># 37 "/usr/src/sys/bsm/audit.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/bsm/audit.h" ># 38 "/usr/src/sys/bsm/audit.h" > >#define AUDIT_RECORD_MAGIC 0x828a0f1b >#define MAX_AUDIT_RECORDS 20 >#define MAXAUDITDATA (0x8000 - 1) >#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA >#define MIN_AUDIT_FILE_SIZE (512 * 1024) > >/* > * Minimum noumber of free blocks on the filesystem containing the audit > * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0 > * as the kernel does an unsigned compare, plus we want to leave a few blocks > * free so userspace can terminate the log, etc. > */ >#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4 > >/* > * Triggers for the audit daemon. > */ >#define AUDIT_TRIGGER_MIN 1 >#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */ >#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */ >#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */ >#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */ >#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */ >#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */ >#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */ >#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */ >#define AUDIT_TRIGGER_MAX 8 > >/* > * The special device filename (FreeBSD). > */ >#define AUDITDEV_FILENAME "audit" >#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME) > >/* > * Pre-defined audit IDs > */ >#define AU_DEFAUDITID (uid_t)(-1) >#define AU_DEFAUDITSID 0 >#define AU_ASSIGN_ASID -1 > >/* > * IPC types. > */ >#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */ >#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */ >#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */ > >/* > * Audit conditions. > */ >#define AUC_UNSET 0 >#define AUC_AUDITING 1 >#define AUC_NOAUDIT 2 >#define AUC_DISABLED -1 > >/* > * auditon(2) commands. > */ >#define A_OLDGETPOLICY 2 >#define A_OLDSETPOLICY 3 >#define A_GETKMASK 4 >#define A_SETKMASK 5 >#define A_OLDGETQCTRL 6 >#define A_OLDSETQCTRL 7 >#define A_GETCWD 8 >#define A_GETCAR 9 >#define A_GETSTAT 12 >#define A_SETSTAT 13 >#define A_SETUMASK 14 >#define A_SETSMASK 15 >#define A_OLDGETCOND 20 >#define A_OLDSETCOND 21 >#define A_GETCLASS 22 >#define A_SETCLASS 23 >#define A_GETPINFO 24 >#define A_SETPMASK 25 >#define A_SETFSIZE 26 >#define A_GETFSIZE 27 >#define A_GETPINFO_ADDR 28 >#define A_GETKAUDIT 29 >#define A_SETKAUDIT 30 >#define A_SENDTRIGGER 31 >#define A_GETSINFO_ADDR 32 >#define A_GETPOLICY 33 >#define A_SETPOLICY 34 >#define A_GETQCTRL 35 >#define A_SETQCTRL 36 >#define A_GETCOND 37 >#define A_SETCOND 38 > >/* > * Audit policy controls. > */ >#define AUDIT_CNT 0x0001 >#define AUDIT_AHLT 0x0002 >#define AUDIT_ARGV 0x0004 >#define AUDIT_ARGE 0x0008 >#define AUDIT_SEQ 0x0010 >#define AUDIT_WINDATA 0x0020 >#define AUDIT_USER 0x0040 >#define AUDIT_GROUP 0x0080 >#define AUDIT_TRAIL 0x0100 >#define AUDIT_PATH 0x0200 >#define AUDIT_SCNT 0x0400 >#define AUDIT_PUBLIC 0x0800 >#define AUDIT_ZONENAME 0x1000 >#define AUDIT_PERZONE 0x2000 > >/* > * Default audit queue control parameters. > */ >#define AQ_HIWATER 100 >#define AQ_MAXHIGH 10000 >#define AQ_LOWATER 10 >#define AQ_BUFSZ MAXAUDITDATA >#define AQ_MAXBUFSZ 1048576 > >/* > * Default minimum percentage free space on file system. > */ >#define AU_FS_MINFREE 20 > >/* > * Type definitions used indicating the length of variable length addresses > * in tokens containing addresses, such as header fields. > */ >#define AU_IPv4 4 >#define AU_IPv6 16 > >__BEGIN_DECLS > >typedef uid_t au_id_t; >typedef pid_t au_asid_t; >typedef u_int16_t au_event_t; >typedef u_int16_t au_emod_t; >typedef u_int32_t au_class_t; >typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8))); > >struct au_tid { > dev_t port; > u_int32_t machine; >}; >typedef struct au_tid au_tid_t; > >struct au_tid_addr { > dev_t at_port; > u_int32_t at_type; > u_int32_t at_addr[4]; >}; >typedef struct au_tid_addr au_tid_addr_t; > >struct au_mask { > unsigned int am_success; /* Success bits. */ > unsigned int am_failure; /* Failure bits. */ >}; >typedef struct au_mask au_mask_t; > >struct auditinfo { > au_id_t ai_auid; /* Audit user ID. */ > au_mask_t ai_mask; /* Audit masks. */ > au_tid_t ai_termid; /* Terminal ID. */ > au_asid_t ai_asid; /* Audit session ID. */ >}; >typedef struct auditinfo auditinfo_t; > >struct auditinfo_addr { > au_id_t ai_auid; /* Audit user ID. */ > au_mask_t ai_mask; /* Audit masks. */ > au_tid_addr_t ai_termid; /* Terminal ID. */ > au_asid_t ai_asid; /* Audit session ID. */ > au_asflgs_t ai_flags; /* Audit session flags. */ >}; >typedef struct auditinfo_addr auditinfo_addr_t; > >struct auditpinfo { > pid_t ap_pid; /* ID of target process. */ > au_id_t ap_auid; /* Audit user ID. */ > au_mask_t ap_mask; /* Audit masks. */ > au_tid_t ap_termid; /* Terminal ID. */ > au_asid_t ap_asid; /* Audit session ID. */ >}; >typedef struct auditpinfo auditpinfo_t; > >struct auditpinfo_addr { > pid_t ap_pid; /* ID of target process. */ > au_id_t ap_auid; /* Audit user ID. */ > au_mask_t ap_mask; /* Audit masks. */ > au_tid_addr_t ap_termid; /* Terminal ID. */ > au_asid_t ap_asid; /* Audit session ID. */ > au_asflgs_t ap_flags; /* Audit session flags. */ >}; >typedef struct auditpinfo_addr auditpinfo_addr_t; > >struct au_session { > auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */ > au_mask_t as_mask; /* Process Audit Masks. */ >}; >typedef struct au_session au_session_t; > >/* > * Contents of token_t are opaque outside of libbsm. > */ >typedef struct au_token token_t; > >/* > * Kernel audit queue control parameters: > * Default: Maximum: > * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000) > * aq_lowater: AQ_LOWATER (10) <aq_hiwater > * aq_bufsz: AQ_BUFSZ (32767) AQ_MAXBUFSZ (1048576) > * aq_delay: 20 20000 (not used) > */ >struct au_qctrl { > int aq_hiwater; /* Max # of audit recs in queue when */ > /* threads with new ARs get blocked. */ > > int aq_lowater; /* # of audit recs in queue when */ > /* blocked threads get unblocked. */ > > int aq_bufsz; /* Max size of audit record for audit(2). */ > int aq_delay; /* Queue delay (not used). */ > int aq_minfree; /* Minimum filesystem percent free space. */ >}; >typedef struct au_qctrl au_qctrl_t; > >/* > * Structure for the audit statistics. > */ >struct audit_stat { > unsigned int as_version; > unsigned int as_numevent; > int as_generated; > int as_nonattrib; > int as_kernel; > int as_audit; > int as_auditctl; > int as_enqueue; > int as_written; > int as_wblocked; > int as_rblocked; > int as_dropped; > int as_totalsize; > unsigned int as_memused; >}; >typedef struct audit_stat au_stat_t; > >/* > * Structure for the audit file statistics. > */ >struct audit_fstat { > u_int64_t af_filesz; > u_int64_t af_currsz; >}; >typedef struct audit_fstat au_fstat_t; > >/* > * Audit to event class mapping. > */ >struct au_evclass_map { > au_event_t ec_number; > au_class_t ec_class; >}; >typedef struct au_evclass_map au_evclass_map_t; > >/* > * Audit system calls. > */ >#if !defined(_KERNEL) && !defined(KERNEL) >int audit(const void *, int); >int auditon(int, void *, int); >int auditctl(const char *); >int getauid(au_id_t *); >int setauid(const au_id_t *); >int getaudit(struct auditinfo *); >int setaudit(const struct auditinfo *); >int getaudit_addr(struct auditinfo_addr *, int); >int setaudit_addr(const struct auditinfo_addr *, int); > >#ifdef __APPLE_API_PRIVATE >#if 0 /* expanded by -frewrite-includes */ >#include <mach/port.h> >#endif /* expanded by -frewrite-includes */ ># 319 "/usr/src/sys/bsm/audit.h" ># 320 "/usr/src/sys/bsm/audit.h" >mach_port_name_t audit_session_self(void); >au_asid_t audit_session_join(mach_port_name_t port); >#endif /* __APPLE_API_PRIVATE */ ># 323 "/usr/src/sys/bsm/audit.h" > >#endif /* defined(_KERNEL) || defined(KERNEL) */ ># 325 "/usr/src/sys/bsm/audit.h" > >__END_DECLS > >#endif /* !_BSM_AUDIT_H */ ># 329 "/usr/src/sys/bsm/audit.h" ># 37 "/usr/src/sys/sys/ucred.h" 2 > >struct loginclass; > >#define XU_NGROUPS 16 > >/* > * Credentials. > * > * Please do not inspect cr_uid directly to determine superuserness. The > * priv(9) interface should be used to check for privilege. > */ >#if defined(_KERNEL) || defined(_WANT_UCRED) >struct ucred { > u_int cr_ref; /* reference count */ >#define cr_startcopy cr_uid > uid_t cr_uid; /* effective user id */ > uid_t cr_ruid; /* real user id */ > uid_t cr_svuid; /* saved user id */ > int cr_ngroups; /* number of groups */ > gid_t cr_rgid; /* real group id */ > gid_t cr_svgid; /* saved group id */ > struct uidinfo *cr_uidinfo; /* per euid resource consumption */ > struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */ > struct prison *cr_prison; /* jail(2) */ > struct loginclass *cr_loginclass; /* login class */ > u_int cr_flags; /* credential flags */ > void *cr_pspare2[2]; /* general use 2 */ >#define cr_endcopy cr_label > struct label *cr_label; /* MAC label */ > struct auditinfo_addr cr_audit; /* Audit properties. */ > gid_t *cr_groups; /* groups */ > int cr_agroups; /* Available groups */ > gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ >}; >#define NOCRED ((struct ucred *)0) /* no credential available */ >#define FSCRED ((struct ucred *)-1) /* filesystem credential */ >#endif /* _KERNEL || _WANT_UCRED */ ># 74 "/usr/src/sys/sys/ucred.h" > >/* > * Flags for cr_flags. > */ >#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */ > >/* > * This is the external representation of struct ucred. > */ >struct xucred { > u_int cr_version; /* structure layout version */ > uid_t cr_uid; /* effective user id */ > short cr_ngroups; /* number of groups */ > gid_t cr_groups[XU_NGROUPS]; /* groups */ > void *_cr_unused1; /* compatibility with old ucred */ >}; >#define XUCRED_VERSION 0 > >/* This can be used for both ucred and xucred structures. */ >#define cr_gid cr_groups[0] > >#ifdef _KERNEL >struct proc; >struct thread; > >void change_egid(struct ucred *newcred, gid_t egid); >void change_euid(struct ucred *newcred, struct uidinfo *euip); >void change_rgid(struct ucred *newcred, gid_t rgid); >void change_ruid(struct ucred *newcred, struct uidinfo *ruip); >void change_svgid(struct ucred *newcred, gid_t svgid); >void change_svuid(struct ucred *newcred, uid_t svuid); >void crcopy(struct ucred *dest, struct ucred *src); >struct ucred *crcopysafe(struct proc *p, struct ucred *cr); >struct ucred *crdup(struct ucred *cr); >void cred_update_thread(struct thread *td); >void proc_set_cred_init(struct proc *p, struct ucred *cr); >struct ucred *proc_set_cred(struct proc *p, struct ucred *cr); >void crfree(struct ucred *cr); >struct ucred *crget(void); >struct ucred *crhold(struct ucred *cr); >void cru2x(struct ucred *cr, struct xucred *xcr); >void crsetgroups(struct ucred *cr, int n, gid_t *groups); >int groupmember(gid_t gid, struct ucred *cred); >#endif /* _KERNEL */ ># 118 "/usr/src/sys/sys/ucred.h" > >#endif /* !_SYS_UCRED_H_ */ ># 120 "/usr/src/sys/sys/ucred.h" ># 66 "/usr/src/sys/sys/proc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/proc.h> /* Machine-dependent proc substruct. */ >#endif /* expanded by -frewrite-includes */ ># 66 "/usr/src/sys/sys/proc.h" ># 1 "./machine/proc.h" 1 >/*- > * Copyright (c) 1991 Regents of the University of California. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 > * $FreeBSD: head/sys/amd64/include/proc.h 233291 2012-03-22 04:52:51Z alc $ > */ > >#ifndef _MACHINE_PROC_H_ >#define _MACHINE_PROC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/segments.h> >#endif /* expanded by -frewrite-includes */ ># 36 "./machine/proc.h" ># 37 "./machine/proc.h" > >struct proc_ldt { > caddr_t ldt_base; > int ldt_refcnt; >}; > >/* > * Machine-dependent part of the proc structure for AMD64. > */ >struct mdthread { > int md_spinlock_count; /* (k) */ > register_t md_saved_flags; /* (k) */ > register_t md_spurflt_addr; /* (k) Spurious page fault address. */ >}; > >struct mdproc { > struct proc_ldt *md_ldt; /* (t) per-process ldt */ > struct system_segment_descriptor md_ldt_sd; >}; > >#define KINFO_PROC_SIZE 1088 >#define KINFO_PROC32_SIZE 768 > >#ifdef _KERNEL > >/* Get the current kernel thread stack usage. */ >#define GET_STACK_USAGE(total, used) do { \ > struct thread *td = curthread; \ > (total) = td->td_kstack_pages * PAGE_SIZE; \ > (used) = (char *)td->td_kstack + \ > td->td_kstack_pages * PAGE_SIZE - \ > (char *)&td; \ >} while (0) > >void set_user_ldt(struct mdproc *); >struct proc_ldt *user_ldt_alloc(struct proc *, int); >void user_ldt_free(struct thread *); >void user_ldt_deref(struct proc_ldt *); >struct sysarch_args; >int sysarch_ldt(struct thread *td, struct sysarch_args *uap, int uap_space); >int amd64_set_ldt_data(struct thread *td, int start, int num, > struct user_segment_descriptor *descs); > >extern struct mtx dt_lock; >extern int max_ldt_segment; > >struct syscall_args { > u_int code; > struct sysent *callp; > register_t args[8]; > int narg; >}; >#endif /* _KERNEL */ ># 90 "./machine/proc.h" > >#endif /* !_MACHINE_PROC_H_ */ ># 92 "./machine/proc.h" ># 67 "/usr/src/sys/sys/proc.h" 2 > >/* > * One structure allocated per session. > * > * List of locks > * (m) locked by s_mtx mtx > * (e) locked by proctree_lock sx > * (c) const until freeing > */ >struct session { > u_int s_count; /* Ref cnt; pgrps in session - atomic. */ > struct proc *s_leader; /* (m + e) Session leader. */ > struct vnode *s_ttyvp; /* (m) Vnode of controlling tty. */ > struct cdev_priv *s_ttydp; /* (m) Device of controlling tty. */ > struct tty *s_ttyp; /* (e) Controlling tty. */ > pid_t s_sid; /* (c) Session ID. */ > /* (m) Setlogin() name: */ > char s_login[roundup(MAXLOGNAME, sizeof(long))]; > struct mtx s_mtx; /* Mutex to protect members. */ >}; > >/* > * One structure allocated per process group. > * > * List of locks > * (m) locked by pg_mtx mtx > * (e) locked by proctree_lock sx > * (c) const until freeing > */ >struct pgrp { > LIST_ENTRY(pgrp) pg_hash; /* (e) Hash chain. */ > LIST_HEAD(, proc) pg_members; /* (m + e) Pointer to pgrp members. */ > struct session *pg_session; /* (c) Pointer to session. */ > struct sigiolst pg_sigiolst; /* (m) List of sigio sources. */ > pid_t pg_id; /* (c) Process group id. */ > int pg_jobc; /* (m) Job control process count. */ > struct mtx pg_mtx; /* Mutex to protect members */ >}; > >/* > * pargs, used to hold a copy of the command line, if it had a sane length. > */ >struct pargs { > u_int ar_ref; /* Reference count. */ > u_int ar_length; /* Length. */ > u_char ar_args[1]; /* Arguments. */ >}; > >/*- > * Description of a process. > * > * This structure contains the information needed to manage a thread of > * control, known in UN*X as a process; it has references to substructures > * containing descriptions of things that the process uses, but may share > * with related processes. The process structure and the substructures > * are always addressable except for those marked "(CPU)" below, > * which might be addressable only on a processor on which the process > * is running. > * > * Below is a key of locks used to protect each member of struct proc. The > * lock is indicated by a reference to a specific character in parens in the > * associated comment. > * * - not yet protected > * a - only touched by curproc or parent during fork/wait > * b - created at fork, never changes > * (exception aiods switch vmspaces, but they are also > * marked 'P_SYSTEM' so hopefully it will be left alone) > * c - locked by proc mtx > * d - locked by allproc_lock lock > * e - locked by proctree_lock lock > * f - session mtx > * g - process group mtx > * h - callout_lock mtx > * i - by curproc or the master session mtx > * j - locked by proc slock > * k - only accessed by curthread > * k*- only accessed by curthread and from an interrupt > * l - the attaching proc or attaching proc parent > * m - Giant > * n - not locked, lazy > * o - ktrace lock > * q - td_contested lock > * r - p_peers lock > * t - thread lock > * u - process stat lock > * w - process timer lock > * x - created at fork, only changes during single threading in exec > * y - created at first aio, doesn't change until exit or exec at which > * point we are single-threaded and only curthread changes it > * z - zombie threads lock > * > * If the locking key specifies two identifiers (for example, p_pptr) then > * either lock is sufficient for read access, but both locks must be held > * for write access. > */ >struct cpuset; >struct kaioinfo; >struct kaudit_record; >struct kdtrace_proc; >struct kdtrace_thread; >struct mqueue_notifier; >struct nlminfo; >struct p_sched; >struct proc; >struct procdesc; >struct racct; >struct sbuf; >struct sleepqueue; >struct td_sched; >struct thread; >struct trapframe; >struct turnstile; > >/* > * XXX: Does this belong in resource.h or resourcevar.h instead? > * Resource usage extension. The times in rusage structs in the kernel are > * never up to date. The actual times are kept as runtimes and tick counts > * (with control info in the "previous" times), and are converted when > * userland asks for rusage info. Backwards compatibility prevents putting > * this directly in the user-visible rusage struct. > * > * Locking for p_rux: (cu) means (u) for p_rux and (c) for p_crux. > * Locking for td_rux: (t) for all fields. > */ >struct rusage_ext { > uint64_t rux_runtime; /* (cu) Real time. */ > uint64_t rux_uticks; /* (cu) Statclock hits in user mode. */ > uint64_t rux_sticks; /* (cu) Statclock hits in sys mode. */ > uint64_t rux_iticks; /* (cu) Statclock hits in intr mode. */ > uint64_t rux_uu; /* (c) Previous user time in usec. */ > uint64_t rux_su; /* (c) Previous sys time in usec. */ > uint64_t rux_tu; /* (c) Previous total time in usec. */ >}; > >/* > * Kernel runnable context (thread). > * This is what is put to sleep and reactivated. > * Thread context. Processes may have multiple threads. > */ >struct thread { > struct mtx *volatile td_lock; /* replaces sched lock */ > struct proc *td_proc; /* (*) Associated process. */ > TAILQ_ENTRY(thread) td_plist; /* (*) All threads in this proc. */ > TAILQ_ENTRY(thread) td_runq; /* (t) Run queue. */ > TAILQ_ENTRY(thread) td_slpq; /* (t) Sleep queue. */ > TAILQ_ENTRY(thread) td_lockq; /* (t) Lock queue. */ > LIST_ENTRY(thread) td_hash; /* (d) Hash chain. */ > struct cpuset *td_cpuset; /* (t) CPU affinity mask. */ > struct seltd *td_sel; /* Select queue/channel. */ > struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */ > struct turnstile *td_turnstile; /* (k) Associated turnstile. */ > struct rl_q_entry *td_rlqe; /* (k) Associated range lock entry. */ > struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */ > lwpid_t td_tid; /* (b) Thread ID. */ > sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */ >#define td_siglist td_sigqueue.sq_signals > u_char td_lend_user_pri; /* (t) Lend user pri. */ > >/* Cleared during fork1() */ >#define td_startzero td_flags > int td_flags; /* (t) TDF_* flags. */ > int td_inhibitors; /* (t) Why can not run. */ > int td_pflags; /* (k) Private thread (TDP_*) flags. */ > int td_dupfd; /* (k) Ret value from fdopen. XXX */ > int td_sqqueue; /* (t) Sleepqueue queue blocked on. */ > void *td_wchan; /* (t) Sleep address. */ > const char *td_wmesg; /* (t) Reason for sleep. */ > int td_lastcpu; /* (t) Last cpu we were on. */ > int td_oncpu; /* (t) Which cpu we are on. */ > volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */ > u_char td_tsqueue; /* (t) Turnstile queue blocked on. */ > short td_locks; /* (k) Count of non-spin locks. */ > short td_rw_rlocks; /* (k) Count of rwlock read locks. */ > short td_lk_slocks; /* (k) Count of lockmgr shared locks. */ > short td_stopsched; /* (k) Scheduler stopped. */ > struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */ > const char *td_lockname; /* (t) Name of lock blocked on. */ > LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */ > struct lock_list_entry *td_sleeplocks; /* (k) Held sleep locks. */ > int td_intr_nesting_level; /* (k) Interrupt recursion. */ > int td_pinned; /* (k) Temporary cpu pin count. */ > struct ucred *td_ucred; /* (k) Reference to credentials. */ > u_int td_estcpu; /* (t) estimated cpu utilization */ > int td_slptick; /* (t) Time at sleep. */ > int td_blktick; /* (t) Time spent blocked. */ > int td_swvoltick; /* (t) Time at last SW_VOL switch. */ > u_int td_cow; /* (*) Number of copy-on-write faults */ > struct rusage td_ru; /* (t) rusage information. */ > struct rusage_ext td_rux; /* (t) Internal rusage information. */ > uint64_t td_incruntime; /* (t) Cpu ticks to transfer to proc. */ > uint64_t td_runtime; /* (t) How many cpu ticks we've run. */ > u_int td_pticks; /* (t) Statclock hits for profiling */ > u_int td_sticks; /* (t) Statclock hits in system mode. */ > u_int td_iticks; /* (t) Statclock hits in intr mode. */ > u_int td_uticks; /* (t) Statclock hits in user mode. */ > int td_intrval; /* (t) Return value for sleepq. */ > sigset_t td_oldsigmask; /* (k) Saved mask from pre sigpause. */ > volatile u_int td_generation; /* (k) For detection of preemption */ > stack_t td_sigstk; /* (k) Stack ptr and on-stack flag. */ > int td_xsig; /* (c) Signal for ptrace */ > u_long td_profil_addr; /* (k) Temporary addr until AST. */ > u_int td_profil_ticks; /* (k) Temporary ticks until AST. */ > char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */ > struct file *td_fpop; /* (k) file referencing cdev under op */ > int td_dbgflags; /* (c) Userland debugger flags */ > struct ksiginfo td_dbgksi; /* (c) ksi reflected to debugger. */ > int td_ng_outbound; /* (k) Thread entered ng from above. */ > struct osd td_osd; /* (k) Object specific data. */ > struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ > pid_t td_dbg_forked; /* (c) Child pid for debugger. */ > u_int td_vp_reserv; /* (k) Count of reserved vnodes. */ > int td_no_sleeping; /* (k) Sleeping disabled count. */ > int td_dom_rr_idx; /* (k) RR Numa domain selection. */ >#define td_endzero td_sigmask > >/* Copied during fork1() or create_thread(). */ >#define td_startcopy td_endzero > sigset_t td_sigmask; /* (c) Current signal mask. */ > u_char td_rqindex; /* (t) Run queue index. */ > u_char td_base_pri; /* (t) Thread base kernel priority. */ > u_char td_priority; /* (t) Thread active priority. */ > u_char td_pri_class; /* (t) Scheduling class. */ > u_char td_user_pri; /* (t) User pri from estcpu and nice. */ > u_char td_base_user_pri; /* (t) Base user pri */ >#define td_endcopy td_pcb > >/* > * Fields that must be manually set in fork1() or create_thread() > * or already have been set in the allocator, constructor, etc. > */ > struct pcb *td_pcb; /* (k) Kernel VA of pcb and kstack. */ > enum { > TDS_INACTIVE = 0x0, > TDS_INHIBITED, > TDS_CAN_RUN, > TDS_RUNQ, > TDS_RUNNING > } td_state; /* (t) thread state */ > union { > register_t tdu_retval[2]; > off_t tdu_off; > } td_uretoff; /* (k) Syscall aux returns. */ >#define td_retval td_uretoff.tdu_retval > struct callout td_slpcallout; /* (h) Callout for sleep. */ > struct trapframe *td_frame; /* (k) */ > struct vm_object *td_kstack_obj;/* (a) Kstack object. */ > vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */ > int td_kstack_pages; /* (a) Size of the kstack. */ > volatile u_int td_critnest; /* (k*) Critical section nest level. */ > struct mdthread td_md; /* (k) Any machine-dependent fields. */ > struct td_sched *td_sched; /* (*) Scheduler-specific data. */ > struct kaudit_record *td_ar; /* (k) Active audit record, if any. */ > struct lpohead td_lprof[2]; /* (a) lock profiling objects. */ > struct kdtrace_thread *td_dtrace; /* (*) DTrace-specific data. */ > int td_errno; /* Error returned by last syscall. */ > struct vnet *td_vnet; /* (k) Effective vnet. */ > const char *td_vnet_lpush; /* (k) Debugging vnet push / pop. */ > struct trapframe *td_intr_frame;/* (k) Frame of the current irq */ > struct proc *td_rfppwait_p; /* (k) The vforked child */ > struct vm_page **td_ma; /* (k) uio pages held */ > int td_ma_cnt; /* (k) size of *td_ma */ >}; > >struct mtx *thread_lock_block(struct thread *); >void thread_lock_unblock(struct thread *, struct mtx *); >void thread_lock_set(struct thread *, struct mtx *); >#define THREAD_LOCK_ASSERT(td, type) \ >do { \ > struct mtx *__m = (td)->td_lock; \ > if (__m != &blocked_lock) \ > mtx_assert(__m, (type)); \ >} while (0) > >#ifdef INVARIANTS >#define THREAD_LOCKPTR_ASSERT(td, lock) \ >do { \ > struct mtx *__m = (td)->td_lock; \ > KASSERT((__m == &blocked_lock || __m == (lock)), \ > ("Thread %p lock %p does not match %p", td, __m, (lock))); \ >} while (0) >#else ># 348 "/usr/src/sys/sys/proc.h" >#define THREAD_LOCKPTR_ASSERT(td, lock) >#endif ># 350 "/usr/src/sys/sys/proc.h" > >/* > * Flags kept in td_flags: > * To change these you MUST have the scheduler lock. > */ >#define TDF_BORROWING 0x00000001 /* Thread is borrowing pri from another. */ >#define TDF_INPANIC 0x00000002 /* Caused a panic, let it drive crashdump. */ >#define TDF_INMEM 0x00000004 /* Thread's stack is in memory. */ >#define TDF_SINTR 0x00000008 /* Sleep is interruptible. */ >#define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */ >#define TDF_IDLETD 0x00000020 /* This is a per-CPU idle thread. */ >#define TDF_CANSWAP 0x00000040 /* Thread can be swapped. */ >#define TDF_SLEEPABORT 0x00000080 /* sleepq_abort was called. */ >#define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */ >#define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */ >#define TDF_BOUNDARY 0x00000400 /* Thread suspended at user boundary */ >#define TDF_ASTPENDING 0x00000800 /* Thread has some asynchronous events. */ >#define TDF_TIMOFAIL 0x00001000 /* Timeout from sleep after we were awake. */ >#define TDF_SBDRY 0x00002000 /* Stop only on usermode boundary. */ >#define TDF_UPIBLOCKED 0x00004000 /* Thread blocked on user PI mutex. */ >#define TDF_NEEDSUSPCHK 0x00008000 /* Thread may need to suspend. */ >#define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */ >#define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */ >#define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */ >#define TDF_UNUSED19 0x00080000 /* --available-- */ >#define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ >#define TDF_UNUSED21 0x00200000 /* --available-- */ >#define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ >#define TDF_UNUSED23 0x00800000 /* --available-- */ >#define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ >#define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */ >#define TDF_SCHED2 0x04000000 /* Reserved for scheduler private use */ >#define TDF_SCHED3 0x08000000 /* Reserved for scheduler private use */ >#define TDF_ALRMPEND 0x10000000 /* Pending SIGVTALRM needs to be posted. */ >#define TDF_PROFPEND 0x20000000 /* Pending SIGPROF needs to be posted. */ >#define TDF_MACPEND 0x40000000 /* AST-based MAC event pending. */ > >/* Userland debug flags */ >#define TDB_SUSPEND 0x00000001 /* Thread is suspended by debugger */ >#define TDB_XSIG 0x00000002 /* Thread is exchanging signal under trace */ >#define TDB_USERWR 0x00000004 /* Debugger modified memory or registers */ >#define TDB_SCE 0x00000008 /* Thread performs syscall enter */ >#define TDB_SCX 0x00000010 /* Thread performs syscall exit */ >#define TDB_EXEC 0x00000020 /* TDB_SCX from exec(2) family */ >#define TDB_FORK 0x00000040 /* TDB_SCX from fork(2) that created new > process */ >#define TDB_STOPATFORK 0x00000080 /* Stop at the return from fork (child > only) */ >#define TDB_CHILD 0x00000100 /* New child indicator for ptrace() */ > >/* > * "Private" flags kept in td_pflags: > * These are only written by curthread and thus need no locking. > */ >#define TDP_OLDMASK 0x00000001 /* Need to restore mask after suspend. */ >#define TDP_INKTR 0x00000002 /* Thread is currently in KTR code. */ >#define TDP_INKTRACE 0x00000004 /* Thread is currently in KTRACE code. */ >#define TDP_BUFNEED 0x00000008 /* Do not recurse into the buf flush */ >#define TDP_COWINPROGRESS 0x00000010 /* Snapshot copy-on-write in progress. */ >#define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */ >#define TDP_DEADLKTREAT 0x00000040 /* Lock aquisition - deadlock treatment. */ >#define TDP_NOFAULTING 0x00000080 /* Do not handle page faults. */ >#define TDP_UNUSED9 0x00000100 /* --available-- */ >#define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */ >#define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */ >#define TDP_SYNCIO 0x00000800 /* Local override, disable async i/o. */ >#define TDP_SCHED1 0x00001000 /* Reserved for scheduler private use */ >#define TDP_SCHED2 0x00002000 /* Reserved for scheduler private use */ >#define TDP_SCHED3 0x00004000 /* Reserved for scheduler private use */ >#define TDP_SCHED4 0x00008000 /* Reserved for scheduler private use */ >#define TDP_GEOM 0x00010000 /* Settle GEOM before finishing syscall */ >#define TDP_SOFTDEP 0x00020000 /* Stuck processing softdep worklist */ >#define TDP_NORUNNINGBUF 0x00040000 /* Ignore runningbufspace check */ >#define TDP_WAKEUP 0x00080000 /* Don't sleep in umtx cond_wait */ >#define TDP_INBDFLUSH 0x00100000 /* Already in BO_BDFLUSH, do not recurse */ >#define TDP_KTHREAD 0x00200000 /* This is an official kernel thread */ >#define TDP_CALLCHAIN 0x00400000 /* Capture thread's callchain */ >#define TDP_IGNSUSP 0x00800000 /* Permission to ignore the MNTK_SUSPEND* */ >#define TDP_AUDITREC 0x01000000 /* Audit record pending on thread */ >#define TDP_RFPPWAIT 0x02000000 /* Handle RFPPWAIT on syscall exit */ >#define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */ >#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */ >#define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */ >#define TDP_UNUSED29 0x20000000 /* --available-- */ >#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */ > >/* > * Reasons that the current thread can not be run yet. > * More than one may apply. > */ >#define TDI_SUSPENDED 0x0001 /* On suspension queue. */ >#define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */ >#define TDI_SWAPPED 0x0004 /* Stack not in mem. Bad juju if run. */ >#define TDI_LOCK 0x0008 /* Stopped on a lock. */ >#define TDI_IWAIT 0x0010 /* Awaiting interrupt. */ > >#define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING) >#define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL) >#define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED) >#define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED) >#define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK) >#define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT) >#define TD_IS_RUNNING(td) ((td)->td_state == TDS_RUNNING) >#define TD_ON_RUNQ(td) ((td)->td_state == TDS_RUNQ) >#define TD_CAN_RUN(td) ((td)->td_state == TDS_CAN_RUN) >#define TD_IS_INHIBITED(td) ((td)->td_state == TDS_INHIBITED) >#define TD_ON_UPILOCK(td) ((td)->td_flags & TDF_UPIBLOCKED) >#define TD_IS_IDLETHREAD(td) ((td)->td_flags & TDF_IDLETD) > > >#define TD_SET_INHIB(td, inhib) do { \ > (td)->td_state = TDS_INHIBITED; \ > (td)->td_inhibitors |= (inhib); \ >} while (0) > >#define TD_CLR_INHIB(td, inhib) do { \ > if (((td)->td_inhibitors & (inhib)) && \ > (((td)->td_inhibitors &= ~(inhib)) == 0)) \ > (td)->td_state = TDS_CAN_RUN; \ >} while (0) > >#define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING) >#define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED) >#define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK) >#define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED) >#define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT) >#define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING) > >#define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING) >#define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED) >#define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK) >#define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED) >#define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT) > >#define TD_SET_RUNNING(td) (td)->td_state = TDS_RUNNING >#define TD_SET_RUNQ(td) (td)->td_state = TDS_RUNQ >#define TD_SET_CAN_RUN(td) (td)->td_state = TDS_CAN_RUN > >/* > * Process structure. > */ >struct proc { > LIST_ENTRY(proc) p_list; /* (d) List of all processes. */ > TAILQ_HEAD(, thread) p_threads; /* (c) all threads. */ > struct mtx p_slock; /* process spin lock */ > struct ucred *p_ucred; /* (c) Process owner's identity. */ > struct filedesc *p_fd; /* (b) Open files. */ > struct filedesc_to_leader *p_fdtol; /* (b) Tracking node */ > struct pstats *p_stats; /* (b) Accounting/statistics (CPU). */ > struct plimit *p_limit; /* (c) Process limits. */ > struct callout p_limco; /* (c) Limit callout handle */ > struct sigacts *p_sigacts; /* (x) Signal actions, state (CPU). */ > > int p_flag; /* (c) P_* flags. */ > int p_flag2; /* (c) P2_* flags. */ > enum { > PRS_NEW = 0, /* In creation */ > PRS_NORMAL, /* threads can be run. */ > PRS_ZOMBIE > } p_state; /* (j/c) Process status. */ > pid_t p_pid; /* (b) Process identifier. */ > LIST_ENTRY(proc) p_hash; /* (d) Hash chain. */ > LIST_ENTRY(proc) p_pglist; /* (g + e) List of processes in pgrp. */ > struct proc *p_pptr; /* (c + e) Pointer to parent process. */ > LIST_ENTRY(proc) p_sibling; /* (e) List of sibling processes. */ > LIST_HEAD(, proc) p_children; /* (e) Pointer to list of children. */ > struct proc *p_reaper; /* (e) My reaper. */ > LIST_HEAD(, proc) p_reaplist; /* (e) List of my descendants > (if I am reaper). */ > LIST_ENTRY(proc) p_reapsibling; /* (e) List of siblings - descendants of > the same reaper. */ > struct mtx p_mtx; /* (n) Lock for this struct. */ > struct mtx p_statmtx; /* Lock for the stats */ > struct mtx p_itimmtx; /* Lock for the virt/prof timers */ > struct mtx p_profmtx; /* Lock for the profiling */ > struct ksiginfo *p_ksi; /* Locked by parent proc lock */ > sigqueue_t p_sigqueue; /* (c) Sigs not delivered to a td. */ >#define p_siglist p_sigqueue.sq_signals > >/* The following fields are all zeroed upon creation in fork. */ >#define p_startzero p_oppid > pid_t p_oppid; /* (c + e) Save ppid in ptrace. XXX */ > struct vmspace *p_vmspace; /* (b) Address space. */ > u_int p_swtick; /* (c) Tick when swapped in or out. */ > struct itimerval p_realtimer; /* (c) Alarm timer. */ > struct rusage p_ru; /* (a) Exit information. */ > struct rusage_ext p_rux; /* (cu) Internal resource usage. */ > struct rusage_ext p_crux; /* (c) Internal child resource usage. */ > int p_profthreads; /* (c) Num threads in addupc_task. */ > volatile int p_exitthreads; /* (j) Number of threads exiting */ > int p_traceflag; /* (o) Kernel trace points. */ > struct vnode *p_tracevp; /* (c + o) Trace to vnode. */ > struct ucred *p_tracecred; /* (o) Credentials to trace with. */ > struct vnode *p_textvp; /* (b) Vnode of executable. */ > u_int p_lock; /* (c) Proclock (prevent swap) count. */ > struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ > int p_sigparent; /* (c) Signal to parent on exit. */ > int p_sig; /* (n) For core dump/debugger XXX. */ > u_long p_code; /* (n) For core dump/debugger XXX. */ > u_int p_stops; /* (c) Stop event bitmask. */ > u_int p_stype; /* (c) Stop event type. */ > char p_step; /* (c) Process is stopped. */ > u_char p_pfsflags; /* (c) Procfs flags. */ > struct nlminfo *p_nlminfo; /* (?) Only used by/for lockd. */ > struct kaioinfo *p_aioinfo; /* (y) ASYNC I/O info. */ > struct thread *p_singlethread;/* (c + j) If single threading this is it */ > int p_suspcount; /* (j) Num threads in suspended mode. */ > struct thread *p_xthread; /* (c) Trap thread */ > int p_boundary_count;/* (j) Num threads at user boundary */ > int p_pendingcnt; /* how many signals are pending */ > struct itimers *p_itimers; /* (c) POSIX interval timers. */ > struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */ > u_int p_treeflag; /* (e) P_TREE flags */ >/* End area that is zeroed on creation. */ >#define p_endzero p_magic > >/* The following fields are all copied upon creation in fork. */ >#define p_startcopy p_endzero > u_int p_magic; /* (b) Magic number. */ > int p_osrel; /* (x) osreldate for the > binary (from ELF note, if any) */ > char p_comm[MAXCOMLEN + 1]; /* (b) Process name. */ > struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */ > struct sysentvec *p_sysent; /* (b) Syscall dispatch info. */ > struct pargs *p_args; /* (c) Process arguments. */ > rlim_t p_cpulimit; /* (c) Current CPU limit in seconds. */ > signed char p_nice; /* (c) Process "nice" value. */ > int p_fibnum; /* in this routing domain XXX MRT */ > pid_t p_reapsubtree; /* (e) Pid of the direct child of the > reaper which spawned > our subtree. */ >/* End area that is copied on creation. */ >#define p_endcopy p_xstat > > u_short p_xstat; /* (c) Exit status; also stop sig. */ > struct knlist p_klist; /* (c) Knotes attached to this proc. */ > int p_numthreads; /* (c) Number of threads. */ > struct mdproc p_md; /* Any machine-dependent fields. */ > struct callout p_itcallout; /* (h + c) Interval timer callout. */ > u_short p_acflag; /* (c) Accounting flags. */ > struct proc *p_peers; /* (r) */ > struct proc *p_leader; /* (b) */ > void *p_emuldata; /* (c) Emulator state data. */ > struct label *p_label; /* (*) Proc (not subject) MAC label. */ > struct p_sched *p_sched; /* (*) Scheduler-specific data. */ > STAILQ_HEAD(, ktr_request) p_ktr; /* (o) KTR event queue. */ > LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/ > struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */ > struct cv p_pwait; /* (*) wait cv for exit/exec. */ > struct cv p_dbgwait; /* (*) wait cv for debugger attach > after fork. */ > uint64_t p_prev_runtime; /* (c) Resource usage accounting. */ > struct racct *p_racct; /* (b) Resource accounting. */ > u_char p_throttled; /* (c) Flag for racct pcpu throttling */ > /* > * An orphan is the child that has beed re-parented to the > * debugger as a result of attaching to it. Need to keep > * track of them for parent to be able to collect the exit > * status of what used to be children. > */ > LIST_ENTRY(proc) p_orphan; /* (e) List of orphan processes. */ > LIST_HEAD(, proc) p_orphans; /* (e) Pointer to list of orphans. */ >}; > >#define p_session p_pgrp->pg_session >#define p_pgid p_pgrp->pg_id > >#define NOCPU (-1) /* For when we aren't on a CPU. */ >#define NOCPU_OLD (255) >#define MAXCPU_OLD (254) > >#define PROC_SLOCK(p) mtx_lock_spin(&(p)->p_slock) >#define PROC_SUNLOCK(p) mtx_unlock_spin(&(p)->p_slock) >#define PROC_SLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type)) > >#define PROC_STATLOCK(p) mtx_lock_spin(&(p)->p_statmtx) >#define PROC_STATUNLOCK(p) mtx_unlock_spin(&(p)->p_statmtx) >#define PROC_STATLOCK_ASSERT(p, type) mtx_assert(&(p)->p_statmtx, (type)) > >#define PROC_ITIMLOCK(p) mtx_lock_spin(&(p)->p_itimmtx) >#define PROC_ITIMUNLOCK(p) mtx_unlock_spin(&(p)->p_itimmtx) >#define PROC_ITIMLOCK_ASSERT(p, type) mtx_assert(&(p)->p_itimmtx, (type)) > >#define PROC_PROFLOCK(p) mtx_lock_spin(&(p)->p_profmtx) >#define PROC_PROFUNLOCK(p) mtx_unlock_spin(&(p)->p_profmtx) >#define PROC_PROFLOCK_ASSERT(p, type) mtx_assert(&(p)->p_profmtx, (type)) > >/* These flags are kept in p_flag. */ >#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */ >#define P_CONTROLT 0x00002 /* Has a controlling terminal. */ >#define P_KTHREAD 0x00004 /* Kernel thread (*). */ >#define P_FOLLOWFORK 0x00008 /* Attach parent debugger to children. */ >#define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */ >#define P_PROFIL 0x00020 /* Has started profiling. */ >#define P_STOPPROF 0x00040 /* Has thread requesting to stop profiling. */ >#define P_HADTHREADS 0x00080 /* Has had threads (no cleanup shortcuts) */ >#define P_SUGID 0x00100 /* Had set id privileges since last exec. */ >#define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */ >#define P_SINGLE_EXIT 0x00400 /* Threads suspending should exit, not wait. */ >#define P_TRACED 0x00800 /* Debugged process being traced. */ >#define P_WAITED 0x01000 /* Someone is waiting for us. */ >#define P_WEXIT 0x02000 /* Working on exiting. */ >#define P_EXEC 0x04000 /* Process called exec. */ >#define P_WKILLED 0x08000 /* Killed, go to kernel/user boundary ASAP. */ >#define P_CONTINUED 0x10000 /* Proc has continued from a stopped state. */ >#define P_STOPPED_SIG 0x20000 /* Stopped due to SIGSTOP/SIGTSTP. */ >#define P_STOPPED_TRACE 0x40000 /* Stopped because of tracing. */ >#define P_STOPPED_SINGLE 0x80000 /* Only 1 thread can continue (not to user). */ >#define P_PROTECTED 0x100000 /* Do not kill on memory overcommit. */ >#define P_SIGEVENT 0x200000 /* Process pending signals changed. */ >#define P_SINGLE_BOUNDARY 0x400000 /* Threads should suspend at user boundary. */ >#define P_HWPMC 0x800000 /* Process is using HWPMCs */ >#define P_JAILED 0x1000000 /* Process is in jail. */ >#define P_TOTAL_STOP 0x2000000 /* Stopped in proc_stop_total. */ >#define P_INEXEC 0x4000000 /* Process is in execve(). */ >#define P_STATCHILD 0x8000000 /* Child process stopped or exited. */ >#define P_INMEM 0x10000000 /* Loaded into memory. */ >#define P_SWAPPINGOUT 0x20000000 /* Process is being swapped out. */ >#define P_SWAPPINGIN 0x40000000 /* Process is being swapped in. */ >#define P_PPTRACE 0x80000000 /* PT_TRACEME by vforked child. */ > >#define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE) >#define P_SHOULDSTOP(p) ((p)->p_flag & P_STOPPED) >#define P_KILLED(p) ((p)->p_flag & P_WKILLED) > >/* These flags are kept in p_flag2. */ >#define P2_INHERIT_PROTECTED 0x00000001 /* New children get P_PROTECTED. */ >#define P2_NOTRACE 0x00000002 /* No ptrace(2) attach or coredumps. */ >#define P2_NOTRACE_EXEC 0x00000004 /* Keep P2_NOPTRACE on exec(2). */ > >/* Flags protected by proctree_lock, kept in p_treeflags. */ >#define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */ >#define P_TREE_FIRST_ORPHAN 0x00000002 /* First element of orphan > list */ >#define P_TREE_REAPER 0x00000004 /* Reaper of subtree */ > >/* > * These were process status values (p_stat), now they are only used in > * legacy conversion code. > */ >#define SIDL 1 /* Process being created by fork. */ >#define SRUN 2 /* Currently runnable. */ >#define SSLEEP 3 /* Sleeping on an address. */ >#define SSTOP 4 /* Process debugging or suspension. */ >#define SZOMB 5 /* Awaiting collection by parent. */ >#define SWAIT 6 /* Waiting for interrupt. */ >#define SLOCK 7 /* Blocked on a lock. */ > >#define P_MAGIC 0xbeefface > >#ifdef _KERNEL > >/* Types and flags for mi_switch(). */ >#define SW_TYPE_MASK 0xff /* First 8 bits are switch type */ >#define SWT_NONE 0 /* Unspecified switch. */ >#define SWT_PREEMPT 1 /* Switching due to preemption. */ >#define SWT_OWEPREEMPT 2 /* Switching due to opepreempt. */ >#define SWT_TURNSTILE 3 /* Turnstile contention. */ >#define SWT_SLEEPQ 4 /* Sleepq wait. */ >#define SWT_SLEEPQTIMO 5 /* Sleepq timeout wait. */ >#define SWT_RELINQUISH 6 /* yield call. */ >#define SWT_NEEDRESCHED 7 /* NEEDRESCHED was set. */ >#define SWT_IDLE 8 /* Switching from the idle thread. */ >#define SWT_IWAIT 9 /* Waiting for interrupts. */ >#define SWT_SUSPEND 10 /* Thread suspended. */ >#define SWT_REMOTEPREEMPT 11 /* Remote processor preempted. */ >#define SWT_REMOTEWAKEIDLE 12 /* Remote processor preempted idle. */ >#define SWT_COUNT 13 /* Number of switch types. */ >/* Flags */ >#define SW_VOL 0x0100 /* Voluntary switch. */ >#define SW_INVOL 0x0200 /* Involuntary switch. */ >#define SW_PREEMPT 0x0400 /* The invol switch is a preemption */ > >/* How values for thread_single(). */ >#define SINGLE_NO_EXIT 0 >#define SINGLE_EXIT 1 >#define SINGLE_BOUNDARY 2 >#define SINGLE_ALLPROC 3 > >#ifdef MALLOC_DECLARE >MALLOC_DECLARE(M_PARGS); >MALLOC_DECLARE(M_PGRP); >MALLOC_DECLARE(M_SESSION); >MALLOC_DECLARE(M_SUBPROC); >#endif ># 735 "/usr/src/sys/sys/proc.h" > >#define FOREACH_PROC_IN_SYSTEM(p) \ > LIST_FOREACH((p), &allproc, p_list) >#define FOREACH_THREAD_IN_PROC(p, td) \ > TAILQ_FOREACH((td), &(p)->p_threads, td_plist) > >#define FIRST_THREAD_IN_PROC(p) TAILQ_FIRST(&(p)->p_threads) > >/* > * We use process IDs <= pid_max <= PID_MAX; PID_MAX + 1 must also fit > * in a pid_t, as it is used to represent "no process group". > */ >#define PID_MAX 99999 >#define NO_PID 100000 >extern pid_t pid_max; > >#define SESS_LEADER(p) ((p)->p_session->s_leader == (p)) > > >#define STOPEVENT(p, e, v) do { \ > WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ > "checking stopevent %d", (e)); \ > if ((p)->p_stops & (e)) { \ > PROC_LOCK(p); \ > stopevent((p), (e), (v)); \ > PROC_UNLOCK(p); \ > } \ >} while (0) >#define _STOPEVENT(p, e, v) do { \ > PROC_LOCK_ASSERT(p, MA_OWNED); \ > WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.lock_object, \ > "checking stopevent %d", (e)); \ > if ((p)->p_stops & (e)) \ > stopevent((p), (e), (v)); \ >} while (0) > >/* Lock and unlock a process. */ >#define PROC_LOCK(p) mtx_lock(&(p)->p_mtx) >#define PROC_TRYLOCK(p) mtx_trylock(&(p)->p_mtx) >#define PROC_UNLOCK(p) mtx_unlock(&(p)->p_mtx) >#define PROC_LOCKED(p) mtx_owned(&(p)->p_mtx) >#define PROC_LOCK_ASSERT(p, type) mtx_assert(&(p)->p_mtx, (type)) > >/* Lock and unlock a process group. */ >#define PGRP_LOCK(pg) mtx_lock(&(pg)->pg_mtx) >#define PGRP_UNLOCK(pg) mtx_unlock(&(pg)->pg_mtx) >#define PGRP_LOCKED(pg) mtx_owned(&(pg)->pg_mtx) >#define PGRP_LOCK_ASSERT(pg, type) mtx_assert(&(pg)->pg_mtx, (type)) > >#define PGRP_LOCK_PGSIGNAL(pg) do { \ > if ((pg) != NULL) \ > PGRP_LOCK(pg); \ >} while (0) >#define PGRP_UNLOCK_PGSIGNAL(pg) do { \ > if ((pg) != NULL) \ > PGRP_UNLOCK(pg); \ >} while (0) > >/* Lock and unlock a session. */ >#define SESS_LOCK(s) mtx_lock(&(s)->s_mtx) >#define SESS_UNLOCK(s) mtx_unlock(&(s)->s_mtx) >#define SESS_LOCKED(s) mtx_owned(&(s)->s_mtx) >#define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type)) > >/* Hold process U-area in memory, normally for ptrace/procfs work. */ >#define PHOLD(p) do { \ > PROC_LOCK(p); \ > _PHOLD(p); \ > PROC_UNLOCK(p); \ >} while (0) >#define _PHOLD(p) do { \ > PROC_LOCK_ASSERT((p), MA_OWNED); \ > KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \ > ("PHOLD of exiting process")); \ > (p)->p_lock++; \ > if (((p)->p_flag & P_INMEM) == 0) \ > faultin((p)); \ >} while (0) >#define PROC_ASSERT_HELD(p) do { \ > KASSERT((p)->p_lock > 0, ("process not held")); \ >} while (0) > >#define PRELE(p) do { \ > PROC_LOCK((p)); \ > _PRELE((p)); \ > PROC_UNLOCK((p)); \ >} while (0) >#define _PRELE(p) do { \ > PROC_LOCK_ASSERT((p), MA_OWNED); \ > PROC_ASSERT_HELD(p); \ > (--(p)->p_lock); \ > if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0) \ > wakeup(&(p)->p_lock); \ >} while (0) >#define PROC_ASSERT_NOT_HELD(p) do { \ > KASSERT((p)->p_lock == 0, ("process held")); \ >} while (0) > >/* Check whether a thread is safe to be swapped out. */ >#define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP) > >/* Control whether or not it is safe for curthread to sleep. */ >#define THREAD_NO_SLEEPING() ((curthread)->td_no_sleeping++) > >#define THREAD_SLEEPING_OK() ((curthread)->td_no_sleeping--) > >#define THREAD_CAN_SLEEP() ((curthread)->td_no_sleeping == 0) > >#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash]) >extern LIST_HEAD(pidhashhead, proc) *pidhashtbl; >extern u_long pidhash; >#define TIDHASH(tid) (&tidhashtbl[(tid) & tidhash]) >extern LIST_HEAD(tidhashhead, thread) *tidhashtbl; >extern u_long tidhash; >extern struct rwlock tidhash_lock; > >#define PGRPHASH(pgid) (&pgrphashtbl[(pgid) & pgrphash]) >extern LIST_HEAD(pgrphashhead, pgrp) *pgrphashtbl; >extern u_long pgrphash; > >extern struct sx allproc_lock; >extern int allproc_gen; >extern struct sx proctree_lock; >extern struct mtx ppeers_lock; >extern struct proc proc0; /* Process slot for swapper. */ >extern struct thread thread0; /* Primary thread in proc0. */ >extern struct vmspace vmspace0; /* VM space for proc0. */ >extern int hogticks; /* Limit on kernel cpu hogs. */ >extern int lastpid; >extern int nprocs, maxproc; /* Current and max number of procs. */ >extern int maxprocperuid; /* Max procs per uid. */ >extern u_long ps_arg_cache_limit; > >LIST_HEAD(proclist, proc); >TAILQ_HEAD(procqueue, proc); >TAILQ_HEAD(threadqueue, thread); >extern struct proclist allproc; /* List of all processes. */ >extern struct proclist zombproc; /* List of zombie processes. */ >extern struct proc *initproc, *pageproc; /* Process slots for init, pager. */ > >extern struct uma_zone *proc_zone; > >struct proc *pfind(pid_t); /* Find process by id. */ >struct proc *pfind_locked(pid_t pid); >struct pgrp *pgfind(pid_t); /* Find process group by id. */ >struct proc *zpfind(pid_t); /* Find zombie process by id. */ > >/* > * pget() flags. > */ >#define PGET_HOLD 0x00001 /* Hold the process. */ >#define PGET_CANSEE 0x00002 /* Check against p_cansee(). */ >#define PGET_CANDEBUG 0x00004 /* Check against p_candebug(). */ >#define PGET_ISCURRENT 0x00008 /* Check that the found process is current. */ >#define PGET_NOTWEXIT 0x00010 /* Check that the process is not in P_WEXIT. */ >#define PGET_NOTINEXEC 0x00020 /* Check that the process is not in P_INEXEC. */ >#define PGET_NOTID 0x00040 /* Do not assume tid if pid > PID_MAX. */ > >#define PGET_WANTREAD (PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT) > >int pget(pid_t pid, int flags, struct proc **pp); > >void ast(struct trapframe *framep); >struct thread *choosethread(void); >int cr_cansignal(struct ucred *cred, struct proc *proc, int signum); >int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp, > struct session *sess); >int enterthispgrp(struct proc *p, struct pgrp *pgrp); >void faultin(struct proc *p); >void fixjobc(struct proc *p, struct pgrp *pgrp, int entering); >int fork1(struct thread *, int, int, struct proc **, int *, int); >void fork_exit(void (*)(void *, struct trapframe *), void *, > struct trapframe *); >void fork_return(struct thread *, struct trapframe *); >int inferior(struct proc *p); >void kern_yield(int); >void kick_proc0(void); >int leavepgrp(struct proc *p); >int maybe_preempt(struct thread *td); >void maybe_yield(void); >void mi_switch(int flags, struct thread *newtd); >int p_candebug(struct thread *td, struct proc *p); >int p_cansee(struct thread *td, struct proc *p); >int p_cansched(struct thread *td, struct proc *p); >int p_cansignal(struct thread *td, struct proc *p, int signum); >int p_canwait(struct thread *td, struct proc *p); >struct pargs *pargs_alloc(int len); >void pargs_drop(struct pargs *pa); >void pargs_hold(struct pargs *pa); >int proc_getargv(struct thread *td, struct proc *p, struct sbuf *sb); >int proc_getauxv(struct thread *td, struct proc *p, struct sbuf *sb); >int proc_getenvv(struct thread *td, struct proc *p, struct sbuf *sb); >void procinit(void); >void proc_linkup0(struct proc *p, struct thread *td); >void proc_linkup(struct proc *p, struct thread *td); >struct proc *proc_realparent(struct proc *child); >void proc_reap(struct thread *td, struct proc *p, int *status, int options); >void proc_reparent(struct proc *child, struct proc *newparent); >struct pstats *pstats_alloc(void); >void pstats_fork(struct pstats *src, struct pstats *dst); >void pstats_free(struct pstats *ps); >void reaper_abandon_children(struct proc *p, bool exiting); >int securelevel_ge(struct ucred *cr, int level); >int securelevel_gt(struct ucred *cr, int level); >void sess_hold(struct session *); >void sess_release(struct session *); >int setrunnable(struct thread *); >void setsugid(struct proc *p); >int should_yield(void); >int sigonstack(size_t sp); >void stopevent(struct proc *, u_int, u_int); >struct thread *tdfind(lwpid_t, pid_t); >void threadinit(void); >void tidhash_add(struct thread *); >void tidhash_remove(struct thread *); >void cpu_idle(int); >int cpu_idle_wakeup(int); >extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */ >void cpu_switch(struct thread *, struct thread *, struct mtx *); >void cpu_throw(struct thread *, struct thread *) __dead2; >void unsleep(struct thread *); >void userret(struct thread *, struct trapframe *); > >void cpu_exit(struct thread *); >void exit1(struct thread *, int) __dead2; >struct syscall_args; >int cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa); >void cpu_fork(struct thread *, struct proc *, struct thread *, int); >void cpu_set_fork_handler(struct thread *, void (*)(void *), void *); >void cpu_set_syscall_retval(struct thread *, int); >void cpu_set_upcall(struct thread *td, struct thread *td0); >void cpu_set_upcall_kse(struct thread *, void (*)(void *), void *, > stack_t *); >int cpu_set_user_tls(struct thread *, void *tls_base); >void cpu_thread_alloc(struct thread *); >void cpu_thread_clean(struct thread *); >void cpu_thread_exit(struct thread *); >void cpu_thread_free(struct thread *); >void cpu_thread_swapin(struct thread *); >void cpu_thread_swapout(struct thread *); >struct thread *thread_alloc(int pages); >int thread_alloc_stack(struct thread *, int pages); >void thread_exit(void) __dead2; >void thread_free(struct thread *td); >void thread_link(struct thread *td, struct proc *p); >void thread_reap(void); >int thread_single(struct proc *p, int how); >void thread_single_end(struct proc *p, int how); >void thread_stash(struct thread *td); >void thread_stopped(struct proc *p); >void childproc_stopped(struct proc *child, int reason); >void childproc_continued(struct proc *child); >void childproc_exited(struct proc *child); >int thread_suspend_check(int how); >bool thread_suspend_check_needed(void); >void thread_suspend_switch(struct thread *, struct proc *p); >void thread_suspend_one(struct thread *td); >void thread_unlink(struct thread *td); >void thread_unsuspend(struct proc *p); >int thread_unsuspend_one(struct thread *td, struct proc *p); >void thread_wait(struct proc *p); >struct thread *thread_find(struct proc *p, lwpid_t tid); > >void stop_all_proc(void); >void resume_all_proc(void); > >static __inline int >curthread_pflags_set(int flags) >{ > struct thread *td; > int save; > > td = curthread; > save = ~flags | (td->td_pflags & flags); > td->td_pflags |= flags; > return (save); >} > >static __inline void >curthread_pflags_restore(int save) >{ > > curthread->td_pflags &= save; >} > >#endif /* _KERNEL */ ># 1021 "/usr/src/sys/sys/proc.h" > >#endif /* !_SYS_PROC_H_ */ ># 1023 "/usr/src/sys/sys/proc.h" ># 60 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 60 "/usr/src/sys/kern/kern_cons.c" ># 61 "/usr/src/sys/kern/kern_cons.c" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/reboot.h> >#endif /* expanded by -frewrite-includes */ ># 61 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/reboot.h" 1 >/*- > * Copyright (c) 1982, 1986, 1988, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)reboot.h 8.3 (Berkeley) 12/13/94 > * $FreeBSD: head/sys/sys/reboot.h 139825 2005-01-07 02:29:27Z imp $ > */ > >#ifndef _SYS_REBOOT_H_ >#define _SYS_REBOOT_H_ > >/* > * Arguments to reboot system call. These are passed to > * the boot program and on to init. > */ >#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ > >#define RB_ASKNAME 0x001 /* ask for file name to reboot from */ >#define RB_SINGLE 0x002 /* reboot to single user only */ >#define RB_NOSYNC 0x004 /* dont sync before reboot */ >#define RB_HALT 0x008 /* don't reboot, just halt */ >#define RB_INITNAME 0x010 /* name given for /etc/init (unused) */ >#define RB_DFLTROOT 0x020 /* use compiled-in rootdev */ >#define RB_KDB 0x040 /* give control to kernel debugger */ >#define RB_RDONLY 0x080 /* mount root fs read-only */ >#define RB_DUMP 0x100 /* dump kernel memory before reboot */ >#define RB_MINIROOT 0x200 /* mini-root present in memory at boot time */ >#define RB_VERBOSE 0x800 /* print all potentially useful info */ >#define RB_SERIAL 0x1000 /* use serial port as console */ >#define RB_CDROM 0x2000 /* use cdrom as root */ >#define RB_POWEROFF 0x4000 /* turn the power off if possible */ >#define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */ >#define RB_MUTE 0x10000 /* start up with the console muted */ >#define RB_SELFTEST 0x20000 /* don't complete the boot; do selftest */ >#define RB_RESERVED1 0x40000 /* reserved for internal use of boot blocks */ >#define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */ >#define RB_PAUSE 0x100000 /* pause after each output line during probe */ >#define RB_MULTIPLE 0x20000000 /* use multiple consoles */ > >#define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */ > >#endif ># 67 "/usr/src/sys/sys/reboot.h" ># 62 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sysctl.h> >#endif /* expanded by -frewrite-includes */ ># 62 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/sysctl.h" 1 >/*- > * Copyright (c) 1989, 1993 > * The Regents of the University of California. All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * Mike Karels at Berkeley Software Design, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: head/sys/sys/sysctl.h 280005 2015-03-14 21:38:51Z ian $ > */ > >#ifndef _SYS_SYSCTL_H_ >#define _SYS_SYSCTL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/sysctl.h" ># 40 "/usr/src/sys/sys/sysctl.h" > >struct thread; >/* > * Definitions for sysctl call. The sysctl call uses a hierarchical name > * for objects that can be examined or modified. The name is expressed as > * a sequence of integers. Like a file path name, the meaning of each > * component depends on its place in the hierarchy. The top-level and kern > * identifiers are defined here, and other identifiers are defined in the > * respective subsystem header files. > */ > >#define CTL_MAXNAME 24 /* largest number of components supported */ > >/* > * Each subsystem defined by sysctl defines a list of variables > * for that subsystem. Each name is either a node with further > * levels defined below it, or it is a leaf of some particular > * type given below. Each sysctl level defines a set of name/type > * pairs to be used by sysctl(8) in manipulating the subsystem. > */ >struct ctlname { > char *ctl_name; /* subsystem name */ > int ctl_type; /* type of name */ >}; > >#define CTLTYPE 0xf /* mask for the type */ >#define CTLTYPE_NODE 1 /* name is a node */ >#define CTLTYPE_INT 2 /* name describes an integer */ >#define CTLTYPE_STRING 3 /* name describes a string */ >#define CTLTYPE_S64 4 /* name describes a signed 64-bit number */ >#define CTLTYPE_OPAQUE 5 /* name describes a structure */ >#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ >#define CTLTYPE_UINT 6 /* name describes an unsigned integer */ >#define CTLTYPE_LONG 7 /* name describes a long */ >#define CTLTYPE_ULONG 8 /* name describes an unsigned long */ >#define CTLTYPE_U64 9 /* name describes an unsigned 64-bit number */ > >#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ >#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ >#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) >#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ >#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ >#define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */ >#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ >#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ >#define CTLMASK_SECURE 0x00F00000 /* Secure level */ >#define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */ >#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) >#define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) >#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ >#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ >#define CTLFLAG_DYING 0x00010000 /* Oid is being removed */ >#define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ >#define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ >#define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ >#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ >#define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) > >/* > * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. > * > * Secure when the securelevel is raised to at least N. > */ >#define CTLSHIFT_SECURE 20 >#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) >#define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE)) >#define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE)) > >/* > * USE THIS instead of a hardwired number from the categories below > * to get dynamically assigned sysctl entries using the linker-set > * technology. This is the way nearly all new sysctl variables should > * be implemented. > * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); > */ >#define OID_AUTO (-1) > >/* > * The starting number for dynamically-assigned entries. WARNING! > * ALL static sysctl entries should have numbers LESS than this! > */ >#define CTL_AUTO_START 0x100 > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/linker_set.h> >#endif /* expanded by -frewrite-includes */ ># 124 "/usr/src/sys/sys/sysctl.h" ># 125 "/usr/src/sys/sys/sysctl.h" > >#ifdef KLD_MODULE >/* XXX allow overspecification of type in external kernel modules */ >#define SYSCTL_CT_ASSERT_MASK CTLTYPE >#else ># 130 "/usr/src/sys/sys/sysctl.h" >#define SYSCTL_CT_ASSERT_MASK 0 >#endif ># 132 "/usr/src/sys/sys/sysctl.h" > >#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \ > intptr_t arg2, struct sysctl_req *req > >/* definitions for sysctl_req 'lock' member */ >#define REQ_UNWIRED 1 >#define REQ_WIRED 2 > >/* definitions for sysctl_req 'flags' member */ >#if defined(__amd64__) || defined(__powerpc64__) ||\ > (defined(__mips__) && defined(__mips_n64)) >#define SCTL_MASK32 1 /* 32 bit emulation */ >#endif ># 145 "/usr/src/sys/sys/sysctl.h" > >/* > * This describes the access space for a sysctl request. This is needed > * so that we can use the interface from the kernel or from user-space. > */ >struct sysctl_req { > struct thread *td; /* used for access checking */ > int lock; /* wiring state */ > void *oldptr; > size_t oldlen; > size_t oldidx; > int (*oldfunc)(struct sysctl_req *, const void *, size_t); > void *newptr; > size_t newlen; > size_t newidx; > int (*newfunc)(struct sysctl_req *, void *, size_t); > size_t validlen; > int flags; >}; > >SLIST_HEAD(sysctl_oid_list, sysctl_oid); > >/* > * This describes one "oid" in the MIB tree. Potentially more nodes can > * be hidden behind it, expanded by the handler. > */ >struct sysctl_oid { > struct sysctl_oid_list oid_children; > struct sysctl_oid_list *oid_parent; > SLIST_ENTRY(sysctl_oid) oid_link; > int oid_number; > u_int oid_kind; > void *oid_arg1; > intptr_t oid_arg2; > const char *oid_name; > int (*oid_handler)(SYSCTL_HANDLER_ARGS); > const char *oid_fmt; > int oid_refcnt; > u_int oid_running; > const char *oid_descr; >}; > >#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) >#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) >#define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1) > >int sysctl_handle_int(SYSCTL_HANDLER_ARGS); >int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); >int sysctl_handle_long(SYSCTL_HANDLER_ARGS); >int sysctl_handle_64(SYSCTL_HANDLER_ARGS); >int sysctl_handle_string(SYSCTL_HANDLER_ARGS); >int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); >int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS); > >int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS); >int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS); > >int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS); >int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS); >int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); > >/* > * These functions are used to add/remove an oid from the mib. > */ >void sysctl_register_oid(struct sysctl_oid *oidp); >void sysctl_unregister_oid(struct sysctl_oid *oidp); > >/* Declare a static oid to allow child oids to be added to it. */ >#define SYSCTL_DECL(name) \ > extern struct sysctl_oid sysctl__##name > >/* Hide these in macros. */ >#define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children) >#define SYSCTL_PARENT(oid_ptr) \ > (((oid_ptr)->oid_parent != &sysctl__children) ? \ > __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \ > oid_children) : (struct sysctl_oid *)NULL) >#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children) > >/* === Structs and macros related to context handling. === */ > >/* All dynamically created sysctls can be tracked in a context list. */ >struct sysctl_ctx_entry { > struct sysctl_oid *entry; > TAILQ_ENTRY(sysctl_ctx_entry) link; >}; > >TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); > >#define SYSCTL_NODE_CHILDREN(parent, name) \ > sysctl__##parent##_##name.oid_children > >#ifndef NO_SYSCTL_DESCR >#define __DESCR(d) d >#else ># 240 "/usr/src/sys/sys/sysctl.h" >#define __DESCR(d) "" >#endif ># 242 "/usr/src/sys/sys/sysctl.h" > >/* This macro is only for internal use */ >#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \ > struct sysctl_oid id = { \ > .oid_parent = (parent_child_head), \ > .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ > .oid_number = (nbr), \ > .oid_kind = (kind), \ > .oid_arg1 = (a1), \ > .oid_arg2 = (a2), \ > .oid_name = (name), \ > .oid_handler = (handler), \ > .oid_fmt = (fmt), \ > .oid_descr = __DESCR(descr) \ > }; \ > DATA_SET(sysctl_set, id) > >/* This constructs a static "raw" MIB oid. */ >#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ > static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ > SYSCTL_CHILDREN(&sysctl__##parent), \ > nbr, #name, kind, a1, a2, handler, fmt, descr) > >/* This constructs a global "raw" MIB oid. */ >#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ > SYSCTL_OID_RAW(sysctl__##parent##_##name, \ > SYSCTL_CHILDREN(&sysctl__##parent), \ > nbr, #name, kind, a1, a2, handler, fmt, descr) > >#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ > sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) > >/* This constructs a root node from which other nodes can hang. */ >#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ > SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ > nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ > handler, "N", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) > >/* This constructs a node from which other oids can hang. */ >#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ > SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ > NULL, 0, handler, "N", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) > >#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ > NULL, 0, handler, "N", __DESCR(descr)); \ >}) > >#define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ > sysctl_add_oid(ctx, &sysctl__children, nbr, name, \ > CTLTYPE_NODE|(access), \ > NULL, 0, handler, "N", __DESCR(descr)); \ >}) > >/* Oid for a string. len can be 0 to indicate '\0' termination. */ >#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ > arg, len, sysctl_handle_string, "A", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) > >#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ >({ \ > char *__arg = (arg); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ > __arg, len, sysctl_handle_string, "A", __DESCR(descr)); \ >}) > >/* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */ >#define SYSCTL_NULL_INT_PTR ((int *)NULL) >#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_int, "I", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) && \ > sizeof(int) == sizeof(*(ptr))) > >#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ >({ \ > int *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > __ptr, val, sysctl_handle_int, "I", __DESCR(descr)); \ >}) > >/* Oid for an unsigned int. If ptr is NULL, val is returned. */ >#define SYSCTL_NULL_UINT_PTR ((unsigned *)NULL) >#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_int, "IU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT) && \ > sizeof(unsigned) == sizeof(*(ptr))) > >#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ >({ \ > unsigned *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ > __ptr, val, sysctl_handle_int, "IU", __DESCR(descr)); \ >}) > >/* Oid for a long. The pointer must be non NULL. */ >#define SYSCTL_NULL_LONG_PTR ((long *)NULL) >#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_long, "L", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG) && \ > sizeof(long) == sizeof(*(ptr))) > >#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > long *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_long, "L", __DESCR(descr)); \ >}) > >/* Oid for an unsigned long. The pointer must be non NULL. */ >#define SYSCTL_NULL_ULONG_PTR ((unsigned long *)NULL) >#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_long, "LU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG) && \ > sizeof(unsigned long) == sizeof(*(ptr))) > >#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > unsigned long *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)); \ >}) > >/* Oid for a quad. The pointer must be non NULL. */ >#define SYSCTL_NULL_QUAD_PTR ((int64_t *)NULL) >#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_64, "Q", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \ > sizeof(int64_t) == sizeof(*(ptr))) > >#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > int64_t *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr)); \ >}) > >#define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL) >#define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_64, "QU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ > sizeof(uint64_t) == sizeof(*(ptr))) > >#define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > uint64_t *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr)); \ >}) > >/* Oid for a CPU dependant variable */ >#define SYSCTL_ADD_UAUTO(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > struct sysctl_oid *__ret; \ > CTASSERT((sizeof(uint64_t) == sizeof(*(ptr)) || \ > sizeof(unsigned) == sizeof(*(ptr))) && \ > ((access) & CTLTYPE) == 0); \ > if (sizeof(uint64_t) == sizeof(*(ptr))) { \ > __ret = sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_64, "QU", \ > __DESCR(descr)); \ > } else { \ > __ret = sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_int, "IU", \ > __DESCR(descr)); \ > } \ > __ret; \ >}) > >/* Oid for a 64-bit unsigned counter(9). The pointer must be non NULL. */ >#define SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_counter_u64, "QU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ > sizeof(counter_u64_t) == sizeof(*(ptr)) && \ > sizeof(uint64_t) == sizeof(**(ptr))) > >#define SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > counter_u64_t *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \ >}) > >/* Oid for an opaque object. Specified by a pointer and a length. */ >#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > ptr, len, sysctl_handle_opaque, fmt, descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) > >#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)); \ >}) > >/* Oid for a struct. Specified by a pointer and a type. */ >#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > ptr, sizeof(struct type), sysctl_handle_opaque, \ > "S," #type, descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) > >#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > (ptr), sizeof(struct type), \ > sysctl_handle_opaque, "S," #type, __DESCR(descr)); \ >}) > >/* Oid for a procedure. Specified by a pointer and an arg. */ >#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ > SYSCTL_OID(parent, nbr, name, (access), \ > ptr, arg, handler, fmt, descr); \ > CTASSERT(((access) & CTLTYPE) != 0) > >#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) != 0); \ > sysctl_add_oid(ctx, parent, nbr, name, (access), \ > (ptr), (arg), (handler), (fmt), __DESCR(descr)); \ >}) > >/* Oid to handle limits on uma(9) zone specified by pointer. */ >#define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_uma_zone_max, "I", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) > >#define SYSCTL_ADD_UMA_MAX(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > uma_zone_t __ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr)); \ >}) > >/* Oid to obtain current use of uma(9) zone specified by pointer. */ >#define SYSCTL_UMA_CUR(parent, nbr, name, access, ptr, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ > (ptr), 0, sysctl_handle_uma_zone_cur, "I", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) > >#define SYSCTL_ADD_UMA_CUR(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > uma_zone_t __ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ > __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr)); \ >}) > >/* > * A macro to generate a read-only sysctl to indicate the presense of optional > * kernel features. > */ >#define FEATURE(name, desc) \ > SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD | CTLFLAG_CAPRD, \ > SYSCTL_NULL_INT_PTR, 1, desc) > >#endif /* _KERNEL */ ># 572 "/usr/src/sys/sys/sysctl.h" > >/* > * Top-level identifiers > */ >#define CTL_UNSPEC 0 /* unused */ >#define CTL_KERN 1 /* "high kernel": proc, limits */ >#define CTL_VM 2 /* virtual memory */ >#define CTL_VFS 3 /* filesystem, mount type is next */ >#define CTL_NET 4 /* network, see socket.h */ >#define CTL_DEBUG 5 /* debugging parameters */ >#define CTL_HW 6 /* generic cpu/io */ >#define CTL_MACHDEP 7 /* machine dependent */ >#define CTL_USER 8 /* user-level */ >#define CTL_P1003_1B 9 /* POSIX 1003.1B */ > >/* > * CTL_KERN identifiers > */ >#define KERN_OSTYPE 1 /* string: system version */ >#define KERN_OSRELEASE 2 /* string: system release */ >#define KERN_OSREV 3 /* int: system revision */ >#define KERN_VERSION 4 /* string: compile time info */ >#define KERN_MAXVNODES 5 /* int: max vnodes */ >#define KERN_MAXPROC 6 /* int: max processes */ >#define KERN_MAXFILES 7 /* int: max open files */ >#define KERN_ARGMAX 8 /* int: max arguments to exec */ >#define KERN_SECURELVL 9 /* int: system security level */ >#define KERN_HOSTNAME 10 /* string: hostname */ >#define KERN_HOSTID 11 /* int: host identifier */ >#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ >#define KERN_VNODE 13 /* struct: vnode structures */ >#define KERN_PROC 14 /* struct: process entries */ >#define KERN_FILE 15 /* struct: file entries */ >#define KERN_PROF 16 /* node: kernel profiling info */ >#define KERN_POSIX1 17 /* int: POSIX.1 version */ >#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ >#define KERN_JOB_CONTROL 19 /* int: is job control available */ >#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ >#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ >#define KERN_NISDOMAINNAME 22 /* string: YP domain name */ >#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */ >#define KERN_OSRELDATE 24 /* int: kernel release date */ >#define KERN_NTP_PLL 25 /* node: NTP PLL control */ >#define KERN_BOOTFILE 26 /* string: name of booted kernel */ >#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ >#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ >#define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */ >#define KERN_IPC 30 /* node: anything related to IPC */ >#define KERN_DUMMY 31 /* unused */ >#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ >#define KERN_USRSTACK 33 /* int: address of USRSTACK */ >#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ >#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ >#define KERN_HOSTUUID 36 /* string: host UUID identifier */ >#define KERN_ARND 37 /* int: from arc4rand() */ >/* > * KERN_PROC subtypes > */ >#define KERN_PROC_ALL 0 /* everything */ >#define KERN_PROC_PID 1 /* by process id */ >#define KERN_PROC_PGRP 2 /* by process group id */ >#define KERN_PROC_SESSION 3 /* by session of pid */ >#define KERN_PROC_TTY 4 /* by controlling tty */ >#define KERN_PROC_UID 5 /* by effective uid */ >#define KERN_PROC_RUID 6 /* by real uid */ >#define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */ >#define KERN_PROC_PROC 8 /* only return procs */ >#define KERN_PROC_SV_NAME 9 /* get syscall vector name */ >#define KERN_PROC_RGID 10 /* by real group id */ >#define KERN_PROC_GID 11 /* by effective group id */ >#define KERN_PROC_PATHNAME 12 /* path to executable */ >#define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */ >#define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */ >#define KERN_PROC_KSTACK 15 /* Kernel stacks for process */ >#define KERN_PROC_INC_THREAD 0x10 /* > * modifier for pid, pgrp, tty, > * uid, ruid, gid, rgid and proc > * This effectively uses 16-31 > */ >#define KERN_PROC_VMMAP 32 /* VM map entries for process */ >#define KERN_PROC_FILEDESC 33 /* File descriptors for process */ >#define KERN_PROC_GROUPS 34 /* process groups */ >#define KERN_PROC_ENV 35 /* get environment */ >#define KERN_PROC_AUXV 36 /* get ELF auxiliary vector */ >#define KERN_PROC_RLIMIT 37 /* process resource limits */ >#define KERN_PROC_PS_STRINGS 38 /* get ps_strings location */ >#define KERN_PROC_UMASK 39 /* process umask */ >#define KERN_PROC_OSREL 40 /* osreldate for process binary */ >#define KERN_PROC_SIGTRAMP 41 /* signal trampoline location */ >#define KERN_PROC_CWD 42 /* process current working directory */ > >/* > * KERN_IPC identifiers > */ >#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ >#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ >#define KIPC_SOMAXCONN 3 /* int: max length of connection q */ >#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ >#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ >#define KIPC_MAX_HDR 6 /* int: max total length of headers */ >#define KIPC_MAX_DATALEN 7 /* int: max length of data? */ > >/* > * CTL_HW identifiers > */ >#define HW_MACHINE 1 /* string: machine class */ >#define HW_MODEL 2 /* string: specific machine model */ >#define HW_NCPU 3 /* int: number of cpus */ >#define HW_BYTEORDER 4 /* int: machine byte order */ >#define HW_PHYSMEM 5 /* int: total memory */ >#define HW_USERMEM 6 /* int: non-kernel memory */ >#define HW_PAGESIZE 7 /* int: software page size */ >#define HW_DISKNAMES 8 /* strings: disk drive names */ >#define HW_DISKSTATS 9 /* struct: diskstats[] */ >#define HW_FLOATINGPT 10 /* int: has HW floating point? */ >#define HW_MACHINE_ARCH 11 /* string: machine architecture */ >#define HW_REALMEM 12 /* int: 'real' memory */ > >/* > * CTL_USER definitions > */ >#define USER_CS_PATH 1 /* string: _CS_PATH */ >#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ >#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ >#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ >#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ >#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ >#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ >#define USER_LINE_MAX 8 /* int: LINE_MAX */ >#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ >#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ >#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ >#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ >#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ >#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ >#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ >#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ >#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ >#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ >#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ >#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ > >#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */ >#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */ >#define CTL_P1003_1B_MEMLOCK 3 /* boolean */ >#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */ >#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */ >#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */ >#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */ >#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */ >#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */ >#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */ >#define CTL_P1003_1B_FSYNC 11 /* boolean */ >#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */ >#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */ >#define CTL_P1003_1B_TIMERS 14 /* boolean */ >#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */ >#define CTL_P1003_1B_AIO_MAX 16 /* int */ >#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */ >#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */ >#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */ >#define CTL_P1003_1B_PAGESIZE 20 /* int */ >#define CTL_P1003_1B_RTSIG_MAX 21 /* int */ >#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */ >#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */ >#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */ >#define CTL_P1003_1B_TIMER_MAX 25 /* int */ > >#define CTL_P1003_1B_MAXID 26 > >#ifdef _KERNEL > >/* > * Declare some common oids. > */ >extern struct sysctl_oid_list sysctl__children; >SYSCTL_DECL(_kern); >SYSCTL_DECL(_kern_features); >SYSCTL_DECL(_kern_ipc); >SYSCTL_DECL(_kern_proc); >SYSCTL_DECL(_kern_sched); >SYSCTL_DECL(_kern_sched_stats); >SYSCTL_DECL(_sysctl); >SYSCTL_DECL(_vm); >SYSCTL_DECL(_vm_stats); >SYSCTL_DECL(_vm_stats_misc); >SYSCTL_DECL(_vfs); >SYSCTL_DECL(_net); >SYSCTL_DECL(_debug); >SYSCTL_DECL(_debug_sizeof); >SYSCTL_DECL(_dev); >SYSCTL_DECL(_hw); >SYSCTL_DECL(_hw_bus); >SYSCTL_DECL(_hw_bus_devices); >SYSCTL_DECL(_hw_bus_info); >SYSCTL_DECL(_machdep); >SYSCTL_DECL(_user); >SYSCTL_DECL(_compat); >SYSCTL_DECL(_regression); >SYSCTL_DECL(_security); >SYSCTL_DECL(_security_bsd); > >extern char machine[]; >extern char osrelease[]; >extern char ostype[]; >extern char kern_ident[]; > >/* Dynamic oid handling */ >struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, > struct sysctl_oid_list *parent, int nbr, const char *name, int kind, > void *arg1, intptr_t arg2, int (*handler)(SYSCTL_HANDLER_ARGS), > const char *fmt, const char *descr); >int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, > int recurse); >void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); >int sysctl_move_oid(struct sysctl_oid *oidp, > struct sysctl_oid_list *parent); >int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); >int sysctl_ctx_init(struct sysctl_ctx_list *clist); >int sysctl_ctx_free(struct sysctl_ctx_list *clist); >struct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, > struct sysctl_oid *oidp); >struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, > struct sysctl_oid *oidp); >int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, > struct sysctl_oid *oidp); > >int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, > size_t *oldlenp, void *new, size_t newlen, size_t *retval, > int flags); >int kernel_sysctlbyname(struct thread *td, char *name, void *old, > size_t *oldlenp, void *new, size_t newlen, size_t *retval, > int flags); >int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, > size_t *oldlenp, int inkernel, void *new, size_t newlen, > size_t *retval, int flags); >int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, > int *nindx, struct sysctl_req *req); >void sysctl_xlock(void); >void sysctl_xunlock(void); >int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); > >struct sbuf; >struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int, > struct sysctl_req *); >#else /* !_KERNEL */ ># 818 "/usr/src/sys/sys/sysctl.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 818 "/usr/src/sys/sys/sysctl.h" ># 819 "/usr/src/sys/sys/sysctl.h" > >__BEGIN_DECLS >int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); >int sysctlbyname(const char *, void *, size_t *, const void *, size_t); >int sysctlnametomib(const char *, int *, size_t *); >__END_DECLS >#endif /* _KERNEL */ ># 826 "/usr/src/sys/sys/sysctl.h" > >#endif /* !_SYS_SYSCTL_H_ */ ># 828 "/usr/src/sys/sys/sysctl.h" ># 63 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sbuf.h> >#endif /* expanded by -frewrite-includes */ ># 63 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/sbuf.h" 1 >/*- > * Copyright (c) 2000-2008 Poul-Henning Kamp > * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer > * in this position and unchanged. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/sbuf.h 279992 2015-03-14 16:02:11Z ian $ > */ > >#ifndef _SYS_SBUF_H_ >#define _SYS_SBUF_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/sys/sys/sbuf.h" ># 35 "/usr/src/sys/sys/sbuf.h" > >struct sbuf; >typedef int (sbuf_drain_func)(void *, const char *, int); > >/* > * Structure definition > */ >struct sbuf { > char *s_buf; /* storage buffer */ > sbuf_drain_func *s_drain_func; /* drain function */ > void *s_drain_arg; /* user-supplied drain argument */ > int s_error; /* current error code */ > ssize_t s_size; /* size of storage buffer */ > ssize_t s_len; /* current length of string */ >#define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ >#define SBUF_AUTOEXTEND 0x00000001 /* automatically extend buffer */ >#define SBUF_INCLUDENUL 0x00000002 /* nulterm byte is counted in len */ >#define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ >#define SBUF_DYNAMIC 0x00010000 /* s_buf must be freed */ >#define SBUF_FINISHED 0x00020000 /* set by sbuf_finish() */ >#define SBUF_DYNSTRUCT 0x00080000 /* sbuf must be freed */ >#define SBUF_INSECTION 0x00100000 /* set by sbuf_start_section() */ > int s_flags; /* flags */ > ssize_t s_sect_len; /* current length of section */ >}; > >__BEGIN_DECLS >/* > * API functions > */ >struct sbuf *sbuf_new(struct sbuf *, char *, int, int); >#define sbuf_new_auto() \ > sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) >int sbuf_get_flags(struct sbuf *); >void sbuf_clear_flags(struct sbuf *, int); >void sbuf_set_flags(struct sbuf *, int); >void sbuf_clear(struct sbuf *); >int sbuf_setpos(struct sbuf *, ssize_t); >int sbuf_bcat(struct sbuf *, const void *, size_t); >int sbuf_bcpy(struct sbuf *, const void *, size_t); >int sbuf_cat(struct sbuf *, const char *); >int sbuf_cpy(struct sbuf *, const char *); >int sbuf_printf(struct sbuf *, const char *, ...) > __printflike(2, 3); >int sbuf_vprintf(struct sbuf *, const char *, __va_list) > __printflike(2, 0); >int sbuf_putc(struct sbuf *, int); >void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *); >int sbuf_trim(struct sbuf *); >int sbuf_error(const struct sbuf *); >int sbuf_finish(struct sbuf *); >char *sbuf_data(struct sbuf *); >ssize_t sbuf_len(struct sbuf *); >int sbuf_done(const struct sbuf *); >void sbuf_delete(struct sbuf *); >void sbuf_start_section(struct sbuf *, ssize_t *); >ssize_t sbuf_end_section(struct sbuf *, ssize_t, size_t, int); > >#ifdef _KERNEL >struct uio; >struct sbuf *sbuf_uionew(struct sbuf *, struct uio *, int *); >int sbuf_bcopyin(struct sbuf *, const void *, size_t); >int sbuf_copyin(struct sbuf *, const void *, size_t); >#endif ># 99 "/usr/src/sys/sys/sbuf.h" >__END_DECLS > >#endif ># 102 "/usr/src/sys/sys/sbuf.h" ># 64 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/tty.h> >#endif /* expanded by -frewrite-includes */ ># 64 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/tty.h" 1 >/*- > * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> > * All rights reserved. > * > * Portions of this software were developed under sponsorship from Snow > * B.V., the Netherlands. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/tty.h 259549 2013-12-18 12:50:43Z glebius $ > */ > >#ifndef _SYS_TTY_H_ >#define _SYS_TTY_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/tty.h" ># 36 "/usr/src/sys/sys/tty.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/tty.h" ># 37 "/usr/src/sys/sys/tty.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/tty.h" ># 38 "/usr/src/sys/sys/tty.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/tty.h" ># 39 "/usr/src/sys/sys/tty.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/condvar.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/tty.h" ># 40 "/usr/src/sys/sys/tty.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/selinfo.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/selinfo.h" 1 >/*- > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)select.h 8.2 (Berkeley) 1/4/94 > * $FreeBSD: head/sys/sys/selinfo.h 225177 2011-08-25 15:51:54Z attilio $ > */ > >#ifndef _SYS_SELINFO_H_ >#define _SYS_SELINFO_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/event.h> /* for struct klist */ >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/selinfo.h" ># 37 "/usr/src/sys/sys/selinfo.h" > >struct selfd; >TAILQ_HEAD(selfdlist, selfd); > >/* > * Used to maintain information about processes that wish to be > * notified when I/O becomes possible. > */ >struct selinfo { > struct selfdlist si_tdlist; /* List of sleeping threads. */ > struct knlist si_note; /* kernel note list */ > struct mtx *si_mtx; /* Lock for tdlist. */ >}; > >#define SEL_WAITING(si) (!TAILQ_EMPTY(&(si)->si_tdlist)) > >#ifdef _KERNEL >void seldrain(struct selinfo *sip); >void selrecord(struct thread *selector, struct selinfo *sip); >void selwakeup(struct selinfo *sip); >void selwakeuppri(struct selinfo *sip, int pri); >void seltdfini(struct thread *td); >#endif ># 60 "/usr/src/sys/sys/selinfo.h" > >#endif /* !_SYS_SELINFO_H_ */ ># 62 "/usr/src/sys/sys/selinfo.h" ># 41 "/usr/src/sys/sys/tty.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_termios.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/_termios.h" 1 >/*- > * Copyright (c) 1988, 1989, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)termios.h 8.3 (Berkeley) 3/28/94 > * $FreeBSD: head/sys/sys/_termios.h 199898 2009-11-28 23:50:48Z ed $ > */ > >#ifndef _SYS__TERMIOS_H_ >#define _SYS__TERMIOS_H_ > >/* > * Special Control Characters > * > * Index into c_cc[] character array. > * > * Name Subscript Enabled by > */ >#define VEOF 0 /* ICANON */ >#define VEOL 1 /* ICANON */ >#ifndef _POSIX_SOURCE >#define VEOL2 2 /* ICANON together with IEXTEN */ >#endif ># 48 "/usr/src/sys/sys/_termios.h" >#define VERASE 3 /* ICANON */ >#ifndef _POSIX_SOURCE >#define VWERASE 4 /* ICANON together with IEXTEN */ >#endif ># 52 "/usr/src/sys/sys/_termios.h" >#define VKILL 5 /* ICANON */ >#ifndef _POSIX_SOURCE >#define VREPRINT 6 /* ICANON together with IEXTEN */ >#define VERASE2 7 /* ICANON */ >#endif ># 57 "/usr/src/sys/sys/_termios.h" >/* 7 ex-spare 1 */ >#define VINTR 8 /* ISIG */ >#define VQUIT 9 /* ISIG */ >#define VSUSP 10 /* ISIG */ >#ifndef _POSIX_SOURCE >#define VDSUSP 11 /* ISIG together with IEXTEN */ >#endif ># 64 "/usr/src/sys/sys/_termios.h" >#define VSTART 12 /* IXON, IXOFF */ >#define VSTOP 13 /* IXON, IXOFF */ >#ifndef _POSIX_SOURCE >#define VLNEXT 14 /* IEXTEN */ >#define VDISCARD 15 /* IEXTEN */ >#endif ># 70 "/usr/src/sys/sys/_termios.h" >#define VMIN 16 /* !ICANON */ >#define VTIME 17 /* !ICANON */ >#ifndef _POSIX_SOURCE >#define VSTATUS 18 /* ICANON together with IEXTEN */ >/* 19 spare 2 */ >#endif ># 76 "/usr/src/sys/sys/_termios.h" >#define NCCS 20 > >#define _POSIX_VDISABLE 0xff > >/* > * Input flags - software input processing > */ >#define IGNBRK 0x00000001 /* ignore BREAK condition */ >#define BRKINT 0x00000002 /* map BREAK to SIGINTR */ >#define IGNPAR 0x00000004 /* ignore (discard) parity errors */ >#define PARMRK 0x00000008 /* mark parity and framing errors */ >#define INPCK 0x00000010 /* enable checking of parity errors */ >#define ISTRIP 0x00000020 /* strip 8th bit off chars */ >#define INLCR 0x00000040 /* map NL into CR */ >#define IGNCR 0x00000080 /* ignore CR */ >#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */ >#define IXON 0x00000200 /* enable output flow control */ >#define IXOFF 0x00000400 /* enable input flow control */ >#ifndef _POSIX_SOURCE >#define IXANY 0x00000800 /* any char will restart after stop */ >#define IMAXBEL 0x00002000 /* ring bell on input queue full */ >#endif /*_POSIX_SOURCE */ ># 98 "/usr/src/sys/sys/_termios.h" > >/* > * Output flags - software output processing > */ >#define OPOST 0x00000001 /* enable following output processing */ >#ifndef _POSIX_SOURCE >#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */ >#define TABDLY 0x00000004 /* tab delay mask */ >#define TAB0 0x00000000 /* no tab delay and expansion */ >#define TAB3 0x00000004 /* expand tabs to spaces */ >#define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */ >#define OCRNL 0x00000010 /* map CR to NL on output */ >#define ONOCR 0x00000020 /* no CR output at column 0 */ >#define ONLRET 0x00000040 /* NL performs CR function */ >#endif /*_POSIX_SOURCE */ ># 113 "/usr/src/sys/sys/_termios.h" > >/* > * Control flags - hardware control of terminal > */ >#ifndef _POSIX_SOURCE >#define CIGNORE 0x00000001 /* ignore control flags */ >#endif ># 120 "/usr/src/sys/sys/_termios.h" >#define CSIZE 0x00000300 /* character size mask */ >#define CS5 0x00000000 /* 5 bits (pseudo) */ >#define CS6 0x00000100 /* 6 bits */ >#define CS7 0x00000200 /* 7 bits */ >#define CS8 0x00000300 /* 8 bits */ >#define CSTOPB 0x00000400 /* send 2 stop bits */ >#define CREAD 0x00000800 /* enable receiver */ >#define PARENB 0x00001000 /* parity enable */ >#define PARODD 0x00002000 /* odd parity, else even */ >#define HUPCL 0x00004000 /* hang up on last close */ >#define CLOCAL 0x00008000 /* ignore modem status lines */ >#ifndef _POSIX_SOURCE >#define CCTS_OFLOW 0x00010000 /* CTS flow control of output */ >#define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW) >#define CRTS_IFLOW 0x00020000 /* RTS flow control of input */ >#define CDTR_IFLOW 0x00040000 /* DTR flow control of input */ >#define CDSR_OFLOW 0x00080000 /* DSR flow control of output */ >#define CCAR_OFLOW 0x00100000 /* DCD flow control of output */ >#endif ># 139 "/usr/src/sys/sys/_termios.h" > > >/* > * "Local" flags - dumping ground for other state > * > * Warning: some flags in this structure begin with > * the letter "I" and look like they belong in the > * input flag. > */ > >#ifndef _POSIX_SOURCE >#define ECHOKE 0x00000001 /* visual erase for line kill */ >#endif /*_POSIX_SOURCE */ ># 152 "/usr/src/sys/sys/_termios.h" >#define ECHOE 0x00000002 /* visually erase chars */ >#define ECHOK 0x00000004 /* echo NL after line kill */ >#define ECHO 0x00000008 /* enable echoing */ >#define ECHONL 0x00000010 /* echo NL even if ECHO is off */ >#ifndef _POSIX_SOURCE >#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */ >#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */ >#endif /*_POSIX_SOURCE */ ># 160 "/usr/src/sys/sys/_termios.h" >#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */ >#define ICANON 0x00000100 /* canonicalize input lines */ >#ifndef _POSIX_SOURCE >#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */ >#endif /*_POSIX_SOURCE */ ># 165 "/usr/src/sys/sys/_termios.h" >#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */ >#define EXTPROC 0x00000800 /* external processing */ >#define TOSTOP 0x00400000 /* stop background jobs from output */ >#ifndef _POSIX_SOURCE >#define FLUSHO 0x00800000 /* output being flushed (state) */ >#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */ >#define PENDIN 0x20000000 /* XXX retype pending input (state) */ >#endif /*_POSIX_SOURCE */ ># 173 "/usr/src/sys/sys/_termios.h" >#define NOFLSH 0x80000000 /* don't flush after interrupt */ > >/* > * Standard speeds > */ >#define B0 0 >#define B50 50 >#define B75 75 >#define B110 110 >#define B134 134 >#define B150 150 >#define B200 200 >#define B300 300 >#define B600 600 >#define B1200 1200 >#define B1800 1800 >#define B2400 2400 >#define B4800 4800 >#define B9600 9600 >#define B19200 19200 >#define B38400 38400 >#ifndef _POSIX_SOURCE >#define B7200 7200 >#define B14400 14400 >#define B28800 28800 >#define B57600 57600 >#define B76800 76800 >#define B115200 115200 >#define B230400 230400 >#define B460800 460800 >#define B921600 921600 >#define EXTA 19200 >#define EXTB 38400 >#endif /* !_POSIX_SOURCE */ ># 207 "/usr/src/sys/sys/_termios.h" > >typedef unsigned int tcflag_t; >typedef unsigned char cc_t; >typedef unsigned int speed_t; > >struct termios { > tcflag_t c_iflag; /* input flags */ > tcflag_t c_oflag; /* output flags */ > tcflag_t c_cflag; /* control flags */ > tcflag_t c_lflag; /* local flags */ > cc_t c_cc[NCCS]; /* control chars */ > speed_t c_ispeed; /* input speed */ > speed_t c_ospeed; /* output speed */ >}; > >#endif /* !_SYS__TERMIOS_H_ */ ># 223 "/usr/src/sys/sys/_termios.h" ># 42 "/usr/src/sys/sys/tty.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ttycom.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/ttycom.h" 1 >/*- > * Copyright (c) 1982, 1986, 1990, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)ttycom.h 8.1 (Berkeley) 3/28/94 > * $FreeBSD: head/sys/sys/ttycom.h 231095 2012-02-06 18:15:46Z ed $ > */ > >#ifndef _SYS_TTYCOM_H_ >#define _SYS_TTYCOM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ioccom.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/ttycom.h" ># 1 "/usr/src/sys/sys/ioccom.h" 1 >/*- > * Copyright (c) 1982, 1986, 1990, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)ioccom.h 8.2 (Berkeley) 3/28/94 > * $FreeBSD: head/sys/sys/ioccom.h 206051 2010-04-01 16:21:35Z pjd $ > */ > >#ifndef _SYS_IOCCOM_H_ >#define _SYS_IOCCOM_H_ > >/* > * Ioctl's have the command encoded in the lower word, and the size of > * any in or out parameters in the upper word. The high 3 bits of the > * upper word are used to encode the in/out status of the parameter. > */ >#define IOCPARM_SHIFT 13 /* number of bits for ioctl size */ >#define IOCPARM_MASK ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */ >#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) >#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16)) >#define IOCGROUP(x) (((x) >> 8) & 0xff) > >#define IOCPARM_MAX (1 << IOCPARM_SHIFT) /* max size of ioctl */ >#define IOC_VOID 0x20000000 /* no parameters */ >#define IOC_OUT 0x40000000 /* copy out parameters */ >#define IOC_IN 0x80000000 /* copy in parameters */ >#define IOC_INOUT (IOC_IN|IOC_OUT) >#define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN) > >#define _IOC(inout,group,num,len) ((unsigned long) \ > ((inout) | (((len) & IOCPARM_MASK) << 16) | ((group) << 8) | (num))) >#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) >#define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int)) >#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) >#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) >/* this should be _IORW, but stdio got there first */ >#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) > >#ifdef _KERNEL > >#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ > defined(COMPAT_FREEBSD4) || defined(COMPAT_43) >#define IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x)) >#endif ># 69 "/usr/src/sys/sys/ioccom.h" > >#else ># 71 "/usr/src/sys/sys/ioccom.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 72 "/usr/src/sys/sys/ioccom.h" ># 73 "/usr/src/sys/sys/ioccom.h" > >__BEGIN_DECLS >int ioctl(int, unsigned long, ...); >__END_DECLS > >#endif ># 79 "/usr/src/sys/sys/ioccom.h" > >#endif /* !_SYS_IOCCOM_H_ */ ># 81 "/usr/src/sys/sys/ioccom.h" ># 42 "/usr/src/sys/sys/ttycom.h" 2 > >/* > * Tty ioctl's except for those supported only for backwards compatibility > * with the old tty driver. > */ > >/* > * Window/terminal size structure. This information is stored by the kernel > * in order to provide a consistent interface, but is not used by the kernel. > */ >struct winsize { > unsigned short ws_row; /* rows, in characters */ > unsigned short ws_col; /* columns, in characters */ > unsigned short ws_xpixel; /* horizontal size, pixels */ > unsigned short ws_ypixel; /* vertical size, pixels */ >}; > > /* 0-2 compat */ > /* 3-7 unused */ > /* 8-10 compat */ > /* 11-12 unused */ >#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */ >#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */ >#define TIOCGPTN _IOR('t', 15, int) /* Get pts number. */ >#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */ > /* 17-18 compat */ >#define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */ >#define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */ >#define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */ >#define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */ > /* 23-25 unused */ >#define TIOCGETD _IOR('t', 26, int) /* get line discipline */ >#define TIOCSETD _IOW('t', 27, int) /* set line discipline */ >#define TIOCPTMASTER _IO('t', 28) /* pts master validation */ > /* 29-85 unused */ >#define TIOCGDRAINWAIT _IOR('t', 86, int) /* get ttywait timeout */ >#define TIOCSDRAINWAIT _IOW('t', 87, int) /* set ttywait timeout */ > /* 88 unused */ > /* 89-91 conflicts: tun and tap */ >#define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* enable/get timestamp > * of last input event */ >#define TIOCMGDTRWAIT _IOR('t', 90, int) /* modem: get wait on close */ >#define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */ > /* 92-93 tun and tap */ > /* 94-97 conflicts: tun and tap */ >#define TIOCDRAIN _IO('t', 94) /* wait till output drained */ >#define TIOCSIG _IOWINT('t', 95) /* pty: generate signal */ >#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */ >#define TIOCSCTTY _IO('t', 97) /* become controlling tty */ >#define TIOCCONS _IOW('t', 98, int) /* become virtual console */ >#define TIOCGSID _IOR('t', 99, int) /* get session id */ > /* 100 unused */ >#define TIOCSTAT _IO('t', 101) /* simulate ^T status message */ >#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ >#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ >#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ >#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ > /* 105 unused */ >#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */ >#define TIOCM_LE 0001 /* line enable */ >#define TIOCM_DTR 0002 /* data terminal ready */ >#define TIOCM_RTS 0004 /* request to send */ >#define TIOCM_ST 0010 /* secondary transmit */ >#define TIOCM_SR 0020 /* secondary receive */ >#define TIOCM_CTS 0040 /* clear to send */ >#define TIOCM_DCD 0100 /* data carrier detect */ >#define TIOCM_RI 0200 /* ring indicate */ >#define TIOCM_DSR 0400 /* data set ready */ >#define TIOCM_CD TIOCM_DCD >#define TIOCM_CAR TIOCM_DCD >#define TIOCM_RNG TIOCM_RI >#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */ >#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */ >#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ >#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ >#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ >#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */ >#define TIOCPKT_DATA 0x00 /* data packet */ >#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */ >#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ >#define TIOCPKT_STOP 0x04 /* stop output */ >#define TIOCPKT_START 0x08 /* start output */ >#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ >#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ >#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */ >#define TIOCNOTTY _IO('t', 113) /* void tty association */ >#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */ >#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ > /* 116-117 compat */ >#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */ >#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */ >#define TIOCCDTR _IO('t', 120) /* clear data terminal ready */ >#define TIOCSDTR _IO('t', 121) /* set data terminal ready */ >#define TIOCCBRK _IO('t', 122) /* clear break bit */ >#define TIOCSBRK _IO('t', 123) /* set break bit */ > /* 124-127 compat */ > >#define TTYDISC 0 /* termios tty line discipline */ >#define SLIPDISC 4 /* serial IP discipline */ >#define PPPDISC 5 /* PPP discipline */ >#define NETGRAPHDISC 6 /* Netgraph tty node discipline */ >#define H4DISC 7 /* Netgraph Bluetooth H4 discipline */ > >#endif /* !_SYS_TTYCOM_H_ */ ># 146 "/usr/src/sys/sys/ttycom.h" ># 43 "/usr/src/sys/sys/tty.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ttyqueue.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/ttyqueue.h" 1 >/*- > * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> > * All rights reserved. > * > * Portions of this software were developed under sponsorship from Snow > * B.V., the Netherlands. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/ttyqueue.h 198223 2009-10-19 07:17:37Z ed $ > */ > >#ifndef _SYS_TTYQUEUE_H_ >#define _SYS_TTYQUEUE_H_ > >#ifndef _SYS_TTY_H_ >#error "can only be included through <sys/tty.h>" >#endif /* !_SYS_TTY_H_ */ ># 38 "/usr/src/sys/sys/ttyqueue.h" > >struct tty; >struct ttyinq_block; >struct ttyoutq_block; >struct uio; > >/* Data input queue. */ >struct ttyinq { > struct ttyinq_block *ti_firstblock; > struct ttyinq_block *ti_startblock; > struct ttyinq_block *ti_reprintblock; > struct ttyinq_block *ti_lastblock; > unsigned int ti_begin; > unsigned int ti_linestart; > unsigned int ti_reprint; > unsigned int ti_end; > unsigned int ti_nblocks; > unsigned int ti_quota; >}; >#define TTYINQ_DATASIZE 128 > >/* Data output queue. */ >struct ttyoutq { > struct ttyoutq_block *to_firstblock; > struct ttyoutq_block *to_lastblock; > unsigned int to_begin; > unsigned int to_end; > unsigned int to_nblocks; > unsigned int to_quota; >}; >#define TTYOUTQ_DATASIZE (256 - sizeof(struct ttyoutq_block *)) > >#ifdef _KERNEL >/* Input queue handling routines. */ >void ttyinq_setsize(struct ttyinq *ti, struct tty *tp, size_t len); >void ttyinq_free(struct ttyinq *ti); >int ttyinq_read_uio(struct ttyinq *ti, struct tty *tp, struct uio *uio, > size_t readlen, size_t flushlen); >size_t ttyinq_write(struct ttyinq *ti, const void *buf, size_t len, > int quote); >int ttyinq_write_nofrag(struct ttyinq *ti, const void *buf, size_t len, > int quote); >void ttyinq_canonicalize(struct ttyinq *ti); >size_t ttyinq_findchar(struct ttyinq *ti, const char *breakc, size_t maxlen, > char *lastc); >void ttyinq_flush(struct ttyinq *ti); >int ttyinq_peekchar(struct ttyinq *ti, char *c, int *quote); >void ttyinq_unputchar(struct ttyinq *ti); >void ttyinq_reprintpos_set(struct ttyinq *ti); >void ttyinq_reprintpos_reset(struct ttyinq *ti); > >static __inline size_t >ttyinq_getsize(struct ttyinq *ti) >{ > return (ti->ti_nblocks * TTYINQ_DATASIZE); >} > >static __inline size_t >ttyinq_getallocatedsize(struct ttyinq *ti) >{ > > return (ti->ti_quota * TTYINQ_DATASIZE); >} > >static __inline size_t >ttyinq_bytesleft(struct ttyinq *ti) >{ > size_t len; > > /* Make sure the usage never exceeds the length. */ > len = ti->ti_nblocks * TTYINQ_DATASIZE; > MPASS(len >= ti->ti_end); > > return (len - ti->ti_end); >} > >static __inline size_t >ttyinq_bytescanonicalized(struct ttyinq *ti) >{ > MPASS(ti->ti_begin <= ti->ti_linestart); > > return (ti->ti_linestart - ti->ti_begin); >} > >static __inline size_t >ttyinq_bytesline(struct ttyinq *ti) >{ > MPASS(ti->ti_linestart <= ti->ti_end); > > return (ti->ti_end - ti->ti_linestart); >} > >/* Input buffer iteration. */ >typedef void ttyinq_line_iterator_t(void *data, char c, int flags); >void ttyinq_line_iterate_from_linestart(struct ttyinq *ti, > ttyinq_line_iterator_t *iterator, void *data); >void ttyinq_line_iterate_from_reprintpos(struct ttyinq *ti, > ttyinq_line_iterator_t *iterator, void *data); > >/* Output queue handling routines. */ >void ttyoutq_flush(struct ttyoutq *to); >void ttyoutq_setsize(struct ttyoutq *to, struct tty *tp, size_t len); >void ttyoutq_free(struct ttyoutq *to); >size_t ttyoutq_read(struct ttyoutq *to, void *buf, size_t len); >int ttyoutq_read_uio(struct ttyoutq *to, struct tty *tp, struct uio *uio); >size_t ttyoutq_write(struct ttyoutq *to, const void *buf, size_t len); >int ttyoutq_write_nofrag(struct ttyoutq *to, const void *buf, size_t len); > >static __inline size_t >ttyoutq_getsize(struct ttyoutq *to) >{ > return (to->to_nblocks * TTYOUTQ_DATASIZE); >} > >static __inline size_t >ttyoutq_getallocatedsize(struct ttyoutq *to) >{ > > return (to->to_quota * TTYOUTQ_DATASIZE); >} > >static __inline size_t >ttyoutq_bytesleft(struct ttyoutq *to) >{ > size_t len; > > /* Make sure the usage never exceeds the length. */ > len = to->to_nblocks * TTYOUTQ_DATASIZE; > MPASS(len >= to->to_end); > > return (len - to->to_end); >} > >static __inline size_t >ttyoutq_bytesused(struct ttyoutq *to) >{ > return (to->to_end - to->to_begin); >} >#endif /* _KERNEL */ ># 177 "/usr/src/sys/sys/ttyqueue.h" > >#endif /* !_SYS_TTYQUEUE_H_ */ ># 179 "/usr/src/sys/sys/ttyqueue.h" ># 44 "/usr/src/sys/sys/tty.h" 2 > >struct cdev; >struct file; >struct pgrp; >struct session; >struct ucred; > >struct ttydevsw; > >/* > * Per-TTY structure, containing buffers, etc. > * > * List of locks > * (t) locked by t_mtx > * (l) locked by tty_list_sx > * (c) const until freeing > */ >struct tty { > struct mtx *t_mtx; /* TTY lock. */ > struct mtx t_mtxobj; /* Per-TTY lock (when not borrowing). */ > TAILQ_ENTRY(tty) t_list; /* (l) TTY list entry. */ > unsigned int t_flags; /* (t) Terminal option flags. */ >/* Keep flags in sync with db_show_tty and pstat(8). */ >#define TF_NOPREFIX 0x00001 /* Don't prepend "tty" to device name. */ >#define TF_INITLOCK 0x00002 /* Create init/lock state devices. */ >#define TF_CALLOUT 0x00004 /* Create "cua" devices. */ >#define TF_OPENED_IN 0x00008 /* "tty" node is in use. */ >#define TF_OPENED_OUT 0x00010 /* "cua" node is in use. */ >#define TF_OPENED_CONS 0x00020 /* Device in use as console. */ >#define TF_OPENED (TF_OPENED_IN|TF_OPENED_OUT|TF_OPENED_CONS) >#define TF_GONE 0x00040 /* Device node is gone. */ >#define TF_OPENCLOSE 0x00080 /* Device is in open()/close(). */ >#define TF_ASYNC 0x00100 /* Asynchronous I/O enabled. */ >#define TF_LITERAL 0x00200 /* Accept the next character literally. */ >#define TF_HIWAT_IN 0x00400 /* We've reached the input watermark. */ >#define TF_HIWAT_OUT 0x00800 /* We've reached the output watermark. */ >#define TF_HIWAT (TF_HIWAT_IN|TF_HIWAT_OUT) >#define TF_STOPPED 0x01000 /* Output flow control - stopped. */ >#define TF_EXCLUDE 0x02000 /* Exclusive access. */ >#define TF_BYPASS 0x04000 /* Optimized input path. */ >#define TF_ZOMBIE 0x08000 /* Modem disconnect received. */ >#define TF_HOOK 0x10000 /* TTY has hook attached. */ >#define TF_BUSY_IN 0x20000 /* Process busy in read() -- not supported. */ >#define TF_BUSY_OUT 0x40000 /* Process busy in write(). */ >#define TF_BUSY (TF_BUSY_IN|TF_BUSY_OUT) > unsigned int t_revokecnt; /* (t) revoke() count. */ > > /* Buffering mechanisms. */ > struct ttyinq t_inq; /* (t) Input queue. */ > size_t t_inlow; /* (t) Input low watermark. */ > struct ttyoutq t_outq; /* (t) Output queue. */ > size_t t_outlow; /* (t) Output low watermark. */ > > /* Sleeping mechanisms. */ > struct cv t_inwait; /* (t) Input wait queue. */ > struct cv t_outwait; /* (t) Output wait queue. */ > struct cv t_outserwait; /* (t) Serial output wait queue. */ > struct cv t_bgwait; /* (t) Background wait queue. */ > struct cv t_dcdwait; /* (t) Carrier Detect wait queue. */ > > /* Polling mechanisms. */ > struct selinfo t_inpoll; /* (t) Input poll queue. */ > struct selinfo t_outpoll; /* (t) Output poll queue. */ > struct sigio *t_sigio; /* (t) Asynchronous I/O. */ > > struct termios t_termios; /* (t) I/O processing flags. */ > struct winsize t_winsize; /* (t) Window size. */ > unsigned int t_column; /* (t) Current cursor position. */ > unsigned int t_writepos; /* (t) Where input was interrupted. */ > int t_compatflags; /* (t) COMPAT_43TTY flags. */ > > /* Init/lock-state devices. */ > struct termios t_termios_init_in; /* tty%s.init. */ > struct termios t_termios_lock_in; /* tty%s.lock. */ > struct termios t_termios_init_out; /* cua%s.init. */ > struct termios t_termios_lock_out; /* cua%s.lock. */ > > struct ttydevsw *t_devsw; /* (c) Driver hooks. */ > struct ttyhook *t_hook; /* (t) Capture/inject hook. */ > > /* Process signal delivery. */ > struct pgrp *t_pgrp; /* (t) Foreground process group. */ > struct session *t_session; /* (t) Associated session. */ > unsigned int t_sessioncnt; /* (t) Backpointing sessions. */ > > void *t_devswsoftc; /* (c) Soft config, for drivers. */ > void *t_hooksoftc; /* (t) Soft config, for hooks. */ > struct cdev *t_dev; /* (c) Primary character device. */ >}; > >/* > * Userland version of struct tty, for sysctl kern.ttys > */ >struct xtty { > size_t xt_size; /* Structure size. */ > size_t xt_insize; /* Input queue size. */ > size_t xt_incc; /* Canonicalized characters. */ > size_t xt_inlc; /* Input line charaters. */ > size_t xt_inlow; /* Input low watermark. */ > size_t xt_outsize; /* Output queue size. */ > size_t xt_outcc; /* Output queue usage. */ > size_t xt_outlow; /* Output low watermark. */ > unsigned int xt_column; /* Current column position. */ > pid_t xt_pgid; /* Foreground process group. */ > pid_t xt_sid; /* Session. */ > unsigned int xt_flags; /* Terminal option flags. */ > dev_t xt_dev; /* Userland device. */ >}; > >#ifdef _KERNEL > >/* Used to distinguish between normal, callout, lock and init devices. */ >#define TTYUNIT_INIT 0x1 >#define TTYUNIT_LOCK 0x2 >#define TTYUNIT_CALLOUT 0x4 > >/* Allocation and deallocation. */ >struct tty *tty_alloc(struct ttydevsw *tsw, void *softc); >struct tty *tty_alloc_mutex(struct ttydevsw *tsw, void *softc, struct mtx *mtx); >void tty_rel_pgrp(struct tty *tp, struct pgrp *pgrp); >void tty_rel_sess(struct tty *tp, struct session *sess); >void tty_rel_gone(struct tty *tp); > >#define tty_lock(tp) mtx_lock((tp)->t_mtx) >#define tty_unlock(tp) mtx_unlock((tp)->t_mtx) >#define tty_lock_owned(tp) mtx_owned((tp)->t_mtx) >#define tty_lock_assert(tp,ma) mtx_assert((tp)->t_mtx, (ma)) >#define tty_getlock(tp) ((tp)->t_mtx) > >/* Device node creation. */ >int tty_makedevf(struct tty *tp, struct ucred *cred, int flags, > const char *fmt, ...) __printflike(4, 5); >#define TTYMK_CLONING 0x1 >#define tty_makedev(tp, cred, fmt, ...) \ > (void )tty_makedevf((tp), (cred), 0, (fmt), ## __VA_ARGS__) >#define tty_makealias(tp,fmt,...) \ > make_dev_alias((tp)->t_dev, fmt, ## __VA_ARGS__) > >/* Signalling processes. */ >void tty_signal_sessleader(struct tty *tp, int signal); >void tty_signal_pgrp(struct tty *tp, int signal); >/* Waking up readers/writers. */ >int tty_wait(struct tty *tp, struct cv *cv); >int tty_wait_background(struct tty *tp, struct thread *td, int sig); >int tty_timedwait(struct tty *tp, struct cv *cv, int timo); >void tty_wakeup(struct tty *tp, int flags); > >/* System messages. */ >int tty_checkoutq(struct tty *tp); >int tty_putchar(struct tty *tp, char c); > >int tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag, > struct thread *td); >int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data, > int fflag, struct thread *td); >void tty_set_winsize(struct tty *tp, const struct winsize *wsz); >void tty_init_console(struct tty *tp, speed_t speed); >void tty_flush(struct tty *tp, int flags); >void tty_hiwat_in_block(struct tty *tp); >void tty_hiwat_in_unblock(struct tty *tp); >dev_t tty_udev(struct tty *tp); >#define tty_opened(tp) ((tp)->t_flags & TF_OPENED) >#define tty_gone(tp) ((tp)->t_flags & TF_GONE) >#define tty_softc(tp) ((tp)->t_devswsoftc) >#define tty_devname(tp) devtoname((tp)->t_dev) > >/* Status line printing. */ >void tty_info(struct tty *tp); > >/* /dev/console selection. */ >void ttyconsdev_select(const char *name); > >/* Pseudo-terminal hooks. */ >int pts_alloc(int fflags, struct thread *td, struct file *fp); >int pts_alloc_external(int fd, struct thread *td, struct file *fp, > struct cdev *dev, const char *name); > >/* Drivers and line disciplines also need to call these. */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ttydisc.h> >#endif /* expanded by -frewrite-includes */ ># 222 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/ttydisc.h" 1 >/*- > * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> > * All rights reserved. > * > * Portions of this software were developed under sponsorship from Snow > * B.V., the Netherlands. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/ttydisc.h 196452 2009-08-23 08:04:40Z ed $ > */ > >#ifndef _SYS_TTYDISC_H_ >#define _SYS_TTYDISC_H_ > >#ifndef _SYS_TTY_H_ >#error "can only be included through <sys/tty.h>" >#endif /* !_SYS_TTY_H_ */ ># 38 "/usr/src/sys/sys/ttydisc.h" > >struct cv; >struct thread; >struct tty; >struct uio; > >/* Top half routines. */ >void ttydisc_open(struct tty *tp); >void ttydisc_close(struct tty *tp); >int ttydisc_read(struct tty *tp, struct uio *uio, int ioflag); >int ttydisc_write(struct tty *tp, struct uio *uio, int ioflag); >void ttydisc_optimize(struct tty *tp); > >/* Bottom half routines. */ >void ttydisc_modem(struct tty *tp, int open); >#define ttydisc_can_bypass(tp) ((tp)->t_flags & TF_BYPASS) >int ttydisc_rint(struct tty *tp, char c, int flags); >size_t ttydisc_rint_simple(struct tty *tp, const void *buf, size_t len); >size_t ttydisc_rint_bypass(struct tty *tp, const void *buf, size_t len); >void ttydisc_rint_done(struct tty *tp); >size_t ttydisc_rint_poll(struct tty *tp); >size_t ttydisc_getc(struct tty *tp, void *buf, size_t len); >int ttydisc_getc_uio(struct tty *tp, struct uio *uio); >size_t ttydisc_getc_poll(struct tty *tp); > >/* Error codes for ttydisc_rint(). */ >#define TRE_FRAMING 0x01 >#define TRE_PARITY 0x02 >#define TRE_OVERRUN 0x04 >#define TRE_BREAK 0x08 > >static __inline size_t >ttydisc_read_poll(struct tty *tp) >{ > > tty_lock_assert(tp, MA_OWNED); > > return ttyinq_bytescanonicalized(&tp->t_inq); >} > >static __inline size_t >ttydisc_write_poll(struct tty *tp) >{ > > tty_lock_assert(tp, MA_OWNED); > > return ttyoutq_bytesleft(&tp->t_outq); >} > >#endif /* !_SYS_TTYDISC_H_ */ ># 88 "/usr/src/sys/sys/ttydisc.h" ># 223 "/usr/src/sys/sys/tty.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ttydevsw.h> >#endif /* expanded by -frewrite-includes */ ># 223 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/ttydevsw.h" 1 >/*- > * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> > * All rights reserved. > * > * Portions of this software were developed under sponsorship from Snow > * B.V., the Netherlands. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/ttydevsw.h 223722 2011-07-02 13:54:20Z ed $ > */ > >#ifndef _SYS_TTYDEVSW_H_ >#define _SYS_TTYDEVSW_H_ > >#ifndef _SYS_TTY_H_ >#error "can only be included through <sys/tty.h>" >#endif /* !_SYS_TTY_H_ */ ># 38 "/usr/src/sys/sys/ttydevsw.h" > >/* > * Driver routines that are called from the line discipline to adjust > * hardware parameters and such. > */ >typedef int tsw_open_t(struct tty *tp); >typedef void tsw_close_t(struct tty *tp); >typedef void tsw_outwakeup_t(struct tty *tp); >typedef void tsw_inwakeup_t(struct tty *tp); >typedef int tsw_ioctl_t(struct tty *tp, u_long cmd, caddr_t data, > struct thread *td); >typedef int tsw_cioctl_t(struct tty *tp, int unit, u_long cmd, caddr_t data, > struct thread *td); >typedef int tsw_param_t(struct tty *tp, struct termios *t); >typedef int tsw_modem_t(struct tty *tp, int sigon, int sigoff); >typedef int tsw_mmap_t(struct tty *tp, vm_ooffset_t offset, > vm_paddr_t * paddr, int nprot, vm_memattr_t *memattr); >typedef void tsw_pktnotify_t(struct tty *tp, char event); >typedef void tsw_free_t(void *softc); > >struct ttydevsw { > unsigned int tsw_flags; /* Default TTY flags. */ > > tsw_open_t *tsw_open; /* Device opening. */ > tsw_close_t *tsw_close; /* Device closure. */ > > tsw_outwakeup_t *tsw_outwakeup; /* Output available. */ > tsw_inwakeup_t *tsw_inwakeup; /* Input can be stored again. */ > > tsw_ioctl_t *tsw_ioctl; /* ioctl() hooks. */ > tsw_cioctl_t *tsw_cioctl; /* ioctl() on control devices. */ > tsw_param_t *tsw_param; /* TIOCSETA device parameter setting. */ > tsw_modem_t *tsw_modem; /* Modem sigon/sigoff. */ > > tsw_mmap_t *tsw_mmap; /* mmap() hooks. */ > tsw_pktnotify_t *tsw_pktnotify; /* TIOCPKT events. */ > > tsw_free_t *tsw_free; /* Destructor. */ > > void *tsw_spare[4]; /* For future use. */ >}; > >static __inline int >ttydevsw_open(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_devsw->tsw_open(tp); >} > >static __inline void >ttydevsw_close(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > tp->t_devsw->tsw_close(tp); >} > >static __inline void >ttydevsw_outwakeup(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > /* Prevent spurious wakeups. */ > if (ttydisc_getc_poll(tp) == 0) > return; > > tp->t_devsw->tsw_outwakeup(tp); >} > >static __inline void >ttydevsw_inwakeup(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > /* Prevent spurious wakeups. */ > if (tp->t_flags & TF_HIWAT_IN) > return; > > tp->t_devsw->tsw_inwakeup(tp); >} > >static __inline int >ttydevsw_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_devsw->tsw_ioctl(tp, cmd, data, td); >} > >static __inline int >ttydevsw_cioctl(struct tty *tp, int unit, u_long cmd, caddr_t data, struct thread *td) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_devsw->tsw_cioctl(tp, unit, cmd, data, td); >} > >static __inline int >ttydevsw_param(struct tty *tp, struct termios *t) >{ > MPASS(!tty_gone(tp)); > > return tp->t_devsw->tsw_param(tp, t); >} > >static __inline int >ttydevsw_modem(struct tty *tp, int sigon, int sigoff) >{ > MPASS(!tty_gone(tp)); > > return tp->t_devsw->tsw_modem(tp, sigon, sigoff); >} > >static __inline int >ttydevsw_mmap(struct tty *tp, vm_ooffset_t offset, vm_paddr_t *paddr, > int nprot, vm_memattr_t *memattr) >{ > MPASS(!tty_gone(tp)); > > return tp->t_devsw->tsw_mmap(tp, offset, paddr, nprot, memattr); >} > >static __inline void >ttydevsw_pktnotify(struct tty *tp, char event) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > tp->t_devsw->tsw_pktnotify(tp, event); >} > >static __inline void >ttydevsw_free(struct tty *tp) >{ > MPASS(tty_gone(tp)); > > tp->t_devsw->tsw_free(tty_softc(tp)); >} > >#endif /* !_SYS_TTYDEVSW_H_ */ ># 185 "/usr/src/sys/sys/ttydevsw.h" ># 224 "/usr/src/sys/sys/tty.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ttyhook.h> >#endif /* expanded by -frewrite-includes */ ># 224 "/usr/src/sys/sys/tty.h" ># 1 "/usr/src/sys/sys/ttyhook.h" 1 >/*- > * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/ttyhook.h 186056 2008-12-13 21:17:46Z mav $ > */ > >#ifndef _SYS_TTYHOOK_H_ >#define _SYS_TTYHOOK_H_ > >#ifndef _SYS_TTY_H_ >#error "can only be included through <sys/tty.h>" >#endif /* !_SYS_TTY_H_ */ ># 35 "/usr/src/sys/sys/ttyhook.h" > >struct tty; > >/* > * Hooks interface, which allows to capture and inject traffic into the > * input and output paths of a TTY. > */ > >typedef int th_rint_t(struct tty *tp, char c, int flags); >typedef size_t th_rint_bypass_t(struct tty *tp, const void *buf, size_t len); >typedef void th_rint_done_t(struct tty *tp); >typedef size_t th_rint_poll_t(struct tty *tp); > >typedef size_t th_getc_inject_t(struct tty *tp, void *buf, size_t len); >typedef void th_getc_capture_t(struct tty *tp, const void *buf, size_t len); >typedef size_t th_getc_poll_t(struct tty *tp); > >typedef void th_close_t(struct tty *tp); > >struct ttyhook { > /* Character input. */ > th_rint_t *th_rint; > th_rint_bypass_t *th_rint_bypass; > th_rint_done_t *th_rint_done; > th_rint_poll_t *th_rint_poll; > > /* Character output. */ > th_getc_inject_t *th_getc_inject; > th_getc_capture_t *th_getc_capture; > th_getc_poll_t *th_getc_poll; > > th_close_t *th_close; >}; > >int ttyhook_register(struct tty **, struct proc *, int, > struct ttyhook *, void *); >void ttyhook_unregister(struct tty *); >#define ttyhook_softc(tp) ((tp)->t_hooksoftc) >#define ttyhook_hashook(tp,hook) ((tp)->t_hook != NULL && \ > (tp)->t_hook->th_ ## hook != NULL) > >static __inline int >ttyhook_rint(struct tty *tp, char c, int flags) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_hook->th_rint(tp, c, flags); >} > >static __inline size_t >ttyhook_rint_bypass(struct tty *tp, const void *buf, size_t len) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_hook->th_rint_bypass(tp, buf, len); >} > >static __inline void >ttyhook_rint_done(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > tp->t_hook->th_rint_done(tp); >} > >static __inline size_t >ttyhook_rint_poll(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_hook->th_rint_poll(tp); >} > >static __inline size_t >ttyhook_getc_inject(struct tty *tp, void *buf, size_t len) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_hook->th_getc_inject(tp, buf, len); >} > >static __inline void >ttyhook_getc_capture(struct tty *tp, const void *buf, size_t len) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > tp->t_hook->th_getc_capture(tp, buf, len); >} > >static __inline size_t >ttyhook_getc_poll(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > MPASS(!tty_gone(tp)); > > return tp->t_hook->th_getc_poll(tp); >} > >static __inline void >ttyhook_close(struct tty *tp) >{ > tty_lock_assert(tp, MA_OWNED); > > tp->t_hook->th_close(tp); >} > >#endif /* !_SYS_TTYHOOK_H_ */ ># 148 "/usr/src/sys/sys/ttyhook.h" ># 225 "/usr/src/sys/sys/tty.h" 2 >#endif /* _KERNEL */ ># 226 "/usr/src/sys/sys/tty.h" > >#endif /* !_SYS_TTY_H_ */ ># 228 "/usr/src/sys/sys/tty.h" ># 65 "/usr/src/sys/kern/kern_cons.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/uio.h> >#endif /* expanded by -frewrite-includes */ ># 65 "/usr/src/sys/kern/kern_cons.c" ># 66 "/usr/src/sys/kern/kern_cons.c" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/vnode.h> >#endif /* expanded by -frewrite-includes */ ># 66 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/sys/vnode.h" 1 >/*- > * Copyright (c) 1989, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)vnode.h 8.7 (Berkeley) 2/4/94 > * $FreeBSD: head/sys/sys/vnode.h 279362 2015-02-27 16:43:50Z kib $ > */ > >#ifndef _SYS_VNODE_H_ >#define _SYS_VNODE_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/bufobj.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/vnode.h" ># 1 "/usr/src/sys/sys/bufobj.h" 1 >/*- > * Copyright (c) 2004 Poul-Henning Kamp > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/bufobj.h 275743 2014-12-13 16:02:37Z kib $ > */ > >/* > * Architectural notes: > * > * bufobj is a new object which is what buffers hang from in the buffer > * cache. > * > * This used to be vnodes, but we need non-vnode code to be able > * to use the buffer cache as well, specifically geom classes like gbde, > * raid3 and raid5. > * > * All vnodes will contain a bufobj initially, but down the road we may > * want to only allocate bufobjs when they are needed. There could be a > * large number of vnodes in the system which wouldn't need a bufobj during > * their lifetime. > * > * The exact relationship to the vmobject is not determined at this point, > * it may in fact be that we find them to be two sides of the same object > * once things starts to crystalize. > */ > >#ifndef _SYS_BUFOBJ_H_ >#define _SYS_BUFOBJ_H_ > >#if defined(_KERNEL) || defined(_KVM_VNODE) > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 54 "/usr/src/sys/sys/bufobj.h" ># 55 "/usr/src/sys/sys/bufobj.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 55 "/usr/src/sys/sys/bufobj.h" ># 56 "/usr/src/sys/sys/bufobj.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_rwlock.h> >#endif /* expanded by -frewrite-includes */ ># 56 "/usr/src/sys/sys/bufobj.h" ># 1 "/usr/src/sys/sys/_rwlock.h" 1 >/*- > * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_rwlock.h 261520 2014-02-05 18:13:27Z jhb $ > */ > >#ifndef _SYS__RWLOCK_H_ >#define _SYS__RWLOCK_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/param.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/_rwlock.h" ># 33 "/usr/src/sys/sys/_rwlock.h" > >/* > * Reader/writer lock. > * > * All reader/writer lock implementations must always have a member > * called rw_lock. Other locking primitive structures are not allowed to > * use this name for their members. > * If this rule needs to change, the bits in the reader/writer lock > * implementation must be modified appropriately. > */ >struct rwlock { > struct lock_object lock_object; > volatile uintptr_t rw_lock; >}; > >/* > * Members of struct rwlock_padalign must mirror members of struct rwlock. > * rwlock_padalign rwlocks can use the rwlock(9) API transparently without > * modification. > * Pad-aligned rwlocks used within structures should generally be the > * first member of the struct. Otherwise, the compiler can generate > * additional padding for the struct to keep a correct alignment for > * the rwlock. > */ >struct rwlock_padalign { > struct lock_object lock_object; > volatile uintptr_t rw_lock; >} __aligned(CACHE_LINE_SIZE); > >#endif /* !_SYS__RWLOCK_H_ */ ># 63 "/usr/src/sys/sys/_rwlock.h" ># 57 "/usr/src/sys/sys/bufobj.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_pctrie.h> >#endif /* expanded by -frewrite-includes */ ># 57 "/usr/src/sys/sys/bufobj.h" ># 1 "/usr/src/sys/sys/_pctrie.h" 1 >/* > * Copyright (c) 2013 EMC Corp. > * Copyright (c) 2011 Jeffrey Roberson <jeff@freebsd.org> > * Copyright (c) 2008 Mayur Shardul <mayur.shardul@gmail.com> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/_pctrie.h 250551 2013-05-12 04:05:01Z jeff $ > */ > >#ifndef __SYS_PCTRIE_H_ >#define __SYS_PCTRIE_H_ > >/* > * Radix tree root. > */ >struct pctrie { > uintptr_t pt_root; >}; > >#ifdef _KERNEL > >static __inline boolean_t >pctrie_is_empty(struct pctrie *ptree) >{ > > return (ptree->pt_root == 0); >} > >#endif /* _KERNEL */ ># 51 "/usr/src/sys/sys/_pctrie.h" >#endif /* !__SYS_PCTRIE_H_ */ ># 52 "/usr/src/sys/sys/_pctrie.h" ># 58 "/usr/src/sys/sys/bufobj.h" 2 > >struct bufobj; >struct buf_ops; > >extern struct buf_ops buf_ops_bio; > >TAILQ_HEAD(buflists, buf); > >/* A Buffer list & trie */ >struct bufv { > struct buflists bv_hd; /* Sorted blocklist */ > struct pctrie bv_root; /* Buf trie */ > int bv_cnt; /* Number of buffers */ >}; > >typedef void b_strategy_t(struct bufobj *, struct buf *); >typedef int b_write_t(struct buf *); >typedef int b_sync_t(struct bufobj *, int waitfor); >typedef void b_bdflush_t(struct bufobj *, struct buf *); > >struct buf_ops { > char *bop_name; > b_write_t *bop_write; > b_strategy_t *bop_strategy; > b_sync_t *bop_sync; > b_bdflush_t *bop_bdflush; >}; > >#define BO_STRATEGY(bo, bp) ((bo)->bo_ops->bop_strategy((bo), (bp))) >#define BO_SYNC(bo, w) ((bo)->bo_ops->bop_sync((bo), (w))) >#define BO_WRITE(bo, bp) ((bo)->bo_ops->bop_write((bp))) >#define BO_BDFLUSH(bo, bp) ((bo)->bo_ops->bop_bdflush((bo), (bp))) > >struct bufobj { > struct rwlock bo_lock; /* Lock which protects "i" things */ > struct buf_ops *bo_ops; /* - Buffer operations */ > struct vm_object *bo_object; /* v Place to store VM object */ > LIST_ENTRY(bufobj) bo_synclist; /* S dirty vnode list */ > void *bo_private; /* private pointer */ > struct vnode *__bo_vnode; /* > * XXX: This vnode pointer is here > * XXX: only to keep the syncer working > * XXX: for now. > */ > struct bufv bo_clean; /* i Clean buffers */ > struct bufv bo_dirty; /* i Dirty buffers */ > long bo_numoutput; /* i Writes in progress */ > u_int bo_flag; /* i Flags */ > int bo_bsize; /* - Block size for i/o */ >}; > >/* > * XXX BO_ONWORKLST could be replaced with a check for NULL list elements > * in v_synclist. > */ >#define BO_ONWORKLST (1 << 0) /* On syncer work-list */ >#define BO_WWAIT (1 << 1) /* Wait for output to complete */ >#define BO_DEAD (1 << 2) /* Dead; only with INVARIANTS */ > >#define BO_LOCKPTR(bo) (&(bo)->bo_lock) >#define BO_LOCK(bo) rw_wlock(BO_LOCKPTR((bo))) >#define BO_UNLOCK(bo) rw_wunlock(BO_LOCKPTR((bo))) >#define BO_RLOCK(bo) rw_rlock(BO_LOCKPTR((bo))) >#define BO_RUNLOCK(bo) rw_runlock(BO_LOCKPTR((bo))) >#define ASSERT_BO_WLOCKED(bo) rw_assert(BO_LOCKPTR((bo)), RA_WLOCKED) >#define ASSERT_BO_LOCKED(bo) rw_assert(BO_LOCKPTR((bo)), RA_LOCKED) >#define ASSERT_BO_UNLOCKED(bo) rw_assert(BO_LOCKPTR((bo)), RA_UNLOCKED) > >void bufobj_wdrop(struct bufobj *bo); >void bufobj_wref(struct bufobj *bo); >void bufobj_wrefl(struct bufobj *bo); >int bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo); >int bufobj_wwait(struct bufobj *bo, int slpflag, int timeo); >int bufsync(struct bufobj *bo, int waitfor); >void bufbdflush(struct bufobj *bo, struct buf *bp); > >#endif /* defined(_KERNEL) || defined(_KVM_VNODE) */ ># 135 "/usr/src/sys/sys/bufobj.h" >#endif /* _SYS_BUFOBJ_H_ */ ># 136 "/usr/src/sys/sys/bufobj.h" ># 37 "/usr/src/sys/sys/vnode.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/vnode.h" ># 38 "/usr/src/sys/sys/vnode.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/sys/sys/vnode.h" ># 39 "/usr/src/sys/sys/vnode.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lockmgr.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/vnode.h" ># 1 "/usr/src/sys/sys/lockmgr.h" 1 >/*- > * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice(s), this list of conditions and the following disclaimer as > * the first lines of this file unmodified other than the possible > * addition of one or more copyright notices. > * 2. Redistributions in binary form must reproduce the above copyright > * notice(s), this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > * DAMAGE. > * > * $FreeBSD: head/sys/sys/lockmgr.h 273966 2014-11-02 13:10:31Z kib $ > */ > >#ifndef _SYS_LOCKMGR_H_ >#define _SYS_LOCKMGR_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/sys/sys/lockmgr.h" ># 35 "/usr/src/sys/sys/lockmgr.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lockmgr.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/lockmgr.h" ># 1 "/usr/src/sys/sys/_lockmgr.h" 1 >/*- > * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice(s), this list of conditions and the following disclaimer as > * the first lines of this file unmodified other than the possible > * addition of one or more copyright notices. > * 2. Redistributions in binary form must reproduce the above copyright > * notice(s), this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > * DAMAGE. > * > * $FreeBSD: head/sys/sys/_lockmgr.h 200447 2009-12-12 21:31:07Z attilio $ > */ > >#ifndef _SYS__LOCKMGR_H_ >#define _SYS__LOCKMGR_H_ > >#ifdef DEBUG_LOCKS >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_stack.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/sys/sys/_lockmgr.h" ># 36 "/usr/src/sys/sys/_lockmgr.h" >#endif ># 37 "/usr/src/sys/sys/_lockmgr.h" > >struct lock { > struct lock_object lock_object; > volatile uintptr_t lk_lock; > u_int lk_exslpfail; > int lk_timo; > int lk_pri; >#ifdef DEBUG_LOCKS > struct stack lk_stack; >#endif ># 47 "/usr/src/sys/sys/_lockmgr.h" >}; > >#endif ># 50 "/usr/src/sys/sys/_lockmgr.h" ># 36 "/usr/src/sys/sys/lockmgr.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/sys/sys/lockmgr.h" ># 37 "/usr/src/sys/sys/lockmgr.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_rwlock.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/sys/sys/lockmgr.h" ># 38 "/usr/src/sys/sys/lockmgr.h" > >#define LK_SHARE 0x01 >#define LK_SHARED_WAITERS 0x02 >#define LK_EXCLUSIVE_WAITERS 0x04 >#define LK_EXCLUSIVE_SPINNERS 0x08 >#define LK_ALL_WAITERS \ > (LK_SHARED_WAITERS | LK_EXCLUSIVE_WAITERS) >#define LK_FLAGMASK \ > (LK_SHARE | LK_ALL_WAITERS | LK_EXCLUSIVE_SPINNERS) > >#define LK_HOLDER(x) ((x) & ~LK_FLAGMASK) >#define LK_SHARERS_SHIFT 4 >#define LK_SHARERS(x) (LK_HOLDER(x) >> LK_SHARERS_SHIFT) >#define LK_SHARERS_LOCK(x) ((x) << LK_SHARERS_SHIFT | LK_SHARE) >#define LK_ONE_SHARER (1 << LK_SHARERS_SHIFT) >#define LK_UNLOCKED LK_SHARERS_LOCK(0) >#define LK_KERNPROC ((uintptr_t)(-1) & ~LK_FLAGMASK) > >#ifdef _KERNEL > >#if !defined(LOCK_FILE) || !defined(LOCK_LINE) >#error "LOCK_FILE and LOCK_LINE not defined, include <sys/lock.h> before" >#endif ># 61 "/usr/src/sys/sys/lockmgr.h" > >struct thread; >#define lk_recurse lock_object.lo_data > >/* > * Function prototipes. Routines that start with an underscore are not part > * of the public interface and might be wrappered with a macro. > */ >int __lockmgr_args(struct lock *lk, u_int flags, struct lock_object *ilk, > const char *wmesg, int prio, int timo, const char *file, int line); >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >void _lockmgr_assert(const struct lock *lk, int what, const char *file, int line); >#endif ># 74 "/usr/src/sys/sys/lockmgr.h" >void _lockmgr_disown(struct lock *lk, const char *file, int line); > >void lockallowrecurse(struct lock *lk); >void lockallowshare(struct lock *lk); >void lockdestroy(struct lock *lk); >void lockdisablerecurse(struct lock *lk); >void lockdisableshare(struct lock *lk); >void lockinit(struct lock *lk, int prio, const char *wmesg, int timo, > int flags); >#ifdef DDB >int lockmgr_chain(struct thread *td, struct thread **ownerp); >#endif ># 86 "/usr/src/sys/sys/lockmgr.h" >void lockmgr_printinfo(const struct lock *lk); >int lockstatus(const struct lock *lk); > >/* > * As far as the ilk can be a static NULL pointer these functions need a > * strict prototype in order to safely use the lock_object member. > */ >static __inline int >_lockmgr_args(struct lock *lk, u_int flags, struct mtx *ilk, const char *wmesg, > int prio, int timo, const char *file, int line) >{ > > return (__lockmgr_args(lk, flags, (ilk != NULL) ? &ilk->lock_object : > NULL, wmesg, prio, timo, file, line)); >} > >static __inline int >_lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk, > const char *wmesg, int prio, int timo, const char *file, int line) >{ > > return (__lockmgr_args(lk, flags, (ilk != NULL) ? &ilk->lock_object : > NULL, wmesg, prio, timo, file, line)); >} > >/* > * Define aliases in order to complete lockmgr KPI. > */ >#define lockmgr(lk, flags, ilk) \ > _lockmgr_args((lk), (flags), (ilk), LK_WMESG_DEFAULT, \ > LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, LOCK_FILE, LOCK_LINE) >#define lockmgr_args(lk, flags, ilk, wmesg, prio, timo) \ > _lockmgr_args((lk), (flags), (ilk), (wmesg), (prio), (timo), \ > LOCK_FILE, LOCK_LINE) >#define lockmgr_args_rw(lk, flags, ilk, wmesg, prio, timo) \ > _lockmgr_args_rw((lk), (flags), (ilk), (wmesg), (prio), (timo), \ > LOCK_FILE, LOCK_LINE) >#define lockmgr_disown(lk) \ > _lockmgr_disown((lk), LOCK_FILE, LOCK_LINE) >#define lockmgr_recursed(lk) \ > ((lk)->lk_recurse != 0) >#define lockmgr_rw(lk, flags, ilk) \ > _lockmgr_args_rw((lk), (flags), (ilk), LK_WMESG_DEFAULT, \ > LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, LOCK_FILE, LOCK_LINE) >#define lockmgr_waiters(lk) \ > ((lk)->lk_lock & LK_ALL_WAITERS) >#ifdef INVARIANTS >#define lockmgr_assert(lk, what) \ > _lockmgr_assert((lk), (what), LOCK_FILE, LOCK_LINE) >#else ># 136 "/usr/src/sys/sys/lockmgr.h" >#define lockmgr_assert(lk, what) >#endif ># 138 "/usr/src/sys/sys/lockmgr.h" > >/* > * Flags for lockinit(). > */ >#define LK_INIT_MASK 0x0000FF >#define LK_CANRECURSE 0x000001 >#define LK_NODUP 0x000002 >#define LK_NOPROFILE 0x000004 >#define LK_NOSHARE 0x000008 >#define LK_NOWITNESS 0x000010 >#define LK_QUIET 0x000020 >#define LK_ADAPTIVE 0x000040 >#define LK_IS_VNODE 0x000080 /* Tell WITNESS about a VNODE lock */ > >/* > * Additional attributes to be used in lockmgr(). > */ >#define LK_EATTR_MASK 0x00FF00 >#define LK_INTERLOCK 0x000100 >#define LK_NOWAIT 0x000200 >#define LK_RETRY 0x000400 >#define LK_SLEEPFAIL 0x000800 >#define LK_TIMELOCK 0x001000 >#define LK_NODDLKTREAT 0x002000 > >/* > * Operations for lockmgr(). > */ >#define LK_TYPE_MASK 0xFF0000 >#define LK_DOWNGRADE 0x010000 >#define LK_DRAIN 0x020000 >#define LK_EXCLOTHER 0x040000 >#define LK_EXCLUSIVE 0x080000 >#define LK_RELEASE 0x100000 >#define LK_SHARED 0x200000 >#define LK_UPGRADE 0x400000 >#define LK_TRYUPGRADE 0x800000 > >#define LK_TOTAL_MASK (LK_INIT_MASK | LK_EATTR_MASK | LK_TYPE_MASK) > >/* > * Default values for lockmgr_args(). > */ >#define LK_WMESG_DEFAULT (NULL) >#define LK_PRIO_DEFAULT (0) >#define LK_TIMO_DEFAULT (0) > >/* > * Assertion flags. > */ >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define KA_LOCKED LA_LOCKED >#define KA_SLOCKED LA_SLOCKED >#define KA_XLOCKED LA_XLOCKED >#define KA_UNLOCKED LA_UNLOCKED >#define KA_RECURSED LA_RECURSED >#define KA_NOTRECURSED LA_NOTRECURSED >#endif ># 196 "/usr/src/sys/sys/lockmgr.h" > >#endif /* _KERNEL */ ># 198 "/usr/src/sys/sys/lockmgr.h" > >#endif /* !_SYS_LOCKMGR_H_ */ ># 200 "/usr/src/sys/sys/lockmgr.h" ># 40 "/usr/src/sys/sys/vnode.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/vnode.h" ># 41 "/usr/src/sys/sys/vnode.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/rangelock.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/vnode.h" ># 1 "/usr/src/sys/sys/rangelock.h" 1 >/*- > * Copyright (c) 2009 Konstantin Belousov <kib@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/rangelock.h 254380 2013-08-15 20:19:17Z cperciva $ > */ > >#ifndef _SYS_RANGELOCK_H >#define _SYS_RANGELOCK_H > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/sys/sys/rangelock.h" ># 33 "/usr/src/sys/sys/rangelock.h" > >#define RL_LOCK_READ 0x0001 >#define RL_LOCK_WRITE 0x0002 >#define RL_LOCK_TYPE_MASK 0x0003 >#define RL_LOCK_GRANTED 0x0004 > >struct rl_q_entry; > >/* > * The structure representing the range lock. Caller may request > * read or write access to the range of bytes. Access is granted if > * all existing lock owners are compatible with the request. Two lock > * owners are compatible if their ranges do not overlap, or both > * owners are for read. > * > * Access to the structure itself is synchronized with the externally > * supplied mutex. > * > * rl_waiters is the queue containing in order (a) granted write lock > * requests, (b) granted read lock requests, and (c) in order of arrival, > * lock requests which cannot be granted yet. > * > * rl_currdep is the first lock request that cannot be granted now due > * to the preceding requests conflicting with it (i.e., it points to > * position (c) in the list above). > */ >struct rangelock { > TAILQ_HEAD(, rl_q_entry) rl_waiters; > struct rl_q_entry *rl_currdep; >}; > >#ifdef _KERNEL > >struct mtx; > >void rangelock_init(struct rangelock *lock); >void rangelock_destroy(struct rangelock *lock); >void rangelock_unlock(struct rangelock *lock, void *cookie, > struct mtx *ilk); >void *rangelock_unlock_range(struct rangelock *lock, void *cookie, > off_t start, off_t end, struct mtx *ilk); >void *rangelock_rlock(struct rangelock *lock, off_t start, off_t end, > struct mtx *ilk); >void *rangelock_wlock(struct rangelock *lock, off_t start, off_t end, > struct mtx *ilk); >void rlqentry_free(struct rl_q_entry *rlqe); > >#endif /* _KERNEL */ ># 81 "/usr/src/sys/sys/rangelock.h" > >#endif /* _SYS_RANGELOCK_H */ ># 83 "/usr/src/sys/sys/rangelock.h" ># 42 "/usr/src/sys/sys/vnode.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/selinfo.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/sys/sys/vnode.h" ># 43 "/usr/src/sys/sys/vnode.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/uio.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/sys/sys/vnode.h" ># 44 "/usr/src/sys/sys/vnode.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/acl.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/sys/vnode.h" ># 1 "/usr/src/sys/sys/acl.h" 1 >/*- > * Copyright (c) 1999-2001 Robert N. M. Watson > * Copyright (c) 2008 Edward Tomasz Napierała <trasz@FreeBSD.org> > * All rights reserved. > * > * This software was developed by Robert Watson for the TrustedBSD Project. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/sys/acl.h 220465 2011-04-09 07:42:25Z trasz $ > */ >/* > * Developed by the TrustedBSD Project. > * Support for POSIX.1e and NFSv4 access control lists. > */ > >#ifndef _SYS_ACL_H_ >#define _SYS_ACL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/sys/acl.h" ># 40 "/usr/src/sys/sys/acl.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/sys/acl.h" ># 41 "/usr/src/sys/sys/acl.h" >#if 0 /* expanded by -frewrite-includes */ >#include <vm/uma.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/sys/sys/acl.h" ># 1 "/usr/src/sys/vm/uma.h" 1 >/*- > * Copyright (c) 2002, 2003, 2004, 2005 Jeffrey Roberson <jeff@FreeBSD.org> > * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: head/sys/vm/uma.h 261725 2014-02-10 19:59:46Z glebius $ > * > */ > >/* > * uma.h - External definitions for the Universal Memory Allocator > * >*/ > >#ifndef _VM_UMA_H_ >#define _VM_UMA_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> /* For NULL */ >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/sys/vm/uma.h" ># 40 "/usr/src/sys/vm/uma.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/malloc.h> /* For M_* */ >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/sys/vm/uma.h" ># 41 "/usr/src/sys/vm/uma.h" > >/* User visible parameters */ >#define UMA_SMALLEST_UNIT (PAGE_SIZE / 256) /* Smallest item allocated */ > >/* Types and type defs */ > >struct uma_zone; >/* Opaque type used as a handle to the zone */ >typedef struct uma_zone * uma_zone_t; > >void zone_drain(uma_zone_t); > >/* > * Item constructor > * > * Arguments: > * item A pointer to the memory which has been allocated. > * arg The arg field passed to uma_zalloc_arg > * size The size of the allocated item > * flags See zalloc flags > * > * Returns: > * 0 on success > * errno on failure > * > * Discussion: > * The constructor is called just before the memory is returned > * to the user. It may block if necessary. > */ >typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags); > >/* > * Item destructor > * > * Arguments: > * item A pointer to the memory which has been allocated. > * size The size of the item being destructed. > * arg Argument passed through uma_zfree_arg > * > * Returns: > * Nothing > * > * Discussion: > * The destructor may perform operations that differ from those performed > * by the initializer, but it must leave the object in the same state. > * This IS type stable storage. This is called after EVERY zfree call. > */ >typedef void (*uma_dtor)(void *mem, int size, void *arg); > >/* > * Item initializer > * > * Arguments: > * item A pointer to the memory which has been allocated. > * size The size of the item being initialized. > * flags See zalloc flags > * > * Returns: > * 0 on success > * errno on failure > * > * Discussion: > * The initializer is called when the memory is cached in the uma zone. > * The initializer and the destructor should leave the object in the same > * state. > */ >typedef int (*uma_init)(void *mem, int size, int flags); > >/* > * Item discard function > * > * Arguments: > * item A pointer to memory which has been 'freed' but has not left the > * zone's cache. > * size The size of the item being discarded. > * > * Returns: > * Nothing > * > * Discussion: > * This routine is called when memory leaves a zone and is returned to the > * system for other uses. It is the counter-part to the init function. > */ >typedef void (*uma_fini)(void *mem, int size); > >/* > * Import new memory into a cache zone. > */ >typedef int (*uma_import)(void *arg, void **store, int count, int flags); > >/* > * Free memory from a cache zone. > */ >typedef void (*uma_release)(void *arg, void **store, int count); > >/* > * What's the difference between initializing and constructing? > * > * The item is initialized when it is cached, and this is the state that the > * object should be in when returned to the allocator. The purpose of this is > * to remove some code which would otherwise be called on each allocation by > * utilizing a known, stable state. This differs from the constructor which > * will be called on EVERY allocation. > * > * For example, in the initializer you may want to initialize embedded locks, > * NULL list pointers, set up initial states, magic numbers, etc. This way if > * the object is held in the allocator and re-used it won't be necessary to > * re-initialize it. > * > * The constructor may be used to lock a data structure, link it on to lists, > * bump reference counts or total counts of outstanding structures, etc. > * > */ > > >/* Function proto types */ > >/* > * Create a new uma zone > * > * Arguments: > * name The text name of the zone for debugging and stats. This memory > * should not be freed until the zone has been deallocated. > * size The size of the object that is being created. > * ctor The constructor that is called when the object is allocated. > * dtor The destructor that is called when the object is freed. > * init An initializer that sets up the initial state of the memory. > * fini A discard function that undoes initialization done by init. > * ctor/dtor/init/fini may all be null, see notes above. > * align A bitmask that corresponds to the requested alignment > * eg 4 would be 0x3 > * flags A set of parameters that control the behavior of the zone. > * > * Returns: > * A pointer to a structure which is intended to be opaque to users of > * the interface. The value may be null if the wait flag is not set. > */ >uma_zone_t uma_zcreate(const char *name, size_t size, uma_ctor ctor, > uma_dtor dtor, uma_init uminit, uma_fini fini, > int align, uint32_t flags); > >/* > * Create a secondary uma zone > * > * Arguments: > * name The text name of the zone for debugging and stats. This memory > * should not be freed until the zone has been deallocated. > * ctor The constructor that is called when the object is allocated. > * dtor The destructor that is called when the object is freed. > * zinit An initializer that sets up the initial state of the memory > * as the object passes from the Keg's slab to the Zone's cache. > * zfini A discard function that undoes initialization done by init > * as the object passes from the Zone's cache to the Keg's slab. > * > * ctor/dtor/zinit/zfini may all be null, see notes above. > * Note that the zinit and zfini specified here are NOT > * exactly the same as the init/fini specified to uma_zcreate() > * when creating a master zone. These zinit/zfini are called > * on the TRANSITION from keg to zone (and vice-versa). Once > * these are set, the primary zone may alter its init/fini > * (which are called when the object passes from VM to keg) > * using uma_zone_set_init/fini()) as well as its own > * zinit/zfini (unset by default for master zone) with > * uma_zone_set_zinit/zfini() (note subtle 'z' prefix). > * > * master A reference to this zone's Master Zone (Primary Zone), > * which contains the backing Keg for the Secondary Zone > * being added. > * > * Returns: > * A pointer to a structure which is intended to be opaque to users of > * the interface. The value may be null if the wait flag is not set. > */ >uma_zone_t uma_zsecond_create(char *name, uma_ctor ctor, uma_dtor dtor, > uma_init zinit, uma_fini zfini, uma_zone_t master); > >/* > * Add a second master to a secondary zone. This provides multiple data > * backends for objects with the same size. Both masters must have > * compatible allocation flags. Presently, UMA_ZONE_MALLOC type zones are > * the only supported. > * > * Returns: > * Error on failure, 0 on success. > */ >int uma_zsecond_add(uma_zone_t zone, uma_zone_t master); > >/* > * Create cache-only zones. > * > * This allows uma's per-cpu cache facilities to handle arbitrary > * pointers. Consumers must specify the import and release functions to > * fill and destroy caches. UMA does not allocate any memory for these > * zones. The 'arg' parameter is passed to import/release and is caller > * specific. > */ >uma_zone_t uma_zcache_create(char *name, int size, uma_ctor ctor, uma_dtor dtor, > uma_init zinit, uma_fini zfini, uma_import zimport, > uma_release zrelease, void *arg, int flags); > >/* > * Definitions for uma_zcreate flags > * > * These flags share space with UMA_ZFLAGs in uma_int.h. Be careful not to > * overlap when adding new features. 0xf0000000 is in use by uma_int.h. > */ >#define UMA_ZONE_PAGEABLE 0x0001 /* Return items not fully backed by > physical memory XXX Not yet */ >#define UMA_ZONE_ZINIT 0x0002 /* Initialize with zeros */ >#define UMA_ZONE_STATIC 0x0004 /* Statically sized zone */ >#define UMA_ZONE_OFFPAGE 0x0008 /* Force the slab structure allocation > off of the real memory */ >#define UMA_ZONE_MALLOC 0x0010 /* For use by malloc(9) only! */ >#define UMA_ZONE_NOFREE 0x0020 /* Do not free slabs of this type! */ >#define UMA_ZONE_MTXCLASS 0x0040 /* Create a new lock class */ >#define UMA_ZONE_VM 0x0080 /* > * Used for internal vm datastructures > * only. > */ >#define UMA_ZONE_HASH 0x0100 /* > * Use a hash table instead of caching > * information in the vm_page. > */ >#define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */ >#define UMA_ZONE_REFCNT 0x0400 /* Allocate refcnts in slabs */ >#define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets */ >#define UMA_ZONE_CACHESPREAD 0x1000 /* > * Spread memory start locations across > * all possible cache lines. May > * require many virtually contiguous > * backend pages and can fail early. > */ >#define UMA_ZONE_VTOSLAB 0x2000 /* Zone uses vtoslab for lookup. */ >#define UMA_ZONE_NODUMP 0x4000 /* > * Zone's pages will not be included in > * mini-dumps. > */ >#define UMA_ZONE_PCPU 0x8000 /* > * Allocates mp_ncpus slabs sized to > * sizeof(struct pcpu). > */ > >/* > * These flags are shared between the keg and zone. In zones wishing to add > * new kegs these flags must be compatible. Some are determined based on > * physical parameters of the request and may not be provided by the consumer. > */ >#define UMA_ZONE_INHERIT \ > (UMA_ZONE_OFFPAGE | UMA_ZONE_MALLOC | UMA_ZONE_NOFREE | \ > UMA_ZONE_HASH | UMA_ZONE_REFCNT | UMA_ZONE_VTOSLAB | UMA_ZONE_PCPU) > >/* Definitions for align */ >#define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */ >#define UMA_ALIGN_LONG (sizeof(long) - 1) /* "" long */ >#define UMA_ALIGN_INT (sizeof(int) - 1) /* "" int */ >#define UMA_ALIGN_SHORT (sizeof(short) - 1) /* "" short */ >#define UMA_ALIGN_CHAR (sizeof(char) - 1) /* "" char */ >#define UMA_ALIGN_CACHE (0 - 1) /* Cache line size align */ > >/* > * Destroys an empty uma zone. If the zone is not empty uma complains loudly. > * > * Arguments: > * zone The zone we want to destroy. > * > */ >void uma_zdestroy(uma_zone_t zone); > >/* > * Allocates an item out of a zone > * > * Arguments: > * zone The zone we are allocating from > * arg This data is passed to the ctor function > * flags See sys/malloc.h for available flags. > * > * Returns: > * A non-null pointer to an initialized element from the zone is > * guaranteed if the wait flag is M_WAITOK. Otherwise a null pointer > * may be returned if the zone is empty or the ctor failed. > */ > >void *uma_zalloc_arg(uma_zone_t zone, void *arg, int flags); > >/* > * Allocates an item out of a zone without supplying an argument > * > * This is just a wrapper for uma_zalloc_arg for convenience. > * > */ >static __inline void *uma_zalloc(uma_zone_t zone, int flags); > >static __inline void * >uma_zalloc(uma_zone_t zone, int flags) >{ > return uma_zalloc_arg(zone, NULL, flags); >} > >/* > * Frees an item back into the specified zone. > * > * Arguments: > * zone The zone the item was originally allocated out of. > * item The memory to be freed. > * arg Argument passed to the destructor > * > * Returns: > * Nothing. > */ > >void uma_zfree_arg(uma_zone_t zone, void *item, void *arg); > >/* > * Frees an item back to a zone without supplying an argument > * > * This is just a wrapper for uma_zfree_arg for convenience. > * > */ >static __inline void uma_zfree(uma_zone_t zone, void *item); > >static __inline void >uma_zfree(uma_zone_t zone, void *item) >{ > uma_zfree_arg(zone, item, NULL); >} > >/* > * XXX The rest of the prototypes in this header are h0h0 magic for the VM. > * If you think you need to use it for a normal zone you're probably incorrect. > */ > >/* > * Backend page supplier routines > * > * Arguments: > * zone The zone that is requesting pages. > * size The number of bytes being requested. > * pflag Flags for these memory pages, see below. > * wait Indicates our willingness to block. > * > * Returns: > * A pointer to the allocated memory or NULL on failure. > */ > >typedef void *(*uma_alloc)(uma_zone_t zone, int size, uint8_t *pflag, int wait); > >/* > * Backend page free routines > * > * Arguments: > * item A pointer to the previously allocated pages. > * size The original size of the allocation. > * pflag The flags for the slab. See UMA_SLAB_* below. > * > * Returns: > * None > */ >typedef void (*uma_free)(void *item, int size, uint8_t pflag); > > > >/* > * Sets up the uma allocator. (Called by vm_mem_init) > * > * Arguments: > * bootmem A pointer to memory used to bootstrap the system. > * > * Returns: > * Nothing > * > * Discussion: > * This memory is used for zones which allocate things before the > * backend page supplier can give us pages. It should be > * UMA_SLAB_SIZE * boot_pages bytes. (see uma_int.h) > * > */ > >void uma_startup(void *bootmem, int boot_pages); > >/* > * Finishes starting up the allocator. This should > * be called when kva is ready for normal allocs. > * > * Arguments: > * None > * > * Returns: > * Nothing > * > * Discussion: > * uma_startup2 is called by kmeminit() to enable us of uma for malloc. > */ > >void uma_startup2(void); > >/* > * Reclaims unused memory for all zones > * > * Arguments: > * None > * Returns: > * None > * > * This should only be called by the page out daemon. > */ > >void uma_reclaim(void); > >/* > * Sets the alignment mask to be used for all zones requesting cache > * alignment. Should be called by MD boot code prior to starting VM/UMA. > * > * Arguments: > * align The alignment mask > * > * Returns: > * Nothing > */ >void uma_set_align(int align); > >/* > * Set a reserved number of items to hold for M_USE_RESERVE allocations. All > * other requests must allocate new backing pages. > */ >void uma_zone_reserve(uma_zone_t zone, int nitems); > >/* > * Reserves the maximum KVA space required by the zone and configures the zone > * to use a VM_ALLOC_NOOBJ-based backend allocator. > * > * Arguments: > * zone The zone to update. > * nitems The upper limit on the number of items that can be allocated. > * > * Returns: > * 0 if KVA space can not be allocated > * 1 if successful > * > * Discussion: > * When the machine supports a direct map and the zone's items are smaller > * than a page, the zone will use the direct map instead of allocating KVA > * space. > */ >int uma_zone_reserve_kva(uma_zone_t zone, int nitems); > >/* > * Sets a high limit on the number of items allowed in a zone > * > * Arguments: > * zone The zone to limit > * nitems The requested upper limit on the number of items allowed > * > * Returns: > * int The effective value of nitems after rounding up based on page size > */ >int uma_zone_set_max(uma_zone_t zone, int nitems); > >/* > * Obtains the effective limit on the number of items in a zone > * > * Arguments: > * zone The zone to obtain the effective limit from > * > * Return: > * 0 No limit > * int The effective limit of the zone > */ >int uma_zone_get_max(uma_zone_t zone); > >/* > * Sets a warning to be printed when limit is reached > * > * Arguments: > * zone The zone we will warn about > * warning Warning content > * > * Returns: > * Nothing > */ >void uma_zone_set_warning(uma_zone_t zone, const char *warning); > >/* > * Obtains the approximate current number of items allocated from a zone > * > * Arguments: > * zone The zone to obtain the current allocation count from > * > * Return: > * int The approximate current number of items allocated from the zone > */ >int uma_zone_get_cur(uma_zone_t zone); > >/* > * The following two routines (uma_zone_set_init/fini) > * are used to set the backend init/fini pair which acts on an > * object as it becomes allocated and is placed in a slab within > * the specified zone's backing keg. These should probably not > * be changed once allocations have already begun, but only be set > * immediately upon zone creation. > */ >void uma_zone_set_init(uma_zone_t zone, uma_init uminit); >void uma_zone_set_fini(uma_zone_t zone, uma_fini fini); > >/* > * The following two routines (uma_zone_set_zinit/zfini) are > * used to set the zinit/zfini pair which acts on an object as > * it passes from the backing Keg's slab cache to the > * specified Zone's bucket cache. These should probably not > * be changed once allocations have already begun, but only be set > * immediately upon zone creation. > */ >void uma_zone_set_zinit(uma_zone_t zone, uma_init zinit); >void uma_zone_set_zfini(uma_zone_t zone, uma_fini zfini); > >/* > * Replaces the standard backend allocator for this zone. > * > * Arguments: > * zone The zone whose backend allocator is being changed. > * allocf A pointer to the allocation function > * > * Returns: > * Nothing > * > * Discussion: > * This could be used to implement pageable allocation, or perhaps > * even DMA allocators if used in conjunction with the OFFPAGE > * zone flag. > */ > >void uma_zone_set_allocf(uma_zone_t zone, uma_alloc allocf); > >/* > * Used for freeing memory provided by the allocf above > * > * Arguments: > * zone The zone that intends to use this free routine. > * freef The page freeing routine. > * > * Returns: > * Nothing > */ > >void uma_zone_set_freef(uma_zone_t zone, uma_free freef); > >/* > * These flags are setable in the allocf and visible in the freef. > */ >#define UMA_SLAB_BOOT 0x01 /* Slab alloced from boot pages */ >#define UMA_SLAB_KMEM 0x02 /* Slab alloced from kmem_map */ >#define UMA_SLAB_KERNEL 0x04 /* Slab alloced from kernel_map */ >#define UMA_SLAB_PRIV 0x08 /* Slab alloced from priv allocator */ >#define UMA_SLAB_OFFP 0x10 /* Slab is managed separately */ >#define UMA_SLAB_MALLOC 0x20 /* Slab is a large malloc slab */ >/* 0x40 and 0x80 are available */ > >/* > * Used to pre-fill a zone with some number of items > * > * Arguments: > * zone The zone to fill > * itemcnt The number of items to reserve > * > * Returns: > * Nothing > * > * NOTE: This is blocking and should only be done at startup > */ >void uma_prealloc(uma_zone_t zone, int itemcnt); > >/* > * Used to lookup the reference counter allocated for an item > * from a UMA_ZONE_REFCNT zone. For UMA_ZONE_REFCNT zones, > * reference counters are allocated for items and stored in > * the underlying slab header. > * > * Arguments: > * zone The UMA_ZONE_REFCNT zone to which the item belongs. > * item The address of the item for which we want a refcnt. > * > * Returns: > * A pointer to a uint32_t reference counter. > */ >uint32_t *uma_find_refcnt(uma_zone_t zone, void *item); > >/* > * Used to determine if a fixed-size zone is exhausted. > * > * Arguments: > * zone The zone to check > * > * Returns: > * Non-zero if zone is exhausted. > */ >int uma_zone_exhausted(uma_zone_t zone); >int uma_zone_exhausted_nolock(uma_zone_t zone); > >/* > * Common UMA_ZONE_PCPU zones. > */ >extern uma_zone_t pcpu_zone_64; >extern uma_zone_t pcpu_zone_ptr; > >/* > * Exported statistics structures to be used by user space monitoring tools. > * Statistics stream consists of a uma_stream_header, followed by a series of > * alternative uma_type_header and uma_type_stat structures. > */ >#define UMA_STREAM_VERSION 0x00000001 >struct uma_stream_header { > uint32_t ush_version; /* Stream format version. */ > uint32_t ush_maxcpus; /* Value of MAXCPU for stream. */ > uint32_t ush_count; /* Number of records. */ > uint32_t _ush_pad; /* Pad/reserved field. */ >}; > >#define UTH_MAX_NAME 32 >#define UTH_ZONE_SECONDARY 0x00000001 >struct uma_type_header { > /* > * Static per-zone data, some extracted from the supporting keg. > */ > char uth_name[UTH_MAX_NAME]; > uint32_t uth_align; /* Keg: alignment. */ > uint32_t uth_size; /* Keg: requested size of item. */ > uint32_t uth_rsize; /* Keg: real size of item. */ > uint32_t uth_maxpages; /* Keg: maximum number of pages. */ > uint32_t uth_limit; /* Keg: max items to allocate. */ > > /* > * Current dynamic zone/keg-derived statistics. > */ > uint32_t uth_pages; /* Keg: pages allocated. */ > uint32_t uth_keg_free; /* Keg: items free. */ > uint32_t uth_zone_free; /* Zone: items free. */ > uint32_t uth_bucketsize; /* Zone: desired bucket size. */ > uint32_t uth_zone_flags; /* Zone: flags. */ > uint64_t uth_allocs; /* Zone: number of allocations. */ > uint64_t uth_frees; /* Zone: number of frees. */ > uint64_t uth_fails; /* Zone: number of alloc failures. */ > uint64_t uth_sleeps; /* Zone: number of alloc sleeps. */ > uint64_t _uth_reserved1[2]; /* Reserved. */ >}; > >struct uma_percpu_stat { > uint64_t ups_allocs; /* Cache: number of allocations. */ > uint64_t ups_frees; /* Cache: number of frees. */ > uint64_t ups_cache_free; /* Cache: free items in cache. */ > uint64_t _ups_reserved[5]; /* Reserved. */ >}; > >#endif /* _VM_UMA_H_ */ ># 693 "/usr/src/sys/vm/uma.h" ># 42 "/usr/src/sys/sys/acl.h" 2 > >/* > * POSIX.1e and NFSv4 ACL types and related constants. > */ > >typedef uint32_t acl_tag_t; >typedef uint32_t acl_perm_t; >typedef uint16_t acl_entry_type_t; >typedef uint16_t acl_flag_t; >typedef int acl_type_t; >typedef int *acl_permset_t; >typedef uint16_t *acl_flagset_t; > >/* > * With 254 entries, "struct acl_t_struct" is exactly one 4kB page big. > * Note that with NFSv4 ACLs, the maximum number of ACL entries one > * may set on file or directory is about half of ACL_MAX_ENTRIES. > * > * If you increase this, you might also need to increase > * _ACL_T_ALIGNMENT_BITS in lib/libc/posix1e/acl_support.h. > * > * The maximum number of POSIX.1e ACLs is controlled > * by OLDACL_MAX_ENTRIES. Changing that one will break binary > * compatibility with pre-8.0 userland and change on-disk ACL layout. > */ >#define ACL_MAX_ENTRIES 254 > >#if defined(_KERNEL) || defined(_ACL_PRIVATE) > >#define POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM >#define POSIX1E_ACL_ACCESS_EXTATTR_NAME "posix1e.acl_access" >#define POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM >#define POSIX1E_ACL_DEFAULT_EXTATTR_NAME "posix1e.acl_default" >#define NFS4_ACL_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM >#define NFS4_ACL_EXTATTR_NAME "nfs4.acl" >#define OLDACL_MAX_ENTRIES 32 > >/* > * "struct oldacl" is used in compatibility ACL syscalls and for on-disk > * storage of POSIX.1e ACLs. > */ >typedef int oldacl_tag_t; >typedef mode_t oldacl_perm_t; > >struct oldacl_entry { > oldacl_tag_t ae_tag; > uid_t ae_id; > oldacl_perm_t ae_perm; >}; >typedef struct oldacl_entry *oldacl_entry_t; > >struct oldacl { > int acl_cnt; > struct oldacl_entry acl_entry[OLDACL_MAX_ENTRIES]; >}; > >/* > * Current "struct acl". > */ >struct acl_entry { > acl_tag_t ae_tag; > uid_t ae_id; > acl_perm_t ae_perm; > /* NFSv4 entry type, "allow" or "deny". Unused in POSIX.1e ACLs. */ > acl_entry_type_t ae_entry_type; > /* NFSv4 ACL inheritance. Unused in POSIX.1e ACLs. */ > acl_flag_t ae_flags; >}; >typedef struct acl_entry *acl_entry_t; > >/* > * Internal ACL structure, used in libc, kernel APIs and for on-disk > * storage of NFSv4 ACLs. POSIX.1e ACLs use "struct oldacl" for on-disk > * storage. > */ >struct acl { > unsigned int acl_maxcnt; > unsigned int acl_cnt; > /* Will be required e.g. to implement NFSv4.1 ACL inheritance. */ > int acl_spare[4]; > struct acl_entry acl_entry[ACL_MAX_ENTRIES]; >}; > >/* > * ACL structure internal to libc. > */ >struct acl_t_struct { > struct acl ats_acl; > int ats_cur_entry; > /* > * ats_brand is for libc internal bookkeeping only. > * Applications should use acl_get_brand_np(3). > * Kernel code should use the "type" argument passed > * to VOP_SETACL, VOP_GETACL or VOP_ACLCHECK calls; > * ACL_TYPE_ACCESS or ACL_TYPE_DEFAULT mean POSIX.1e > * ACL, ACL_TYPE_NFS4 means NFSv4 ACL. > */ > int ats_brand; >}; >typedef struct acl_t_struct *acl_t; > >#else /* _KERNEL || _ACL_PRIVATE */ ># 144 "/usr/src/sys/sys/acl.h" > >typedef void *acl_entry_t; >typedef void *acl_t; > >#endif /* !_KERNEL && !_ACL_PRIVATE */ ># 149 "/usr/src/sys/sys/acl.h" > >/* > * Possible valid values for ats_brand field. > */ >#define ACL_BRAND_UNKNOWN 0 >#define ACL_BRAND_POSIX 1 >#define ACL_BRAND_NFS4 2 > >/* > * Possible valid values for ae_tag field. For explanation, see acl(9). > */ >#define ACL_UNDEFINED_TAG 0x00000000 >#define ACL_USER_OBJ 0x00000001 >#define ACL_USER 0x00000002 >#define ACL_GROUP_OBJ 0x00000004 >#define ACL_GROUP 0x00000008 >#define ACL_MASK 0x00000010 >#define ACL_OTHER 0x00000020 >#define ACL_OTHER_OBJ ACL_OTHER >#define ACL_EVERYONE 0x00000040 > >/* > * Possible valid values for ae_entry_type field, valid only for NFSv4 ACLs. > */ >#define ACL_ENTRY_TYPE_ALLOW 0x0100 >#define ACL_ENTRY_TYPE_DENY 0x0200 >#define ACL_ENTRY_TYPE_AUDIT 0x0400 >#define ACL_ENTRY_TYPE_ALARM 0x0800 > >/* > * Possible valid values for acl_type_t arguments. First two > * are provided only for backwards binary compatibility. > */ >#define ACL_TYPE_ACCESS_OLD 0x00000000 >#define ACL_TYPE_DEFAULT_OLD 0x00000001 >#define ACL_TYPE_ACCESS 0x00000002 >#define ACL_TYPE_DEFAULT 0x00000003 >#define ACL_TYPE_NFS4 0x00000004 > >/* > * Possible bits in ae_perm field for POSIX.1e ACLs. Note > * that ACL_EXECUTE may be used in both NFSv4 and POSIX.1e ACLs. > */ >#define ACL_EXECUTE 0x0001 >#define ACL_WRITE 0x0002 >#define ACL_READ 0x0004 >#define ACL_PERM_NONE 0x0000 >#define ACL_PERM_BITS (ACL_EXECUTE | ACL_WRITE | ACL_READ) >#define ACL_POSIX1E_BITS (ACL_EXECUTE | ACL_WRITE | ACL_READ) > >/* > * Possible bits in ae_perm field for NFSv4 ACLs. > */ >#define ACL_READ_DATA 0x00000008 >#define ACL_LIST_DIRECTORY 0x00000008 >#define ACL_WRITE_DATA 0x00000010 >#define ACL_ADD_FILE 0x00000010 >#define ACL_APPEND_DATA 0x00000020 >#define ACL_ADD_SUBDIRECTORY 0x00000020 >#define ACL_READ_NAMED_ATTRS 0x00000040 >#define ACL_WRITE_NAMED_ATTRS 0x00000080 >/* ACL_EXECUTE is defined above. */ >#define ACL_DELETE_CHILD 0x00000100 >#define ACL_READ_ATTRIBUTES 0x00000200 >#define ACL_WRITE_ATTRIBUTES 0x00000400 >#define ACL_DELETE 0x00000800 >#define ACL_READ_ACL 0x00001000 >#define ACL_WRITE_ACL 0x00002000 >#define ACL_WRITE_OWNER 0x00004000 >#define ACL_SYNCHRONIZE 0x00008000 > >#define ACL_FULL_SET (ACL_READ_DATA | ACL_WRITE_DATA | \ > ACL_APPEND_DATA | ACL_READ_NAMED_ATTRS | ACL_WRITE_NAMED_ATTRS | \ > ACL_EXECUTE | ACL_DELETE_CHILD | ACL_READ_ATTRIBUTES | \ > ACL_WRITE_ATTRIBUTES | ACL_DELETE | ACL_READ_ACL | ACL_WRITE_ACL | \ > ACL_WRITE_OWNER | ACL_SYNCHRONIZE) > >#define ACL_MODIFY_SET (ACL_FULL_SET & \ > ~(ACL_WRITE_ACL | ACL_WRITE_OWNER)) > >#define ACL_READ_SET (ACL_READ_DATA | ACL_READ_NAMED_ATTRS | \ > ACL_READ_ATTRIBUTES | ACL_READ_ACL) > >#define ACL_WRITE_SET (ACL_WRITE_DATA | ACL_APPEND_DATA | \ > ACL_WRITE_NAMED_ATTRS | ACL_WRITE_ATTRIBUTES) > >#define ACL_NFS4_PERM_BITS ACL_FULL_SET > >/* > * Possible entry_id values for acl_get_entry(3). > */ >#define ACL_FIRST_ENTRY 0 >#define ACL_NEXT_ENTRY 1 > >/* > * Possible values in ae_flags field; valid only for NFSv4 ACLs. > */ >#define ACL_ENTRY_FILE_INHERIT 0x0001 >#define ACL_ENTRY_DIRECTORY_INHERIT 0x0002 >#define ACL_ENTRY_NO_PROPAGATE_INHERIT 0x0004 >#define ACL_ENTRY_INHERIT_ONLY 0x0008 >#define ACL_ENTRY_SUCCESSFUL_ACCESS 0x0010 >#define ACL_ENTRY_FAILED_ACCESS 0x0020 > >#define ACL_FLAGS_BITS (ACL_ENTRY_FILE_INHERIT | \ > ACL_ENTRY_DIRECTORY_INHERIT | ACL_ENTRY_NO_PROPAGATE_INHERIT | \ > ACL_ENTRY_INHERIT_ONLY | ACL_ENTRY_SUCCESSFUL_ACCESS | \ > ACL_ENTRY_FAILED_ACCESS) > >/* > * Undefined value in ae_id field. ae_id should be set to this value > * iff ae_tag is ACL_USER_OBJ, ACL_GROUP_OBJ, ACL_OTHER or ACL_EVERYONE. > */ >#define ACL_UNDEFINED_ID ((uid_t)-1) > >/* > * Possible values for _flags parameter in acl_to_text_np(3). > */ >#define ACL_TEXT_VERBOSE 0x01 >#define ACL_TEXT_NUMERIC_IDS 0x02 >#define ACL_TEXT_APPEND_ID 0x04 > >/* > * POSIX.1e ACLs are capable of expressing the read, write, and execute bits > * of the POSIX mode field. We provide two masks: one that defines the bits > * the ACL will replace in the mode, and the other that defines the bits that > * must be preseved when an ACL is updating a mode. > */ >#define ACL_OVERRIDE_MASK (S_IRWXU | S_IRWXG | S_IRWXO) >#define ACL_PRESERVE_MASK (~ACL_OVERRIDE_MASK) > >#ifdef _KERNEL > >/* > * Filesystem-independent code to move back and forth between POSIX mode and > * POSIX.1e ACL representations. > */ >acl_perm_t acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode); >struct acl_entry acl_posix1e_mode_to_entry(acl_tag_t tag, uid_t uid, > gid_t gid, mode_t mode); >mode_t acl_posix1e_perms_to_mode( > struct acl_entry *acl_user_obj_entry, > struct acl_entry *acl_group_obj_entry, > struct acl_entry *acl_other_entry); >mode_t acl_posix1e_acl_to_mode(struct acl *acl); >mode_t acl_posix1e_newfilemode(mode_t cmode, > struct acl *dacl); >struct acl *acl_alloc(int flags); >void acl_free(struct acl *aclp); > >void acl_nfs4_sync_acl_from_mode(struct acl *aclp, > mode_t mode, int file_owner_id); >void acl_nfs4_sync_mode_from_acl(mode_t *mode, > const struct acl *aclp); >int acl_nfs4_is_trivial(const struct acl *aclp, > int file_owner_id); >void acl_nfs4_compute_inherited_acl( > const struct acl *parent_aclp, > struct acl *child_aclp, mode_t mode, > int file_owner_id, int is_directory); >int acl_copy_oldacl_into_acl(const struct oldacl *source, > struct acl *dest); >int acl_copy_acl_into_oldacl(const struct acl *source, > struct oldacl *dest); > >/* > * To allocate 'struct acl', use acl_alloc()/acl_free() instead of this. > */ >MALLOC_DECLARE(M_ACL); >/* > * Filesystem-independent syntax check for a POSIX.1e ACL. > */ >int acl_posix1e_check(struct acl *acl); >int acl_nfs4_check(const struct acl *aclp, int is_directory); > >#else /* !_KERNEL */ ># 325 "/usr/src/sys/sys/acl.h" > >#if defined(_ACL_PRIVATE) > >/* > * Syscall interface -- use the library calls instead as the syscalls have > * strict ACL entry ordering requirements. > */ >__BEGIN_DECLS >int __acl_aclcheck_fd(int _filedes, acl_type_t _type, struct acl *_aclp); >int __acl_aclcheck_file(const char *_path, acl_type_t _type, > struct acl *_aclp); >int __acl_aclcheck_link(const char *_path, acl_type_t _type, > struct acl *_aclp); >int __acl_delete_fd(int _filedes, acl_type_t _type); >int __acl_delete_file(const char *_path_p, acl_type_t _type); >int __acl_delete_link(const char *_path_p, acl_type_t _type); >int __acl_get_fd(int _filedes, acl_type_t _type, struct acl *_aclp); >int __acl_get_file(const char *_path, acl_type_t _type, struct acl *_aclp); >int __acl_get_link(const char *_path, acl_type_t _type, struct acl *_aclp); >int __acl_set_fd(int _filedes, acl_type_t _type, struct acl *_aclp); >int __acl_set_file(const char *_path, acl_type_t _type, struct acl *_aclp); >int __acl_set_link(const char *_path, acl_type_t _type, struct acl *_aclp); >__END_DECLS > >#endif /* _ACL_PRIVATE */ ># 350 "/usr/src/sys/sys/acl.h" > >/* > * Supported POSIX.1e ACL manipulation and assignment/retrieval API _np calls > * are local extensions that reflect an environment capable of opening file > * descriptors of directories, and allowing additional ACL type for different > * filesystems (i.e., AFS). > */ >__BEGIN_DECLS >int acl_add_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); >int acl_add_perm(acl_permset_t _permset_d, acl_perm_t _perm); >int acl_calc_mask(acl_t *_acl_p); >int acl_clear_flags_np(acl_flagset_t _flagset_d); >int acl_clear_perms(acl_permset_t _permset_d); >int acl_copy_entry(acl_entry_t _dest_d, acl_entry_t _src_d); >ssize_t acl_copy_ext(void *_buf_p, acl_t _acl, ssize_t _size); >acl_t acl_copy_int(const void *_buf_p); >int acl_create_entry(acl_t *_acl_p, acl_entry_t *_entry_p); >int acl_create_entry_np(acl_t *_acl_p, acl_entry_t *_entry_p, int _index); >int acl_delete_entry(acl_t _acl, acl_entry_t _entry_d); >int acl_delete_entry_np(acl_t _acl, int _index); >int acl_delete_fd_np(int _filedes, acl_type_t _type); >int acl_delete_file_np(const char *_path_p, acl_type_t _type); >int acl_delete_link_np(const char *_path_p, acl_type_t _type); >int acl_delete_def_file(const char *_path_p); >int acl_delete_def_link_np(const char *_path_p); >int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); >int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); >acl_t acl_dup(acl_t _acl); >int acl_free(void *_obj_p); >acl_t acl_from_text(const char *_buf_p); >int acl_get_brand_np(acl_t _acl, int *_brand_p); >int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); >acl_t acl_get_fd(int _fd); >acl_t acl_get_fd_np(int fd, acl_type_t _type); >acl_t acl_get_file(const char *_path_p, acl_type_t _type); >int acl_get_entry_type_np(acl_entry_t _entry_d, acl_entry_type_t *_entry_type_p); >acl_t acl_get_link_np(const char *_path_p, acl_type_t _type); >void *acl_get_qualifier(acl_entry_t _entry_d); >int acl_get_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); >int acl_get_perm_np(acl_permset_t _permset_d, acl_perm_t _perm); >int acl_get_flagset_np(acl_entry_t _entry_d, acl_flagset_t *_flagset_p); >int acl_get_permset(acl_entry_t _entry_d, acl_permset_t *_permset_p); >int acl_get_tag_type(acl_entry_t _entry_d, acl_tag_t *_tag_type_p); >acl_t acl_init(int _count); >int acl_set_fd(int _fd, acl_t _acl); >int acl_set_fd_np(int _fd, acl_t _acl, acl_type_t _type); >int acl_set_file(const char *_path_p, acl_type_t _type, acl_t _acl); >int acl_set_entry_type_np(acl_entry_t _entry_d, acl_entry_type_t _entry_type); >int acl_set_link_np(const char *_path_p, acl_type_t _type, acl_t _acl); >int acl_set_flagset_np(acl_entry_t _entry_d, acl_flagset_t _flagset_d); >int acl_set_permset(acl_entry_t _entry_d, acl_permset_t _permset_d); >int acl_set_qualifier(acl_entry_t _entry_d, const void *_tag_qualifier_p); >int acl_set_tag_type(acl_entry_t _entry_d, acl_tag_t _tag_type); >ssize_t acl_size(acl_t _acl); >char *acl_to_text(acl_t _acl, ssize_t *_len_p); >char *acl_to_text_np(acl_t _acl, ssize_t *_len_p, int _flags); >int acl_valid(acl_t _acl); >int acl_valid_fd_np(int _fd, acl_type_t _type, acl_t _acl); >int acl_valid_file_np(const char *_path_p, acl_type_t _type, acl_t _acl); >int acl_valid_link_np(const char *_path_p, acl_type_t _type, acl_t _acl); >int acl_is_trivial_np(const acl_t _acl, int *_trivialp); >acl_t acl_strip_np(const acl_t _acl, int recalculate_mask); >__END_DECLS > >#endif /* !_KERNEL */ ># 415 "/usr/src/sys/sys/acl.h" > >#endif /* !_SYS_ACL_H_ */ ># 417 "/usr/src/sys/sys/acl.h" ># 45 "/usr/src/sys/sys/vnode.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ktr.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/sys/sys/vnode.h" ># 46 "/usr/src/sys/sys/vnode.h" > >/* > * The vnode is the focus of all file activity in UNIX. There is a > * unique vnode allocated for each active file, each current directory, > * each mounted-on file, text file, and the root. > */ > >/* > * Vnode types. VNON means no type. > */ >enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD, > VMARKER }; > >/* > * Each underlying filesystem allocates its own private area and hangs > * it from v_data. If non-null, this area is freed in getnewvnode(). > */ > >struct namecache; > >struct vpollinfo { > struct mtx vpi_lock; /* lock to protect below */ > struct selinfo vpi_selinfo; /* identity of poller(s) */ > short vpi_events; /* what they are looking for */ > short vpi_revents; /* what has happened */ >}; > >/* > * Reading or writing any of these items requires holding the appropriate lock. > * > * Lock reference: > * c - namecache mutex > * f - freelist mutex > * i - interlock > * m - mount point interlock > * p - pollinfo lock > * u - Only a reference to the vnode is needed to read. > * v - vnode lock > * > * Vnodes may be found on many lists. The general way to deal with operating > * on a vnode that is on a list is: > * 1) Lock the list and find the vnode. > * 2) Lock interlock so that the vnode does not go away. > * 3) Unlock the list to avoid lock order reversals. > * 4) vget with LK_INTERLOCK and check for ENOENT, or > * 5) Check for DOOMED if the vnode lock is not required. > * 6) Perform your operation, then vput(). > */ > >#if defined(_KERNEL) || defined(_KVM_VNODE) > >struct vnode { > /* > * Fields which define the identity of the vnode. These fields are > * owned by the filesystem (XXX: and vgone() ?) > */ > const char *v_tag; /* u type of underlying data */ > struct vop_vector *v_op; /* u vnode operations vector */ > void *v_data; /* u private data for fs */ > > /* > * Filesystem instance stuff > */ > struct mount *v_mount; /* u ptr to vfs we are in */ > TAILQ_ENTRY(vnode) v_nmntvnodes; /* m vnodes for mount point */ > > /* > * Type specific fields, only one applies to any given vnode. > * See #defines below for renaming to v_* namespace. > */ > union { > struct mount *vu_mount; /* v ptr to mountpoint (VDIR) */ > struct socket *vu_socket; /* v unix domain net (VSOCK) */ > struct cdev *vu_cdev; /* v device (VCHR, VBLK) */ > struct fifoinfo *vu_fifoinfo; /* v fifo (VFIFO) */ > } v_un; > > /* > * vfs_hash: (mount + inode) -> vnode hash. The hash value > * itself is grouped with other int fields, to avoid padding. > */ > LIST_ENTRY(vnode) v_hashlist; > > /* > * VFS_namecache stuff > */ > LIST_HEAD(, namecache) v_cache_src; /* c Cache entries from us */ > TAILQ_HEAD(, namecache) v_cache_dst; /* c Cache entries to us */ > struct namecache *v_cache_dd; /* c Cache entry for .. vnode */ > > /* > * Locking > */ > struct lock v_lock; /* u (if fs don't have one) */ > struct mtx v_interlock; /* lock for "i" things */ > struct lock *v_vnlock; /* u pointer to vnode lock */ > > /* > * The machinery of being a vnode > */ > TAILQ_ENTRY(vnode) v_actfreelist; /* f vnode active/free lists */ > struct bufobj v_bufobj; /* * Buffer cache object */ > > /* > * Hooks for various subsystems and features. > */ > struct vpollinfo *v_pollinfo; /* i Poll events, p for *v_pi */ > struct label *v_label; /* MAC label for vnode */ > struct lockf *v_lockf; /* Byte-level advisory lock list */ > struct rangelock v_rl; /* Byte-range lock */ > > /* > * clustering stuff > */ > daddr_t v_cstart; /* v start block of cluster */ > daddr_t v_lasta; /* v last allocation */ > daddr_t v_lastw; /* v last write */ > int v_clen; /* v length of cur. cluster */ > > int v_holdcnt; /* i prevents recycling. */ > int v_usecount; /* i ref count of users */ > u_int v_iflag; /* i vnode flags (see below) */ > u_int v_vflag; /* v vnode flags */ > int v_writecount; /* v ref count of writers */ > u_int v_hash; > enum vtype v_type; /* u vnode type */ >}; > >#endif /* defined(_KERNEL) || defined(_KVM_VNODE) */ ># 175 "/usr/src/sys/sys/vnode.h" > >#define v_mountedhere v_un.vu_mount >#define v_socket v_un.vu_socket >#define v_rdev v_un.vu_cdev >#define v_fifoinfo v_un.vu_fifoinfo > >/* XXX: These are temporary to avoid a source sweep at this time */ >#define v_object v_bufobj.bo_object > >/* > * Userland version of struct vnode, for sysctl. > */ >struct xvnode { > size_t xv_size; /* sizeof(struct xvnode) */ > void *xv_vnode; /* address of real vnode */ > u_long xv_flag; /* vnode vflags */ > int xv_usecount; /* reference count of users */ > int xv_writecount; /* reference count of writers */ > int xv_holdcnt; /* page & buffer references */ > u_long xv_id; /* capability identifier */ > void *xv_mount; /* address of parent mount */ > long xv_numoutput; /* num of writes in progress */ > enum vtype xv_type; /* vnode type */ > union { > void *xvu_socket; /* socket, if VSOCK */ > void *xvu_fifo; /* fifo, if VFIFO */ > dev_t xvu_rdev; /* maj/min, if VBLK/VCHR */ > struct { > dev_t xvu_dev; /* device, if VDIR/VREG/VLNK */ > ino_t xvu_ino; /* id, if VDIR/VREG/VLNK */ > } xv_uns; > } xv_un; >}; >#define xv_socket xv_un.xvu_socket >#define xv_fifo xv_un.xvu_fifo >#define xv_rdev xv_un.xvu_rdev >#define xv_dev xv_un.xv_uns.xvu_dev >#define xv_ino xv_un.xv_uns.xvu_ino > >/* We don't need to lock the knlist */ >#define VN_KNLIST_EMPTY(vp) ((vp)->v_pollinfo == NULL || \ > KNLIST_EMPTY(&(vp)->v_pollinfo->vpi_selinfo.si_note)) > >#define VN_KNOTE(vp, b, a) \ > do { \ > if (!VN_KNLIST_EMPTY(vp)) \ > KNOTE(&vp->v_pollinfo->vpi_selinfo.si_note, (b), \ > (a) | KNF_NOKQLOCK); \ > } while (0) >#define VN_KNOTE_LOCKED(vp, b) VN_KNOTE(vp, b, KNF_LISTLOCKED) >#define VN_KNOTE_UNLOCKED(vp, b) VN_KNOTE(vp, b, 0) > >/* > * Vnode flags. > * VI flags are protected by interlock and live in v_iflag > * VV flags are protected by the vnode lock and live in v_vflag > * > * VI_DOOMED is doubly protected by the interlock and vnode lock. Both > * are required for writing but the status may be checked with either. > */ >#define VI_MOUNT 0x0020 /* Mount in progress */ >#define VI_AGE 0x0040 /* Insert vnode at head of free list */ >#define VI_DOOMED 0x0080 /* This vnode is being recycled */ >#define VI_FREE 0x0100 /* This vnode is on the freelist */ >#define VI_ACTIVE 0x0200 /* This vnode is on the active list */ >#define VI_DOINGINACT 0x0800 /* VOP_INACTIVE is in progress */ >#define VI_OWEINACT 0x1000 /* Need to call inactive */ > >#define VV_ROOT 0x0001 /* root of its filesystem */ >#define VV_ISTTY 0x0002 /* vnode represents a tty */ >#define VV_NOSYNC 0x0004 /* unlinked, stop syncing */ >#define VV_ETERNALDEV 0x0008 /* device that is never destroyed */ >#define VV_CACHEDLABEL 0x0010 /* Vnode has valid cached MAC label */ >#define VV_TEXT 0x0020 /* vnode is a pure text prototype */ >#define VV_COPYONWRITE 0x0040 /* vnode is doing copy-on-write */ >#define VV_SYSTEM 0x0080 /* vnode being used by kernel */ >#define VV_PROCDEP 0x0100 /* vnode is process dependent */ >#define VV_NOKNOTE 0x0200 /* don't activate knotes on this vnode */ >#define VV_DELETED 0x0400 /* should be removed */ >#define VV_MD 0x0800 /* vnode backs the md device */ >#define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */ > >/* > * Vnode attributes. A field value of VNOVAL represents a field whose value > * is unavailable (getattr) or which is not to be changed (setattr). > */ >struct vattr { > enum vtype va_type; /* vnode type (for create) */ > u_short va_mode; /* files access mode and type */ > short va_nlink; /* number of references to file */ > uid_t va_uid; /* owner user id */ > gid_t va_gid; /* owner group id */ > dev_t va_fsid; /* filesystem id */ > long va_fileid; /* file id */ > u_quad_t va_size; /* file size in bytes */ > long va_blocksize; /* blocksize preferred for i/o */ > struct timespec va_atime; /* time of last access */ > struct timespec va_mtime; /* time of last modification */ > struct timespec va_ctime; /* time file changed */ > struct timespec va_birthtime; /* time file created */ > u_long va_gen; /* generation number of file */ > u_long va_flags; /* flags defined for file */ > dev_t va_rdev; /* device the special file represents */ > u_quad_t va_bytes; /* bytes of disk space held by file */ > u_quad_t va_filerev; /* file modification number */ > u_int va_vaflags; /* operations flags, see below */ > long va_spare; /* remain quad aligned */ >}; > >/* > * Flags for va_vaflags. > */ >#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ >#define VA_EXCLUSIVE 0x02 /* exclusive create request */ > >/* > * Flags for ioflag. (high 16 bits used to ask for read-ahead and > * help with write clustering) > * NB: IO_NDELAY and IO_DIRECT are linked to fcntl.h > */ >#define IO_UNIT 0x0001 /* do I/O as atomic unit */ >#define IO_APPEND 0x0002 /* append write to end */ >#define IO_NDELAY 0x0004 /* FNDELAY flag set in file table */ >#define IO_NODELOCKED 0x0008 /* underlying node already locked */ >#define IO_ASYNC 0x0010 /* bawrite rather then bdwrite */ >#define IO_VMIO 0x0020 /* data already in VMIO space */ >#define IO_INVAL 0x0040 /* invalidate after I/O */ >#define IO_SYNC 0x0080 /* do I/O synchronously */ >#define IO_DIRECT 0x0100 /* attempt to bypass buffer cache */ >#define IO_EXT 0x0400 /* operate on external attributes */ >#define IO_NORMAL 0x0800 /* operate on regular data */ >#define IO_NOMACCHECK 0x1000 /* MAC checks unnecessary */ >#define IO_BUFLOCKED 0x2000 /* ffs flag; indir buf is locked */ >#define IO_RANGELOCKED 0x4000 /* range locked */ > >#define IO_SEQMAX 0x7F /* seq heuristic max value */ >#define IO_SEQSHIFT 16 /* seq heuristic in upper 16 bits */ > >/* > * Flags for accmode_t. > */ >#define VEXEC 000000000100 /* execute/search permission */ >#define VWRITE 000000000200 /* write permission */ >#define VREAD 000000000400 /* read permission */ >#define VADMIN 000000010000 /* being the file owner */ >#define VAPPEND 000000040000 /* permission to write/append */ >/* > * VEXPLICIT_DENY makes VOP_ACCESSX(9) return EPERM or EACCES only > * if permission was denied explicitly, by a "deny" rule in NFSv4 ACL, > * and 0 otherwise. This never happens with ordinary unix access rights > * or POSIX.1e ACLs. Obviously, VEXPLICIT_DENY must be OR-ed with > * some other V* constant. > */ >#define VEXPLICIT_DENY 000000100000 >#define VREAD_NAMED_ATTRS 000000200000 /* not used */ >#define VWRITE_NAMED_ATTRS 000000400000 /* not used */ >#define VDELETE_CHILD 000001000000 >#define VREAD_ATTRIBUTES 000002000000 /* permission to stat(2) */ >#define VWRITE_ATTRIBUTES 000004000000 /* change {m,c,a}time */ >#define VDELETE 000010000000 >#define VREAD_ACL 000020000000 /* read ACL and file mode */ >#define VWRITE_ACL 000040000000 /* change ACL and/or file mode */ >#define VWRITE_OWNER 000100000000 /* change file owner */ >#define VSYNCHRONIZE 000200000000 /* not used */ > >/* > * Permissions that were traditionally granted only to the file owner. > */ >#define VADMIN_PERMS (VADMIN | VWRITE_ATTRIBUTES | VWRITE_ACL | \ > VWRITE_OWNER) > >/* > * Permissions that were traditionally granted to everyone. > */ >#define VSTAT_PERMS (VREAD_ATTRIBUTES | VREAD_ACL) > >/* > * Permissions that allow to change the state of the file in any way. > */ >#define VMODIFY_PERMS (VWRITE | VAPPEND | VADMIN_PERMS | VDELETE_CHILD | \ > VDELETE) > >/* > * Token indicating no attribute value yet assigned. > */ >#define VNOVAL (-1) > >/* > * LK_TIMELOCK timeout for vnode locks (used mainly by the pageout daemon) > */ >#define VLKTIMEOUT (hz / 20 + 1) > >#ifdef _KERNEL > >#ifdef MALLOC_DECLARE >MALLOC_DECLARE(M_VNODE); >#endif ># 372 "/usr/src/sys/sys/vnode.h" > >/* > * Convert between vnode types and inode formats (since POSIX.1 > * defines mode word of stat structure in terms of inode formats). > */ >extern enum vtype iftovt_tab[]; >extern int vttoif_tab[]; >#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) >#define VTTOIF(indx) (vttoif_tab[(int)(indx)]) >#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) > >/* > * Flags to various vnode functions. > */ >#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */ >#define FORCECLOSE 0x0002 /* vflush: force file closure */ >#define WRITECLOSE 0x0004 /* vflush: only close writable files */ >#define EARLYFLUSH 0x0008 /* vflush: early call for ffs_flushfiles */ >#define V_SAVE 0x0001 /* vinvalbuf: sync file first */ >#define V_ALT 0x0002 /* vinvalbuf: invalidate only alternate bufs */ >#define V_NORMAL 0x0004 /* vinvalbuf: invalidate only regular bufs */ >#define V_CLEANONLY 0x0008 /* vinvalbuf: invalidate only clean bufs */ >#define REVOKEALL 0x0001 /* vop_revoke: revoke all aliases */ >#define V_WAIT 0x0001 /* vn_start_write: sleep for suspend */ >#define V_NOWAIT 0x0002 /* vn_start_write: don't sleep for suspend */ >#define V_XSLEEP 0x0004 /* vn_start_write: just return after sleep */ > >#define VR_START_WRITE 0x0001 /* vfs_write_resume: start write atomically */ >#define VR_NO_SUSPCLR 0x0002 /* vfs_write_resume: do not clear suspension */ > >#define VS_SKIP_UNMOUNT 0x0001 /* vfs_write_suspend: fail if the > filesystem is being unmounted */ > >#define VREF(vp) vref(vp) > >#ifdef DIAGNOSTIC >#define VATTR_NULL(vap) vattr_null(vap) >#else ># 410 "/usr/src/sys/sys/vnode.h" >#define VATTR_NULL(vap) (*(vap) = va_null) /* initialize a vattr */ >#endif /* DIAGNOSTIC */ ># 412 "/usr/src/sys/sys/vnode.h" > >#define NULLVP ((struct vnode *)NULL) > >/* > * Global vnode data. > */ >extern struct vnode *rootvnode; /* root (i.e. "/") vnode */ >extern int async_io_version; /* 0 or POSIX version of AIO i'face */ >extern int desiredvnodes; /* number of vnodes desired */ >extern struct uma_zone *namei_zone; >extern struct vattr va_null; /* predefined null vattr structure */ > >#define VI_LOCK(vp) mtx_lock(&(vp)->v_interlock) >#define VI_LOCK_FLAGS(vp, flags) mtx_lock_flags(&(vp)->v_interlock, (flags)) >#define VI_TRYLOCK(vp) mtx_trylock(&(vp)->v_interlock) >#define VI_UNLOCK(vp) mtx_unlock(&(vp)->v_interlock) >#define VI_MTX(vp) (&(vp)->v_interlock) > >#define VN_LOCK_AREC(vp) lockallowrecurse((vp)->v_vnlock) >#define VN_LOCK_ASHARE(vp) lockallowshare((vp)->v_vnlock) >#define VN_LOCK_DSHARE(vp) lockdisableshare((vp)->v_vnlock) > >#endif /* _KERNEL */ ># 435 "/usr/src/sys/sys/vnode.h" > >/* > * Mods for extensibility. > */ > >/* > * Flags for vdesc_flags: > */ >#define VDESC_MAX_VPS 16 >/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */ >#define VDESC_VP0_WILLRELE 0x0001 >#define VDESC_VP1_WILLRELE 0x0002 >#define VDESC_VP2_WILLRELE 0x0004 >#define VDESC_VP3_WILLRELE 0x0008 >#define VDESC_NOMAP_VPP 0x0100 >#define VDESC_VPP_WILLRELE 0x0200 > >/* > * A generic structure. > * This can be used by bypass routines to identify generic arguments. > */ >struct vop_generic_args { > struct vnodeop_desc *a_desc; > /* other random data follows, presumably */ >}; > >typedef int vop_bypass_t(struct vop_generic_args *); > >/* > * VDESC_NO_OFFSET is used to identify the end of the offset list > * and in places where no such field exists. > */ >#define VDESC_NO_OFFSET -1 > >/* > * This structure describes the vnode operation taking place. > */ >struct vnodeop_desc { > char *vdesc_name; /* a readable name for debugging */ > int vdesc_flags; /* VDESC_* flags */ > vop_bypass_t *vdesc_call; /* Function to call */ > > /* > * These ops are used by bypass routines to map and locate arguments. > * Creds and procs are not needed in bypass routines, but sometimes > * they are useful to (for example) transport layers. > * Nameidata is useful because it has a cred in it. > */ > int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ > int vdesc_vpp_offset; /* return vpp location */ > int vdesc_cred_offset; /* cred location, if any */ > int vdesc_thread_offset; /* thread location, if any */ > int vdesc_componentname_offset; /* if any */ >}; > >#ifdef _KERNEL >/* > * A list of all the operation descs. > */ >extern struct vnodeop_desc *vnodeop_descs[]; > >#define VOPARG_OFFSETOF(s_type, field) __offsetof(s_type, field) >#define VOPARG_OFFSETTO(s_type, s_offset, struct_p) \ > ((s_type)(((char*)(struct_p)) + (s_offset))) > > >#ifdef DEBUG_VFS_LOCKS >/* > * Support code to aid in debugging VFS locking problems. Not totally > * reliable since if the thread sleeps between changing the lock > * state and checking it with the assert, some other thread could > * change the state. They are good enough for debugging a single > * filesystem using a single-threaded test. Note that the unreliability is > * limited to false negatives; efforts were made to ensure that false > * positives cannot occur. > */ >void assert_vi_locked(struct vnode *vp, const char *str); >void assert_vi_unlocked(struct vnode *vp, const char *str); >void assert_vop_elocked(struct vnode *vp, const char *str); >#if 0 >void assert_vop_elocked_other(struct vnode *vp, const char *str); >#endif ># 517 "/usr/src/sys/sys/vnode.h" >void assert_vop_locked(struct vnode *vp, const char *str); >#if 0 >voi0 assert_vop_slocked(struct vnode *vp, const char *str); >#endif ># 521 "/usr/src/sys/sys/vnode.h" >void assert_vop_unlocked(struct vnode *vp, const char *str); > >#define ASSERT_VI_LOCKED(vp, str) assert_vi_locked((vp), (str)) >#define ASSERT_VI_UNLOCKED(vp, str) assert_vi_unlocked((vp), (str)) >#define ASSERT_VOP_ELOCKED(vp, str) assert_vop_elocked((vp), (str)) >#if 0 >#define ASSERT_VOP_ELOCKED_OTHER(vp, str) assert_vop_locked_other((vp), (str)) >#endif ># 529 "/usr/src/sys/sys/vnode.h" >#define ASSERT_VOP_LOCKED(vp, str) assert_vop_locked((vp), (str)) >#if 0 >#define ASSERT_VOP_SLOCKED(vp, str) assert_vop_slocked((vp), (str)) >#endif ># 533 "/usr/src/sys/sys/vnode.h" >#define ASSERT_VOP_UNLOCKED(vp, str) assert_vop_unlocked((vp), (str)) > >#else /* !DEBUG_VFS_LOCKS */ ># 536 "/usr/src/sys/sys/vnode.h" > >#define ASSERT_VI_LOCKED(vp, str) ((void)0) >#define ASSERT_VI_UNLOCKED(vp, str) ((void)0) >#define ASSERT_VOP_ELOCKED(vp, str) ((void)0) >#if 0 >#define ASSERT_VOP_ELOCKED_OTHER(vp, str) >#endif ># 543 "/usr/src/sys/sys/vnode.h" >#define ASSERT_VOP_LOCKED(vp, str) ((void)0) >#if 0 >#define ASSERT_VOP_SLOCKED(vp, str) >#endif ># 547 "/usr/src/sys/sys/vnode.h" >#define ASSERT_VOP_UNLOCKED(vp, str) ((void)0) >#endif /* DEBUG_VFS_LOCKS */ ># 549 "/usr/src/sys/sys/vnode.h" > > >/* > * This call works for vnodes in the kernel. > */ >#define VCALL(c) ((c)->a_desc->vdesc_call(c)) > >#define DOINGASYNC(vp) \ > (((vp)->v_mount->mnt_kern_flag & MNTK_ASYNC) != 0 && \ > ((curthread->td_pflags & TDP_SYNCIO) == 0)) > >/* > * VMIO support inline > */ > >extern int vmiodirenable; > >static __inline int >vn_canvmio(struct vnode *vp) >{ > if (vp && (vp->v_type == VREG || (vmiodirenable && vp->v_type == VDIR))) > return(TRUE); > return(FALSE); >} > >/* > * Finally, include the default set of vnode operations. > */ >typedef void vop_getpages_iodone_t(void *, vm_page_t *, int, int); >#if 0 /* expanded by -frewrite-includes */ >#include "vnode_if.h" >#endif /* expanded by -frewrite-includes */ ># 578 "/usr/src/sys/sys/vnode.h" ># 1 "./vnode_if.h" 1 >/* > * This file is produced automatically. > * Do not modify anything in here by hand. > * > * Created from $FreeBSD: head/sys/tools/vnode_if.awk 258622 2013-11-26 08:46:27Z avg $ > */ > >extern struct vnodeop_desc vop_default_desc; >#if 0 /* expanded by -frewrite-includes */ >#include "vnode_if_typedef.h" >#endif /* expanded by -frewrite-includes */ ># 9 "./vnode_if.h" ># 1 "./vnode_if_typedef.h" 1 >/* > * This file is produced automatically. > * Do not modify anything in here by hand. > * > * Created from $FreeBSD: head/sys/tools/vnode_if.awk 258622 2013-11-26 08:46:27Z avg $ > */ > > >struct vop_islocked_args; >typedef int vop_islocked_t(struct vop_islocked_args *); > >struct vop_lookup_args; >typedef int vop_lookup_t(struct vop_lookup_args *); > >struct vop_cachedlookup_args; >typedef int vop_cachedlookup_t(struct vop_cachedlookup_args *); > >struct vop_create_args; >typedef int vop_create_t(struct vop_create_args *); > >struct vop_whiteout_args; >typedef int vop_whiteout_t(struct vop_whiteout_args *); > >struct vop_mknod_args; >typedef int vop_mknod_t(struct vop_mknod_args *); > >struct vop_open_args; >typedef int vop_open_t(struct vop_open_args *); > >struct vop_close_args; >typedef int vop_close_t(struct vop_close_args *); > >struct vop_access_args; >typedef int vop_access_t(struct vop_access_args *); > >struct vop_accessx_args; >typedef int vop_accessx_t(struct vop_accessx_args *); > >struct vop_getattr_args; >typedef int vop_getattr_t(struct vop_getattr_args *); > >struct vop_setattr_args; >typedef int vop_setattr_t(struct vop_setattr_args *); > >struct vop_markatime_args; >typedef int vop_markatime_t(struct vop_markatime_args *); > >struct vop_read_args; >typedef int vop_read_t(struct vop_read_args *); > >struct vop_write_args; >typedef int vop_write_t(struct vop_write_args *); > >struct vop_ioctl_args; >typedef int vop_ioctl_t(struct vop_ioctl_args *); > >struct vop_poll_args; >typedef int vop_poll_t(struct vop_poll_args *); > >struct vop_kqfilter_args; >typedef int vop_kqfilter_t(struct vop_kqfilter_args *); > >struct vop_revoke_args; >typedef int vop_revoke_t(struct vop_revoke_args *); > >struct vop_fsync_args; >typedef int vop_fsync_t(struct vop_fsync_args *); > >struct vop_remove_args; >typedef int vop_remove_t(struct vop_remove_args *); > >struct vop_link_args; >typedef int vop_link_t(struct vop_link_args *); > >struct vop_rename_args; >typedef int vop_rename_t(struct vop_rename_args *); > >struct vop_mkdir_args; >typedef int vop_mkdir_t(struct vop_mkdir_args *); > >struct vop_rmdir_args; >typedef int vop_rmdir_t(struct vop_rmdir_args *); > >struct vop_symlink_args; >typedef int vop_symlink_t(struct vop_symlink_args *); > >struct vop_readdir_args; >typedef int vop_readdir_t(struct vop_readdir_args *); > >struct vop_readlink_args; >typedef int vop_readlink_t(struct vop_readlink_args *); > >struct vop_inactive_args; >typedef int vop_inactive_t(struct vop_inactive_args *); > >struct vop_reclaim_args; >typedef int vop_reclaim_t(struct vop_reclaim_args *); > >struct vop_lock1_args; >typedef int vop_lock1_t(struct vop_lock1_args *); > >struct vop_unlock_args; >typedef int vop_unlock_t(struct vop_unlock_args *); > >struct vop_bmap_args; >typedef int vop_bmap_t(struct vop_bmap_args *); > >struct vop_strategy_args; >typedef int vop_strategy_t(struct vop_strategy_args *); > >struct vop_getwritemount_args; >typedef int vop_getwritemount_t(struct vop_getwritemount_args *); > >struct vop_print_args; >typedef int vop_print_t(struct vop_print_args *); > >struct vop_pathconf_args; >typedef int vop_pathconf_t(struct vop_pathconf_args *); > >struct vop_advlock_args; >typedef int vop_advlock_t(struct vop_advlock_args *); > >struct vop_advlockasync_args; >typedef int vop_advlockasync_t(struct vop_advlockasync_args *); > >struct vop_advlockpurge_args; >typedef int vop_advlockpurge_t(struct vop_advlockpurge_args *); > >struct vop_reallocblks_args; >typedef int vop_reallocblks_t(struct vop_reallocblks_args *); > >struct vop_getpages_args; >typedef int vop_getpages_t(struct vop_getpages_args *); > >struct vop_getpages_async_args; >typedef int vop_getpages_async_t(struct vop_getpages_async_args *); > >struct vop_putpages_args; >typedef int vop_putpages_t(struct vop_putpages_args *); > >struct vop_getacl_args; >typedef int vop_getacl_t(struct vop_getacl_args *); > >struct vop_setacl_args; >typedef int vop_setacl_t(struct vop_setacl_args *); > >struct vop_aclcheck_args; >typedef int vop_aclcheck_t(struct vop_aclcheck_args *); > >struct vop_closeextattr_args; >typedef int vop_closeextattr_t(struct vop_closeextattr_args *); > >struct vop_getextattr_args; >typedef int vop_getextattr_t(struct vop_getextattr_args *); > >struct vop_listextattr_args; >typedef int vop_listextattr_t(struct vop_listextattr_args *); > >struct vop_openextattr_args; >typedef int vop_openextattr_t(struct vop_openextattr_args *); > >struct vop_deleteextattr_args; >typedef int vop_deleteextattr_t(struct vop_deleteextattr_args *); > >struct vop_setextattr_args; >typedef int vop_setextattr_t(struct vop_setextattr_args *); > >struct vop_setlabel_args; >typedef int vop_setlabel_t(struct vop_setlabel_args *); > >struct vop_vptofh_args; >typedef int vop_vptofh_t(struct vop_vptofh_args *); > >struct vop_vptocnp_args; >typedef int vop_vptocnp_t(struct vop_vptocnp_args *); > >struct vop_allocate_args; >typedef int vop_allocate_t(struct vop_allocate_args *); > >struct vop_advise_args; >typedef int vop_advise_t(struct vop_advise_args *); > >struct vop_unp_bind_args; >typedef int vop_unp_bind_t(struct vop_unp_bind_args *); > >struct vop_unp_connect_args; >typedef int vop_unp_connect_t(struct vop_unp_connect_args *); > >struct vop_unp_detach_args; >typedef int vop_unp_detach_t(struct vop_unp_detach_args *); > >struct vop_is_text_args; >typedef int vop_is_text_t(struct vop_is_text_args *); > >struct vop_set_text_args; >typedef int vop_set_text_t(struct vop_set_text_args *); > >struct vop_unset_text_args; >typedef int vop_unset_text_t(struct vop_unset_text_args *); > >struct vop_get_writecount_args; >typedef int vop_get_writecount_t(struct vop_get_writecount_args *); > >struct vop_add_writecount_args; >typedef int vop_add_writecount_t(struct vop_add_writecount_args *); > >struct vop_spare1_args; >typedef int vop_spare1_t(struct vop_spare1_args *); > >struct vop_spare2_args; >typedef int vop_spare2_t(struct vop_spare2_args *); > >struct vop_spare3_args; >typedef int vop_spare3_t(struct vop_spare3_args *); > >struct vop_spare4_args; >typedef int vop_spare4_t(struct vop_spare4_args *); > >struct vop_spare5_args; >typedef int vop_spare5_t(struct vop_spare5_args *); > ># 10 "./vnode_if.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include "vnode_if_newproto.h" >#endif /* expanded by -frewrite-includes */ ># 10 "./vnode_if.h" ># 1 "./vnode_if_newproto.h" 1 >/* > * This file is produced automatically. > * Do not modify anything in here by hand. > * > * Created from $FreeBSD: head/sys/tools/vnode_if.awk 258622 2013-11-26 08:46:27Z avg $ > */ > > >struct vop_vector { > struct vop_vector *vop_default; > vop_bypass_t *vop_bypass; > vop_islocked_t *vop_islocked; > vop_lookup_t *vop_lookup; > vop_cachedlookup_t *vop_cachedlookup; > vop_create_t *vop_create; > vop_whiteout_t *vop_whiteout; > vop_mknod_t *vop_mknod; > vop_open_t *vop_open; > vop_close_t *vop_close; > vop_access_t *vop_access; > vop_accessx_t *vop_accessx; > vop_getattr_t *vop_getattr; > vop_setattr_t *vop_setattr; > vop_markatime_t *vop_markatime; > vop_read_t *vop_read; > vop_write_t *vop_write; > vop_ioctl_t *vop_ioctl; > vop_poll_t *vop_poll; > vop_kqfilter_t *vop_kqfilter; > vop_revoke_t *vop_revoke; > vop_fsync_t *vop_fsync; > vop_remove_t *vop_remove; > vop_link_t *vop_link; > vop_rename_t *vop_rename; > vop_mkdir_t *vop_mkdir; > vop_rmdir_t *vop_rmdir; > vop_symlink_t *vop_symlink; > vop_readdir_t *vop_readdir; > vop_readlink_t *vop_readlink; > vop_inactive_t *vop_inactive; > vop_reclaim_t *vop_reclaim; > vop_lock1_t *vop_lock1; > vop_unlock_t *vop_unlock; > vop_bmap_t *vop_bmap; > vop_strategy_t *vop_strategy; > vop_getwritemount_t *vop_getwritemount; > vop_print_t *vop_print; > vop_pathconf_t *vop_pathconf; > vop_advlock_t *vop_advlock; > vop_advlockasync_t *vop_advlockasync; > vop_advlockpurge_t *vop_advlockpurge; > vop_reallocblks_t *vop_reallocblks; > vop_getpages_t *vop_getpages; > vop_getpages_async_t *vop_getpages_async; > vop_putpages_t *vop_putpages; > vop_getacl_t *vop_getacl; > vop_setacl_t *vop_setacl; > vop_aclcheck_t *vop_aclcheck; > vop_closeextattr_t *vop_closeextattr; > vop_getextattr_t *vop_getextattr; > vop_listextattr_t *vop_listextattr; > vop_openextattr_t *vop_openextattr; > vop_deleteextattr_t *vop_deleteextattr; > vop_setextattr_t *vop_setextattr; > vop_setlabel_t *vop_setlabel; > vop_vptofh_t *vop_vptofh; > vop_vptocnp_t *vop_vptocnp; > vop_allocate_t *vop_allocate; > vop_advise_t *vop_advise; > vop_unp_bind_t *vop_unp_bind; > vop_unp_connect_t *vop_unp_connect; > vop_unp_detach_t *vop_unp_detach; > vop_is_text_t *vop_is_text; > vop_set_text_t *vop_set_text; > vop_unset_text_t *vop_unset_text; > vop_get_writecount_t *vop_get_writecount; > vop_add_writecount_t *vop_add_writecount; > vop_spare1_t *vop_spare1; > vop_spare2_t *vop_spare2; > vop_spare3_t *vop_spare3; > vop_spare4_t *vop_spare4; > vop_spare5_t *vop_spare5; >}; ># 11 "./vnode_if.h" 2 >struct vop_islocked_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_islocked_desc; > >int VOP_ISLOCKED_AP(struct vop_islocked_args *); >int VOP_ISLOCKED_APV(struct vop_vector *vop, struct vop_islocked_args *); > >static __inline int VOP_ISLOCKED( > struct vnode *vp) >{ > struct vop_islocked_args a; > > a.a_gen.a_desc = &vop_islocked_desc; > a.a_vp = vp; > return (VOP_ISLOCKED_APV(vp->v_op, &a)); >} > >struct vop_lookup_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode **a_vpp; > struct componentname *a_cnp; >}; > >extern struct vnodeop_desc vop_lookup_desc; > >int VOP_LOOKUP_AP(struct vop_lookup_args *); >int VOP_LOOKUP_APV(struct vop_vector *vop, struct vop_lookup_args *); > >static __inline int VOP_LOOKUP( > struct vnode *dvp, > struct vnode **vpp, > struct componentname *cnp) >{ > struct vop_lookup_args a; > > a.a_gen.a_desc = &vop_lookup_desc; > a.a_dvp = dvp; > a.a_vpp = vpp; > a.a_cnp = cnp; > return (VOP_LOOKUP_APV(dvp->v_op, &a)); >} > >struct vop_cachedlookup_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode **a_vpp; > struct componentname *a_cnp; >}; > >extern struct vnodeop_desc vop_cachedlookup_desc; > >int VOP_CACHEDLOOKUP_AP(struct vop_cachedlookup_args *); >int VOP_CACHEDLOOKUP_APV(struct vop_vector *vop, struct vop_cachedlookup_args *); > >static __inline int VOP_CACHEDLOOKUP( > struct vnode *dvp, > struct vnode **vpp, > struct componentname *cnp) >{ > struct vop_cachedlookup_args a; > > a.a_gen.a_desc = &vop_cachedlookup_desc; > a.a_dvp = dvp; > a.a_vpp = vpp; > a.a_cnp = cnp; > return (VOP_CACHEDLOOKUP_APV(dvp->v_op, &a)); >} > >struct vop_create_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode **a_vpp; > struct componentname *a_cnp; > struct vattr *a_vap; >}; > >extern struct vnodeop_desc vop_create_desc; > >int VOP_CREATE_AP(struct vop_create_args *); >int VOP_CREATE_APV(struct vop_vector *vop, struct vop_create_args *); > >static __inline int VOP_CREATE( > struct vnode *dvp, > struct vnode **vpp, > struct componentname *cnp, > struct vattr *vap) >{ > struct vop_create_args a; > > a.a_gen.a_desc = &vop_create_desc; > a.a_dvp = dvp; > a.a_vpp = vpp; > a.a_cnp = cnp; > a.a_vap = vap; > return (VOP_CREATE_APV(dvp->v_op, &a)); >} > >struct vop_whiteout_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct componentname *a_cnp; > int a_flags; >}; > >extern struct vnodeop_desc vop_whiteout_desc; > >int VOP_WHITEOUT_AP(struct vop_whiteout_args *); >int VOP_WHITEOUT_APV(struct vop_vector *vop, struct vop_whiteout_args *); > >static __inline int VOP_WHITEOUT( > struct vnode *dvp, > struct componentname *cnp, > int flags) >{ > struct vop_whiteout_args a; > > a.a_gen.a_desc = &vop_whiteout_desc; > a.a_dvp = dvp; > a.a_cnp = cnp; > a.a_flags = flags; > return (VOP_WHITEOUT_APV(dvp->v_op, &a)); >} > >struct vop_mknod_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode **a_vpp; > struct componentname *a_cnp; > struct vattr *a_vap; >}; > >extern struct vnodeop_desc vop_mknod_desc; > >int VOP_MKNOD_AP(struct vop_mknod_args *); >int VOP_MKNOD_APV(struct vop_vector *vop, struct vop_mknod_args *); > >static __inline int VOP_MKNOD( > struct vnode *dvp, > struct vnode **vpp, > struct componentname *cnp, > struct vattr *vap) >{ > struct vop_mknod_args a; > > a.a_gen.a_desc = &vop_mknod_desc; > a.a_dvp = dvp; > a.a_vpp = vpp; > a.a_cnp = cnp; > a.a_vap = vap; > return (VOP_MKNOD_APV(dvp->v_op, &a)); >} > >struct vop_open_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_mode; > struct ucred *a_cred; > struct thread *a_td; > struct file *a_fp; >}; > >extern struct vnodeop_desc vop_open_desc; > >int VOP_OPEN_AP(struct vop_open_args *); >int VOP_OPEN_APV(struct vop_vector *vop, struct vop_open_args *); > >static __inline int VOP_OPEN( > struct vnode *vp, > int mode, > struct ucred *cred, > struct thread *td, > struct file *fp) >{ > struct vop_open_args a; > > a.a_gen.a_desc = &vop_open_desc; > a.a_vp = vp; > a.a_mode = mode; > a.a_cred = cred; > a.a_td = td; > a.a_fp = fp; > return (VOP_OPEN_APV(vp->v_op, &a)); >} > >struct vop_close_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_fflag; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_close_desc; > >int VOP_CLOSE_AP(struct vop_close_args *); >int VOP_CLOSE_APV(struct vop_vector *vop, struct vop_close_args *); > >static __inline int VOP_CLOSE( > struct vnode *vp, > int fflag, > struct ucred *cred, > struct thread *td) >{ > struct vop_close_args a; > > a.a_gen.a_desc = &vop_close_desc; > a.a_vp = vp; > a.a_fflag = fflag; > a.a_cred = cred; > a.a_td = td; > return (VOP_CLOSE_APV(vp->v_op, &a)); >} > >struct vop_access_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > accmode_t a_accmode; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_access_desc; > >int VOP_ACCESS_AP(struct vop_access_args *); >int VOP_ACCESS_APV(struct vop_vector *vop, struct vop_access_args *); > >static __inline int VOP_ACCESS( > struct vnode *vp, > accmode_t accmode, > struct ucred *cred, > struct thread *td) >{ > struct vop_access_args a; > > a.a_gen.a_desc = &vop_access_desc; > a.a_vp = vp; > a.a_accmode = accmode; > a.a_cred = cred; > a.a_td = td; > return (VOP_ACCESS_APV(vp->v_op, &a)); >} > >struct vop_accessx_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > accmode_t a_accmode; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_accessx_desc; > >int VOP_ACCESSX_AP(struct vop_accessx_args *); >int VOP_ACCESSX_APV(struct vop_vector *vop, struct vop_accessx_args *); > >static __inline int VOP_ACCESSX( > struct vnode *vp, > accmode_t accmode, > struct ucred *cred, > struct thread *td) >{ > struct vop_accessx_args a; > > a.a_gen.a_desc = &vop_accessx_desc; > a.a_vp = vp; > a.a_accmode = accmode; > a.a_cred = cred; > a.a_td = td; > return (VOP_ACCESSX_APV(vp->v_op, &a)); >} > >struct vop_getattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct vattr *a_vap; > struct ucred *a_cred; >}; > >extern struct vnodeop_desc vop_getattr_desc; > >int VOP_GETATTR_AP(struct vop_getattr_args *); >int VOP_GETATTR_APV(struct vop_vector *vop, struct vop_getattr_args *); > >static __inline int VOP_GETATTR( > struct vnode *vp, > struct vattr *vap, > struct ucred *cred) >{ > struct vop_getattr_args a; > > a.a_gen.a_desc = &vop_getattr_desc; > a.a_vp = vp; > a.a_vap = vap; > a.a_cred = cred; > return (VOP_GETATTR_APV(vp->v_op, &a)); >} > >struct vop_setattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct vattr *a_vap; > struct ucred *a_cred; >}; > >extern struct vnodeop_desc vop_setattr_desc; > >int VOP_SETATTR_AP(struct vop_setattr_args *); >int VOP_SETATTR_APV(struct vop_vector *vop, struct vop_setattr_args *); > >static __inline int VOP_SETATTR( > struct vnode *vp, > struct vattr *vap, > struct ucred *cred) >{ > struct vop_setattr_args a; > > a.a_gen.a_desc = &vop_setattr_desc; > a.a_vp = vp; > a.a_vap = vap; > a.a_cred = cred; > return (VOP_SETATTR_APV(vp->v_op, &a)); >} > >struct vop_markatime_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_markatime_desc; > >int VOP_MARKATIME_AP(struct vop_markatime_args *); >int VOP_MARKATIME_APV(struct vop_vector *vop, struct vop_markatime_args *); > >static __inline int VOP_MARKATIME( > struct vnode *vp) >{ > struct vop_markatime_args a; > > a.a_gen.a_desc = &vop_markatime_desc; > a.a_vp = vp; > return (VOP_MARKATIME_APV(vp->v_op, &a)); >} > >struct vop_read_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct uio *a_uio; > int a_ioflag; > struct ucred *a_cred; >}; > >extern struct vnodeop_desc vop_read_desc; > >int VOP_READ_AP(struct vop_read_args *); >int VOP_READ_APV(struct vop_vector *vop, struct vop_read_args *); > >static __inline int VOP_READ( > struct vnode *vp, > struct uio *uio, > int ioflag, > struct ucred *cred) >{ > struct vop_read_args a; > > a.a_gen.a_desc = &vop_read_desc; > a.a_vp = vp; > a.a_uio = uio; > a.a_ioflag = ioflag; > a.a_cred = cred; > return (VOP_READ_APV(vp->v_op, &a)); >} > >struct vop_write_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct uio *a_uio; > int a_ioflag; > struct ucred *a_cred; >}; > >extern struct vnodeop_desc vop_write_desc; > >int VOP_WRITE_AP(struct vop_write_args *); >int VOP_WRITE_APV(struct vop_vector *vop, struct vop_write_args *); > >static __inline int VOP_WRITE( > struct vnode *vp, > struct uio *uio, > int ioflag, > struct ucred *cred) >{ > struct vop_write_args a; > > a.a_gen.a_desc = &vop_write_desc; > a.a_vp = vp; > a.a_uio = uio; > a.a_ioflag = ioflag; > a.a_cred = cred; > return (VOP_WRITE_APV(vp->v_op, &a)); >} > >struct vop_ioctl_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > u_long a_command; > void *a_data; > int a_fflag; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_ioctl_desc; > >int VOP_IOCTL_AP(struct vop_ioctl_args *); >int VOP_IOCTL_APV(struct vop_vector *vop, struct vop_ioctl_args *); > >static __inline int VOP_IOCTL( > struct vnode *vp, > u_long command, > void *data, > int fflag, > struct ucred *cred, > struct thread *td) >{ > struct vop_ioctl_args a; > > a.a_gen.a_desc = &vop_ioctl_desc; > a.a_vp = vp; > a.a_command = command; > a.a_data = data; > a.a_fflag = fflag; > a.a_cred = cred; > a.a_td = td; > return (VOP_IOCTL_APV(vp->v_op, &a)); >} > >struct vop_poll_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_events; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_poll_desc; > >int VOP_POLL_AP(struct vop_poll_args *); >int VOP_POLL_APV(struct vop_vector *vop, struct vop_poll_args *); > >static __inline int VOP_POLL( > struct vnode *vp, > int events, > struct ucred *cred, > struct thread *td) >{ > struct vop_poll_args a; > > a.a_gen.a_desc = &vop_poll_desc; > a.a_vp = vp; > a.a_events = events; > a.a_cred = cred; > a.a_td = td; > return (VOP_POLL_APV(vp->v_op, &a)); >} > >struct vop_kqfilter_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct knote *a_kn; >}; > >extern struct vnodeop_desc vop_kqfilter_desc; > >int VOP_KQFILTER_AP(struct vop_kqfilter_args *); >int VOP_KQFILTER_APV(struct vop_vector *vop, struct vop_kqfilter_args *); > >static __inline int VOP_KQFILTER( > struct vnode *vp, > struct knote *kn) >{ > struct vop_kqfilter_args a; > > a.a_gen.a_desc = &vop_kqfilter_desc; > a.a_vp = vp; > a.a_kn = kn; > return (VOP_KQFILTER_APV(vp->v_op, &a)); >} > >struct vop_revoke_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_flags; >}; > >extern struct vnodeop_desc vop_revoke_desc; > >int VOP_REVOKE_AP(struct vop_revoke_args *); >int VOP_REVOKE_APV(struct vop_vector *vop, struct vop_revoke_args *); > >static __inline int VOP_REVOKE( > struct vnode *vp, > int flags) >{ > struct vop_revoke_args a; > > a.a_gen.a_desc = &vop_revoke_desc; > a.a_vp = vp; > a.a_flags = flags; > return (VOP_REVOKE_APV(vp->v_op, &a)); >} > >struct vop_fsync_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_waitfor; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_fsync_desc; > >int VOP_FSYNC_AP(struct vop_fsync_args *); >int VOP_FSYNC_APV(struct vop_vector *vop, struct vop_fsync_args *); > >static __inline int VOP_FSYNC( > struct vnode *vp, > int waitfor, > struct thread *td) >{ > struct vop_fsync_args a; > > a.a_gen.a_desc = &vop_fsync_desc; > a.a_vp = vp; > a.a_waitfor = waitfor; > a.a_td = td; > return (VOP_FSYNC_APV(vp->v_op, &a)); >} > >struct vop_remove_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode *a_vp; > struct componentname *a_cnp; >}; > >extern struct vnodeop_desc vop_remove_desc; > >int VOP_REMOVE_AP(struct vop_remove_args *); >int VOP_REMOVE_APV(struct vop_vector *vop, struct vop_remove_args *); > >static __inline int VOP_REMOVE( > struct vnode *dvp, > struct vnode *vp, > struct componentname *cnp) >{ > struct vop_remove_args a; > > a.a_gen.a_desc = &vop_remove_desc; > a.a_dvp = dvp; > a.a_vp = vp; > a.a_cnp = cnp; > return (VOP_REMOVE_APV(dvp->v_op, &a)); >} > >struct vop_link_args { > struct vop_generic_args a_gen; > struct vnode *a_tdvp; > struct vnode *a_vp; > struct componentname *a_cnp; >}; > >extern struct vnodeop_desc vop_link_desc; > >int VOP_LINK_AP(struct vop_link_args *); >int VOP_LINK_APV(struct vop_vector *vop, struct vop_link_args *); > >static __inline int VOP_LINK( > struct vnode *tdvp, > struct vnode *vp, > struct componentname *cnp) >{ > struct vop_link_args a; > > a.a_gen.a_desc = &vop_link_desc; > a.a_tdvp = tdvp; > a.a_vp = vp; > a.a_cnp = cnp; > return (VOP_LINK_APV(tdvp->v_op, &a)); >} > >struct vop_rename_args { > struct vop_generic_args a_gen; > struct vnode *a_fdvp; > struct vnode *a_fvp; > struct componentname *a_fcnp; > struct vnode *a_tdvp; > struct vnode *a_tvp; > struct componentname *a_tcnp; >}; > >extern struct vnodeop_desc vop_rename_desc; > >int VOP_RENAME_AP(struct vop_rename_args *); >int VOP_RENAME_APV(struct vop_vector *vop, struct vop_rename_args *); > >static __inline int VOP_RENAME( > struct vnode *fdvp, > struct vnode *fvp, > struct componentname *fcnp, > struct vnode *tdvp, > struct vnode *tvp, > struct componentname *tcnp) >{ > struct vop_rename_args a; > > a.a_gen.a_desc = &vop_rename_desc; > a.a_fdvp = fdvp; > a.a_fvp = fvp; > a.a_fcnp = fcnp; > a.a_tdvp = tdvp; > a.a_tvp = tvp; > a.a_tcnp = tcnp; > return (VOP_RENAME_APV(fdvp->v_op, &a)); >} > >struct vop_mkdir_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode **a_vpp; > struct componentname *a_cnp; > struct vattr *a_vap; >}; > >extern struct vnodeop_desc vop_mkdir_desc; > >int VOP_MKDIR_AP(struct vop_mkdir_args *); >int VOP_MKDIR_APV(struct vop_vector *vop, struct vop_mkdir_args *); > >static __inline int VOP_MKDIR( > struct vnode *dvp, > struct vnode **vpp, > struct componentname *cnp, > struct vattr *vap) >{ > struct vop_mkdir_args a; > > a.a_gen.a_desc = &vop_mkdir_desc; > a.a_dvp = dvp; > a.a_vpp = vpp; > a.a_cnp = cnp; > a.a_vap = vap; > return (VOP_MKDIR_APV(dvp->v_op, &a)); >} > >struct vop_rmdir_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode *a_vp; > struct componentname *a_cnp; >}; > >extern struct vnodeop_desc vop_rmdir_desc; > >int VOP_RMDIR_AP(struct vop_rmdir_args *); >int VOP_RMDIR_APV(struct vop_vector *vop, struct vop_rmdir_args *); > >static __inline int VOP_RMDIR( > struct vnode *dvp, > struct vnode *vp, > struct componentname *cnp) >{ > struct vop_rmdir_args a; > > a.a_gen.a_desc = &vop_rmdir_desc; > a.a_dvp = dvp; > a.a_vp = vp; > a.a_cnp = cnp; > return (VOP_RMDIR_APV(dvp->v_op, &a)); >} > >struct vop_symlink_args { > struct vop_generic_args a_gen; > struct vnode *a_dvp; > struct vnode **a_vpp; > struct componentname *a_cnp; > struct vattr *a_vap; > char *a_target; >}; > >extern struct vnodeop_desc vop_symlink_desc; > >int VOP_SYMLINK_AP(struct vop_symlink_args *); >int VOP_SYMLINK_APV(struct vop_vector *vop, struct vop_symlink_args *); > >static __inline int VOP_SYMLINK( > struct vnode *dvp, > struct vnode **vpp, > struct componentname *cnp, > struct vattr *vap, > char *target) >{ > struct vop_symlink_args a; > > a.a_gen.a_desc = &vop_symlink_desc; > a.a_dvp = dvp; > a.a_vpp = vpp; > a.a_cnp = cnp; > a.a_vap = vap; > a.a_target = target; > return (VOP_SYMLINK_APV(dvp->v_op, &a)); >} > >struct vop_readdir_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct uio *a_uio; > struct ucred *a_cred; > int *a_eofflag; > int *a_ncookies; > u_long **a_cookies; >}; > >extern struct vnodeop_desc vop_readdir_desc; > >int VOP_READDIR_AP(struct vop_readdir_args *); >int VOP_READDIR_APV(struct vop_vector *vop, struct vop_readdir_args *); > >static __inline int VOP_READDIR( > struct vnode *vp, > struct uio *uio, > struct ucred *cred, > int *eofflag, > int *ncookies, > u_long **cookies) >{ > struct vop_readdir_args a; > > a.a_gen.a_desc = &vop_readdir_desc; > a.a_vp = vp; > a.a_uio = uio; > a.a_cred = cred; > a.a_eofflag = eofflag; > a.a_ncookies = ncookies; > a.a_cookies = cookies; > return (VOP_READDIR_APV(vp->v_op, &a)); >} > >struct vop_readlink_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct uio *a_uio; > struct ucred *a_cred; >}; > >extern struct vnodeop_desc vop_readlink_desc; > >int VOP_READLINK_AP(struct vop_readlink_args *); >int VOP_READLINK_APV(struct vop_vector *vop, struct vop_readlink_args *); > >static __inline int VOP_READLINK( > struct vnode *vp, > struct uio *uio, > struct ucred *cred) >{ > struct vop_readlink_args a; > > a.a_gen.a_desc = &vop_readlink_desc; > a.a_vp = vp; > a.a_uio = uio; > a.a_cred = cred; > return (VOP_READLINK_APV(vp->v_op, &a)); >} > >struct vop_inactive_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_inactive_desc; > >int VOP_INACTIVE_AP(struct vop_inactive_args *); >int VOP_INACTIVE_APV(struct vop_vector *vop, struct vop_inactive_args *); > >static __inline int VOP_INACTIVE( > struct vnode *vp, > struct thread *td) >{ > struct vop_inactive_args a; > > a.a_gen.a_desc = &vop_inactive_desc; > a.a_vp = vp; > a.a_td = td; > return (VOP_INACTIVE_APV(vp->v_op, &a)); >} > >struct vop_reclaim_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_reclaim_desc; > >int VOP_RECLAIM_AP(struct vop_reclaim_args *); >int VOP_RECLAIM_APV(struct vop_vector *vop, struct vop_reclaim_args *); > >static __inline int VOP_RECLAIM( > struct vnode *vp, > struct thread *td) >{ > struct vop_reclaim_args a; > > a.a_gen.a_desc = &vop_reclaim_desc; > a.a_vp = vp; > a.a_td = td; > return (VOP_RECLAIM_APV(vp->v_op, &a)); >} > >struct vop_lock1_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_flags; > char *a_file; > int a_line; >}; > >extern struct vnodeop_desc vop_lock1_desc; > >int VOP_LOCK1_AP(struct vop_lock1_args *); >int VOP_LOCK1_APV(struct vop_vector *vop, struct vop_lock1_args *); > >static __inline int VOP_LOCK1( > struct vnode *vp, > int flags, > char *file, > int line) >{ > struct vop_lock1_args a; > > a.a_gen.a_desc = &vop_lock1_desc; > a.a_vp = vp; > a.a_flags = flags; > a.a_file = file; > a.a_line = line; > return (VOP_LOCK1_APV(vp->v_op, &a)); >} > >struct vop_unlock_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_flags; >}; > >extern struct vnodeop_desc vop_unlock_desc; > >int VOP_UNLOCK_AP(struct vop_unlock_args *); >int VOP_UNLOCK_APV(struct vop_vector *vop, struct vop_unlock_args *); > >static __inline int VOP_UNLOCK( > struct vnode *vp, > int flags) >{ > struct vop_unlock_args a; > > a.a_gen.a_desc = &vop_unlock_desc; > a.a_vp = vp; > a.a_flags = flags; > return (VOP_UNLOCK_APV(vp->v_op, &a)); >} > >struct vop_bmap_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > daddr_t a_bn; > struct bufobj **a_bop; > daddr_t *a_bnp; > int *a_runp; > int *a_runb; >}; > >extern struct vnodeop_desc vop_bmap_desc; > >int VOP_BMAP_AP(struct vop_bmap_args *); >int VOP_BMAP_APV(struct vop_vector *vop, struct vop_bmap_args *); > >static __inline int VOP_BMAP( > struct vnode *vp, > daddr_t bn, > struct bufobj **bop, > daddr_t *bnp, > int *runp, > int *runb) >{ > struct vop_bmap_args a; > > a.a_gen.a_desc = &vop_bmap_desc; > a.a_vp = vp; > a.a_bn = bn; > a.a_bop = bop; > a.a_bnp = bnp; > a.a_runp = runp; > a.a_runb = runb; > return (VOP_BMAP_APV(vp->v_op, &a)); >} > >struct vop_strategy_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct buf *a_bp; >}; > >extern struct vnodeop_desc vop_strategy_desc; > >int VOP_STRATEGY_AP(struct vop_strategy_args *); >int VOP_STRATEGY_APV(struct vop_vector *vop, struct vop_strategy_args *); > >static __inline int VOP_STRATEGY( > struct vnode *vp, > struct buf *bp) >{ > struct vop_strategy_args a; > > a.a_gen.a_desc = &vop_strategy_desc; > a.a_vp = vp; > a.a_bp = bp; > return (VOP_STRATEGY_APV(vp->v_op, &a)); >} > >struct vop_getwritemount_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct mount **a_mpp; >}; > >extern struct vnodeop_desc vop_getwritemount_desc; > >int VOP_GETWRITEMOUNT_AP(struct vop_getwritemount_args *); >int VOP_GETWRITEMOUNT_APV(struct vop_vector *vop, struct vop_getwritemount_args *); > >static __inline int VOP_GETWRITEMOUNT( > struct vnode *vp, > struct mount **mpp) >{ > struct vop_getwritemount_args a; > > a.a_gen.a_desc = &vop_getwritemount_desc; > a.a_vp = vp; > a.a_mpp = mpp; > return (VOP_GETWRITEMOUNT_APV(vp->v_op, &a)); >} > >struct vop_print_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_print_desc; > >int VOP_PRINT_AP(struct vop_print_args *); >int VOP_PRINT_APV(struct vop_vector *vop, struct vop_print_args *); > >static __inline int VOP_PRINT( > struct vnode *vp) >{ > struct vop_print_args a; > > a.a_gen.a_desc = &vop_print_desc; > a.a_vp = vp; > return (VOP_PRINT_APV(vp->v_op, &a)); >} > >struct vop_pathconf_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_name; > register_t *a_retval; >}; > >extern struct vnodeop_desc vop_pathconf_desc; > >int VOP_PATHCONF_AP(struct vop_pathconf_args *); >int VOP_PATHCONF_APV(struct vop_vector *vop, struct vop_pathconf_args *); > >static __inline int VOP_PATHCONF( > struct vnode *vp, > int name, > register_t *retval) >{ > struct vop_pathconf_args a; > > a.a_gen.a_desc = &vop_pathconf_desc; > a.a_vp = vp; > a.a_name = name; > a.a_retval = retval; > return (VOP_PATHCONF_APV(vp->v_op, &a)); >} > >struct vop_advlock_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > void *a_id; > int a_op; > struct flock *a_fl; > int a_flags; >}; > >extern struct vnodeop_desc vop_advlock_desc; > >int VOP_ADVLOCK_AP(struct vop_advlock_args *); >int VOP_ADVLOCK_APV(struct vop_vector *vop, struct vop_advlock_args *); > >static __inline int VOP_ADVLOCK( > struct vnode *vp, > void *id, > int op, > struct flock *fl, > int flags) >{ > struct vop_advlock_args a; > > a.a_gen.a_desc = &vop_advlock_desc; > a.a_vp = vp; > a.a_id = id; > a.a_op = op; > a.a_fl = fl; > a.a_flags = flags; > return (VOP_ADVLOCK_APV(vp->v_op, &a)); >} > >struct vop_advlockasync_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > void *a_id; > int a_op; > struct flock *a_fl; > int a_flags; > struct task *a_task; > void **a_cookiep; >}; > >extern struct vnodeop_desc vop_advlockasync_desc; > >int VOP_ADVLOCKASYNC_AP(struct vop_advlockasync_args *); >int VOP_ADVLOCKASYNC_APV(struct vop_vector *vop, struct vop_advlockasync_args *); > >static __inline int VOP_ADVLOCKASYNC( > struct vnode *vp, > void *id, > int op, > struct flock *fl, > int flags, > struct task *task, > void **cookiep) >{ > struct vop_advlockasync_args a; > > a.a_gen.a_desc = &vop_advlockasync_desc; > a.a_vp = vp; > a.a_id = id; > a.a_op = op; > a.a_fl = fl; > a.a_flags = flags; > a.a_task = task; > a.a_cookiep = cookiep; > return (VOP_ADVLOCKASYNC_APV(vp->v_op, &a)); >} > >struct vop_advlockpurge_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_advlockpurge_desc; > >int VOP_ADVLOCKPURGE_AP(struct vop_advlockpurge_args *); >int VOP_ADVLOCKPURGE_APV(struct vop_vector *vop, struct vop_advlockpurge_args *); > >static __inline int VOP_ADVLOCKPURGE( > struct vnode *vp) >{ > struct vop_advlockpurge_args a; > > a.a_gen.a_desc = &vop_advlockpurge_desc; > a.a_vp = vp; > return (VOP_ADVLOCKPURGE_APV(vp->v_op, &a)); >} > >struct vop_reallocblks_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct cluster_save *a_buflist; >}; > >extern struct vnodeop_desc vop_reallocblks_desc; > >int VOP_REALLOCBLKS_AP(struct vop_reallocblks_args *); >int VOP_REALLOCBLKS_APV(struct vop_vector *vop, struct vop_reallocblks_args *); > >static __inline int VOP_REALLOCBLKS( > struct vnode *vp, > struct cluster_save *buflist) >{ > struct vop_reallocblks_args a; > > a.a_gen.a_desc = &vop_reallocblks_desc; > a.a_vp = vp; > a.a_buflist = buflist; > return (VOP_REALLOCBLKS_APV(vp->v_op, &a)); >} > >struct vop_getpages_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > vm_page_t *a_m; > int a_count; > int a_reqpage; >}; > >extern struct vnodeop_desc vop_getpages_desc; > >int VOP_GETPAGES_AP(struct vop_getpages_args *); >int VOP_GETPAGES_APV(struct vop_vector *vop, struct vop_getpages_args *); > >static __inline int VOP_GETPAGES( > struct vnode *vp, > vm_page_t *m, > int count, > int reqpage) >{ > struct vop_getpages_args a; > > a.a_gen.a_desc = &vop_getpages_desc; > a.a_vp = vp; > a.a_m = m; > a.a_count = count; > a.a_reqpage = reqpage; > return (VOP_GETPAGES_APV(vp->v_op, &a)); >} > >struct vop_getpages_async_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > vm_page_t *a_m; > int a_count; > int a_reqpage; > vm_ooffset_t a_offset; > vop_getpages_iodone_t *a_iodone; > void *a_arg; >}; > >extern struct vnodeop_desc vop_getpages_async_desc; > >int VOP_GETPAGES_ASYNC_AP(struct vop_getpages_async_args *); >int VOP_GETPAGES_ASYNC_APV(struct vop_vector *vop, struct vop_getpages_async_args *); > >static __inline int VOP_GETPAGES_ASYNC( > struct vnode *vp, > vm_page_t *m, > int count, > int reqpage, > vm_ooffset_t offset, > vop_getpages_iodone_t *iodone, > void *arg) >{ > struct vop_getpages_async_args a; > > a.a_gen.a_desc = &vop_getpages_async_desc; > a.a_vp = vp; > a.a_m = m; > a.a_count = count; > a.a_reqpage = reqpage; > a.a_offset = offset; > a.a_iodone = iodone; > a.a_arg = arg; > return (VOP_GETPAGES_ASYNC_APV(vp->v_op, &a)); >} > >struct vop_putpages_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > vm_page_t *a_m; > int a_count; > int a_sync; > int *a_rtvals; >}; > >extern struct vnodeop_desc vop_putpages_desc; > >int VOP_PUTPAGES_AP(struct vop_putpages_args *); >int VOP_PUTPAGES_APV(struct vop_vector *vop, struct vop_putpages_args *); > >static __inline int VOP_PUTPAGES( > struct vnode *vp, > vm_page_t *m, > int count, > int sync, > int *rtvals) >{ > struct vop_putpages_args a; > > a.a_gen.a_desc = &vop_putpages_desc; > a.a_vp = vp; > a.a_m = m; > a.a_count = count; > a.a_sync = sync; > a.a_rtvals = rtvals; > return (VOP_PUTPAGES_APV(vp->v_op, &a)); >} > >struct vop_getacl_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > acl_type_t a_type; > struct acl *a_aclp; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_getacl_desc; > >int VOP_GETACL_AP(struct vop_getacl_args *); >int VOP_GETACL_APV(struct vop_vector *vop, struct vop_getacl_args *); > >static __inline int VOP_GETACL( > struct vnode *vp, > acl_type_t type, > struct acl *aclp, > struct ucred *cred, > struct thread *td) >{ > struct vop_getacl_args a; > > a.a_gen.a_desc = &vop_getacl_desc; > a.a_vp = vp; > a.a_type = type; > a.a_aclp = aclp; > a.a_cred = cred; > a.a_td = td; > return (VOP_GETACL_APV(vp->v_op, &a)); >} > >struct vop_setacl_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > acl_type_t a_type; > struct acl *a_aclp; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_setacl_desc; > >int VOP_SETACL_AP(struct vop_setacl_args *); >int VOP_SETACL_APV(struct vop_vector *vop, struct vop_setacl_args *); > >static __inline int VOP_SETACL( > struct vnode *vp, > acl_type_t type, > struct acl *aclp, > struct ucred *cred, > struct thread *td) >{ > struct vop_setacl_args a; > > a.a_gen.a_desc = &vop_setacl_desc; > a.a_vp = vp; > a.a_type = type; > a.a_aclp = aclp; > a.a_cred = cred; > a.a_td = td; > return (VOP_SETACL_APV(vp->v_op, &a)); >} > >struct vop_aclcheck_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > acl_type_t a_type; > struct acl *a_aclp; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_aclcheck_desc; > >int VOP_ACLCHECK_AP(struct vop_aclcheck_args *); >int VOP_ACLCHECK_APV(struct vop_vector *vop, struct vop_aclcheck_args *); > >static __inline int VOP_ACLCHECK( > struct vnode *vp, > acl_type_t type, > struct acl *aclp, > struct ucred *cred, > struct thread *td) >{ > struct vop_aclcheck_args a; > > a.a_gen.a_desc = &vop_aclcheck_desc; > a.a_vp = vp; > a.a_type = type; > a.a_aclp = aclp; > a.a_cred = cred; > a.a_td = td; > return (VOP_ACLCHECK_APV(vp->v_op, &a)); >} > >struct vop_closeextattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_commit; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_closeextattr_desc; > >int VOP_CLOSEEXTATTR_AP(struct vop_closeextattr_args *); >int VOP_CLOSEEXTATTR_APV(struct vop_vector *vop, struct vop_closeextattr_args *); > >static __inline int VOP_CLOSEEXTATTR( > struct vnode *vp, > int commit, > struct ucred *cred, > struct thread *td) >{ > struct vop_closeextattr_args a; > > a.a_gen.a_desc = &vop_closeextattr_desc; > a.a_vp = vp; > a.a_commit = commit; > a.a_cred = cred; > a.a_td = td; > return (VOP_CLOSEEXTATTR_APV(vp->v_op, &a)); >} > >struct vop_getextattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_attrnamespace; > const char *a_name; > struct uio *a_uio; > size_t *a_size; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_getextattr_desc; > >int VOP_GETEXTATTR_AP(struct vop_getextattr_args *); >int VOP_GETEXTATTR_APV(struct vop_vector *vop, struct vop_getextattr_args *); > >static __inline int VOP_GETEXTATTR( > struct vnode *vp, > int attrnamespace, > const char *name, > struct uio *uio, > size_t *size, > struct ucred *cred, > struct thread *td) >{ > struct vop_getextattr_args a; > > a.a_gen.a_desc = &vop_getextattr_desc; > a.a_vp = vp; > a.a_attrnamespace = attrnamespace; > a.a_name = name; > a.a_uio = uio; > a.a_size = size; > a.a_cred = cred; > a.a_td = td; > return (VOP_GETEXTATTR_APV(vp->v_op, &a)); >} > >struct vop_listextattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_attrnamespace; > struct uio *a_uio; > size_t *a_size; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_listextattr_desc; > >int VOP_LISTEXTATTR_AP(struct vop_listextattr_args *); >int VOP_LISTEXTATTR_APV(struct vop_vector *vop, struct vop_listextattr_args *); > >static __inline int VOP_LISTEXTATTR( > struct vnode *vp, > int attrnamespace, > struct uio *uio, > size_t *size, > struct ucred *cred, > struct thread *td) >{ > struct vop_listextattr_args a; > > a.a_gen.a_desc = &vop_listextattr_desc; > a.a_vp = vp; > a.a_attrnamespace = attrnamespace; > a.a_uio = uio; > a.a_size = size; > a.a_cred = cred; > a.a_td = td; > return (VOP_LISTEXTATTR_APV(vp->v_op, &a)); >} > >struct vop_openextattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_openextattr_desc; > >int VOP_OPENEXTATTR_AP(struct vop_openextattr_args *); >int VOP_OPENEXTATTR_APV(struct vop_vector *vop, struct vop_openextattr_args *); > >static __inline int VOP_OPENEXTATTR( > struct vnode *vp, > struct ucred *cred, > struct thread *td) >{ > struct vop_openextattr_args a; > > a.a_gen.a_desc = &vop_openextattr_desc; > a.a_vp = vp; > a.a_cred = cred; > a.a_td = td; > return (VOP_OPENEXTATTR_APV(vp->v_op, &a)); >} > >struct vop_deleteextattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_attrnamespace; > const char *a_name; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_deleteextattr_desc; > >int VOP_DELETEEXTATTR_AP(struct vop_deleteextattr_args *); >int VOP_DELETEEXTATTR_APV(struct vop_vector *vop, struct vop_deleteextattr_args *); > >static __inline int VOP_DELETEEXTATTR( > struct vnode *vp, > int attrnamespace, > const char *name, > struct ucred *cred, > struct thread *td) >{ > struct vop_deleteextattr_args a; > > a.a_gen.a_desc = &vop_deleteextattr_desc; > a.a_vp = vp; > a.a_attrnamespace = attrnamespace; > a.a_name = name; > a.a_cred = cred; > a.a_td = td; > return (VOP_DELETEEXTATTR_APV(vp->v_op, &a)); >} > >struct vop_setextattr_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_attrnamespace; > const char *a_name; > struct uio *a_uio; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_setextattr_desc; > >int VOP_SETEXTATTR_AP(struct vop_setextattr_args *); >int VOP_SETEXTATTR_APV(struct vop_vector *vop, struct vop_setextattr_args *); > >static __inline int VOP_SETEXTATTR( > struct vnode *vp, > int attrnamespace, > const char *name, > struct uio *uio, > struct ucred *cred, > struct thread *td) >{ > struct vop_setextattr_args a; > > a.a_gen.a_desc = &vop_setextattr_desc; > a.a_vp = vp; > a.a_attrnamespace = attrnamespace; > a.a_name = name; > a.a_uio = uio; > a.a_cred = cred; > a.a_td = td; > return (VOP_SETEXTATTR_APV(vp->v_op, &a)); >} > >struct vop_setlabel_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct label *a_label; > struct ucred *a_cred; > struct thread *a_td; >}; > >extern struct vnodeop_desc vop_setlabel_desc; > >int VOP_SETLABEL_AP(struct vop_setlabel_args *); >int VOP_SETLABEL_APV(struct vop_vector *vop, struct vop_setlabel_args *); > >static __inline int VOP_SETLABEL( > struct vnode *vp, > struct label *label, > struct ucred *cred, > struct thread *td) >{ > struct vop_setlabel_args a; > > a.a_gen.a_desc = &vop_setlabel_desc; > a.a_vp = vp; > a.a_label = label; > a.a_cred = cred; > a.a_td = td; > return (VOP_SETLABEL_APV(vp->v_op, &a)); >} > >struct vop_vptofh_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct fid *a_fhp; >}; > >extern struct vnodeop_desc vop_vptofh_desc; > >int VOP_VPTOFH_AP(struct vop_vptofh_args *); >int VOP_VPTOFH_APV(struct vop_vector *vop, struct vop_vptofh_args *); > >static __inline int VOP_VPTOFH( > struct vnode *vp, > struct fid *fhp) >{ > struct vop_vptofh_args a; > > a.a_gen.a_desc = &vop_vptofh_desc; > a.a_vp = vp; > a.a_fhp = fhp; > return (VOP_VPTOFH_APV(vp->v_op, &a)); >} > >struct vop_vptocnp_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct vnode **a_vpp; > struct ucred *a_cred; > char *a_buf; > int *a_buflen; >}; > >extern struct vnodeop_desc vop_vptocnp_desc; > >int VOP_VPTOCNP_AP(struct vop_vptocnp_args *); >int VOP_VPTOCNP_APV(struct vop_vector *vop, struct vop_vptocnp_args *); > >static __inline int VOP_VPTOCNP( > struct vnode *vp, > struct vnode **vpp, > struct ucred *cred, > char *buf, > int *buflen) >{ > struct vop_vptocnp_args a; > > a.a_gen.a_desc = &vop_vptocnp_desc; > a.a_vp = vp; > a.a_vpp = vpp; > a.a_cred = cred; > a.a_buf = buf; > a.a_buflen = buflen; > return (VOP_VPTOCNP_APV(vp->v_op, &a)); >} > >struct vop_allocate_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > off_t *a_offset; > off_t *a_len; >}; > >extern struct vnodeop_desc vop_allocate_desc; > >int VOP_ALLOCATE_AP(struct vop_allocate_args *); >int VOP_ALLOCATE_APV(struct vop_vector *vop, struct vop_allocate_args *); > >static __inline int VOP_ALLOCATE( > struct vnode *vp, > off_t *offset, > off_t *len) >{ > struct vop_allocate_args a; > > a.a_gen.a_desc = &vop_allocate_desc; > a.a_vp = vp; > a.a_offset = offset; > a.a_len = len; > return (VOP_ALLOCATE_APV(vp->v_op, &a)); >} > >struct vop_advise_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > off_t a_start; > off_t a_end; > int a_advice; >}; > >extern struct vnodeop_desc vop_advise_desc; > >int VOP_ADVISE_AP(struct vop_advise_args *); >int VOP_ADVISE_APV(struct vop_vector *vop, struct vop_advise_args *); > >static __inline int VOP_ADVISE( > struct vnode *vp, > off_t start, > off_t end, > int advice) >{ > struct vop_advise_args a; > > a.a_gen.a_desc = &vop_advise_desc; > a.a_vp = vp; > a.a_start = start; > a.a_end = end; > a.a_advice = advice; > return (VOP_ADVISE_APV(vp->v_op, &a)); >} > >struct vop_unp_bind_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct socket *a_socket; >}; > >extern struct vnodeop_desc vop_unp_bind_desc; > >int VOP_UNP_BIND_AP(struct vop_unp_bind_args *); >int VOP_UNP_BIND_APV(struct vop_vector *vop, struct vop_unp_bind_args *); > >static __inline int VOP_UNP_BIND( > struct vnode *vp, > struct socket *socket) >{ > struct vop_unp_bind_args a; > > a.a_gen.a_desc = &vop_unp_bind_desc; > a.a_vp = vp; > a.a_socket = socket; > return (VOP_UNP_BIND_APV(vp->v_op, &a)); >} > >struct vop_unp_connect_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > struct socket **a_socket; >}; > >extern struct vnodeop_desc vop_unp_connect_desc; > >int VOP_UNP_CONNECT_AP(struct vop_unp_connect_args *); >int VOP_UNP_CONNECT_APV(struct vop_vector *vop, struct vop_unp_connect_args *); > >static __inline int VOP_UNP_CONNECT( > struct vnode *vp, > struct socket **socket) >{ > struct vop_unp_connect_args a; > > a.a_gen.a_desc = &vop_unp_connect_desc; > a.a_vp = vp; > a.a_socket = socket; > return (VOP_UNP_CONNECT_APV(vp->v_op, &a)); >} > >struct vop_unp_detach_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_unp_detach_desc; > >int VOP_UNP_DETACH_AP(struct vop_unp_detach_args *); >int VOP_UNP_DETACH_APV(struct vop_vector *vop, struct vop_unp_detach_args *); > >static __inline int VOP_UNP_DETACH( > struct vnode *vp) >{ > struct vop_unp_detach_args a; > > a.a_gen.a_desc = &vop_unp_detach_desc; > a.a_vp = vp; > return (VOP_UNP_DETACH_APV(vp->v_op, &a)); >} > >struct vop_is_text_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_is_text_desc; > >int VOP_IS_TEXT_AP(struct vop_is_text_args *); >int VOP_IS_TEXT_APV(struct vop_vector *vop, struct vop_is_text_args *); > >static __inline int VOP_IS_TEXT( > struct vnode *vp) >{ > struct vop_is_text_args a; > > a.a_gen.a_desc = &vop_is_text_desc; > a.a_vp = vp; > return (VOP_IS_TEXT_APV(vp->v_op, &a)); >} > >struct vop_set_text_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_set_text_desc; > >int VOP_SET_TEXT_AP(struct vop_set_text_args *); >int VOP_SET_TEXT_APV(struct vop_vector *vop, struct vop_set_text_args *); > >static __inline int VOP_SET_TEXT( > struct vnode *vp) >{ > struct vop_set_text_args a; > > a.a_gen.a_desc = &vop_set_text_desc; > a.a_vp = vp; > return (VOP_SET_TEXT_APV(vp->v_op, &a)); >} > >struct vop_unset_text_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_unset_text_desc; > >int VOP_UNSET_TEXT_AP(struct vop_unset_text_args *); >int VOP_UNSET_TEXT_APV(struct vop_vector *vop, struct vop_unset_text_args *); > >static __inline int VOP_UNSET_TEXT( > struct vnode *vp) >{ > struct vop_unset_text_args a; > > a.a_gen.a_desc = &vop_unset_text_desc; > a.a_vp = vp; > return (VOP_UNSET_TEXT_APV(vp->v_op, &a)); >} > >struct vop_get_writecount_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int *a_writecount; >}; > >extern struct vnodeop_desc vop_get_writecount_desc; > >int VOP_GET_WRITECOUNT_AP(struct vop_get_writecount_args *); >int VOP_GET_WRITECOUNT_APV(struct vop_vector *vop, struct vop_get_writecount_args *); > >static __inline int VOP_GET_WRITECOUNT( > struct vnode *vp, > int *writecount) >{ > struct vop_get_writecount_args a; > > a.a_gen.a_desc = &vop_get_writecount_desc; > a.a_vp = vp; > a.a_writecount = writecount; > return (VOP_GET_WRITECOUNT_APV(vp->v_op, &a)); >} > >struct vop_add_writecount_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; > int a_inc; >}; > >extern struct vnodeop_desc vop_add_writecount_desc; > >int VOP_ADD_WRITECOUNT_AP(struct vop_add_writecount_args *); >int VOP_ADD_WRITECOUNT_APV(struct vop_vector *vop, struct vop_add_writecount_args *); > >static __inline int VOP_ADD_WRITECOUNT( > struct vnode *vp, > int inc) >{ > struct vop_add_writecount_args a; > > a.a_gen.a_desc = &vop_add_writecount_desc; > a.a_vp = vp; > a.a_inc = inc; > return (VOP_ADD_WRITECOUNT_APV(vp->v_op, &a)); >} > >struct vop_spare1_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_spare1_desc; > >int VOP_SPARE1_AP(struct vop_spare1_args *); >int VOP_SPARE1_APV(struct vop_vector *vop, struct vop_spare1_args *); > >static __inline int VOP_SPARE1( > struct vnode *vp) >{ > struct vop_spare1_args a; > > a.a_gen.a_desc = &vop_spare1_desc; > a.a_vp = vp; > return (VOP_SPARE1_APV(vp->v_op, &a)); >} > >struct vop_spare2_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_spare2_desc; > >int VOP_SPARE2_AP(struct vop_spare2_args *); >int VOP_SPARE2_APV(struct vop_vector *vop, struct vop_spare2_args *); > >static __inline int VOP_SPARE2( > struct vnode *vp) >{ > struct vop_spare2_args a; > > a.a_gen.a_desc = &vop_spare2_desc; > a.a_vp = vp; > return (VOP_SPARE2_APV(vp->v_op, &a)); >} > >struct vop_spare3_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_spare3_desc; > >int VOP_SPARE3_AP(struct vop_spare3_args *); >int VOP_SPARE3_APV(struct vop_vector *vop, struct vop_spare3_args *); > >static __inline int VOP_SPARE3( > struct vnode *vp) >{ > struct vop_spare3_args a; > > a.a_gen.a_desc = &vop_spare3_desc; > a.a_vp = vp; > return (VOP_SPARE3_APV(vp->v_op, &a)); >} > >struct vop_spare4_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_spare4_desc; > >int VOP_SPARE4_AP(struct vop_spare4_args *); >int VOP_SPARE4_APV(struct vop_vector *vop, struct vop_spare4_args *); > >static __inline int VOP_SPARE4( > struct vnode *vp) >{ > struct vop_spare4_args a; > > a.a_gen.a_desc = &vop_spare4_desc; > a.a_vp = vp; > return (VOP_SPARE4_APV(vp->v_op, &a)); >} > >struct vop_spare5_args { > struct vop_generic_args a_gen; > struct vnode *a_vp; >}; > >extern struct vnodeop_desc vop_spare5_desc; > >int VOP_SPARE5_AP(struct vop_spare5_args *); >int VOP_SPARE5_APV(struct vop_vector *vop, struct vop_spare5_args *); > >static __inline int VOP_SPARE5( > struct vnode *vp) >{ > struct vop_spare5_args a; > > a.a_gen.a_desc = &vop_spare5_desc; > a.a_vp = vp; > return (VOP_SPARE5_APV(vp->v_op, &a)); >} > ># 579 "/usr/src/sys/sys/vnode.h" 2 > >/* vn_open_flags */ >#define VN_OPEN_NOAUDIT 0x00000001 >#define VN_OPEN_NOCAPCHECK 0x00000002 >#define VN_OPEN_NAMECACHE 0x00000004 > >/* > * Public vnode manipulation functions. > */ >struct componentname; >struct file; >struct mount; >struct nameidata; >struct ostat; >struct thread; >struct proc; >struct stat; >struct nstat; >struct ucred; >struct uio; >struct vattr; >struct vnode; > >typedef int (*vn_get_ino_t)(struct mount *, void *, int, struct vnode **); > >/* cache_* may belong in namei.h. */ >#define cache_enter(dvp, vp, cnp) \ > cache_enter_time(dvp, vp, cnp, NULL, NULL) >void cache_enter_time(struct vnode *dvp, struct vnode *vp, > struct componentname *cnp, struct timespec *tsp, > struct timespec *dtsp); >int cache_lookup(struct vnode *dvp, struct vnode **vpp, > struct componentname *cnp, struct timespec *tsp, int *ticksp); >void cache_purge(struct vnode *vp); >void cache_purge_negative(struct vnode *vp); >void cache_purgevfs(struct mount *mp); >int change_dir(struct vnode *vp, struct thread *td); >int change_root(struct vnode *vp, struct thread *td); >void cvtstat(struct stat *st, struct ostat *ost); >void cvtnstat(struct stat *sb, struct nstat *nsb); >int getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops, > struct vnode **vpp); >void getnewvnode_reserve(u_int count); >void getnewvnode_drop_reserve(void); >int insmntque1(struct vnode *vp, struct mount *mp, > void (*dtr)(struct vnode *, void *), void *dtr_arg); >int insmntque(struct vnode *vp, struct mount *mp); >u_quad_t init_va_filerev(void); >int speedup_syncer(void); >int vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, > u_int *buflen); >#define textvp_fullpath(p, rb, rfb) \ > vn_fullpath(FIRST_THREAD_IN_PROC(p), (p)->p_textvp, rb, rfb) >int vn_fullpath(struct thread *td, struct vnode *vn, > char **retbuf, char **freebuf); >int vn_fullpath_global(struct thread *td, struct vnode *vn, > char **retbuf, char **freebuf); >struct vnode * > vn_dir_dd_ino(struct vnode *vp); >int vn_commname(struct vnode *vn, char *buf, u_int buflen); >int vn_path_to_global_path(struct thread *td, struct vnode *vp, > char *path, u_int pathlen); >int vaccess(enum vtype type, mode_t file_mode, uid_t file_uid, > gid_t file_gid, accmode_t accmode, struct ucred *cred, > int *privused); >int vaccess_acl_nfs4(enum vtype type, uid_t file_uid, gid_t file_gid, > struct acl *aclp, accmode_t accmode, struct ucred *cred, > int *privused); >int vaccess_acl_posix1e(enum vtype type, uid_t file_uid, > gid_t file_gid, struct acl *acl, accmode_t accmode, > struct ucred *cred, int *privused); >void vattr_null(struct vattr *vap); >int vcount(struct vnode *vp); >void vdrop(struct vnode *); >void vdropl(struct vnode *); >int vflush(struct mount *mp, int rootrefs, int flags, struct thread *td); >int vget(struct vnode *vp, int lockflag, struct thread *td); >void vgone(struct vnode *vp); >void vhold(struct vnode *); >void vholdl(struct vnode *); >void vinactive(struct vnode *, struct thread *); >int vinvalbuf(struct vnode *vp, int save, int slpflag, int slptimeo); >int vtruncbuf(struct vnode *vp, struct ucred *cred, off_t length, > int blksize); >void vunref(struct vnode *); >void vn_printf(struct vnode *vp, const char *fmt, ...) __printflike(2,3); >#define vprint(label, vp) vn_printf((vp), "%s\n", (label)) >int vrecycle(struct vnode *vp); >int vn_bmap_seekhole(struct vnode *vp, u_long cmd, off_t *off, > struct ucred *cred); >int vn_close(struct vnode *vp, > int flags, struct ucred *file_cred, struct thread *td); >void vn_finished_write(struct mount *mp); >void vn_finished_secondary_write(struct mount *mp); >int vn_isdisk(struct vnode *vp, int *errp); >int _vn_lock(struct vnode *vp, int flags, char *file, int line); >#define vn_lock(vp, flags) _vn_lock(vp, flags, __FILE__, __LINE__) >int vn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp); >int vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, > u_int vn_open_flags, struct ucred *cred, struct file *fp); >int vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, > struct thread *td, struct file *fp); >void vn_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end); >int vn_pollrecord(struct vnode *vp, struct thread *p, int events); >int vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, > int len, off_t offset, enum uio_seg segflg, int ioflg, > struct ucred *active_cred, struct ucred *file_cred, ssize_t *aresid, > struct thread *td); >int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, void *base, > size_t len, off_t offset, enum uio_seg segflg, int ioflg, > struct ucred *active_cred, struct ucred *file_cred, size_t *aresid, > struct thread *td); >int vn_rlimit_fsize(const struct vnode *vn, const struct uio *uio, > const struct thread *td); >int vn_stat(struct vnode *vp, struct stat *sb, struct ucred *active_cred, > struct ucred *file_cred, struct thread *td); >int vn_start_write(struct vnode *vp, struct mount **mpp, int flags); >int vn_start_secondary_write(struct vnode *vp, struct mount **mpp, > int flags); >int vn_writechk(struct vnode *vp); >int vn_extattr_get(struct vnode *vp, int ioflg, int attrnamespace, > const char *attrname, int *buflen, char *buf, struct thread *td); >int vn_extattr_set(struct vnode *vp, int ioflg, int attrnamespace, > const char *attrname, int buflen, char *buf, struct thread *td); >int vn_extattr_rm(struct vnode *vp, int ioflg, int attrnamespace, > const char *attrname, struct thread *td); >int vn_vget_ino(struct vnode *vp, ino_t ino, int lkflags, > struct vnode **rvp); >int vn_vget_ino_gen(struct vnode *vp, vn_get_ino_t alloc, > void *alloc_arg, int lkflags, struct vnode **rvp); >int vn_utimes_perm(struct vnode *vp, struct vattr *vap, > struct ucred *cred, struct thread *td); > >int vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio); >int vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize, > struct uio *uio); > >#define vn_rangelock_unlock(vp, cookie) \ > rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp)) >#define vn_rangelock_unlock_range(vp, cookie, start, end) \ > rangelock_unlock_range(&(vp)->v_rl, (cookie), (start), (end), \ > VI_MTX(vp)) >#define vn_rangelock_rlock(vp, start, end) \ > rangelock_rlock(&(vp)->v_rl, (start), (end), VI_MTX(vp)) >#define vn_rangelock_wlock(vp, start, end) \ > rangelock_wlock(&(vp)->v_rl, (start), (end), VI_MTX(vp)) > >int vfs_cache_lookup(struct vop_lookup_args *ap); >void vfs_timestamp(struct timespec *); >void vfs_write_resume(struct mount *mp, int flags); >int vfs_write_suspend(struct mount *mp, int flags); >int vfs_write_suspend_umnt(struct mount *mp); >int vop_stdbmap(struct vop_bmap_args *); >int vop_stdfsync(struct vop_fsync_args *); >int vop_stdgetwritemount(struct vop_getwritemount_args *); >int vop_stdgetpages(struct vop_getpages_args *); >int vop_stdinactive(struct vop_inactive_args *); >int vop_stdislocked(struct vop_islocked_args *); >int vop_stdkqfilter(struct vop_kqfilter_args *); >int vop_stdlock(struct vop_lock1_args *); >int vop_stdputpages(struct vop_putpages_args *); >int vop_stdunlock(struct vop_unlock_args *); >int vop_nopoll(struct vop_poll_args *); >int vop_stdaccess(struct vop_access_args *ap); >int vop_stdaccessx(struct vop_accessx_args *ap); >int vop_stdadvise(struct vop_advise_args *ap); >int vop_stdadvlock(struct vop_advlock_args *ap); >int vop_stdadvlockasync(struct vop_advlockasync_args *ap); >int vop_stdadvlockpurge(struct vop_advlockpurge_args *ap); >int vop_stdallocate(struct vop_allocate_args *ap); >int vop_stdpathconf(struct vop_pathconf_args *); >int vop_stdpoll(struct vop_poll_args *); >int vop_stdvptocnp(struct vop_vptocnp_args *ap); >int vop_stdvptofh(struct vop_vptofh_args *ap); >int vop_stdunp_bind(struct vop_unp_bind_args *ap); >int vop_stdunp_connect(struct vop_unp_connect_args *ap); >int vop_stdunp_detach(struct vop_unp_detach_args *ap); >int vop_eopnotsupp(struct vop_generic_args *ap); >int vop_ebadf(struct vop_generic_args *ap); >int vop_einval(struct vop_generic_args *ap); >int vop_enoent(struct vop_generic_args *ap); >int vop_enotty(struct vop_generic_args *ap); >int vop_null(struct vop_generic_args *ap); >int vop_panic(struct vop_generic_args *ap); >int dead_poll(struct vop_poll_args *ap); >int dead_read(struct vop_read_args *ap); >int dead_write(struct vop_write_args *ap); > >/* These are called from within the actual VOPS. */ >void vop_create_post(void *a, int rc); >void vop_deleteextattr_post(void *a, int rc); >void vop_link_post(void *a, int rc); >void vop_lock_pre(void *a); >void vop_lock_post(void *a, int rc); >void vop_lookup_post(void *a, int rc); >void vop_lookup_pre(void *a); >void vop_mkdir_post(void *a, int rc); >void vop_mknod_post(void *a, int rc); >void vop_remove_post(void *a, int rc); >void vop_rename_post(void *a, int rc); >void vop_rename_pre(void *a); >void vop_rmdir_post(void *a, int rc); >void vop_setattr_post(void *a, int rc); >void vop_setextattr_post(void *a, int rc); >void vop_strategy_pre(void *a); >void vop_symlink_post(void *a, int rc); >void vop_unlock_post(void *a, int rc); >void vop_unlock_pre(void *a); > >void vop_rename_fail(struct vop_rename_args *ap); > >#define VOP_WRITE_PRE(ap) \ > struct vattr va; \ > int error, osize, ooffset, noffset; \ > \ > osize = ooffset = noffset = 0; \ > if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \ > error = VOP_GETATTR((ap)->a_vp, &va, (ap)->a_cred); \ > if (error) \ > return (error); \ > ooffset = (ap)->a_uio->uio_offset; \ > osize = va.va_size; \ > } > >#define VOP_WRITE_POST(ap, ret) \ > noffset = (ap)->a_uio->uio_offset; \ > if (noffset > ooffset && !VN_KNLIST_EMPTY((ap)->a_vp)) { \ > VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE \ > | (noffset > osize ? NOTE_EXTEND : 0)); \ > } > >#define VOP_LOCK(vp, flags) VOP_LOCK1(vp, flags, __FILE__, __LINE__) > > >void vput(struct vnode *vp); >void vrele(struct vnode *vp); >void vref(struct vnode *vp); >int vrefcnt(struct vnode *vp); >void v_addpollinfo(struct vnode *vp); > >int vnode_create_vobject(struct vnode *vp, off_t size, struct thread *td); >void vnode_destroy_vobject(struct vnode *vp); > >extern struct vop_vector fifo_specops; >extern struct vop_vector dead_vnodeops; >extern struct vop_vector default_vnodeops; >extern struct vop_vector devfs_specops; > >#define VOP_PANIC ((void*)(uintptr_t)vop_panic) >#define VOP_NULL ((void*)(uintptr_t)vop_null) >#define VOP_EBADF ((void*)(uintptr_t)vop_ebadf) >#define VOP_ENOTTY ((void*)(uintptr_t)vop_enotty) >#define VOP_EINVAL ((void*)(uintptr_t)vop_einval) >#define VOP_ENOENT ((void*)(uintptr_t)vop_enoent) >#define VOP_EOPNOTSUPP ((void*)(uintptr_t)vop_eopnotsupp) > >/* fifo_vnops.c */ >int fifo_printinfo(struct vnode *); > >/* vfs_hash.c */ >typedef int vfs_hash_cmp_t(struct vnode *vp, void *arg); > >int vfs_hash_get(const struct mount *mp, u_int hash, int flags, struct thread *td, struct vnode **vpp, vfs_hash_cmp_t *fn, void *arg); >u_int vfs_hash_index(struct vnode *vp); >int vfs_hash_insert(struct vnode *vp, u_int hash, int flags, struct thread *td, struct vnode **vpp, vfs_hash_cmp_t *fn, void *arg); >void vfs_hash_rehash(struct vnode *vp, u_int hash); >void vfs_hash_remove(struct vnode *vp); > >int vfs_kqfilter(struct vop_kqfilter_args *); >void vfs_mark_atime(struct vnode *vp, struct ucred *cred); >struct dirent; >int vfs_read_dirent(struct vop_readdir_args *ap, struct dirent *dp, off_t off); > >int vfs_unixify_accmode(accmode_t *accmode); > >void vfs_unp_reclaim(struct vnode *vp); > >int setfmode(struct thread *td, struct ucred *cred, struct vnode *vp, int mode); >int setfown(struct thread *td, struct ucred *cred, struct vnode *vp, uid_t uid, > gid_t gid); >int vn_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, > struct thread *td); >int vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, > struct thread *td); > >#endif /* _KERNEL */ ># 865 "/usr/src/sys/sys/vnode.h" > >#endif /* !_SYS_VNODE_H_ */ ># 867 "/usr/src/sys/sys/vnode.h" ># 67 "/usr/src/sys/kern/kern_cons.c" 2 > >#if 0 /* expanded by -frewrite-includes */ >#include <ddb/ddb.h> >#endif /* expanded by -frewrite-includes */ ># 68 "/usr/src/sys/kern/kern_cons.c" ># 1 "/usr/src/sys/ddb/ddb.h" 1 >/*- > * Copyright (c) 1993, Garrett A. Wollman. > * Copyright (c) 1993, University of Vermont and State Agricultural College. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: head/sys/ddb/ddb.h 272098 2014-09-25 08:28:10Z royger $ > */ > >/* > * Necessary declarations for the `ddb' kernel debugger. > */ > >#ifndef _DDB_DDB_H_ >#define _DDB_DDB_H_ > >#ifdef SYSCTL_DECL >SYSCTL_DECL(_debug_ddb); >#endif ># 43 "/usr/src/sys/ddb/ddb.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/db_machdep.h> /* type definitions */ >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/sys/ddb/ddb.h" ># 1 "./machine/db_machdep.h" 1 >/*- > * Mach Operating System > * Copyright (c) 1991,1990 Carnegie Mellon University > * All Rights Reserved. > * > * Permission to use, copy, modify and distribute this software and its > * documentation is hereby granted, provided that both the copyright > * notice and this permission notice appear in all copies of the > * software, derivative works or modified versions, and any portions > * thereof, and that both notices appear in supporting documentation. > * > * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" > * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR > * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. > * > * Carnegie Mellon requests users of this software to return to > * > * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU > * School of Computer Science > * Carnegie Mellon University > * Pittsburgh PA 15213-3890 > * > * any improvements or extensions that they make and grant Carnegie Mellon > * the rights to redistribute these changes. > * > * $FreeBSD: head/sys/amd64/include/db_machdep.h 139731 2005-01-05 20:17:21Z imp $ > */ > >#ifndef _MACHINE_DB_MACHDEP_H_ >#define _MACHINE_DB_MACHDEP_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/frame.h> >#endif /* expanded by -frewrite-includes */ ># 32 "./machine/db_machdep.h" ># 1 "./machine/frame.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/frame.h 247047 2013-02-20 17:39:52Z kib $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/frame.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/frame.h" ># 7 "./machine/frame.h" ># 33 "./machine/db_machdep.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/trap.h> >#endif /* expanded by -frewrite-includes */ ># 33 "./machine/db_machdep.h" ># 1 "./machine/trap.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: head/sys/amd64/include/trap.h 232492 2012-03-04 14:12:57Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/trap.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/trap.h" ># 7 "./machine/trap.h" ># 34 "./machine/db_machdep.h" 2 > >typedef vm_offset_t db_addr_t; /* address - unsigned */ >typedef long db_expr_t; /* expression - signed */ > >#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_rip) > >#define BKPT_INST 0xcc /* breakpoint instruction */ >#define BKPT_SIZE (1) /* size of breakpoint inst */ >#define BKPT_SET(inst) (BKPT_INST) > >#define BKPT_SKIP \ >do { \ > kdb_frame->tf_rip += 1; \ > kdb_thrctx->pcb_rip += 1; \ >} while(0) > >#define FIXUP_PC_AFTER_BREAK \ >do { \ > kdb_frame->tf_rip -= 1; \ > kdb_thrctx->pcb_rip -= 1; \ >} while(0); > >#define db_clear_single_step kdb_cpu_clear_singlestep >#define db_set_single_step kdb_cpu_set_singlestep > >#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) >/* > * Watchpoints are not supported. The debug exception type is in %dr6 > * and not yet in the args to this macro. > */ >#define IS_WATCHPOINT_TRAP(type, code) 0 > >#define I_CALL 0xe8 >#define I_CALLI 0xff >#define I_RET 0xc3 >#define I_IRET 0xcf > >#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) >#define inst_return(ins) (((ins)&0xff) == I_RET) >#define inst_call(ins) (((ins)&0xff) == I_CALL || \ > (((ins)&0xff) == I_CALLI && \ > ((ins)&0x3800) == 0x1000)) >#define inst_load(ins) 0 >#define inst_store(ins) 0 > >/* > * There no interesting addresses below _kstack = 0xefbfe000. There > * are small absolute values for GUPROF, but we don't want to see them. > * Treat "negative" addresses below _kstack as non-small to allow for > * future reductions of _kstack and to avoid sign extension problems. > * > * There is one interesting symbol above -db_maxoff = 0xffff0000, > * namely _APTD = 0xfffff000. Accepting this would mess up the > * printing of small negative offsets. The next largest symbol is > * _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is > * set to >= 0x400000 - (max stack offset)). > */ >#define DB_SMALL_VALUE_MAX 0x7fffffff >#define DB_SMALL_VALUE_MIN (-0x400001) > >#endif /* !_MACHINE_DB_MACHDEP_H_ */ ># 95 "./machine/db_machdep.h" ># 45 "/usr/src/sys/ddb/ddb.h" 2 > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> /* LIST_* */ >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/sys/ddb/ddb.h" ># 47 "/usr/src/sys/ddb/ddb.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/kernel.h> /* SYSINIT */ >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/sys/ddb/ddb.h" ># 48 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_MAXARGS >#define DB_MAXARGS 10 >#endif ># 52 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_MAXLINE >#define DB_MAXLINE 120 >#endif ># 56 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_MAXSCRIPTS >#define DB_MAXSCRIPTS 8 >#endif ># 60 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_MAXSCRIPTNAME >#define DB_MAXSCRIPTNAME 32 >#endif ># 64 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_MAXSCRIPTLEN >#define DB_MAXSCRIPTLEN 128 >#endif ># 68 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_MAXSCRIPTRECURSION >#define DB_MAXSCRIPTRECURSION 3 >#endif ># 72 "/usr/src/sys/ddb/ddb.h" > >#ifndef DB_CALL >#define DB_CALL db_fncall_generic >#else ># 76 "/usr/src/sys/ddb/ddb.h" >int DB_CALL(db_expr_t, db_expr_t *, int, db_expr_t[]); >#endif ># 78 "/usr/src/sys/ddb/ddb.h" > >/* > * Extern variables to set the address and size of the symtab and strtab. > * Most users should use db_fetch_symtab in order to set them from the > * boot loader provided values. > */ >extern vm_offset_t ksymtab, kstrtab, ksymtab_size; > >/* > * There are three "command tables": > * - One for simple commands; a list of these is displayed > * by typing 'help' at the debugger prompt. > * - One for sub-commands of 'show'; to see this type 'show' > * without any arguments. > * - The last one for sub-commands of 'show all'; type 'show all' > * without any argument to get a list. > */ >struct command; >LIST_HEAD(command_table, command); >extern struct command_table db_cmd_table; >extern struct command_table db_show_table; >extern struct command_table db_show_all_table; > >/* > * Type signature for a function implementing a ddb command. > */ >typedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count, > char *modif); > >/* > * Command table entry. > */ >struct command { > char * name; /* command name */ > db_cmdfcn_t *fcn; /* function to call */ > int flag; /* extra info: */ >#define CS_OWN 0x1 /* non-standard syntax */ >#define CS_MORE 0x2 /* standard syntax, but may have other words > * at end */ >#define CS_SET_DOT 0x100 /* set dot after command */ > struct command_table *more; /* another level of command */ > LIST_ENTRY(command) next; /* next entry in the command table */ >}; > >/* > * Arrange for the specified ddb command to be defined and > * bound to the specified function. Commands can be defined > * in modules in which case they will be available only when > * the module is loaded. > */ >#define _DB_SET(_suffix, _name, _func, list, _flag, _more) \ >static struct command __CONCAT(_name,_suffix) = { \ > .name = __STRING(_name), \ > .fcn = _func, \ > .flag = _flag, \ > .more = _more \ >}; \ >static void __CONCAT(__CONCAT(_name,_suffix),_add)(void *arg __unused) \ > { db_command_register(&list, &__CONCAT(_name,_suffix)); } \ >SYSINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \ > __CONCAT(__CONCAT(_name,_suffix),_add), NULL); \ >static void __CONCAT(__CONCAT(_name,_suffix),_del)(void *arg __unused) \ > { db_command_unregister(&list, &__CONCAT(_name,_suffix)); } \ >SYSUNINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \ > __CONCAT(__CONCAT(_name,_suffix),_del), NULL); > >/* > * Like _DB_SET but also create the function declaration which > * must be followed immediately by the body; e.g. > * _DB_FUNC(_cmd, panic, db_panic, db_cmd_table, 0, NULL) > * { > * ...panic implementation... > * } > * > * This macro is mostly used to define commands placed in one of > * the ddb command tables; see DB_COMMAND, etc. below. > */ >#define _DB_FUNC(_suffix, _name, _func, list, _flag, _more) \ >static db_cmdfcn_t _func; \ >_DB_SET(_suffix, _name, _func, list, _flag, _more); \ >static void \ >_func(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif) > >/* common idom provided for backwards compatibility */ >#define DB_FUNC(_name, _func, list, _flag, _more) \ > _DB_FUNC(_cmd, _name, _func, list, _flag, _more) > >#define DB_COMMAND(cmd_name, func_name) \ > _DB_FUNC(_cmd, cmd_name, func_name, db_cmd_table, 0, NULL) >#define DB_ALIAS(alias_name, func_name) \ > _DB_SET(_cmd, alias_name, func_name, db_cmd_table, 0, NULL) >#define DB_SHOW_COMMAND(cmd_name, func_name) \ > _DB_FUNC(_show, cmd_name, func_name, db_show_table, 0, NULL) >#define DB_SHOW_ALIAS(alias_name, func_name) \ > _DB_SET(_show, alias_name, func_name, db_show_table, 0, NULL) >#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \ > _DB_FUNC(_show_all, cmd_name, func_name, db_show_all_table, 0, NULL) >#define DB_SHOW_ALL_ALIAS(alias_name, func_name) \ > _DB_SET(_show_all, alias_name, func_name, db_show_all_table, 0, NULL) > >extern db_expr_t db_maxoff; >extern int db_indent; >extern int db_inst_count; >extern int db_load_count; >extern int db_store_count; >extern volatile int db_pager_quit; >extern db_expr_t db_radix; >extern db_expr_t db_max_width; >extern db_expr_t db_tab_stop_width; >extern db_expr_t db_lines_per_page; > >struct thread; >struct vm_map; > >void db_check_interrupt(void); >void db_clear_watchpoints(void); >db_addr_t db_disasm(db_addr_t loc, boolean_t altfmt); > /* instruction disassembler */ >void db_error(const char *s); >int db_expression(db_expr_t *valuep); >int db_get_variable(db_expr_t *valuep); >void db_iprintf(const char *,...) __printflike(1, 2); >struct proc *db_lookup_proc(db_expr_t addr); >struct thread *db_lookup_thread(db_expr_t addr, boolean_t check_pid); >struct vm_map *db_map_addr(vm_offset_t); >boolean_t db_map_current(struct vm_map *); >boolean_t db_map_equal(struct vm_map *, struct vm_map *); >int db_md_set_watchpoint(db_expr_t addr, db_expr_t size); >int db_md_clr_watchpoint(db_expr_t addr, db_expr_t size); >void db_md_list_watchpoints(void); >void db_print_loc_and_inst(db_addr_t loc); >void db_print_thread(void); >int db_printf(const char *fmt, ...) __printflike(1, 2); >int db_read_bytes(vm_offset_t addr, size_t size, char *data); > /* machine-dependent */ >int db_readline(char *lstart, int lsize); >void db_restart_at_pc(boolean_t watchpt); >int db_set_variable(db_expr_t value); >void db_set_watchpoints(void); >void db_skip_to_eol(void); >boolean_t db_stop_at_pc(boolean_t *is_breakpoint); >#define db_strcpy strcpy >void db_trace_self(void); >int db_trace_thread(struct thread *, int); >int db_value_of_name(const char *name, db_expr_t *valuep); >int db_value_of_name_pcpu(const char *name, db_expr_t *valuep); >int db_value_of_name_vnet(const char *name, db_expr_t *valuep); >int db_write_bytes(vm_offset_t addr, size_t size, char *data); >void db_command_register(struct command_table *, struct command *); >void db_command_unregister(struct command_table *, struct command *); >int db_fetch_ksymtab(vm_offset_t ksym_start, vm_offset_t ksym_end); > >db_cmdfcn_t db_breakpoint_cmd; >db_cmdfcn_t db_capture_cmd; >db_cmdfcn_t db_continue_cmd; >db_cmdfcn_t db_delete_cmd; >db_cmdfcn_t db_deletehwatch_cmd; >db_cmdfcn_t db_deletewatch_cmd; >db_cmdfcn_t db_examine_cmd; >db_cmdfcn_t db_findstack_cmd; >db_cmdfcn_t db_hwatchpoint_cmd; >db_cmdfcn_t db_listbreak_cmd; >db_cmdfcn_t db_scripts_cmd; >db_cmdfcn_t db_print_cmd; >db_cmdfcn_t db_ps; >db_cmdfcn_t db_run_cmd; >db_cmdfcn_t db_script_cmd; >db_cmdfcn_t db_search_cmd; >db_cmdfcn_t db_set_cmd; >db_cmdfcn_t db_set_thread; >db_cmdfcn_t db_show_regs; >db_cmdfcn_t db_show_threads; >db_cmdfcn_t db_single_step_cmd; >db_cmdfcn_t db_textdump_cmd; >db_cmdfcn_t db_trace_until_call_cmd; >db_cmdfcn_t db_trace_until_matching_cmd; >db_cmdfcn_t db_unscript_cmd; >db_cmdfcn_t db_watchpoint_cmd; >db_cmdfcn_t db_write_cmd; > >/* > * Interface between DDB and the DDB output capture facility. > */ >struct dumperinfo; >void db_capture_dump(struct dumperinfo *di); >void db_capture_enterpager(void); >void db_capture_exitpager(void); >void db_capture_write(char *buffer, u_int buflen); >void db_capture_writech(char ch); > >/* > * Interface between DDB and the script facility. > */ >void db_script_kdbenter(const char *eventname); /* KDB enter event. */ > >/* > * Interface between DDB and the textdump facility. > * > * Text dump blocks are of a fixed size; textdump_block_buffer is a > * statically allocated buffer that code interacting with textdumps can use > * to prepare and hold a pending block in when calling writenextblock(). > */ >#define TEXTDUMP_BLOCKSIZE 512 >extern char textdump_block_buffer[TEXTDUMP_BLOCKSIZE]; > >void textdump_mkustar(char *block_buffer, const char *filename, > u_int size); >void textdump_restoreoff(off_t offset); >void textdump_saveoff(off_t *offsetp); >int textdump_writenextblock(struct dumperinfo *di, char *buffer); > >/* > * Interface between the kernel and textdumps. > */ >extern int textdump_pending; /* Call textdump_dumpsys() instead. */ >void textdump_dumpsys(struct dumperinfo *di); > >#endif /* !_DDB_DDB_H_ */ ># 296 "/usr/src/sys/ddb/ddb.h" ># 69 "/usr/src/sys/kern/kern_cons.c" 2 > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpu.h> >#endif /* expanded by -frewrite-includes */ ># 70 "/usr/src/sys/kern/kern_cons.c" ># 71 "/usr/src/sys/kern/kern_cons.c" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/clock.h> >#endif /* expanded by -frewrite-includes */ ># 71 "/usr/src/sys/kern/kern_cons.c" ># 1 "./machine/clock.h" 1 >/*- > * Kernel interface to machine-dependent clock driver. > * Garrett Wollman, September 1994. > * This file is in the public domain. > * > * $FreeBSD: head/sys/amd64/include/clock.h 263008 2014-03-11 10:20:42Z royger $ > */ > >#ifndef _MACHINE_CLOCK_H_ >#define _MACHINE_CLOCK_H_ > >#ifdef _KERNEL >/* > * i386 to clock driver interface. > * XXX large parts of the driver and its interface are misplaced. > */ >extern int clkintr_pending; >extern u_int i8254_freq; >extern int i8254_max_count; >extern uint64_t tsc_freq; >extern int tsc_is_invariant; >extern int tsc_perf_stat; >#ifdef SMP >extern int smp_tsc; >#endif ># 26 "./machine/clock.h" > >void i8254_init(void); >void i8254_delay(int); >void clock_init(void); > >/* > * Driver to clock driver interface. > */ > >void startrtclock(void); >void init_TSC(void); > >#define HAS_TIMER_SPKR 1 >int timer_spkr_acquire(void); >int timer_spkr_release(void); >void timer_spkr_setfreq(int freq); > >#endif /* _KERNEL */ ># 44 "./machine/clock.h" > >#endif /* !_MACHINE_CLOCK_H_ */ ># 46 "./machine/clock.h" ># 72 "/usr/src/sys/kern/kern_cons.c" 2 > >static MALLOC_DEFINE(M_TTYCONS, "tty console", "tty console handling"); > >struct cn_device { > STAILQ_ENTRY(cn_device) cnd_next; > struct consdev *cnd_cn; >}; > >#define CNDEVPATHMAX 32 >#define CNDEVTAB_SIZE 4 >static struct cn_device cn_devtab[CNDEVTAB_SIZE]; >static STAILQ_HEAD(, cn_device) cn_devlist = > STAILQ_HEAD_INITIALIZER(cn_devlist); > >int cons_avail_mask = 0; /* Bit mask. Each registered low level console > * which is currently unavailable for inpit > * (i.e., if it is in graphics mode) will have > * this bit cleared. > */ >static int cn_mute; >static char *consbuf; /* buffer used by `consmsgbuf' */ >static struct callout conscallout; /* callout for outputting to constty */ >struct msgbuf consmsgbuf; /* message buffer for console tty */ >static u_char console_pausing; /* pause after each line during probe */ >static char *console_pausestr= >"<pause; press any key to proceed to next line or '.' to end pause mode>"; >struct tty *constty; /* pointer to console "window" tty */ >static struct mtx cnputs_mtx; /* Mutex for cnputs(). */ >static int use_cnputs_mtx = 0; /* != 0 if cnputs_mtx locking reqd. */ > >static void constty_timeout(void *arg); > >static struct consdev cons_consdev; >DATA_SET(cons_set, cons_consdev); >SET_DECLARE(cons_set, struct consdev); > >void >cninit(void) >{ > struct consdev *best_cn, *cn, **list; > > /* > * Check if we should mute the console (for security reasons perhaps) > * It can be changes dynamically using sysctl kern.consmute > * once we are up and going. > * > */ > cn_mute = ((boothowto & (RB_MUTE > |RB_SINGLE > |RB_VERBOSE > |RB_ASKNAME)) == RB_MUTE); > > /* > * Find the first console with the highest priority. > */ > best_cn = NULL; > SET_FOREACH(list, cons_set) { > cn = *list; > cnremove(cn); > /* Skip cons_consdev. */ > if (cn->cn_ops == NULL) > continue; > cn->cn_ops->cn_probe(cn); > if (cn->cn_pri == CN_DEAD) > continue; > if (best_cn == NULL || cn->cn_pri > best_cn->cn_pri) > best_cn = cn; > if (boothowto & RB_MULTIPLE) { > /* > * Initialize console, and attach to it. > */ > cn->cn_ops->cn_init(cn); > cnadd(cn); > } > } > if (best_cn == NULL) > return; > if ((boothowto & RB_MULTIPLE) == 0) { > best_cn->cn_ops->cn_init(best_cn); > cnadd(best_cn); > } > if (boothowto & RB_PAUSE) > console_pausing = 1; > /* > * Make the best console the preferred console. > */ > cnselect(best_cn); > >#ifdef EARLY_PRINTF > /* > * Release early console. > */ > early_putc = NULL; >#endif ># 166 "/usr/src/sys/kern/kern_cons.c" >} > >void >cninit_finish() >{ > console_pausing = 0; >} > >/* add a new physical console to back the virtual console */ >int >cnadd(struct consdev *cn) >{ > struct cn_device *cnd; > int i; > > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) > if (cnd->cnd_cn == cn) > return (0); > for (i = 0; i < CNDEVTAB_SIZE; i++) { > cnd = &cn_devtab[i]; > if (cnd->cnd_cn == NULL) > break; > } > if (cnd->cnd_cn != NULL) > return (ENOMEM); > cnd->cnd_cn = cn; > if (cn->cn_name[0] == '\0') { > /* XXX: it is unclear if/where this print might output */ > printf("WARNING: console at %p has no name\n", cn); > } > STAILQ_INSERT_TAIL(&cn_devlist, cnd, cnd_next); > if (STAILQ_FIRST(&cn_devlist) == cnd) > ttyconsdev_select(cnd->cnd_cn->cn_name); > > /* Add device to the active mask. */ > cnavailable(cn, (cn->cn_flags & CN_FLAG_NOAVAIL) == 0); > > return (0); >} > >void >cnremove(struct consdev *cn) >{ > struct cn_device *cnd; > int i; > > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { > if (cnd->cnd_cn != cn) > continue; > if (STAILQ_FIRST(&cn_devlist) == cnd) > ttyconsdev_select(NULL); > STAILQ_REMOVE(&cn_devlist, cnd, cn_device, cnd_next); > cnd->cnd_cn = NULL; > > /* Remove this device from available mask. */ > for (i = 0; i < CNDEVTAB_SIZE; i++) > if (cnd == &cn_devtab[i]) { > cons_avail_mask &= ~(1 << i); > break; > } >#if 0 > /* > * XXX > * syscons gets really confused if console resources are > * freed after the system has initialized. > */ > if (cn->cn_term != NULL) > cn->cn_ops->cn_term(cn); >#endif ># 235 "/usr/src/sys/kern/kern_cons.c" > return; > } >} > >void >cnselect(struct consdev *cn) >{ > struct cn_device *cnd; > > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { > if (cnd->cnd_cn != cn) > continue; > if (cnd == STAILQ_FIRST(&cn_devlist)) > return; > STAILQ_REMOVE(&cn_devlist, cnd, cn_device, cnd_next); > STAILQ_INSERT_HEAD(&cn_devlist, cnd, cnd_next); > ttyconsdev_select(cnd->cnd_cn->cn_name); > return; > } >} > >void >cnavailable(struct consdev *cn, int available) >{ > int i; > > for (i = 0; i < CNDEVTAB_SIZE; i++) { > if (cn_devtab[i].cnd_cn == cn) > break; > } > if (available) { > if (i < CNDEVTAB_SIZE) > cons_avail_mask |= (1 << i); > cn->cn_flags &= ~CN_FLAG_NOAVAIL; > } else { > if (i < CNDEVTAB_SIZE) > cons_avail_mask &= ~(1 << i); > cn->cn_flags |= CN_FLAG_NOAVAIL; > } >} > >int >cnunavailable(void) >{ > > return (cons_avail_mask == 0); >} > >/* > * sysctl_kern_console() provides output parseable in conscontrol(1). > */ >static int >sysctl_kern_console(SYSCTL_HANDLER_ARGS) >{ > struct cn_device *cnd; > struct consdev *cp, **list; > char *p; > int delete, error; > struct sbuf *sb; > > sb = sbuf_new(NULL, NULL, CNDEVPATHMAX * 2, SBUF_AUTOEXTEND | > SBUF_INCLUDENUL); > if (sb == NULL) > return (ENOMEM); > sbuf_clear(sb); > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) > sbuf_printf(sb, "%s,", cnd->cnd_cn->cn_name); > sbuf_printf(sb, "/"); > SET_FOREACH(list, cons_set) { > cp = *list; > if (cp->cn_name[0] != '\0') > sbuf_printf(sb, "%s,", cp->cn_name); > } > sbuf_finish(sb); > error = sysctl_handle_string(oidp, sbuf_data(sb), sbuf_len(sb), req); > if (error == 0 && req->newptr != NULL) { > p = sbuf_data(sb); > error = ENXIO; > delete = 0; > if (*p == '-') { > delete = 1; > p++; > } > SET_FOREACH(list, cons_set) { > cp = *list; > if (strcmp(p, cp->cn_name) != 0) > continue; > if (delete) { > cnremove(cp); > error = 0; > } else { > error = cnadd(cp); > if (error == 0) > cnselect(cp); > } > break; > } > } > sbuf_delete(sb); > return (error); >} > >SYSCTL_PROC(_kern, OID_AUTO, console, CTLTYPE_STRING|CTLFLAG_RW, > 0, 0, sysctl_kern_console, "A", "Console device control"); > >/* > * User has changed the state of the console muting. > * This may require us to open or close the device in question. > */ >static int >sysctl_kern_consmute(SYSCTL_HANDLER_ARGS) >{ > int error; > > error = sysctl_handle_int(oidp, &cn_mute, 0, req); > if (error != 0 || req->newptr == NULL) > return (error); > return (error); >} > >SYSCTL_PROC(_kern, OID_AUTO, consmute, CTLTYPE_INT|CTLFLAG_RW, > 0, sizeof(cn_mute), sysctl_kern_consmute, "I", > "State of the console muting"); > >void >cngrab() >{ > struct cn_device *cnd; > struct consdev *cn; > > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { > cn = cnd->cnd_cn; > if (!kdb_active || !(cn->cn_flags & CN_FLAG_NODEBUG)) > cn->cn_ops->cn_grab(cn); > } >} > >void >cnungrab() >{ > struct cn_device *cnd; > struct consdev *cn; > > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { > cn = cnd->cnd_cn; > if (!kdb_active || !(cn->cn_flags & CN_FLAG_NODEBUG)) > cn->cn_ops->cn_ungrab(cn); > } >} > >/* > * Low level console routines. > */ >int >cngetc(void) >{ > int c; > > if (cn_mute) > return (-1); > while ((c = cncheckc()) == -1) > cpu_spinwait(); > if (c == '\r') > c = '\n'; /* console input is always ICRNL */ > return (c); >} > >int >cncheckc(void) >{ > struct cn_device *cnd; > struct consdev *cn; > int c; > > if (cn_mute) > return (-1); > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { > cn = cnd->cnd_cn; > if (!kdb_active || !(cn->cn_flags & CN_FLAG_NODEBUG)) { > c = cn->cn_ops->cn_getc(cn); > if (c != -1) > return (c); > } > } > return (-1); >} > >void >cngets(char *cp, size_t size, int visible) >{ > char *lp, *end; > int c; > > cngrab(); > > lp = cp; > end = cp + size - 1; > for (;;) { > c = cngetc() & 0177; > switch (c) { > case '\n': > case '\r': > cnputc(c); > *lp = '\0'; > cnungrab(); > return; > case '\b': > case '\177': > if (lp > cp) { > if (visible) > cnputs("\b \b"); > lp--; > } > continue; > case '\0': > continue; > default: > if (lp < end) { > switch (visible) { > case GETS_NOECHO: > break; > case GETS_ECHOPASS: > cnputc('*'); > break; > default: > cnputc(c); > break; > } > *lp++ = c; > } > } > } >} > >void >cnputc(int c) >{ > struct cn_device *cnd; > struct consdev *cn; > char *cp; > >#ifdef EARLY_PRINTF > if (early_putc != NULL) { > if (c == '\n') > early_putc('\r'); > early_putc(c); > return; > } >#endif ># 484 "/usr/src/sys/kern/kern_cons.c" > > if (cn_mute || c == '\0') > return; > STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { > cn = cnd->cnd_cn; > if (!kdb_active || !(cn->cn_flags & CN_FLAG_NODEBUG)) { > if (c == '\n') > cn->cn_ops->cn_putc(cn, '\r'); > cn->cn_ops->cn_putc(cn, c); > } > } > if (console_pausing && c == '\n' && !kdb_active) { > for (cp = console_pausestr; *cp != '\0'; cp++) > cnputc(*cp); > cngrab(); > if (cngetc() == '.') > console_pausing = 0; > cnungrab(); > cnputc('\r'); > for (cp = console_pausestr; *cp != '\0'; cp++) > cnputc(' '); > cnputc('\r'); > } >} > >void >cnputs(char *p) >{ > int c; > int unlock_reqd = 0; > > if (use_cnputs_mtx) { > /* > * NOTE: Debug prints and/or witness printouts in > * console driver clients can cause the "cnputs_mtx" > * mutex to recurse. Simply return if that happens. > */ > if (mtx_owned(&cnputs_mtx)) > return; > mtx_lock_spin(&cnputs_mtx); > unlock_reqd = 1; > } > > while ((c = *p++) != '\0') > cnputc(c); > > if (unlock_reqd) > mtx_unlock_spin(&cnputs_mtx); >} > >static int consmsgbuf_size = 8192; >SYSCTL_INT(_kern, OID_AUTO, consmsgbuf_size, CTLFLAG_RW, &consmsgbuf_size, 0, > "Console tty buffer size"); > >/* > * Redirect console output to a tty. > */ >void >constty_set(struct tty *tp) >{ > int size; > > KASSERT(tp != NULL, ("constty_set: NULL tp")); > if (consbuf == NULL) { > size = consmsgbuf_size; > consbuf = malloc(size, M_TTYCONS, M_WAITOK); > msgbuf_init(&consmsgbuf, consbuf, size); > callout_init(&conscallout, 0); > } > constty = tp; > constty_timeout(NULL); >} > >/* > * Disable console redirection to a tty. > */ >void >constty_clear(void) >{ > int c; > > constty = NULL; > if (consbuf == NULL) > return; > callout_stop(&conscallout); > while ((c = msgbuf_getchar(&consmsgbuf)) != -1) > cnputc(c); > free(consbuf, M_TTYCONS); > consbuf = NULL; >} > >/* Times per second to check for pending console tty messages. */ >static int constty_wakeups_per_second = 5; >SYSCTL_INT(_kern, OID_AUTO, constty_wakeups_per_second, CTLFLAG_RW, > &constty_wakeups_per_second, 0, > "Times per second to check for pending console tty messages"); > >static void >constty_timeout(void *arg) >{ > int c; > > if (constty != NULL) { > tty_lock(constty); > while ((c = msgbuf_getchar(&consmsgbuf)) != -1) { > if (tty_putchar(constty, c) < 0) { > tty_unlock(constty); > constty = NULL; > break; > } > } > > if (constty != NULL) > tty_unlock(constty); > } > if (constty != NULL) { > callout_reset(&conscallout, hz / constty_wakeups_per_second, > constty_timeout, NULL); > } else { > /* Deallocate the constty buffer memory. */ > constty_clear(); > } >} > >static void >cn_drvinit(void *unused) >{ > > mtx_init(&cnputs_mtx, "cnputs_mtx", NULL, MTX_SPIN | MTX_NOWITNESS); > use_cnputs_mtx = 1; >} > >SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, cn_drvinit, NULL); > >/* > * Sysbeep(), if we have hardware for it > */ > >#ifdef HAS_TIMER_SPKR > >static int beeping; >static struct callout beeping_timer; > >static void >sysbeepstop(void *chan) >{ > > timer_spkr_release(); > beeping = 0; >} > >int >sysbeep(int pitch, int period) >{ > > if (timer_spkr_acquire()) { > if (!beeping) { > /* Something else owns it. */ > return (EBUSY); > } > } > timer_spkr_setfreq(pitch); > if (!beeping) { > beeping = period; > callout_reset(&beeping_timer, period, sysbeepstop, NULL); > } > return (0); >} > >static void >sysbeep_init(void *unused) >{ > > callout_init(&beeping_timer, CALLOUT_MPSAFE); >} >SYSINIT(sysbeep, SI_SUB_SOFTINTR, SI_ORDER_ANY, sysbeep_init, NULL); >#else ># 661 "/usr/src/sys/kern/kern_cons.c" > >/* > * No hardware, no sound > */ > >int >sysbeep(int pitch __unused, int period __unused) >{ > > return (ENODEV); >} > >#endif ># 674 "/usr/src/sys/kern/kern_cons.c" > >/* > * Temporary support for sc(4) to vt(4) transition. > */ >static unsigned vty_prefer; >static char vty_name[16]; >SYSCTL_STRING(_kern, OID_AUTO, vty, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, vty_name, > 0, "Console vty driver"); > >int >vty_enabled(unsigned vty) >{ > static unsigned vty_selected = 0; > > if (vty_selected == 0) { > TUNABLE_STR_FETCH("kern.vty", vty_name, sizeof(vty_name)); > do { >#if defined(DEV_SC) > if (strcmp(vty_name, "sc") == 0) { > vty_selected = VTY_SC; > break; > } >#endif ># 697 "/usr/src/sys/kern/kern_cons.c" >#if defined(DEV_VT) > if (strcmp(vty_name, "vt") == 0) { > vty_selected = VTY_VT; > break; > } >#endif ># 703 "/usr/src/sys/kern/kern_cons.c" > if (vty_prefer != 0) { > vty_selected = vty_prefer; > break; > } >#if defined(DEV_VT) > vty_selected = VTY_VT; >#elif defined(DEV_SC) ># 710 "/usr/src/sys/kern/kern_cons.c" > vty_selected = VTY_SC; >#endif ># 712 "/usr/src/sys/kern/kern_cons.c" > } while (0); > > if (vty_selected == VTY_VT) > strcpy(vty_name, "vt"); > else if (vty_selected == VTY_SC) > strcpy(vty_name, "sc"); > } > return ((vty_selected & vty) != 0); >} > >void >vty_set_preferred(unsigned vty) >{ > > vty_prefer = vty; >#if !defined(DEV_SC) > vty_prefer &= ~VTY_SC; >#endif ># 730 "/usr/src/sys/kern/kern_cons.c" >#if !defined(DEV_VT) > vty_prefer &= ~VTY_VT; >#endif ># 733 "/usr/src/sys/kern/kern_cons.c" >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 198806
: 154676 |
154677