Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/string.h | /*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* NOTICE: This file was modified by McAfee Research in 2004 to introduce
* support for mandatory and extensible security protections. This notice
* is included in support of clause 2.2 (b) of the Apple Public License,
* Version 2.0.
*/
/*
* HISTORY
* @OSF_COPYRIGHT@
*/
#ifndef _STRING_H_
#define _STRING_H_ 1
#include <sys/types.h>
#include <sys/cdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
#if defined (__cplusplus)
#if __cplusplus >= 201103L
#define NULL nullptr
#else
#define NULL 0
#endif
#else
#define NULL ((void *)0)
#endif
#endif
extern void *memcpy(void *dst , const void *src , size_t n);
extern int memcmp(const void *s1 , const void *s2 , size_t n) __stateful_pure;
extern void *memmove(void *dst , const void *src , size_t n);
extern void *memset(void *s , int, size_t n);
extern int memset_s(void *s , size_t smax, int c, size_t n);
extern size_t strlen(const char *) __stateful_pure;
extern size_t strnlen(const char *, size_t) __stateful_pure;
/* strcpy() and strncpy() are deprecated. Please use strlcpy() instead. */
__kpi_deprecated_arm64_macos_unavailable
extern char *strcpy(char *, const char *) __deprecated;
__kpi_deprecated_arm64_macos_unavailable
extern char *strncpy(char *, const char *, size_t);
/* strcat() and strncat() are deprecated. Please use strlcat() instead. */
__kpi_deprecated_arm64_macos_unavailable
extern char *strcat(char *, const char *) __deprecated;
__kpi_deprecated_arm64_macos_unavailable
extern char *strncat(char *, const char *, size_t);
extern int strcmp(const char *, const char *) __stateful_pure;
extern int strncmp(const char *, const char *, size_t) __stateful_pure;
extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
extern int strcasecmp(const char *s1, const char *s2) __stateful_pure;
extern int strncasecmp(const char *s1, const char *s2, size_t n) __stateful_pure;
extern char *strnstr(const char *s, const char *find, size_t slen) __stateful_pure;
extern char *strchr(const char *s, int c) __stateful_pure;
extern char *STRDUP(const char *, int);
extern int strprefix(const char *s1, const char *s2) __stateful_pure;
extern int bcmp(const void *s1 , const void *s2 , size_t n) __stateful_pure;
extern void bcopy(const void *src , void *dst , size_t n);
extern void bzero(void *s , size_t n);
extern int timingsafe_bcmp(const void *b1 , const void *b2 , size_t n);
#if __has_builtin(__builtin_dynamic_object_size)
#define XNU_BOS __builtin_dynamic_object_size
#else
#define XNU_BOS __builtin_object_size
#endif
/* __nochk_ functions for opting out of type 1 bounds checking */
__attribute__((always_inline)) static inline void *
__nochk_memcpy(void *dest , const void *src , size_t len)
{
return __builtin___memcpy_chk(dest, src, len, XNU_BOS(dest, 0));
}
__attribute__((always_inline)) static inline void *
__nochk_memmove(void *dest , const void *src , size_t len)
{
return __builtin___memmove_chk(dest, src, len, XNU_BOS(dest, 0));
}
__attribute__((always_inline)) static inline void
__nochk_bcopy(const void *src , void *dest , size_t len)
{
__builtin___memmove_chk(dest, src, len, XNU_BOS(dest, 0));
}
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13
/* older deployment target */
#elif defined(KASAN) || (defined (_FORTIFY_SOURCE) && _FORTIFY_SOURCE == 0)
/* _FORTIFY_SOURCE disabled */
#else /* _chk macros */
#if defined XNU_KERNEL_PRIVATE || defined(_FORTIFY_SOURCE_STRICT)
/* Stricter checking is optional for kexts. When type is set to 1, __builtin_object_size
* returns the size of the closest surrounding sub-object, which would detect copying past
* the end of a struct member. */
#define BOS_COPY_TYPE 1
#else
#define BOS_COPY_TYPE 0
#endif
#if __has_builtin(__builtin___memcpy_chk)
#define memcpy(dest, src, len) __builtin___memcpy_chk(dest, src, len, XNU_BOS(dest, BOS_COPY_TYPE))
#endif
#if __has_builtin(__builtin___memmove_chk)
#define memmove(dest, src, len) __builtin___memmove_chk(dest, src, len, XNU_BOS(dest, BOS_COPY_TYPE))
#endif
#if __has_builtin(__builtin___strncpy_chk)
#define strncpy(dest, src, len) __builtin___strncpy_chk(dest, src, len, XNU_BOS(dest, 1))
#endif
#if __has_builtin(__builtin___strncat_chk)
#define strncat(dest, src, len) __builtin___strncat_chk(dest, src, len, XNU_BOS(dest, 1))
#endif
#if __has_builtin(__builtin___strlcat_chk)
#define strlcat(dest, src, len) __builtin___strlcat_chk(dest, src, len, XNU_BOS(dest, 1))
#endif
#if __has_builtin(__builtin___strlcpy_chk)
#define strlcpy(dest, src, len) __builtin___strlcpy_chk(dest, src, len, XNU_BOS(dest, 1))
#endif
#if __has_builtin(__builtin___strcpy_chk)
#define strcpy(dest, src, len) __builtin___strcpy_chk(dest, src, XNU_BOS(dest, 1))
#endif
#if __has_builtin(__builtin___strcat_chk)
#define strcat(dest, src) __builtin___strcat_chk(dest, src, XNU_BOS(dest, 1))
#endif
#if __has_builtin(__builtin___memmove_chk)
#define bcopy(src, dest, len) __builtin___memmove_chk(dest, src, len, XNU_BOS(dest, BOS_COPY_TYPE))
#endif
#endif /* _chk macros */
#ifdef __cplusplus
}
#endif
#endif /* _STRING_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/stdbool.h | /*
* Copyright (c) 2000 Jeroen Ruigrok van der Werven <[email protected]>
* 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: src/include/stdbool.h,v 1.6 2002/08/16 07:33:14 alfred Exp $
*/
#ifndef _STDBOOL_H_
#define _STDBOOL_H_
#define __bool_true_false_are_defined 1
#ifndef __cplusplus
#define false 0
#define true 1
#define bool _Bool
#if __STDC_VERSION__ < 199901L && __GNUC__ < 3
typedef int _Bool;
#endif
#endif /* !__cplusplus */
#endif /* !_STDBOOL_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/stdint.h | /*
* Copyright (c) 2000-2010 Apple Inc.
* All rights reserved.
*/
#ifndef _KERNEL_STDINT_H_
#define _KERNEL_STDINT_H_
#include <machine/types.h>
#if __LP64__
#define __WORDSIZE 64
#else
#define __WORDSIZE 32
#endif
/* from ISO/IEC 988:1999 spec */
/* 7.18.1.1 Exact-width integer types */
/* int8_t is defined in <machine/types.h> */
/* int16_t is defined in <machine/types.h> */
/* int32_t is defined in <machine/types.h> */
/* int64_t is defined in <machine/types.h> */
typedef u_int8_t uint8_t; /* u_int8_t is defined in <machine/types.h> */
typedef u_int16_t uint16_t; /* u_int16_t is defined in <machine/types.h> */
typedef u_int32_t uint32_t; /* u_int32_t is defined in <machine/types.h> */
typedef u_int64_t uint64_t; /* u_int64_t is defined in <machine/types.h> */
/* 7.18.1.2 Minimum-width integer types */
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_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;
/* 7.18.1.3 Fastest-width integer types */
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
/* 7.18.1.4 Integer types capable of holding object pointers */
/* intptr_t is defined in <machine/types.h> */
/* uintptr_t is defined in <machine/types.h> */
/* 7.18.1.5 Greatest-width integer types */
#ifdef __INTMAX_TYPE__
typedef __INTMAX_TYPE__ intmax_t;
#else
#ifdef __LP64__
typedef long int intmax_t;
#else
typedef long long int intmax_t;
#endif /* __LP64__ */
#endif /* __INTMAX_TYPE__ */
#ifdef __UINTMAX_TYPE__
typedef __UINTMAX_TYPE__ uintmax_t;
#else
#ifdef __LP64__
typedef long unsigned int uintmax_t;
#else
typedef long long unsigned int uintmax_t;
#endif /* __LP64__ */
#endif /* __UINTMAX_TYPE__ */
/* 7.18.4 Macros for integer constants */
#define INT8_C(v) (v)
#define INT16_C(v) (v)
#define INT32_C(v) (v)
#define INT64_C(v) (v ## LL)
#define UINT8_C(v) (v)
#define UINT16_C(v) (v)
#define UINT32_C(v) (v ## U)
#define UINT64_C(v) (v ## ULL)
#ifdef __LP64__
#define INTMAX_C(v) (v ## L)
#define UINTMAX_C(v) (v ## UL)
#else
#define INTMAX_C(v) (v ## LL)
#define UINTMAX_C(v) (v ## ULL)
#endif
/* 7.18.2 Limits of specified-width integer types:
* These #defines specify the minimum and maximum limits
* of each of the types declared above.
*
* They must have "the same type as would an expression that is an
* object of the corresponding type converted according to the integer
* promotion".
*/
/* 7.18.2.1 Limits of exact-width integer types */
#define INT8_MAX 127
#define INT16_MAX 32767
#define INT32_MAX 2147483647
#define INT64_MAX 9223372036854775807LL
#define INT8_MIN -128
#define INT16_MIN -32768
/*
Note: the literal "most negative int" cannot be written in C --
the rules in the standard (section 6.4.4.1 in C99) will give it
an unsigned type, so INT32_MIN (and the most negative member of
any larger signed type) must be written via a constant expression.
*/
#define INT32_MIN (-INT32_MAX-1)
#define INT64_MIN (-INT64_MAX-1)
#define UINT8_MAX 255
#define UINT16_MAX 65535
#define UINT32_MAX 4294967295U
#define UINT64_MAX 18446744073709551615ULL
/* 7.18.2.2 Limits of minimum-width 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
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
/* 7.18.2.3 Limits of fastest minimum-width integer types */
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
#if __WORDSIZE == 64
#define INTPTR_MAX 9223372036854775807L
#else
#define INTPTR_MAX 2147483647L
#endif
#define INTPTR_MIN (-INTPTR_MAX-1)
#if __WORDSIZE == 64
#define UINTPTR_MAX 18446744073709551615UL
#else
#define UINTPTR_MAX 4294967295UL
#endif
/* 7.18.2.5 Limits of greatest-width integer types */
#define INTMAX_MAX INTMAX_C(9223372036854775807)
#define UINTMAX_MAX UINTMAX_C(18446744073709551615)
#define INTMAX_MIN (-INTMAX_MAX-1)
/* 7.18.3 "Other" */
#if __WORDSIZE == 64
#define PTRDIFF_MIN INTMAX_MIN
#define PTRDIFF_MAX INTMAX_MAX
#else
#define PTRDIFF_MIN INT32_MIN
#define PTRDIFF_MAX INT32_MAX
#endif
#define SIZE_MAX UINTPTR_MAX
#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
#define RSIZE_MAX (SIZE_MAX >> 1)
#endif
#ifndef WCHAR_MAX
# ifdef __WCHAR_MAX__
# define WCHAR_MAX __WCHAR_MAX__
# else
# define WCHAR_MAX 0x7fffffff
# endif
#endif
/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
(-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
it turns out that -fshort-wchar changes the signedness of
the type. */
#ifndef WCHAR_MIN
# if WCHAR_MAX == 0xffff
# define WCHAR_MIN 0
# else
# define WCHAR_MIN (-WCHAR_MAX-1)
# endif
#endif
#define WINT_MIN INT32_MIN
#define WINT_MAX INT32_MAX
#define SIG_ATOMIC_MIN INT32_MIN
#define SIG_ATOMIC_MAX INT32_MAX
#endif /* _KERNEL_STDINT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/math.h | /*
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __MATH_H__
#define __MATH_H__
#ifndef __MATH__
#define __MATH__
#endif
#include <sys/cdefs.h>
#include <Availability.h>
__BEGIN_DECLS
/******************************************************************************
* Floating point data types *
******************************************************************************/
/* Define float_t and double_t per C standard, ISO/IEC 9899:2011 7.12 2,
taking advantage of GCC's __FLT_EVAL_METHOD__ (which a compiler may
define anytime and GCC does) that shadows FLT_EVAL_METHOD (which a
compiler must define only in float.h). */
#if __FLT_EVAL_METHOD__ == 0
typedef float float_t;
typedef double double_t;
#elif __FLT_EVAL_METHOD__ == 1
typedef double float_t;
typedef double double_t;
#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1
typedef long double float_t;
typedef long double double_t;
#else /* __FLT_EVAL_METHOD__ */
# error "Unsupported value of __FLT_EVAL_METHOD__."
#endif /* __FLT_EVAL_METHOD__ */
#if defined(__GNUC__)
# define HUGE_VAL __builtin_huge_val()
# define HUGE_VALF __builtin_huge_valf()
# define HUGE_VALL __builtin_huge_vall()
# define NAN __builtin_nanf("0x7fc00000")
#else
# define HUGE_VAL 1e500
# define HUGE_VALF 1e50f
# define HUGE_VALL 1e5000L
# define NAN __nan()
#endif
#define INFINITY HUGE_VALF
/******************************************************************************
* Taxonomy of floating point data types *
******************************************************************************/
#define FP_NAN 1
#define FP_INFINITE 2
#define FP_ZERO 3
#define FP_NORMAL 4
#define FP_SUBNORMAL 5
#define FP_SUPERNORMAL 6 /* legacy PowerPC support; this is otherwise unused */
#if defined __arm64__ || defined __ARM_VFPV4__
/* On these architectures, fma(), fmaf( ), and fmal( ) are generally about as
fast as (or faster than) separate multiply and add of the same operands. */
# define FP_FAST_FMA 1
# define FP_FAST_FMAF 1
# define FP_FAST_FMAL 1
#elif (defined __i386__ || defined __x86_64__) && (defined __FMA__ || defined __AVX512F__)
/* When targeting the FMA ISA extension, fma() and fmaf( ) are generally
about as fast as (or faster than) separate multiply and add of the same
operands, but fmal( ) may be more costly. */
# define FP_FAST_FMA 1
# define FP_FAST_FMAF 1
# undef FP_FAST_FMAL
#else
/* On these architectures, fma( ), fmaf( ), and fmal( ) function calls are
significantly more costly than separate multiply and add operations. */
# undef FP_FAST_FMA
# undef FP_FAST_FMAF
# undef FP_FAST_FMAL
#endif
/* The values returned by `ilogb' for 0 and NaN respectively. */
#define FP_ILOGB0 (-2147483647 - 1)
#define FP_ILOGBNAN (-2147483647 - 1)
/* Bitmasks for the math_errhandling macro. */
#define MATH_ERRNO 1 /* errno set by math functions. */
#define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */
#define math_errhandling (__math_errhandling())
extern int __math_errhandling(void);
/******************************************************************************
* *
* Inquiry macros *
* *
* fpclassify Returns one of the FP_* values. *
* isnormal Non-zero if and only if the argument x is normalized. *
* isfinite Non-zero if and only if the argument x is finite. *
* isnan Non-zero if and only if the argument x is a NaN. *
* signbit Non-zero if and only if the sign of the argument x is *
* negative. This includes, NaNs, infinities and zeros. *
* *
******************************************************************************/
#define fpclassify(x) \
( sizeof(x) == sizeof(float) ? __fpclassifyf((float)(x)) \
: sizeof(x) == sizeof(double) ? __fpclassifyd((double)(x)) \
: __fpclassifyl((long double)(x)))
extern int __fpclassifyf(float);
extern int __fpclassifyd(double);
extern int __fpclassifyl(long double);
#if (defined(__GNUC__) && 0 == __FINITE_MATH_ONLY__)
/* These inline functions may fail to return expected results if unsafe
math optimizations like those enabled by -ffast-math are turned on.
Thus, (somewhat surprisingly) you only get the fast inline
implementations if such compiler options are NOT enabled. This is
because the inline functions require the compiler to be adhering to
the standard in order to work properly; -ffast-math, among other
things, implies that NaNs don't happen, which allows the compiler to
optimize away checks like x != x, which might lead to things like
isnan(NaN) returning false.
Thus, if you compile with -ffast-math, actual function calls are
generated for these utilities. */
#define isnormal(x) \
( sizeof(x) == sizeof(float) ? __inline_isnormalf((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_isnormald((double)(x)) \
: __inline_isnormall((long double)(x)))
#define isfinite(x) \
( sizeof(x) == sizeof(float) ? __inline_isfinitef((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_isfinited((double)(x)) \
: __inline_isfinitel((long double)(x)))
#define isinf(x) \
( sizeof(x) == sizeof(float) ? __inline_isinff((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_isinfd((double)(x)) \
: __inline_isinfl((long double)(x)))
#define isnan(x) \
( sizeof(x) == sizeof(float) ? __inline_isnanf((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_isnand((double)(x)) \
: __inline_isnanl((long double)(x)))
#define signbit(x) \
( sizeof(x) == sizeof(float) ? __inline_signbitf((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_signbitd((double)(x)) \
: __inline_signbitl((long double)(x)))
__header_always_inline int __inline_isfinitef(float);
__header_always_inline int __inline_isfinited(double);
__header_always_inline int __inline_isfinitel(long double);
__header_always_inline int __inline_isinff(float);
__header_always_inline int __inline_isinfd(double);
__header_always_inline int __inline_isinfl(long double);
__header_always_inline int __inline_isnanf(float);
__header_always_inline int __inline_isnand(double);
__header_always_inline int __inline_isnanl(long double);
__header_always_inline int __inline_isnormalf(float);
__header_always_inline int __inline_isnormald(double);
__header_always_inline int __inline_isnormall(long double);
__header_always_inline int __inline_signbitf(float);
__header_always_inline int __inline_signbitd(double);
__header_always_inline int __inline_signbitl(long double);
__header_always_inline int __inline_isfinitef(float __x) {
return __x == __x && __builtin_fabsf(__x) != __builtin_inff();
}
__header_always_inline int __inline_isfinited(double __x) {
return __x == __x && __builtin_fabs(__x) != __builtin_inf();
}
__header_always_inline int __inline_isfinitel(long double __x) {
return __x == __x && __builtin_fabsl(__x) != __builtin_infl();
}
__header_always_inline int __inline_isinff(float __x) {
return __builtin_fabsf(__x) == __builtin_inff();
}
__header_always_inline int __inline_isinfd(double __x) {
return __builtin_fabs(__x) == __builtin_inf();
}
__header_always_inline int __inline_isinfl(long double __x) {
return __builtin_fabsl(__x) == __builtin_infl();
}
__header_always_inline int __inline_isnanf(float __x) {
return __x != __x;
}
__header_always_inline int __inline_isnand(double __x) {
return __x != __x;
}
__header_always_inline int __inline_isnanl(long double __x) {
return __x != __x;
}
__header_always_inline int __inline_signbitf(float __x) {
union { float __f; unsigned int __u; } __u;
__u.__f = __x;
return (int)(__u.__u >> 31);
}
__header_always_inline int __inline_signbitd(double __x) {
union { double __f; unsigned long long __u; } __u;
__u.__f = __x;
return (int)(__u.__u >> 63);
}
#if defined __i386__ || defined __x86_64__
__header_always_inline int __inline_signbitl(long double __x) {
union {
long double __ld;
struct{ unsigned long long __m; unsigned short __sexp; } __p;
} __u;
__u.__ld = __x;
return (int)(__u.__p.__sexp >> 15);
}
#else
__header_always_inline int __inline_signbitl(long double __x) {
union { long double __f; unsigned long long __u;} __u;
__u.__f = __x;
return (int)(__u.__u >> 63);
}
#endif
__header_always_inline int __inline_isnormalf(float __x) {
return __inline_isfinitef(__x) && __builtin_fabsf(__x) >= __FLT_MIN__;
}
__header_always_inline int __inline_isnormald(double __x) {
return __inline_isfinited(__x) && __builtin_fabs(__x) >= __DBL_MIN__;
}
__header_always_inline int __inline_isnormall(long double __x) {
return __inline_isfinitel(__x) && __builtin_fabsl(__x) >= __LDBL_MIN__;
}
#else /* defined(__GNUC__) && 0 == __FINITE_MATH_ONLY__ */
/* Implementations making function calls to fall back on when -ffast-math
or similar is specified. These are not available in iOS versions prior
to 6.0. If you need them, you must target that version or later. */
#define isnormal(x) \
( sizeof(x) == sizeof(float) ? __isnormalf((float)(x)) \
: sizeof(x) == sizeof(double) ? __isnormald((double)(x)) \
: __isnormall((long double)(x)))
#define isfinite(x) \
( sizeof(x) == sizeof(float) ? __isfinitef((float)(x)) \
: sizeof(x) == sizeof(double) ? __isfinited((double)(x)) \
: __isfinitel((long double)(x)))
#define isinf(x) \
( sizeof(x) == sizeof(float) ? __isinff((float)(x)) \
: sizeof(x) == sizeof(double) ? __isinfd((double)(x)) \
: __isinfl((long double)(x)))
#define isnan(x) \
( sizeof(x) == sizeof(float) ? __isnanf((float)(x)) \
: sizeof(x) == sizeof(double) ? __isnand((double)(x)) \
: __isnanl((long double)(x)))
#define signbit(x) \
( sizeof(x) == sizeof(float) ? __signbitf((float)(x)) \
: sizeof(x) == sizeof(double) ? __signbitd((double)(x)) \
: __signbitl((long double)(x)))
extern int __isnormalf(float);
extern int __isnormald(double);
extern int __isnormall(long double);
extern int __isfinitef(float);
extern int __isfinited(double);
extern int __isfinitel(long double);
extern int __isinff(float);
extern int __isinfd(double);
extern int __isinfl(long double);
extern int __isnanf(float);
extern int __isnand(double);
extern int __isnanl(long double);
extern int __signbitf(float);
extern int __signbitd(double);
extern int __signbitl(long double);
#endif /* defined(__GNUC__) && 0 == __FINITE_MATH_ONLY__ */
/******************************************************************************
* *
* Math Functions *
* *
******************************************************************************/
extern float acosf(float);
extern double acos(double);
extern long double acosl(long double);
extern float asinf(float);
extern double asin(double);
extern long double asinl(long double);
extern float atanf(float);
extern double atan(double);
extern long double atanl(long double);
extern float atan2f(float, float);
extern double atan2(double, double);
extern long double atan2l(long double, long double);
extern float cosf(float);
extern double cos(double);
extern long double cosl(long double);
extern float sinf(float);
extern double sin(double);
extern long double sinl(long double);
extern float tanf(float);
extern double tan(double);
extern long double tanl(long double);
extern float acoshf(float);
extern double acosh(double);
extern long double acoshl(long double);
extern float asinhf(float);
extern double asinh(double);
extern long double asinhl(long double);
extern float atanhf(float);
extern double atanh(double);
extern long double atanhl(long double);
extern float coshf(float);
extern double cosh(double);
extern long double coshl(long double);
extern float sinhf(float);
extern double sinh(double);
extern long double sinhl(long double);
extern float tanhf(float);
extern double tanh(double);
extern long double tanhl(long double);
extern float expf(float);
extern double exp(double);
extern long double expl(long double);
extern float exp2f(float);
extern double exp2(double);
extern long double exp2l(long double);
extern float expm1f(float);
extern double expm1(double);
extern long double expm1l(long double);
extern float logf(float);
extern double log(double);
extern long double logl(long double);
extern float log10f(float);
extern double log10(double);
extern long double log10l(long double);
extern float log2f(float);
extern double log2(double);
extern long double log2l(long double);
extern float log1pf(float);
extern double log1p(double);
extern long double log1pl(long double);
extern float logbf(float);
extern double logb(double);
extern long double logbl(long double);
extern float modff(float, float *);
extern double modf(double, double *);
extern long double modfl(long double, long double *);
extern float ldexpf(float, int);
extern double ldexp(double, int);
extern long double ldexpl(long double, int);
extern float frexpf(float, int *);
extern double frexp(double, int *);
extern long double frexpl(long double, int *);
extern int ilogbf(float);
extern int ilogb(double);
extern int ilogbl(long double);
extern float scalbnf(float, int);
extern double scalbn(double, int);
extern long double scalbnl(long double, int);
extern float scalblnf(float, long int);
extern double scalbln(double, long int);
extern long double scalblnl(long double, long int);
extern float fabsf(float);
extern double fabs(double);
extern long double fabsl(long double);
extern float cbrtf(float);
extern double cbrt(double);
extern long double cbrtl(long double);
extern float hypotf(float, float);
extern double hypot(double, double);
extern long double hypotl(long double, long double);
extern float powf(float, float);
extern double pow(double, double);
extern long double powl(long double, long double);
extern float sqrtf(float);
extern double sqrt(double);
extern long double sqrtl(long double);
extern float erff(float);
extern double erf(double);
extern long double erfl(long double);
extern float erfcf(float);
extern double erfc(double);
extern long double erfcl(long double);
/* lgammaf, lgamma, and lgammal are not thread-safe. The thread-safe
variants lgammaf_r, lgamma_r, and lgammal_r are made available if
you define the _REENTRANT symbol before including <math.h> */
extern float lgammaf(float);
extern double lgamma(double);
extern long double lgammal(long double);
extern float tgammaf(float);
extern double tgamma(double);
extern long double tgammal(long double);
extern float ceilf(float);
extern double ceil(double);
extern long double ceill(long double);
extern float floorf(float);
extern double floor(double);
extern long double floorl(long double);
extern float nearbyintf(float);
extern double nearbyint(double);
extern long double nearbyintl(long double);
extern float rintf(float);
extern double rint(double);
extern long double rintl(long double);
extern long int lrintf(float);
extern long int lrint(double);
extern long int lrintl(long double);
extern float roundf(float);
extern double round(double);
extern long double roundl(long double);
extern long int lroundf(float);
extern long int lround(double);
extern long int lroundl(long double);
/* long long is not part of C90. Make sure you are passing -std=c99 or
-std=gnu99 or higher if you need these functions returning long longs */
#if !(__DARWIN_NO_LONG_LONG)
extern long long int llrintf(float);
extern long long int llrint(double);
extern long long int llrintl(long double);
extern long long int llroundf(float);
extern long long int llround(double);
extern long long int llroundl(long double);
#endif /* !(__DARWIN_NO_LONG_LONG) */
extern float truncf(float);
extern double trunc(double);
extern long double truncl(long double);
extern float fmodf(float, float);
extern double fmod(double, double);
extern long double fmodl(long double, long double);
extern float remainderf(float, float);
extern double remainder(double, double);
extern long double remainderl(long double, long double);
extern float remquof(float, float, int *);
extern double remquo(double, double, int *);
extern long double remquol(long double, long double, int *);
extern float copysignf(float, float);
extern double copysign(double, double);
extern long double copysignl(long double, long double);
extern float nanf(const char *);
extern double nan(const char *);
extern long double nanl(const char *);
extern float nextafterf(float, float);
extern double nextafter(double, double);
extern long double nextafterl(long double, long double);
extern double nexttoward(double, long double);
extern float nexttowardf(float, long double);
extern long double nexttowardl(long double, long double);
extern float fdimf(float, float);
extern double fdim(double, double);
extern long double fdiml(long double, long double);
extern float fmaxf(float, float);
extern double fmax(double, double);
extern long double fmaxl(long double, long double);
extern float fminf(float, float);
extern double fmin(double, double);
extern long double fminl(long double, long double);
extern float fmaf(float, float, float);
extern double fma(double, double, double);
extern long double fmal(long double, long double, long double);
#define isgreater(x, y) __builtin_isgreater((x),(y))
#define isgreaterequal(x, y) __builtin_isgreaterequal((x),(y))
#define isless(x, y) __builtin_isless((x),(y))
#define islessequal(x, y) __builtin_islessequal((x),(y))
#define islessgreater(x, y) __builtin_islessgreater((x),(y))
#define isunordered(x, y) __builtin_isunordered((x),(y))
#if defined __i386__ || defined __x86_64__
/* Deprecated functions; use the INFINITY and NAN macros instead. */
extern float __inff(void)
__API_DEPRECATED("use `(float)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
extern double __inf(void)
__API_DEPRECATED("use `INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
extern long double __infl(void)
__API_DEPRECATED("use `(long double)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
extern float __nan(void)
__API_DEPRECATED("use `NAN` instead", macos(10.0, 10.14)) __API_UNAVAILABLE(ios, watchos, tvos);
#endif
/******************************************************************************
* Reentrant variants of lgamma[fl] *
******************************************************************************/
#ifdef _REENTRANT
/* Reentrant variants of the lgamma[fl] functions. */
extern float lgammaf_r(float, int *) __API_AVAILABLE(macos(10.6), ios(3.1));
extern double lgamma_r(double, int *) __API_AVAILABLE(macos(10.6), ios(3.1));
extern long double lgammal_r(long double, int *) __API_AVAILABLE(macos(10.6), ios(3.1));
#endif /* _REENTRANT */
/******************************************************************************
* Apple extensions to the C standard *
******************************************************************************/
/* Because these functions are not specified by any relevant standard, they
are prefixed with __, which places them in the implementor's namespace, so
they should not conflict with any developer or third-party code. If they
are added to a relevant standard in the future, un-prefixed names may be
added to the library and they may be moved out of this section of the
header.
Because these functions are non-standard, they may not be available on non-
Apple platforms. */
/* __exp10(x) returns 10**x. Edge cases match those of exp( ) and exp2( ). */
extern float __exp10f(float) __API_AVAILABLE(macos(10.9), ios(7.0));
extern double __exp10(double) __API_AVAILABLE(macos(10.9), ios(7.0));
/* __sincos(x,sinp,cosp) computes the sine and cosine of x with a single
function call, storing the sine in the memory pointed to by sinp, and
the cosine in the memory pointed to by cosp. Edge cases match those of
separate calls to sin( ) and cos( ). */
__header_always_inline void __sincosf(float __x, float *__sinp, float *__cosp);
__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp);
/* __sinpi(x) returns the sine of pi times x; __cospi(x) and __tanpi(x) return
the cosine and tangent, respectively. These functions can produce a more
accurate answer than expressions of the form sin(M_PI * x) because they
avoid any loss of precision that results from rounding the result of the
multiplication M_PI * x. They may also be significantly more efficient in
some cases because the argument reduction for these functions is easier
to compute. Consult the man pages for edge case details. */
extern float __cospif(float) __API_AVAILABLE(macos(10.9), ios(7.0));
extern double __cospi(double) __API_AVAILABLE(macos(10.9), ios(7.0));
extern float __sinpif(float) __API_AVAILABLE(macos(10.9), ios(7.0));
extern double __sinpi(double) __API_AVAILABLE(macos(10.9), ios(7.0));
extern float __tanpif(float) __API_AVAILABLE(macos(10.9), ios(7.0));
extern double __tanpi(double) __API_AVAILABLE(macos(10.9), ios(7.0));
#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090) || \
(defined __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 70000)
/* __sincos and __sincosf were introduced in OSX 10.9 and iOS 7.0. When
targeting an older system, we simply split them up into discrete calls
to sin( ) and cos( ). */
__header_always_inline void __sincosf(float __x, float *__sinp, float *__cosp) {
*__sinp = sinf(__x);
*__cosp = cosf(__x);
}
__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp) {
*__sinp = sin(__x);
*__cosp = cos(__x);
}
#else
/* __sincospi(x,sinp,cosp) computes the sine and cosine of pi times x with a
single function call, storing the sine in the memory pointed to by sinp,
and the cosine in the memory pointed to by cosp. Edge cases match those
of separate calls to __sinpi( ) and __cospi( ), and are documented in the
man pages.
These functions were introduced in OSX 10.9 and iOS 7.0. Because they are
implemented as header inlines, weak-linking does not function as normal,
and they are simply hidden when targeting earlier OS versions. */
__header_always_inline void __sincospif(float __x, float *__sinp, float *__cosp);
__header_always_inline void __sincospi(double __x, double *__sinp, double *__cosp);
/* Implementation details of __sincos and __sincospi allowing them to return
two results while allowing the compiler to optimize away unnecessary load-
store traffic. Although these interfaces are exposed in the math.h header
to allow compilers to generate better code, users should call __sincos[f]
and __sincospi[f] instead and allow the compiler to emit these calls. */
struct __float2 { float __sinval; float __cosval; };
struct __double2 { double __sinval; double __cosval; };
extern struct __float2 __sincosf_stret(float);
extern struct __double2 __sincos_stret(double);
extern struct __float2 __sincospif_stret(float);
extern struct __double2 __sincospi_stret(double);
__header_always_inline void __sincosf(float __x, float *__sinp, float *__cosp) {
const struct __float2 __stret = __sincosf_stret(__x);
*__sinp = __stret.__sinval; *__cosp = __stret.__cosval;
}
__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp) {
const struct __double2 __stret = __sincos_stret(__x);
*__sinp = __stret.__sinval; *__cosp = __stret.__cosval;
}
__header_always_inline void __sincospif(float __x, float *__sinp, float *__cosp) {
const struct __float2 __stret = __sincospif_stret(__x);
*__sinp = __stret.__sinval; *__cosp = __stret.__cosval;
}
__header_always_inline void __sincospi(double __x, double *__sinp, double *__cosp) {
const struct __double2 __stret = __sincospi_stret(__x);
*__sinp = __stret.__sinval; *__cosp = __stret.__cosval;
}
#endif
/******************************************************************************
* POSIX/UNIX extensions to the C standard *
******************************************************************************/
#if __DARWIN_C_LEVEL >= 199506L
extern double j0(double) __API_AVAILABLE(macos(10.0), ios(3.2));
extern double j1(double) __API_AVAILABLE(macos(10.0), ios(3.2));
extern double jn(int, double) __API_AVAILABLE(macos(10.0), ios(3.2));
extern double y0(double) __API_AVAILABLE(macos(10.0), ios(3.2));
extern double y1(double) __API_AVAILABLE(macos(10.0), ios(3.2));
extern double yn(int, double) __API_AVAILABLE(macos(10.0), ios(3.2));
extern double scalb(double, double);
extern int signgam;
/* Even though these might be more useful as long doubles, POSIX requires
that they be double-precision literals. */
#define M_E 2.71828182845904523536028747135266250 /* e */
#define M_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */
#define M_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */
#define M_LN2 0.693147180559945309417232121458176568 /* loge(2) */
#define M_LN10 2.30258509299404568401799145468436421 /* loge(10) */
#define M_PI 3.14159265358979323846264338327950288 /* pi */
#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
#define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
#define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
#define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
#define MAXFLOAT 0x1.fffffep+127f
#endif /* __DARWIN_C_LEVEL >= 199506L */
/* Long-double versions of M_E, etc for convenience on Intel where long-
double is not the same as double. Define __MATH_LONG_DOUBLE_CONSTANTS
to make these constants available. */
#if defined __MATH_LONG_DOUBLE_CONSTANTS
#define M_El 0xa.df85458a2bb4a9bp-2L
#define M_LOG2El 0xb.8aa3b295c17f0bcp-3L
#define M_LOG10El 0xd.e5bd8a937287195p-5L
#define M_LN2l 0xb.17217f7d1cf79acp-4L
#define M_LN10l 0x9.35d8dddaaa8ac17p-2L
#define M_PIl 0xc.90fdaa22168c235p-2L
#define M_PI_2l 0xc.90fdaa22168c235p-3L
#define M_PI_4l 0xc.90fdaa22168c235p-4L
#define M_1_PIl 0xa.2f9836e4e44152ap-5L
#define M_2_PIl 0xa.2f9836e4e44152ap-4L
#define M_2_SQRTPIl 0x9.06eba8214db688dp-3L
#define M_SQRT2l 0xb.504f333f9de6484p-3L
#define M_SQRT1_2l 0xb.504f333f9de6484p-4L
#endif /* defined __MATH_LONG_DOUBLE_CONSTANTS */
/******************************************************************************
* Legacy BSD extensions to the C standard *
******************************************************************************/
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#define FP_SNAN FP_NAN
#define FP_QNAN FP_NAN
#define HUGE MAXFLOAT
#define X_TLOSS 1.41484755040568800000e+16
#define DOMAIN 1
#define SING 2
#define OVERFLOW 3
#define UNDERFLOW 4
#define TLOSS 5
#define PLOSS 6
#if defined __i386__ || defined __x86_64__
/* Legacy BSD API; use the C99 `lrint( )` function instead. */
extern long int rinttol(double)
__API_DEPRECATED_WITH_REPLACEMENT("lrint", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
/* Legacy BSD API; use the C99 `lround( )` function instead. */
extern long int roundtol(double)
__API_DEPRECATED_WITH_REPLACEMENT("lround", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
/* Legacy BSD API; use the C99 `remainder( )` function instead. */
extern double drem(double, double)
__API_DEPRECATED_WITH_REPLACEMENT("remainder", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
/* Legacy BSD API; use the C99 `isfinite( )` macro instead. */
extern int finite(double)
__API_DEPRECATED("Use `isfinite((double)x)` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
/* Legacy BSD API; use the C99 `tgamma( )` function instead. */
extern double gamma(double)
__API_DEPRECATED_WITH_REPLACEMENT("tgamma", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
/* Legacy BSD API; use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead. */
extern double significand(double)
__API_DEPRECATED("Use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
#endif
#if !defined __cplusplus
struct exception {
int type;
char *name;
double arg1;
double arg2;
double retval;
};
#endif /* !defined __cplusplus */
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
__END_DECLS
#endif /* __MATH_H__ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/stdarg.h | /*===---- stdarg.h - Variable argument handling ----------------------------===
*
* Copyright (c) 2008 Eli Friedman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*===-----------------------------------------------------------------------===
*/
#ifndef __STDARG_H
#define __STDARG_H
#ifndef _VA_LIST
typedef __builtin_va_list va_list;
#define _VA_LIST
#endif
#define va_start(ap, param) __builtin_va_start(ap, param)
#define va_end(ap) __builtin_va_end(ap)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
* or -ansi is not specified, since it was not part of C90.
*/
#define __va_copy(d,s) __builtin_va_copy(d,s)
#if __STDC_VERSION__ >= 199900L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__)
#define va_copy(dest, src) __builtin_va_copy(dest, src)
#endif
/* Hack required to make standard headers work, at least on Ubuntu */
#define __GNUC_VA_LIST 1
typedef __builtin_va_list __gnuc_va_list;
#endif /* __STDARG_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/stdatomic.h | /*===---- stdatomic.h - Standard header for atomic types and operations -----===
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*===-----------------------------------------------------------------------===
*/
#ifndef __clang__
#error unsupported compiler
#endif
#ifndef __CLANG_STDATOMIC_H
#define __CLANG_STDATOMIC_H
/* If we're hosted, fall back to the system's stdatomic.h. FreeBSD, for
* example, already has a Clang-compatible stdatomic.h header.
*/
#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
# include_next <stdatomic.h>
#else
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* 7.17.1 Introduction */
#define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __CLANG_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __CLANG_ATOMIC_INT_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
/* 7.17.2 Initialization */
#define ATOMIC_VAR_INIT(value) (value)
#define atomic_init __c11_atomic_init
/* 7.17.3 Order and consistency */
typedef enum memory_order {
memory_order_relaxed = __ATOMIC_RELAXED,
memory_order_consume = __ATOMIC_CONSUME,
memory_order_acquire = __ATOMIC_ACQUIRE,
memory_order_release = __ATOMIC_RELEASE,
memory_order_acq_rel = __ATOMIC_ACQ_REL,
memory_order_seq_cst = __ATOMIC_SEQ_CST
} memory_order;
#define kill_dependency(y) (y)
/* 7.17.4 Fences */
#define atomic_thread_fence(order) __c11_atomic_thread_fence(order)
#define atomic_signal_fence(order) __c11_atomic_signal_fence(order)
/* 7.17.5 Lock-free property */
#define atomic_is_lock_free(obj) __c11_atomic_is_lock_free(sizeof(*(obj)))
/* 7.17.6 Atomic integer types */
#ifdef __cplusplus
typedef _Atomic(bool) atomic_bool;
#else
typedef _Atomic(_Bool) atomic_bool;
#endif
typedef _Atomic(char) atomic_char;
typedef _Atomic(signed char) atomic_schar;
typedef _Atomic(unsigned char) atomic_uchar;
typedef _Atomic(short) atomic_short;
typedef _Atomic(unsigned short) atomic_ushort;
typedef _Atomic(int) atomic_int;
typedef _Atomic(unsigned int) atomic_uint;
typedef _Atomic(long) atomic_long;
typedef _Atomic(unsigned long) atomic_ulong;
typedef _Atomic(long long) atomic_llong;
typedef _Atomic(unsigned long long) atomic_ullong;
typedef _Atomic(uint_least16_t) atomic_char16_t;
typedef _Atomic(uint_least32_t) atomic_char32_t;
typedef _Atomic(wchar_t) atomic_wchar_t;
typedef _Atomic(int_least8_t) atomic_int_least8_t;
typedef _Atomic(uint_least8_t) atomic_uint_least8_t;
typedef _Atomic(int_least16_t) atomic_int_least16_t;
typedef _Atomic(uint_least16_t) atomic_uint_least16_t;
typedef _Atomic(int_least32_t) atomic_int_least32_t;
typedef _Atomic(uint_least32_t) atomic_uint_least32_t;
typedef _Atomic(int_least64_t) atomic_int_least64_t;
typedef _Atomic(uint_least64_t) atomic_uint_least64_t;
typedef _Atomic(int_fast8_t) atomic_int_fast8_t;
typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t;
typedef _Atomic(int_fast16_t) atomic_int_fast16_t;
typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t;
typedef _Atomic(int_fast32_t) atomic_int_fast32_t;
typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t;
typedef _Atomic(int_fast64_t) atomic_int_fast64_t;
typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t;
typedef _Atomic(intptr_t) atomic_intptr_t;
typedef _Atomic(uintptr_t) atomic_uintptr_t;
typedef _Atomic(size_t) atomic_size_t;
typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t;
typedef _Atomic(intmax_t) atomic_intmax_t;
typedef _Atomic(uintmax_t) atomic_uintmax_t;
/* 7.17.7 Operations on atomic types */
#define atomic_store(object, desired) __c11_atomic_store(object, desired, __ATOMIC_SEQ_CST)
#define atomic_store_explicit __c11_atomic_store
#define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
#define atomic_load_explicit __c11_atomic_load
#define atomic_exchange(object, desired) __c11_atomic_exchange(object, desired, __ATOMIC_SEQ_CST)
#define atomic_exchange_explicit __c11_atomic_exchange
#define atomic_compare_exchange_strong(object, expected, desired) __c11_atomic_compare_exchange_strong(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
#define atomic_compare_exchange_strong_explicit __c11_atomic_compare_exchange_strong
#define atomic_compare_exchange_weak(object, expected, desired) __c11_atomic_compare_exchange_weak(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
#define atomic_compare_exchange_weak_explicit __c11_atomic_compare_exchange_weak
#define atomic_fetch_add(object, operand) __c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_add_explicit __c11_atomic_fetch_add
#define atomic_fetch_sub(object, operand) __c11_atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_sub_explicit __c11_atomic_fetch_sub
#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_or_explicit __c11_atomic_fetch_or
#define atomic_fetch_xor(object, operand) __c11_atomic_fetch_xor(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_xor_explicit __c11_atomic_fetch_xor
#define atomic_fetch_and(object, operand) __c11_atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_and_explicit __c11_atomic_fetch_and
/* 7.17.8 Atomic flag type and operations */
typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
#define ATOMIC_FLAG_INIT { 0 }
#define atomic_flag_test_and_set(object) __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST)
#define atomic_flag_test_and_set_explicit(object, order) __c11_atomic_exchange(&(object)->_Value, 1, order)
#define atomic_flag_clear(object) __c11_atomic_store(&(object)->_Value, 0, __ATOMIC_SEQ_CST)
#define atomic_flag_clear_explicit(object, order) __c11_atomic_store(&(object)->_Value, 0, order)
#ifdef __cplusplus
}
#endif
#endif /* __STDC_HOSTED__ */
#endif /* __CLANG_STDATOMIC_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/stddef.h | /*===---- stddef.h - Basic type definitions --------------------------------===
*
* Copyright (c) 2008 Eli Friedman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*===-----------------------------------------------------------------------===
*/
#ifndef __STDDEF_H
#define __STDDEF_H
#undef NULL
#ifdef __cplusplus
#if __cplusplus >= 201103L
#define NULL nullptr
#else
#undef __null // VC++ hack.
#define NULL __null
#endif
#else
#define NULL ((void*)0)
#endif
#ifndef _PTRDIFF_T
#define _PTRDIFF_T
typedef __typeof__(((int*)NULL)-((int*)NULL)) ptrdiff_t;
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef __typeof__(sizeof(int)) size_t;
#endif
#ifndef __cplusplus
#ifndef _WCHAR_T
#define _WCHAR_T
typedef __WCHAR_TYPE__ wchar_t;
#endif
#endif
#ifndef offsetof
#define offsetof(t, d) __builtin_offsetof(t, d)
#endif
#endif /* __STDDEF_H */
/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
#if defined(__need_wint_t)
#if !defined(_WINT_T)
#define _WINT_T
typedef __WINT_TYPE__ wint_t;
#endif /* _WINT_T */
#undef __need_wint_t
#endif /* __need_wint_t */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs/fifofs/fifo.h | /*
* Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*
* 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.
* 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.
*
* @(#)fifo.h 8.3 (Berkeley) 8/10/94
*/
#ifndef __FIFOFS_FOFO_H__
#define __FIFOFS_FOFO_H__
__BEGIN_DECLS
/*
* Prototypes for fifo operations on vnodes.
*/
int fifo_ebadf(void *);
#define fifo_create (int (*) (struct vnop_create_args *))err_create
#define fifo_mknod (int (*) (struct vnop_mknod_args *))err_mknod
#define fifo_access (int (*) (struct vnop_access_args *))fifo_ebadf
#define fifo_getattr (int (*) (struct vnop_getattr_args *))fifo_ebadf
#define fifo_setattr (int (*) (struct vnop_setattr_args *))fifo_ebadf
#define fifo_revoke nop_revoke
#define fifo_mmap (int (*) (struct vnop_mmap_args *))err_mmap
#define fifo_fsync (int (*) (struct vnop_fsync_args *))nullop
#define fifo_remove (int (*) (struct vnop_remove_args *))err_remove
#define fifo_link (int (*) (struct vnop_link_args *))err_link
#define fifo_rename (int (*) (struct vnop_rename_args *))err_rename
#define fifo_mkdir (int (*) (struct vnop_mkdir_args *))err_mkdir
#define fifo_rmdir (int (*) (struct vnop_rmdir_args *))err_rmdir
#define fifo_symlink (int (*) (struct vnop_symlink_args *))err_symlink
#define fifo_readdir (int (*) (struct vnop_readdir_args *))err_readdir
#define fifo_readlink (int (*) (struct vnop_readlink_args *))err_readlink
#define fifo_reclaim (int (*) (struct vnop_reclaim_args *))nullop
#define fifo_strategy (int (*) (struct vnop_strategy_args *))err_strategy
#define fifo_valloc (int (*) (struct vnop_valloc_args *))err_valloc
#define fifo_vfree (int (*) (struct vnop_vfree_args *))err_vfree
#define fifo_bwrite (int (*) (struct vnop_bwrite_args *))nullop
#define fifo_blktooff (int (*) (struct vnop_blktooff_args *))err_blktooff
int fifo_lookup(struct vnop_lookup_args *);
int fifo_open(struct vnop_open_args *);
int fifo_close(struct vnop_close_args *);
int fifo_read(struct vnop_read_args *);
int fifo_write(struct vnop_write_args *);
int fifo_ioctl(struct vnop_ioctl_args *);
int fifo_select(struct vnop_select_args *);
int fifo_inactive(struct vnop_inactive_args *);
int fifo_pathconf(struct vnop_pathconf_args *);
int fifo_advlock(struct vnop_advlock_args *);
__END_DECLS
#endif /* __FIFOFS_FOFO_H__ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs/devfs/devfs.h | /*
* Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright 1997,1998 Julian Elischer. All rights reserved.
* [email protected]
*
* 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 COPYRIGHT HOLDER ``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 HOLDER 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.
*
* miscfs/devfs/devfs.h
*/
#ifndef _MISCFS_DEVFS_DEVFS_H_
#define _MISCFS_DEVFS_DEVFS_H_
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
#define DEVFS_CHAR 0
#define DEVFS_BLOCK 1
/*
* Argument to clone callback after dev
*/
#define DEVFS_CLONE_ALLOC 1 /* Allocate minor number slot */
#define DEVFS_CLONE_FREE 0 /* Free minor number slot */
__BEGIN_DECLS
/*
* Function: devfs_make_node_clone
*
* Purpose
* Create a device node with the given pathname in the devfs namespace;
* before returning a dev_t value for an open instance, the dev_t has
* it's minor number updated by calling the supplied clone function on
* the supplied dev..
*
* Parameters:
* dev - the dev_t value to associate
* chrblk - block or character device (DEVFS_CHAR or DEVFS_BLOCK)
* uid, gid - ownership
* perms - permissions
* clone - minor number cloning function
* fmt, ... - print format string and args to format the path name
* Returns:
* A handle to a device node if successful, NULL otherwise.
*/
void * devfs_make_node_clone(dev_t dev, int chrblk, uid_t uid, gid_t gid,
int perms, int (*clone)(dev_t dev, int action),
const char *fmt, ...);
/*
* Function: devfs_make_node
*
* Purpose
* Create a device node with the given pathname in the devfs namespace.
*
* Parameters:
* dev - the dev_t value to associate
* chrblk - block or character device (DEVFS_CHAR or DEVFS_BLOCK)
* uid, gid - ownership
* perms - permissions
* fmt, ... - print format string and args to format the path name
* Returns:
* A handle to a device node if successful, NULL otherwise.
*/
void * devfs_make_node(dev_t dev, int chrblk, uid_t uid, gid_t gid,
int perms, const char *fmt, ...);
/*
* Function: devfs_remove
*
* Purpose:
* Remove the device node returned by devfs_make_node() along with
* any links created with devfs_make_link().
*/
void devfs_remove(void * handle);
__END_DECLS
#ifdef __APPLE_API_PRIVATE
/* XXX */
#define UID_ROOT 0
#define UID_BIN 3
#define UID_UUCP 66
#define UID_LOGD 272
/* XXX */
#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_WINDOWSERVER 88
#define GID_LOGD 272
#endif /* __APPLE_API_PRIVATE */
#endif /* !_MISCFS_DEVFS_DEVFS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs/union/union.h | /*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*
* Copyright (c) 1994 The Regents of the University of California.
* Copyright (c) 1994 Jan-Simon Pendry.
* All rights reserved.
*
* This code is derived from software donated to Berkeley by
* Jan-Simon Pendry.
*
* 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.
*
* @(#)union.h 8.9 (Berkeley) 12/10/94
*/
#ifndef __UNION_UNION_H__
#define __UNION_UNION_H__
#endif /* __UNION_UNION_H__ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/miscfs/specfs/specdev.h | /*
* Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1995, 1998 Apple Computer, Inc. All Rights Reserved.
* 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.
*
* @(#)specdev.h 8.6 (Berkeley) 5/21/95
*/
#ifndef _MISCFS_SPECFS_SPECDEV_H_
#define _MISCFS_SPECFS_SPECDEV_H_
#include <sys/appleapiopts.h>
#ifdef __APPLE_API_PRIVATE
#include <vfs/vfs_support.h>
/*
* This structure defines the information maintained about
* special devices. It is allocated in checkalias and freed
* in vgone.
*/
struct specinfo {
struct vnode **si_hashchain;
struct vnode *si_specnext;
long si_flags;
dev_t si_rdev;
int32_t si_opencount;
daddr_t si_size; /* device block size in bytes */
daddr64_t si_lastr; /* last read blkno (read-ahead) */
u_int64_t si_devsize; /* actual device size in bytes */
u_int8_t si_initted;
u_int8_t si_throttleable;
u_int16_t si_isssd;
u_int32_t si_devbsdunit;
u_int64_t si_throttle_mask;
};
/*
* Exported shorthand
*/
#define v_rdev v_specinfo->si_rdev
#define v_hashchain v_specinfo->si_hashchain
#define v_specnext v_specinfo->si_specnext
#define v_specflags v_specinfo->si_flags
#define v_specsize v_specinfo->si_size
#define v_specdevsize v_specinfo->si_devsize
#define v_speclastr v_specinfo->si_lastr
/*
* Flags for specinfo
*/
#define SI_MOUNTEDON 0x0001 /* block special device is mounted on */
#define SI_ALIASED 0x0002 /* multiple active vnodes refer to this device */
/*
* Special device management
*/
#define SPECHSZ 64
#if ((SPECHSZ & (SPECHSZ - 1)) == 0)
#define SPECHASH(rdev) (((rdev>>21)+(rdev))&(SPECHSZ-1))
#else
#define SPECHASH(rdev) (((unsigned)((rdev>>21)+(rdev)))%SPECHSZ)
#endif
extern struct vnode *speclisth[SPECHSZ];
/*
* Prototypes for special file operations on vnodes.
*/
extern int(**spec_vnodeop_p)(void *);
struct nameidata;
struct componentname;
struct flock;
struct buf;
struct uio;
__BEGIN_DECLS
int spec_ebadf(void *);
int spec_lookup(struct vnop_lookup_args *);
#define spec_create (int (*) (struct vnop_access_args *))err_create
#define spec_mknod (int (*) (struct vnop_access_args *))err_mknod
int spec_open(struct vnop_open_args *);
int spec_close(struct vnop_close_args *);
#define spec_access (int (*) (struct vnop_access_args *))spec_ebadf
#define spec_getattr (int (*) (struct vnop_getattr_args *))spec_ebadf
#define spec_setattr (int (*) (struct vnop_setattr_args *))spec_ebadf
int spec_read(struct vnop_read_args *);
int spec_write(struct vnop_write_args *);
int spec_ioctl(struct vnop_ioctl_args *);
int spec_select(struct vnop_select_args *);
#define spec_revoke (int (*) (struct vnop_access_args *))nop_revoke
#define spec_mmap (int (*) (struct vnop_access_args *))err_mmap
int spec_fsync(struct vnop_fsync_args *);
#define spec_remove (int (*) (struct vnop_access_args *))err_remove
#define spec_link (int (*) (struct vnop_access_args *))err_link
#define spec_rename (int (*) (struct vnop_access_args *))err_rename
#define spec_mkdir (int (*) (struct vnop_access_args *))err_mkdir
#define spec_rmdir (int (*) (struct vnop_access_args *))err_rmdir
#define spec_symlink (int (*) (struct vnop_access_args *))err_symlink
#define spec_readdir (int (*) (struct vnop_access_args *))err_readdir
#define spec_readlink (int (*) (struct vnop_access_args *))err_readlink
#define spec_inactive (int (*) (struct vnop_access_args *))nop_inactive
#define spec_reclaim (int (*) (struct vnop_access_args *))nop_reclaim
#define spec_lock (int (*) (struct vnop_access_args *))nop_lock
#define spec_unlock (int (*)(struct vnop_access_args *))nop_unlock
int spec_strategy(struct vnop_strategy_args *);
#define spec_islocked (int (*) (struct vnop_access_args *))nop_islocked
int spec_pathconf(struct vnop_pathconf_args *);
#define spec_advlock (int (*) (struct vnop_access_args *))err_advlock
#define spec_blkatoff (int (*) (struct vnop_access_args *))err_blkatoff
#define spec_valloc (int (*) (struct vnop_access_args *))err_valloc
#define spec_vfree (int (*) (struct vnop_access_args *))err_vfree
#define spec_bwrite (int (*) (struct vnop_bwrite_args *))nop_bwrite
__END_DECLS
#endif /* __APPLE_API_PRIVATE */
#endif /* _MISCFS_SPECFS_SPECDEV_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/atomic.h | /*
* Copyright (c) 2015-2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_ATOMIC_H
#define _MACHINE_ATOMIC_H
#include <os/atomic_private.h>
#if defined (__x86_64__)
#include "i386/atomic.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/atomic.h"
#else
#error architecture not supported
#endif
#endif /* _MACHINE_ATOMIC_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/types.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright 1995 NeXT Computer, Inc. All rights reserved.
*/
#ifndef _BSD_MACHINE_TYPES_H_
#define _BSD_MACHINE_TYPES_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/types.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/types.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_TYPES_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/signal.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE_SIGNAL_H_
#define _BSD_MACHINE_SIGNAL_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/signal.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/signal.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_SIGNAL_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/endian.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright 1995 NeXT Computer, Inc. All rights reserved.
*/
#ifndef _BSD_MACHINE_ENDIAN_H_
#define _BSD_MACHINE_ENDIAN_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/endian.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/endian.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_ENDIAN_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/vmparam.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE_VMPARAM_H_
#define _BSD_MACHINE_VMPARAM_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/vmparam.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/vmparam.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_VMPARAM_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/smp.h | /*
* Copyright (c) 2014 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_SMP_H
#define _MACHINE_SMP_H
#if defined (__x86_64__)
#include "i386/smp.h"
#elif defined (__arm__) || defined (__arm64__)
#else
#error architecture not supported
#endif
#endif /* _MACHINE_SMP_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/_limits.h | /*
* Copyright (c) 2004-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE__LIMITS_H_
#define _BSD_MACHINE__LIMITS_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/_limits.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/_limits.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE__LIMITS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/config.h | /*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_CONFIG_H
#define _MACHINE_CONFIG_H
#if defined (__i386__) || defined (__x86_64__)
#elif defined (__arm__)
#include <pexpert/arm/board_config.h>
#elif defined (__arm64__)
#include <pexpert/arm64/board_config.h>
#else
#error architecture not supported
#endif
#endif /* _MACHINE_CONFIG_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/disklabel.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE_CPU_H_
#define _BSD_MACHINE_CPU_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/disklabel.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/disklabel.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_CPU_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/machine_perfmon.h | // Copyright (c) 2020 Apple Inc. All rights reserved.
//
// @APPLE_OSREFERENCE_LICENSE_HEADER_START@
//
// This file contains Original Code and/or Modifications of Original Code
// as defined in and that are subject to the Apple Public Source License
// Version 2.0 (the 'License'). You may not use this file except in
// compliance with the License. The rights granted to you under the License
// may not be used to create, or enable the creation or redistribution of,
// unlawful or unlicensed copies of an Apple operating system, or to
// circumvent, violate, or enable the circumvention or violation of, any
// terms of an Apple operating system software license agreement.
//
// Please obtain a copy of the License at
// http://www.opensource.apple.com/apsl/ and read it before using this file.
//
// The Original Code and all software distributed under the License are
// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
// Please see the License for the specific language governing rights and
// limitations under the License.
//
// @APPLE_OSREFERENCE_LICENSE_HEADER_END@
#include <kern/perfmon.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/queue.h>
struct perfmon_counter {
uint64_t pc_number;
};
struct perfmon_config {
struct perfmon_source *pc_source;
struct perfmon_spec pc_spec;
unsigned short pc_attr_ids[PERFMON_SPEC_MAX_ATTR_COUNT];
struct perfmon_counter *pc_counters;
uint64_t pc_counters_used;
uint64_t pc_attrs_used;
bool pc_configured:1;
};
static_assert(PERFMON_SPEC_MAX_ATTR_COUNT < sizeof(uint64_t) * CHAR_BIT,
"attr IDs must fit in 64-bit integer");
/// Fill in an array of register values for all units.
void perfmon_machine_sample_regs(enum perfmon_kind kind, uint64_t *regs,
size_t regs_len);
// Set up the counters as specified by the configuration.
int perfmon_machine_configure(enum perfmon_kind kind,
const perfmon_config_t config);
// Reset the counters to an inactive state.
void perfmon_machine_reset(enum perfmon_kind kind);
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/_mcontext.h | /*
* Copyright (c) 2003-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE__MCONTEXT_H_
#define _BSD_MACHINE__MCONTEXT_H_
#if defined (__i386__) || defined (__x86_64__)
#include "i386/_mcontext.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/_mcontext.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE__MCONTEXT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/byte_order.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1995 NeXT Computer, Inc.
*/
#ifndef _BSD_MACHINE_BYTE_ORDER_H_
#define _BSD_MACHINE_BYTE_ORDER_H_
#include <architecture/byte_order.h>
#endif /* _BSD_MACHINE_BYTE_ORDER_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/trap.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_TRAP_H
#define _MACHINE_TRAP_H
#if defined (__i386__) || defined (__x86_64__)
#include "i386/trap.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/trap.h"
#else
#error architecture not supported
#endif
#endif /* _MACHINE_TRAP_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/pal_routines.h | /*
* Copyright (c) 2009 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_PAL_ROUTINES_H
#define _MACHINE_PAL_ROUTINES_H
#if defined (__i386__) || defined(__x86_64__)
#include "i386/pal_routines.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/pal_routines.h"
#else
#error architecture not supported
#endif
#endif /* _MACHINE_PAL_ROUTINES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/memory_types.h | /*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_MEMORY_TYPES_H
#define _MACHINE_MEMORY_TYPES_H
#if defined (__i386__) || defined(__x86_64__)
#include "i386/memory_types.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/memory_types.h"
#else
#error architecture not supported
#endif
#endif /* _MACHINE_MEMORY_TYPES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/monotonic.h | /*
* Copyright (c) 2017 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef MACHINE_MONOTONIC_H
#define MACHINE_MONOTONIC_H
#if defined(__x86_64__)
#include <x86_64/monotonic.h>
#elif defined(__arm64__)
#include <arm64/monotonic.h>
#elif defined(__arm__)
#include <arm/monotonic.h>
#else
#error unsupported architecture
#endif
#include <stdatomic.h>
#include <stdbool.h>
#include <stdint.h>
extern bool mt_core_supported;
struct mt_cpu {
uint64_t mtc_snaps[MT_CORE_NFIXED];
uint64_t mtc_counts[MT_CORE_NFIXED];
uint64_t mtc_counts_last[MT_CORE_NFIXED];
uint64_t mtc_npmis;
/*
* Whether this CPU should be using PMCs.
*/
bool mtc_active;
};
struct mt_thread {
_Atomic uint64_t mth_gen;
uint64_t mth_counts[MT_CORE_NFIXED];
};
struct mt_task {
uint64_t mtk_counts[MT_CORE_NFIXED];
};
struct mt_cpu *mt_cur_cpu(void);
uint64_t mt_count_pmis(void);
void mt_mtc_update_fixed_counts(struct mt_cpu *mtc, uint64_t *counts,
uint64_t *counts_since);
uint64_t mt_mtc_update_count(struct mt_cpu *mtc, unsigned int ctr);
uint64_t mt_core_snap(unsigned int ctr);
void mt_core_set_snap(unsigned int ctr, uint64_t snap);
void mt_mtc_set_snap(struct mt_cpu *mtc, unsigned int ctr, uint64_t snap);
typedef void (*mt_pmi_fn)(bool user_mode, void *ctx);
extern bool mt_microstackshots;
extern unsigned int mt_microstackshot_ctr;
extern mt_pmi_fn mt_microstackshot_pmi_handler;
extern void *mt_microstackshot_ctx;
extern uint64_t mt_core_reset_values[MT_CORE_NFIXED];
int mt_microstackshot_start_arch(uint64_t period);
#endif /* !defined(MACHINE_MONOTONIC_H) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/limits.h | /* This is the `system' limits.h, independent of any particular
* compiler. GCC provides its own limits.h which can be found in
* /usr/lib/gcc, although it is not very informative.
* This file is public domain. */
#ifndef _BSD_MACHINE_LIMITS_H_
#define _BSD_MACHINE_LIMITS_H_
#if defined (__i386__) || defined(__x86_64__)
#include <i386/limits.h>
#elif defined (__arm__) || defined (__arm64__)
#include <arm/limits.h>
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_LIMITS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/_types.h | /*
* Copyright (c) 2003-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE__TYPES_H_
#define _BSD_MACHINE__TYPES_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/_types.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/_types.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE__TYPES_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/locks.h | /*
* Copyright (c) 2004-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_LOCKS_H_
#define _MACHINE_LOCKS_H_
#if defined (__i386__) || defined (__x86_64__)
#include "i386/locks.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/locks.h"
#else
#error architecture not supported
#endif
#endif /* _MACHINE_LOCKS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/machine_routines.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_MACHINE_ROUTINES_H
#define _MACHINE_MACHINE_ROUTINES_H
#include <sys/cdefs.h>
#if defined (__i386__) || defined(__x86_64__)
#include "i386/machine_routines.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/machine_routines.h"
#else
#error architecture not supported
#endif
__BEGIN_DECLS
/*!
* @enum cpu_event
* @abstract Broadcast events allowing clients to hook CPU state transitions.
* @constant CPU_BOOT_REQUESTED Called from processor_start(); may block.
* @constant CPU_BOOTED Called from platform code on the newly-booted CPU; may not block.
* @constant CPU_ACTIVE Called from scheduler code; may block.
* @constant CLUSTER_ACTIVE Called from platform code; may not block.
* @constant CPU_EXIT_REQUESTED Called from processor_exit(); may block.
* @constant CPU_DOWN Called from platform code on the disabled CPU; may not block.
* @constant CLUSTER_EXIT_REQUESTED Called from platform code; may not block.
* @constant CPU_EXITED Called after CPU is stopped; may block.
*/
enum cpu_event {
CPU_BOOT_REQUESTED = 0,
CPU_BOOTED,
CPU_ACTIVE,
CLUSTER_ACTIVE,
CPU_EXIT_REQUESTED,
CPU_DOWN,
CLUSTER_EXIT_REQUESTED,
CPU_EXITED,
};
typedef bool (*cpu_callback_t)(void *param, enum cpu_event event, unsigned int cpu_or_cluster);
/*!
* @function cpu_event_register_callback
* @abstract Register a function to be called on CPU state changes.
* @param fn Function to call on state change events.
* @param param Optional argument to be passed to the callback (e.g. object pointer).
*/
void cpu_event_register_callback(cpu_callback_t fn, void *param);
/*!
* @function cpu_event_unregister_callback
* @abstract Unregister a previously-registered callback function.
* @param fn Function pointer previously passed to cpu_event_register_callback().
*/
void cpu_event_unregister_callback(cpu_callback_t fn);
/*!
* @function ml_io_read()
* @brief Perform an MMIO read access
*
* @return The value resulting from the read.
*
*/
unsigned long long ml_io_read(uintptr_t iovaddr, int iovsz);
unsigned int ml_io_read8(uintptr_t iovaddr);
unsigned int ml_io_read16(uintptr_t iovaddr);
unsigned int ml_io_read32(uintptr_t iovaddr);
unsigned long long ml_io_read64(uintptr_t iovaddr);
/*!
* @function ml_io_write()
* @brief Perform an MMIO write access
*
*/
void ml_io_write(uintptr_t vaddr, uint64_t val, int size);
void ml_io_write8(uintptr_t vaddr, uint8_t val);
void ml_io_write16(uintptr_t vaddr, uint16_t val);
void ml_io_write32(uintptr_t vaddr, uint32_t val);
void ml_io_write64(uintptr_t vaddr, uint64_t val);
__END_DECLS
#endif /* _MACHINE_MACHINE_ROUTINES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/param.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright 1995 NeXT Computer, Inc. All rights reserved.
*/
#ifndef _BSD_MACHINE_PARAM_H_
#define _BSD_MACHINE_PARAM_H_
#if defined (__i386__) || defined(__x86_64__)
#include <i386/param.h>
#elif defined (__arm__) || defined (__arm64__)
#include <arm/param.h>
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_PARAM_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/pal_hibernate.h | /*
* Copyright (c) 2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/**
* Platform abstraction layer to support hibernation.
*/
#ifndef _MACHINE_PAL_HIBERNATE_H
#define _MACHINE_PAL_HIBERNATE_H
#include <sys/cdefs.h>
#if defined (__i386__) || defined(__x86_64__)
#include "i386/pal_hibernate.h"
#elif defined (__arm__)
//#include "arm/pal_hibernate.h"
#elif defined(__arm64__)
#include "arm64/pal_hibernate.h"
#else
#error architecture not supported
#endif
__BEGIN_DECLS
/*!
* @typedef pal_hib_restore_stage_t
* @discussion hibernate_kernel_entrypoint restores data in multiple stages; this enum defines those stages.
*/
typedef enum {
pal_hib_restore_stage_dram_pages = 0,
pal_hib_restore_stage_preview_pages = 1,
pal_hib_restore_stage_handoff_data = 2,
} pal_hib_restore_stage_t;
/*!
* @typedef pal_hib_ctx_t
* @discussion This type is used to pass context between pal_hib_resume_init, pal_hib_restored_page, and
* pal_hib_patchup during hibernation resume. The context is declared on the stack in
* hibernate_kernel_entrypoint, so it should be relatively small. During pal_hib_resume_init(),
* additional memory can be allocated with hibernate_page_list_grab if necessary.
*/
typedef struct pal_hib_ctx pal_hib_ctx_t;
/*!
* @function __hib_assert
* @discussion Called when a fatal assertion has been detected during hibernation. Logs the
* expression string and loops indefinitely.
*
* @param file The source file in which the failed assertion occurred
* @param line The line number at which the failed assertion occurred
* @param expression A string describing the failed assertion
*/
void __hib_assert(const char *file, int line, const char *expression) __attribute__((noreturn));
#define HIB_ASSERT(ex) \
(__builtin_expect(!!((ex)), 1L) ? (void)0 : __hib_assert(__FILE__, __LINE__, # ex))
/*!
* @function pal_hib_map
* @discussion Given a map type and a physical address, return the corresponding virtual address.
*
* @param virt Which memory region to access
* @param phys The physical address to access
*
* @result The virtual address corresponding to this physical address.
*/
uintptr_t pal_hib_map(pal_hib_map_type_t virt, uint64_t phys);
/*!
* @function pal_hib_restore_pal_state
* @discussion Callout to the platform abstraction layer to restore platform-specific data.
*
* @param src Pointer to platform-specific data
*/
void pal_hib_restore_pal_state(uint32_t *src);
/*!
* @function pal_hib_init
* @discussion Platform-specific hibernation initialization.
*/
void pal_hib_init(void);
/*!
* @function pal_hib_write_hook
* @discussion Platform-specific callout before the hibernation image is written.
*/
void pal_hib_write_hook(void);
/*!
* @function pal_hib_resume_init
* @discussion Initialize the platform-specific hibernation resume context. Additional memory can
* be allocated with hibernate_page_list_grab if necessary
*
* @param palHibCtx Pointer to platform-specific hibernation resume context
* @param map map argument that can be passed to hibernate_page_list_grab
* @param nextFree nextFree argument that can be passed to hibernate_page_list_grab
*/
void pal_hib_resume_init(pal_hib_ctx_t *palHibCtx, hibernate_page_list_t *map, uint32_t *nextFree);
/*!
* @function pal_hib_restored_page
* @discussion Inform the platform abstraction layer of a page that will be restored.
*
* @param palHibCtx Pointer to platform-specific hibernation resume context
* @param stage The stage of hibernation resume during which this page will be resumed
* @param ppnum The page number of the page that will be resumed.
*/
void pal_hib_restored_page(pal_hib_ctx_t *palHibCtx, pal_hib_restore_stage_t stage, ppnum_t ppnum);
/*!
* @function pal_hib_patchup
* @discussion Allow the platform abstraction layer to perform post-restore fixups.
*
* @param palHibCtx Pointer to platform-specific hibernation resume context
*/
void pal_hib_patchup(pal_hib_ctx_t *palHibCtx);
/*!
* @function pal_hib_teardown_pmap_structs
* @discussion Platform-specific function to return a range of memory that doesn't need to be saved during hibernation.
*
* @param unneeded_start Out parameter: the beginning of the unneeded range
* @param unneeded_end Out parameter: the end of the unneeded range
*/
void pal_hib_teardown_pmap_structs(addr64_t *unneeded_start, addr64_t *unneeded_end);
/*!
* @function pal_hib_rebuild_pmap_structs
* @discussion Platform-specific function to fix up the teardown done by pal_hib_teardown_pmap_structs.
*/
void pal_hib_rebuild_pmap_structs(void);
/*!
* @function pal_hib_decompress_page
* @discussion Decompress a page of memory using WKdm
*
* @param src The compressed data
* @param dst A page-sized buffer to decompress into; must be page aligned
* @param scratch A page-sized scratch buffer to use during decompression
* @param compressedSize The number of bytes to decompress
*/
void pal_hib_decompress_page(void *src, void *dst, void *scratch, unsigned int compressedSize);
__END_DECLS
#endif /* _MACHINE_PAL_HIBERNATE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/profile.h | /*
* Copyright (c) 1997-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* History :
* 29-Sep-1997 Umesh Vaishampayan
* Created.
*/
#ifndef _BSD_MACHINE_PROFILE_H_
#define _BSD_MACHINE_PROFILE_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/profile.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/profile.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_PROFILE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/_param.h | /*
* Copyright (c) 2004-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _BSD_MACHINE__PARAM_H_
#define _BSD_MACHINE__PARAM_H_
#if defined (__i386__) || defined (__x86_64__)
#include <i386/_param.h>
#elif defined (__arm__) || defined (__arm64__)
#include <arm/_param.h>
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE__PARAM_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/machine_remote_time.h | /*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef MACHINE_REMOTE_TIME_H
#define MACHINE_REMOTE_TIME_H
#if defined (__x86_64__)
#include "x86_64/machine_remote_time.h"
#elif defined (__arm64__)
#include "arm64/machine_remote_time.h"
#endif
#define BT_SLEEP_SENTINEL_TS (~1ULL)
#define BT_WAKE_SENTINEL_TS (~2ULL)
#define BT_RESET_SENTINEL_TS (~3ULL)
#endif /* MACHINE_REMOTE_TIME_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/machine/machine_kpc.h | /*
* Copyright (c) 2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACHINE_MACHINE_KPC_H
#define _MACHINE_MACHINE_KPC_H
#if defined (__x86_64__)
#include "x86_64/machine_kpc.h"
#elif defined (__arm64__)
#include "arm64/machine_kpc.h"
#elif defined (__arm__)
#include "arm/machine_kpc.h"
#else
#error architecture not supported
#endif
#endif /* _MACHINE_MACHINE_KPC_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/nfs/rpcv2.h | /*
* Copyright (c) 2000-2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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.
*
* @(#)rpcv2.h 8.2 (Berkeley) 3/30/95
* FreeBSD-Id: rpcv2.h,v 1.8 1997/05/11 18:05:39 tegge Exp $
*/
#ifndef _NFS_RPCV2_H_
#define _NFS_RPCV2_H_
#include <sys/appleapiopts.h>
#ifdef __APPLE_API_PRIVATE
/*
* Definitions for Sun RPC Version 2, from
* "RPC: Remote Procedure Call Protocol Specification" RFC1057
*/
/* Version # */
#define RPC_VER2 2
/* Authentication */
#define RPCAUTH_NULL 0
#define RPCAUTH_NONE RPCAUTH_NULL
#define RPCAUTH_UNIX 1
#define RPCAUTH_SYS RPCAUTH_UNIX
#define RPCAUTH_SHORT 2
#define RPCAUTH_KERB4 4
#define RPCAUTH_KRB5 390003
#define RPCAUTH_KRB5I 390004
#define RPCAUTH_KRB5P 390005
#define RPCAUTH_INVALID ~0U
#define RPCAUTH_UNKNOWN RPCAUTH_INVALID
#define RPCAUTH_MAXSIZ 400
#define RPCAUTH_UNIXGIDS 16
/*
* Constants associated with authentication flavours.
*/
#define RPCAKN_FULLNAME 0
#define RPCAKN_NICKNAME 1
/* Rpc Constants */
#define RPC_CALL 0
#define RPC_REPLY 1
#define RPC_MSGACCEPTED 0
#define RPC_MSGDENIED 1
#define RPC_SUCCESS 0
#define RPC_PROGUNAVAIL 1
#define RPC_PROGMISMATCH 2
#define RPC_PROCUNAVAIL 3
#define RPC_GARBAGE 4 /* I like this one */
#define RPC_SYSTEM_ERR 5
#define RPC_MISMATCH 0
#define RPC_AUTHERR 1
/* Authentication failures */
#define AUTH_BADCRED 1
#define AUTH_REJECTCRED 2
#define AUTH_BADVERF 3
#define AUTH_REJECTVERF 4
#define AUTH_TOOWEAK 5 /* Give em wheaties */
#define AUTH_INVALIDRESP 6
#define AUTH_FAILED 7
#define AUTH_KERB_GENERIC 8
#define AUTH_TIMEEXPIRE 9
#define AUTH_TKT_FILE 10
#define AUTH_DECODE 11
#define AUTH_NET_ADDR 12
#define RPCSEC_GSS_CREDPROBLEM 13
#define RPCSEC_GSS_CTXPROBLEM 14
/* Sizes of rpc header parts */
#define RPC_SIZ 24
#define RPC_REPLYSIZ 28
/* RPC Prog definitions */
#define RPCPROG_MNT 100005
#define RPCMNT_VER1 1
#define RPCMNT_VER3 3
#define RPCMNT_MOUNT 1
#define RPCMNT_DUMP 2
#define RPCMNT_UMOUNT 3
#define RPCMNT_UMNTALL 4
#define RPCMNT_EXPORT 5
#define RPCMNT_NAMELEN 255
#define RPCMNT_PATHLEN 1024
#define RPCPROG_NFS 100003
#define RPCPROG_STAT 100024
#define RPCPROG_RQUOTA 100011
#define RPCRQUOTA_VER 1
#define RPCRQUOTA_EXT_VER 2
#define RPCRQUOTA_GET 1
#define RQUOTA_STAT_OK 1
#define RQUOTA_STAT_NOQUOTA 2
#define RQUOTA_STAT_EPERM 3
/* Local transports for rpcbind */
#define RPCB_TICOTSORD_PATH "/var/run/rpcb.ticotsord"
#define RPCB_TICLTS_PATH "/var/run/rpcb.ticlst"
/* Local transport for nfs */
#define NFS_TICOTSORD_PATH "/var/ran/nfs.ticotsord"
#define NFS_TICLTS_PATH "/var/run/nfs.ticlts"
#endif /* __APPLE_API_PRIVATE */
#endif /* _NFS_RPCV2_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/nfs/xdr_subs.h | /*
* Copyright (c) 2000-2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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.
*
* @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95
* FreeBSD-Id: xdr_subs.h,v 1.9 1997/02/22 09:42:53 peter Exp $
*/
#ifndef _NFS_XDR_SUBS_H_
#define _NFS_XDR_SUBS_H_
#include <sys/appleapiopts.h>
#ifdef __APPLE_API_PRIVATE
/*
* Macros used for conversion to/from xdr representation by nfs...
* These use the MACHINE DEPENDENT routines ntohl, htonl
* As defined by "XDR: External Data Representation Standard" RFC1014
*
* To simplify the implementation, we use ntohl/htonl even on big-endian
* machines, and count on them being `#define'd away. Some of these
* might be slightly more efficient as quad_t copies on a big-endian,
* but we cannot count on their alignment anyway.
*/
#define fxdr_unsigned(t, v) ((t)ntohl((uint32_t)(v)))
#define txdr_unsigned(v) (htonl((uint32_t)(v)))
#define fxdr_hyper(f, t) { \
((uint32_t *)(t))[_QUAD_HIGHWORD] = ntohl(((uint32_t *)(f))[0]); \
((uint32_t *)(t))[_QUAD_LOWWORD] = ntohl(((uint32_t *)(f))[1]); \
}
#define txdr_hyper(f, t) { \
((uint32_t *)(t))[0] = htonl(((uint32_t *)(f))[_QUAD_HIGHWORD]); \
((uint32_t *)(t))[1] = htonl(((uint32_t *)(f))[_QUAD_LOWWORD]); \
}
/*
* xdrbuf
*
* generalized functionality for managing the building/dissecting of XDR data
*/
typedef enum xdrbuf_type {
XDRBUF_NONE = 0,
XDRBUF_BUFFER = 1,
} xdrbuf_type;
struct xdrbuf {
union {
struct {
char * xbb_base; /* base address of buffer */
size_t xbb_size; /* size of buffer */
size_t xbb_len; /* length of data in buffer */
} xb_buffer;
} xb_u;
char * xb_ptr; /* pointer to current position */
size_t xb_left; /* bytes remaining in current buffer */
size_t xb_growsize; /* bytes to allocate when growing */
xdrbuf_type xb_type; /* type of xdr buffer */
uint32_t xb_flags; /* XB_* (see below) */
};
#define XB_CLEANUP 0x0001 /* needs cleanup */
#define XDRWORD 4 /* the basic XDR building block is a 4 byte (32 bit) word */
#define xdr_rndup(a) (((a)+3)&(~0x3)) /* round up to XDRWORD size */
#define xdr_pad(a) (xdr_rndup(a) - (a)) /* calculate round up padding */
void xb_init(struct xdrbuf *, xdrbuf_type);
void xb_init_buffer(struct xdrbuf *, char *, size_t);
void xb_cleanup(struct xdrbuf *);
void *xb_malloc(size_t);
void xb_free(void *);
int xb_grow(struct xdrbuf *);
void xb_set_cur_buf_len(struct xdrbuf *);
char *xb_buffer_base(struct xdrbuf *);
int xb_advance(struct xdrbuf *, size_t);
size_t xb_offset(struct xdrbuf *);
int xb_seek(struct xdrbuf *, size_t);
int xb_add_bytes(struct xdrbuf *, const char *, size_t, int);
int xb_get_bytes(struct xdrbuf *, char *, uint32_t, int);
#ifdef _NFS_XDR_SUBS_FUNCS_
/*
* basic initialization of xdrbuf structure
*/
void
xb_init(struct xdrbuf *xbp, xdrbuf_type type)
{
bzero(xbp, sizeof(*xbp));
xbp->xb_type = type;
xbp->xb_flags |= XB_CLEANUP;
}
/*
* initialize a single-buffer xdrbuf
*/
void
xb_init_buffer(struct xdrbuf *xbp, char *buf, size_t buflen)
{
xb_init(xbp, XDRBUF_BUFFER);
xbp->xb_u.xb_buffer.xbb_base = buf;
xbp->xb_u.xb_buffer.xbb_size = buflen;
xbp->xb_u.xb_buffer.xbb_len = buflen;
xbp->xb_growsize = 512;
xbp->xb_ptr = buf;
xbp->xb_left = buflen;
if (buf) { /* when using an existing buffer, xb code should skip cleanup */
xbp->xb_flags &= ~XB_CLEANUP;
}
}
/*
* get the pointer to the single-buffer xdrbuf's buffer
*/
char *
xb_buffer_base(struct xdrbuf *xbp)
{
return xbp->xb_u.xb_buffer.xbb_base;
}
/*
* clean up any resources held by an xdrbuf
*/
void
xb_cleanup(struct xdrbuf *xbp)
{
if (!(xbp->xb_flags & XB_CLEANUP)) {
return;
}
switch (xbp->xb_type) {
case XDRBUF_BUFFER:
if (xbp->xb_u.xb_buffer.xbb_base) {
xb_free(xbp->xb_u.xb_buffer.xbb_base);
}
break;
default:
break;
}
xbp->xb_flags &= ~XB_CLEANUP;
}
/*
* set the length of valid data in the current buffer to
* be up to the current location within the buffer
*/
void
xb_set_cur_buf_len(struct xdrbuf *xbp)
{
switch (xbp->xb_type) {
case XDRBUF_BUFFER:
xbp->xb_u.xb_buffer.xbb_len = xbp->xb_ptr - xbp->xb_u.xb_buffer.xbb_base;
break;
default:
break;
}
}
/*
* advance forward through existing data in xdrbuf
*/
int
xb_advance(struct xdrbuf *xbp, size_t len)
{
size_t tlen;
while (len) {
if (xbp->xb_left <= 0) {
return EBADRPC;
}
tlen = MIN(xbp->xb_left, len);
if (tlen) {
xbp->xb_ptr += tlen;
xbp->xb_left -= tlen;
len -= tlen;
}
}
return 0;
}
/*
* Calculate the current offset in the XDR buffer.
*/
size_t
xb_offset(struct xdrbuf *xbp)
{
size_t offset = 0;
switch (xbp->xb_type) {
case XDRBUF_BUFFER:
offset = xbp->xb_ptr - xbp->xb_u.xb_buffer.xbb_base;
break;
default:
break;
}
return offset;
}
/*
* Seek to the given offset in the existing data in the XDR buffer.
*/
int
xb_seek(struct xdrbuf *xbp, size_t offset)
{
switch (xbp->xb_type) {
case XDRBUF_BUFFER:
xbp->xb_ptr = xbp->xb_u.xb_buffer.xbb_base + offset;
xbp->xb_left = xbp->xb_u.xb_buffer.xbb_len - offset;
break;
default:
break;
}
return 0;
}
/*
* allocate memory
*/
void *
xb_malloc(size_t size)
{
void *buf = NULL;
MALLOC(buf, void *, size, M_TEMP, M_WAITOK);
return buf;
}
/*
* free a chunk of memory allocated with xb_malloc()
*/
void
xb_free(void *buf)
{
FREE(buf, M_TEMP);
}
/*
* Increase space available for new data in XDR buffer.
*/
int
xb_grow(struct xdrbuf *xbp)
{
char *newbuf, *oldbuf;
size_t newsize, oldsize;
switch (xbp->xb_type) {
case XDRBUF_BUFFER:
oldsize = xbp->xb_u.xb_buffer.xbb_size;
oldbuf = xbp->xb_u.xb_buffer.xbb_base;
newsize = oldsize + xbp->xb_growsize;
if (newsize < oldsize) {
return ENOMEM;
}
newbuf = xb_malloc(newsize);
if (newbuf == NULL) {
return ENOMEM;
}
if (oldbuf != NULL) {
bcopy(oldbuf, newbuf, oldsize);
xb_free(oldbuf);
}
xbp->xb_u.xb_buffer.xbb_base = newbuf;
xbp->xb_u.xb_buffer.xbb_size = newsize;
xbp->xb_ptr = newbuf + oldsize;
xbp->xb_left = xbp->xb_growsize;
break;
default:
break;
}
return 0;
}
/*
* xb_add_bytes()
*
* Add "count" bytes of opaque data pointed to by "buf" to the given XDR buffer.
*/
int
xb_add_bytes(struct xdrbuf *xbp, const char *buf, size_t count, int nopad)
{
size_t len, tlen;
int error;
len = nopad ? count : xdr_rndup(count);
/* copy in "count" bytes and zero out any pad bytes */
while (len) {
if (xbp->xb_left <= 0) {
/* need more space */
if ((error = xb_grow(xbp))) {
return error;
}
if (xbp->xb_left <= 0) {
return ENOMEM;
}
}
tlen = MIN(xbp->xb_left, len);
if (tlen) {
if (count) {
if (tlen > count) {
tlen = count;
}
bcopy(buf, xbp->xb_ptr, tlen);
} else {
bzero(xbp->xb_ptr, tlen);
}
xbp->xb_ptr += tlen;
xbp->xb_left -= tlen;
len -= tlen;
if (count) {
buf += tlen;
count -= tlen;
}
}
}
return 0;
}
/*
* xb_get_bytes()
*
* Get "count" bytes of opaque data from the given XDR buffer.
*/
int
xb_get_bytes(struct xdrbuf *xbp, char *buf, uint32_t count, int nopad)
{
size_t len, tlen;
len = nopad ? count : xdr_rndup(count);
/* copy in "count" bytes and zero out any pad bytes */
while (len) {
if (xbp->xb_left <= 0) {
return ENOMEM;
}
tlen = MIN(xbp->xb_left, len);
if (tlen) {
if (count) {
if (tlen > count) {
tlen = count;
}
bcopy(xbp->xb_ptr, buf, tlen);
}
xbp->xb_ptr += tlen;
xbp->xb_left -= tlen;
len -= tlen;
if (count) {
buf += tlen;
count -= tlen;
}
}
}
return 0;
}
#endif /* _NFS_XDR_SUBS_FUNCS_ */
/*
* macros for building XDR data
*/
/* finalize the data that has been added to the buffer */
#define xb_build_done(E, XB) \
do { \
if (E) break; \
xb_set_cur_buf_len(XB); \
} while (0)
/* add a 32-bit value */
#define xb_add_32(E, XB, VAL) \
do { \
uint32_t __tmp; \
if (E) break; \
__tmp = txdr_unsigned(VAL); \
(E) = xb_add_bytes((XB), (void*)&__tmp, XDRWORD, 0); \
} while (0)
/* add a 64-bit value */
#define xb_add_64(E, XB, VAL) \
do { \
uint64_t __tmp1, __tmp2; \
if (E) break; \
__tmp1 = (VAL); \
txdr_hyper(&__tmp1, &__tmp2); \
(E) = xb_add_bytes((XB), (char*)&__tmp2, 2 * XDRWORD, 0); \
} while (0)
/* add an array of XDR words */
#define xb_add_word_array(E, XB, A, LEN) \
do { \
uint32_t __i; \
xb_add_32((E), (XB), (LEN)); \
for (__i=0; __i < (uint32_t)(LEN); __i++) \
xb_add_32((E), (XB), (A)[__i]); \
} while (0)
#define xb_add_bitmap(E, XB, B, LEN) xb_add_word_array((E), (XB), (B), (LEN))
/* add a file handle */
#define xb_add_fh(E, XB, FHP, FHLEN) \
do { \
xb_add_32((E), (XB), (FHLEN)); \
if (E) break; \
(E) = xb_add_bytes((XB), (char*)(FHP), (FHLEN), 0); \
} while (0)
/* add a string */
#define xb_add_string(E, XB, S, LEN) \
do { \
xb_add_32((E), (XB), (LEN)); \
if (E) break; \
(E) = xb_add_bytes((XB), (const char*)(S), (LEN), 0); \
} while (0)
/*
* macros for decoding XDR data
*/
/* skip past data in the buffer */
#define xb_skip(E, XB, LEN) \
do { \
if (E) break; \
(E) = xb_advance((XB), (LEN)); \
} while (0)
/* get a 32-bit value */
#define xb_get_32(E, XB, LVAL) \
do { \
uint32_t __tmp; \
(LVAL) = (typeof((LVAL))) 0; \
if (E) break; \
(E) = xb_get_bytes((XB), (char*)&__tmp, XDRWORD, 0); \
if (E) break; \
(LVAL) = fxdr_unsigned(uint32_t, __tmp); \
} while (0)
/* get a 64-bit value */
#define xb_get_64(E, XB, LVAL) \
do { \
uint64_t __tmp; \
(LVAL) = 0; \
if (E) break; \
(E) = xb_get_bytes((XB), (char*)&__tmp, 2 * XDRWORD, 0); \
if (E) break; \
fxdr_hyper(&__tmp, &(LVAL)); \
} while (0)
/* get an array of XDR words (of a given expected/maximum length) */
#define xb_get_word_array(E, XB, A, LEN) \
do { \
uint32_t __len = 0, __i; \
xb_get_32((E), (XB), __len); \
if (E) break; \
for (__i=0; __i < MIN(__len, (uint32_t)(LEN)); __i++) \
xb_get_32((E), (XB), (A)[__i]); \
if (E) break; \
for (; __i < __len; __i++) \
xb_skip((E), (XB), XDRWORD); \
for (; __i < (uint32_t)(LEN); __i++) \
(A)[__i] = 0; \
(LEN) = __len; \
} while (0)
#define xb_get_bitmap(E, XB, B, LEN) xb_get_word_array((E), (XB), (B), (LEN))
#endif /* __APPLE_API_PRIVATE */
#endif /* _NFS_XDR_SUBS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/nfs/krpc.h | /*
* Copyright (c) 2000-2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
#ifndef __NFS_KRPC_H__
#define __NFS_KRPC_H__
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
#ifdef __APPLE_API_PRIVATE
int krpc_call(struct sockaddr_in *sin, u_int sotype,
u_int prog, u_int vers, u_int func,
mbuf_t *data, struct sockaddr_in *from);
int krpc_portmap(struct sockaddr_in *sin,
u_int prog, u_int vers, u_int proto, u_int16_t *portp);
/*
* RPC definitions for the portmapper (portmap and rpcbind)
*/
#define PMAPPORT 111
#define PMAPPROG 100000
#define PMAPVERS 2
#define PMAPPROC_NULL 0
#define PMAPPROC_SET 1
#define PMAPPROC_UNSET 2
#define PMAPPROC_GETPORT 3
#define PMAPPROC_DUMP 4
#define PMAPPROC_CALLIT 5
#define RPCBPROG PMAPPROG
#define RPCBVERS3 3
#define RPCBVERS4 4
#define RPCBPROC_NULL 0
#define RPCBPROC_SET 1
#define RPCBPROC_UNSET 2
#define RPCBPROC_GETADDR 3
#define RPCBPROC_DUMP 4
#define RPCBPROC_CALLIT 5
#define RPCBPROC_BCAST RPCBPROC_CALLIT
#define RPCBPROC_GETTIME 6
#define RPCBPROC_UADDR2TADDR 7
#define RPCBPROC_TADDR2UADDR 8
#define RPCBPROC_GETVERSADDR 9
#define RPCBPROC_INDIRECT 10
#define RPCBPROC_GETADDRLIST 11
#define RPCBPROC_GETSTAT 12
/*
* RPC definitions for bootparamd
*/
#define BOOTPARAM_PROG 100026
#define BOOTPARAM_VERS 1
#define BOOTPARAM_WHOAMI 1
#define BOOTPARAM_GETFILE 2
#endif /* __APPLE_API_PRIVATE */
#endif /* __NFS_KRPC_H__ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/nfs/nfs.h | /*
* Copyright (c) 2000-2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*
* Copyright (c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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.
*
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
* FreeBSD-Id: nfs.h,v 1.32 1997/10/12 20:25:38 phk Exp $
*/
#ifndef _NFS_NFS_H_
#define _NFS_NFS_H_
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/user.h>
#include <net/radix.h>
#include <kern/locks.h>
#include <kern/lock_group.h>
#include <nfs/rpcv2.h>
#include <nfs/nfsproto.h>
#ifdef __APPLE_API_PRIVATE
/*
* Tunable constants for nfs
*/
#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
extern int nfs_ticks;
#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
#define NFS_MAXREXMIT 100 /* Stop counting after this many */
#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
#define NFS_TRYLATERDEL 4 /* Initial try later delay (sec) */
#define NFS_MAXGRPS 16U /* Max. size of groups list */
#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */
#define NFS_MAXATTRTIMO 60
#define NFS_MINDIRATTRTIMO 5 /* directory attribute cache timeout in sec */
#define NFS_MAXDIRATTRTIMO 60
#define NFS_MAXPORT 0xffff
#define NFS_IOSIZE (1024 * 1024) /* suggested I/O size */
#define NFS_RWSIZE 32768 /* Def. read/write data size <= 32K */
#define NFS_WSIZE NFS_RWSIZE /* Def. write data size <= 32K */
#define NFS_RSIZE NFS_RWSIZE /* Def. read data size <= 32K */
#define NFS_DGRAM_WSIZE 8192 /* UDP Def. write data size <= 8K */
#define NFS_DGRAM_RSIZE 8192 /* UDP Def. read data size <= 8K */
#define NFS_READDIRSIZE 32768 /* Def. readdir size */
#define NFS_DEFRAHEAD 16 /* Def. read ahead # blocks */
#define NFS_MAXRAHEAD 128 /* Max. read ahead # blocks */
#define NFS_DEFMAXASYNCWRITES 128 /* Def. max # concurrent async write RPCs */
#define NFS_DEFASYNCTHREAD 16 /* Def. # nfsiod threads */
#define NFS_MAXASYNCTHREAD 64 /* max # nfsiod threads */
#define NFS_ASYNCTHREADMAXIDLE 60 /* Seconds before idle nfsiods are reaped */
#define NFS_DEFSTATFSRATELIMIT 10 /* Def. max # statfs RPCs per second */
#define NFS_REQUESTDELAY 10 /* ms interval to check request queue */
#define NFSRV_MAXWGATHERDELAY 100 /* Max. write gather delay (msec) */
#ifndef NFSRV_WGATHERDELAY
#define NFSRV_WGATHERDELAY 1 /* Default write gather delay (msec) */
#endif
#define NFS_DIRBLKSIZ 4096 /* size of NFS directory buffers */
#if defined(KERNEL) && !defined(DIRBLKSIZ)
#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
/* can't be larger than NFS_FABLKSIZE */
#endif
/* default values for unresponsive mount timeouts */
#define NFS_TPRINTF_INITIAL_DELAY 5
#define NFS_TPRINTF_DELAY 30
/* NFS client mount timeouts */
#define NFS_MOUNT_TIMEOUT 30
#define NFS_MOUNT_QUICK_TIMEOUT 8
/*
* Oddballs
*/
#define NFS_CMPFH(n, f, s) \
((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
#define NFSRV_NDMAXDATA(n) \
(((n)->nd_vers == NFS_VER3) ? (((n)->nd_nam2) ? \
NFS_MAXDGRAMDATA : NFSRV_MAXDATA) : NFS_V2MAXDATA)
#define NFS_PORT_INVALID(port) \
(((port) > NFS_MAXPORT) || ((port) < 0))
/*
* The IO_METASYNC flag should be implemented for local file systems.
* (Until then, it is nothin at all.)
*/
#ifndef IO_METASYNC
#define IO_METASYNC 0
#endif
/*
* Expected allocation sizes for major data structures. If the actual size
* of the structure exceeds these sizes, then malloc() will be allocating
* almost twice the memory required. This is used in nfs_init() to warn
* the sysadmin that the size of a structure should be reduced.
* (These sizes are always a power of 2. If the kernel malloc() changes
* to one that does not allocate space in powers of 2 size, then this all
* becomes bunk!).
* Note that some of these structures come out of their own nfs zones.
*/
#define NFS_NODEALLOC 1024
#define NFS_MNTALLOC 1024
#define NFS_SVCALLOC 512
#define NFS_ARGSVERSION_XDR 88 /* NFS mount args are in XDR format */
#define NFS_XDRARGS_VERSION_0 0
#define NFS_MATTR_BITMAP_LEN 1 /* length of mount attributes bitmap */
#define NFS_MFLAG_BITMAP_LEN 1 /* length of mount flags bitmap */
/* NFS mount attributes */
#define NFS_MATTR_FLAGS 0 /* mount flags (NFS_MATTR_*) */
#define NFS_MATTR_NFS_VERSION 1 /* NFS protocol version */
#define NFS_MATTR_NFS_MINOR_VERSION 2 /* NFS protocol minor version */
#define NFS_MATTR_READ_SIZE 3 /* READ RPC size */
#define NFS_MATTR_WRITE_SIZE 4 /* WRITE RPC size */
#define NFS_MATTR_READDIR_SIZE 5 /* READDIR RPC size */
#define NFS_MATTR_READAHEAD 6 /* block readahead count */
#define NFS_MATTR_ATTRCACHE_REG_MIN 7 /* minimum attribute cache time */
#define NFS_MATTR_ATTRCACHE_REG_MAX 8 /* maximum attribute cache time */
#define NFS_MATTR_ATTRCACHE_DIR_MIN 9 /* minimum attribute cache time for dirs */
#define NFS_MATTR_ATTRCACHE_DIR_MAX 10 /* maximum attribute cache time for dirs */
#define NFS_MATTR_LOCK_MODE 11 /* advisory file locking mode (NFS_LOCK_MODE_*) */
#define NFS_MATTR_SECURITY 12 /* RPC security flavors to use */
#define NFS_MATTR_MAX_GROUP_LIST 13 /* max # of RPC AUTH_SYS groups */
#define NFS_MATTR_SOCKET_TYPE 14 /* socket transport type as a netid-like string */
#define NFS_MATTR_NFS_PORT 15 /* port # to use for NFS protocol */
#define NFS_MATTR_MOUNT_PORT 16 /* port # to use for MOUNT protocol */
#define NFS_MATTR_REQUEST_TIMEOUT 17 /* initial RPC request timeout value */
#define NFS_MATTR_SOFT_RETRY_COUNT 18 /* max RPC retransmissions for soft mounts */
#define NFS_MATTR_DEAD_TIMEOUT 19 /* how long until unresponsive mount is considered dead */
#define NFS_MATTR_FH 20 /* file handle for mount directory */
#define NFS_MATTR_FS_LOCATIONS 21 /* list of locations for the file system */
#define NFS_MATTR_MNTFLAGS 22 /* VFS mount flags (MNT_*) */
#define NFS_MATTR_MNTFROM 23 /* fixed string to use for "f_mntfromname" */
#define NFS_MATTR_REALM 24 /* Realm to authenticate with */
#define NFS_MATTR_PRINCIPAL 25 /* GSS principal to authenticate with */
#define NFS_MATTR_SVCPRINCIPAL 26 /* GSS principal to authenticate to, the server principal */
#define NFS_MATTR_NFS_VERSION_RANGE 27 /* Packed version range to try */
#define NFS_MATTR_KERB_ETYPE 28 /* Enctype to use for kerberos mounts */
#define NFS_MATTR_LOCAL_NFS_PORT 29 /* Unix domain socket for NFS protocol */
#define NFS_MATTR_LOCAL_MOUNT_PORT 30 /* Unix domain socket for MOUNT protocol */
#define NFS_MATTR_SET_MOUNT_OWNER 31 /* Set owner of mount point */
/* NFS mount flags */
#define NFS_MFLAG_SOFT 0 /* soft mount (requests fail if unresponsive) */
#define NFS_MFLAG_INTR 1 /* allow operations to be interrupted */
#define NFS_MFLAG_RESVPORT 2 /* use a reserved port */
#define NFS_MFLAG_NOCONNECT 3 /* don't connect the socket (UDP) */
#define NFS_MFLAG_DUMBTIMER 4 /* don't estimate RTT dynamically */
#define NFS_MFLAG_CALLUMNT 5 /* call MOUNTPROC_UMNT on unmount */
#define NFS_MFLAG_RDIRPLUS 6 /* request additional info when reading directories */
#define NFS_MFLAG_NONEGNAMECACHE 7 /* don't do negative name caching */
#define NFS_MFLAG_MUTEJUKEBOX 8 /* don't treat jukebox errors as unresponsive */
#define NFS_MFLAG_EPHEMERAL 9 /* ephemeral (mirror) mount */
#define NFS_MFLAG_NOCALLBACK 10 /* don't provide callback RPC service */
#define NFS_MFLAG_NAMEDATTR 11 /* don't use named attributes */
#define NFS_MFLAG_NOACL 12 /* don't support ACLs */
#define NFS_MFLAG_ACLONLY 13 /* only support ACLs - not mode */
#define NFS_MFLAG_NFC 14 /* send NFC strings */
#define NFS_MFLAG_NOQUOTA 15 /* don't support QUOTA requests */
#define NFS_MFLAG_MNTUDP 16 /* MOUNT protocol should use UDP */
#define NFS_MFLAG_MNTQUICK 17 /* use short timeouts while mounting */
/* 18 reserved */
#define NFS_MFLAG_NOOPAQUE_AUTH 19 /* don't make the mount AUTH_OPAQUE. Used by V3 */
/* Macros for packing and unpacking packed versions */
#define PVER2MAJOR(M) ((uint32_t)(((M) >> 16) & 0xffff))
#define PVER2MINOR(m) ((uint32_t)((m) & 0xffff))
#define VER2PVER(M, m) ((uint32_t)((M) << 16) | ((m) & 0xffff))
/* NFS advisory file locking modes */
#define NFS_LOCK_MODE_ENABLED 0 /* advisory file locking enabled */
#define NFS_LOCK_MODE_DISABLED 1 /* do not support advisory file locking */
#define NFS_LOCK_MODE_LOCAL 2 /* perform advisory file locking locally */
#define NFS_STRLEN_INT(str) \
(int)strnlen(str, INT_MAX)
#define NFS_UIO_ADDIOV(a_uio, a_baseaddr, a_length) \
assert(a_length <= UINT32_MAX); uio_addiov(a_uio, a_baseaddr, (uint32_t)(a_length));
#define NFS_BZERO(off, bytes) \
do { \
uint32_t bytes32 = bytes > UINT32_MAX ? UINT32_MAX : (uint32_t)(bytes); \
bzero(off, bytes32); \
if (bytes > UINT32_MAX) { \
bzero(off + bytes32, (uint32_t)(bytes - UINT32_MAX)); \
} \
} while(0);
#define NFS_ZFREE(zone, ptr) \
do { \
if ((ptr)) { \
zfree((zone), (ptr)); \
(ptr) = NULL; \
} \
} while (0); \
/* Supported encryption types for kerberos session keys */
typedef enum nfs_supported_kerberos_etypes {
NFS_DES3_CBC_SHA1_KD = 16,
NFS_AES128_CTS_HMAC_SHA1_96 = 17,
NFS_AES256_CTS_HMAC_SHA1_96 = 18
} nfs_supported_kerberos_etypes;
/* Structure to hold an array of kerberos enctypes to allow on a mount */
#define NFS_MAX_ETYPES 3
struct nfs_etype {
uint32_t count;
uint32_t selected; /* index in etypes that is being used. Set to count if nothing has been selected */
nfs_supported_kerberos_etypes etypes[NFS_MAX_ETYPES];
};
/*
* Old-style arguments to mount NFS
*/
#define NFS_ARGSVERSION 6 /* change when nfs_args changes */
struct nfs_args {
int version; /* args structure version number */
user32_addr_t addr; /* file server address */
uint8_t addrlen; /* length of address */
int sotype; /* Socket type */
int proto; /* and Protocol */
user32_addr_t fh; /* File handle to be mounted */
int fhsize; /* Size, in bytes, of fh */
int flags; /* flags */
int wsize; /* write size in bytes */
int rsize; /* read size in bytes */
int readdirsize; /* readdir size in bytes */
int timeo; /* initial timeout in .1 secs */
int retrans; /* times to retry send */
int maxgrouplist; /* Max. size of group list */
int readahead; /* # of blocks to readahead */
int leaseterm; /* obsolete: Term (sec) of lease */
int deadthresh; /* obsolete: Retrans threshold */
user32_addr_t hostname; /* server's name */
/* NFS_ARGSVERSION 3 ends here */
int acregmin; /* reg file min attr cache timeout */
int acregmax; /* reg file max attr cache timeout */
int acdirmin; /* dir min attr cache timeout */
int acdirmax; /* dir max attr cache timeout */
/* NFS_ARGSVERSION 4 ends here */
uint32_t auth; /* security mechanism flavor */
/* NFS_ARGSVERSION 5 ends here */
uint32_t deadtimeout; /* secs until unresponsive mount considered dead */
};
/* incremental size additions in each version of nfs_args */
#define NFS_ARGSVERSION4_INCSIZE (4 * sizeof(int))
#define NFS_ARGSVERSION5_INCSIZE (sizeof(uint32_t))
#define NFS_ARGSVERSION6_INCSIZE (sizeof(uint32_t))
/* LP64 version of nfs_args. all pointers and longs
* grow when we're dealing with a 64-bit process.
* WARNING - keep in sync with nfs_args
*/
struct user_nfs_args {
int version; /* args structure version number */
user_addr_t addr __attribute((aligned(8))); /* file server address */
uint8_t addrlen; /* length of address */
int sotype; /* Socket type */
int proto; /* and Protocol */
user_addr_t fh __attribute((aligned(8))); /* File handle to be mounted */
int fhsize; /* Size, in bytes, of fh */
int flags; /* flags */
int wsize; /* write size in bytes */
int rsize; /* read size in bytes */
int readdirsize; /* readdir size in bytes */
int timeo; /* initial timeout in .1 secs */
int retrans; /* times to retry send */
int maxgrouplist; /* Max. size of group list */
int readahead; /* # of blocks to readahead */
int leaseterm; /* obsolete: Term (sec) of lease */
int deadthresh; /* obsolete: Retrans threshold */
user_addr_t hostname __attribute((aligned(8))); /* server's name */
/* NFS_ARGSVERSION 3 ends here */
int acregmin; /* reg file min attr cache timeout */
int acregmax; /* reg file max attr cache timeout */
int acdirmin; /* dir min attr cache timeout */
int acdirmax; /* dir max attr cache timeout */
/* NFS_ARGSVERSION 4 ends here */
uint32_t auth; /* security mechanism flavor */
/* NFS_ARGSVERSION 5 ends here */
uint32_t deadtimeout; /* secs until unresponsive mount considered dead */
};
/*
* Old-style NFS mount option flags
*/
#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
#define NFSMNT_WSIZE 0x00000002 /* set write size */
#define NFSMNT_RSIZE 0x00000004 /* set read size */
#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
#define NFSMNT_NONEGNAMECACHE 0x00000100 /* Don't do negative name caching */
#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
#define NFSMNT_NFSV4 0x00000400 /* Use NFS Version 4 protocol */
#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
#define NFSMNT_DEADTIMEOUT 0x00001000 /* unmount after a period of unresponsiveness */
#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
#define NFSMNT_CALLUMNT 0x00004000 /* call MOUNTPROC_UMNT on unmount */
#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
#define NFSMNT_NOLOCKS 0x00040000 /* don't support file locking */
#define NFSMNT_LOCALLOCKS 0x00080000 /* do file locking locally on client */
#define NFSMNT_ACREGMIN 0x00100000 /* reg min attr cache timeout */
#define NFSMNT_ACREGMAX 0x00200000 /* reg max attr cache timeout */
#define NFSMNT_ACDIRMIN 0x00400000 /* dir min attr cache timeout */
#define NFSMNT_ACDIRMAX 0x00800000 /* dir max attr cache timeout */
#define NFSMNT_SECFLAVOR 0x01000000 /* Use security flavor */
#define NFSMNT_SECSYSOK 0x02000000 /* Server can support auth sys */
#define NFSMNT_MUTEJUKEBOX 0x04000000 /* don't treat jukebox errors as unresponsive */
#define NFSMNT_NOQUOTA 0x08000000 /* don't support QUOTA requests */
/*
* fs.nfs sysctl(3) NFS_MOUNTINFO defines
*/
#define NFS_MOUNT_INFO_VERSION 0 /* nfsstat mount information version */
#define NFS_MIATTR_BITMAP_LEN 1 /* length of mount info attributes bitmap */
#define NFS_MIFLAG_BITMAP_LEN 1 /* length of mount info flags bitmap */
/* NFS mount info attributes */
#define NFS_MIATTR_FLAGS 0 /* mount info flags bitmap (MIFLAG_*) */
#define NFS_MIATTR_ORIG_ARGS 1 /* original mount args passed into mount call */
#define NFS_MIATTR_CUR_ARGS 2 /* current mount args values */
#define NFS_MIATTR_CUR_LOC_INDEX 3 /* current fs location index */
/* NFS mount info flags */
#define NFS_MIFLAG_DEAD 0 /* mount is dead */
#define NFS_MIFLAG_NOTRESP 1 /* server is unresponsive */
#define NFS_MIFLAG_RECOVERY 2 /* mount in recovery */
/*
* Structures for the nfssvc(2) syscall. Not that anyone but nfsd
* should ever try and use it.
*/
struct nfsd_args {
int sock; /* Socket to serve */
user32_addr_t name; /* Client addr for connection based sockets */
int namelen; /* Length of name */
};
/* LP64 version of nfsd_args. all pointers and longs
* grow when we're dealing with a 64-bit process.
* WARNING - keep in sync with nfsd_args
*/
struct user_nfsd_args {
int sock; /* Socket to serve */
user_addr_t name __attribute((aligned(8))); /* Client addr for connection based sockets */
int namelen; /* Length of name */
};
/*
* NFS Server File Handle structures
*/
/* NFS export handle identifies which NFS export */
#define NFS_FH_VERSION 0x4e580000 /* 'NX00' */
struct nfs_exphandle {
uint32_t nxh_version; /* data structure version */
uint32_t nxh_fsid; /* File System Export ID */
uint32_t nxh_expid; /* Export ID */
uint16_t nxh_flags; /* export handle flags */
uint8_t nxh_reserved; /* future use */
uint32_t nxh_fidlen; /* length of File ID */
};
/* nxh_flags */
#define NXHF_INVALIDFH 0x0001 /* file handle is invalid */
#define NFS_MAX_FID_SIZE (NFS_MAX_FH_SIZE - sizeof(struct nfs_exphandle))
#define NFSV4_MAX_FID_SIZE (NFSV4_MAX_FH_SIZE - sizeof(struct nfs_exphandle))
#define NFSV3_MAX_FID_SIZE (NFSV3_MAX_FH_SIZE - sizeof(struct nfs_exphandle))
#define NFSV2_MAX_FID_SIZE (NFSV2_MAX_FH_SIZE - sizeof(struct nfs_exphandle))
/* NFS server internal view of fhandle_t */
/* The first sizeof(fhandle_t) bytes must match what goes into fhandle_t. */
/* (fhp is used to allow use of an external buffer) */
struct nfs_filehandle {
uint32_t nfh_len; /* total length of file handle */
struct nfs_exphandle nfh_xh; /* export handle */
unsigned char nfh_fid[NFS_MAX_FID_SIZE]; /* File ID */
unsigned char *nfh_fhp; /* pointer to file handle */
};
/*
* NFS export data structures
*/
/* Structure to hold an array of security flavors */
#define NX_MAX_SEC_FLAVORS 5
struct nfs_sec {
int count;
uint32_t flavors[NX_MAX_SEC_FLAVORS];
};
struct nfs_export_net_args {
uint32_t nxna_flags; /* export flags */
struct xucred nxna_cred; /* mapped credential for root/all user */
struct sockaddr_storage nxna_addr; /* net address to which exported */
struct sockaddr_storage nxna_mask; /* mask for net address */
struct nfs_sec nxna_sec; /* security mechanism flavors */
};
struct nfs_export_args {
uint32_t nxa_fsid; /* export FS ID */
uint32_t nxa_expid; /* export ID */
user32_addr_t nxa_fspath; /* export FS path */
user32_addr_t nxa_exppath; /* export sub-path */
uint32_t nxa_flags; /* export arg flags */
uint32_t nxa_netcount; /* #entries in ex_nets array */
user32_addr_t nxa_nets; /* array of net args */
};
/* LP64 version of export_args */
struct user_nfs_export_args {
uint32_t nxa_fsid; /* export FS ID */
uint32_t nxa_expid; /* export ID */
user_addr_t nxa_fspath; /* export FS path */
user_addr_t nxa_exppath; /* export sub-path */
uint32_t nxa_flags; /* export arg flags */
uint32_t nxa_netcount; /* #entries in ex_nets array */
user_addr_t nxa_nets; /* array of net args */
};
/* nfs export arg flags */
#define NXA_DELETE 0x0001 /* delete the specified export(s) */
#define NXA_ADD 0x0002 /* add the specified export(s) */
#define NXA_REPLACE 0x0003 /* delete and add the specified export(s) */
#define NXA_DELETE_ALL 0x0004 /* delete all exports */
#define NXA_OFFLINE 0x0008 /* export is offline */
#define NXA_CHECK 0x0010 /* check if exportable */
/* export option flags */
#define NX_READONLY 0x0001 /* exported read-only */
#define NX_DEFAULTEXPORT 0x0002 /* exported to the world */
#define NX_MAPROOT 0x0004 /* map root access to anon credential */
#define NX_MAPALL 0x0008 /* map all access to anon credential */
#define NX_32BITCLIENTS 0x0020 /* restrict directory cookies to 32 bits */
#define NX_OFFLINE 0x0040 /* export is offline */
#define NX_MANGLEDNAMES 0x0080 /* export will return mangled names for names > 255 bytes */
/*
* fs.nfs sysctl(3) export stats record structures
*/
#define NFS_EXPORT_STAT_REC_VERSION 1 /* export stat record version */
#define NFS_USER_STAT_REC_VERSION 1 /* active user list record version */
/* descriptor describing following records */
struct nfs_export_stat_desc {
uint32_t rec_vers; /* version of export stat records */
uint64_t rec_count; /* total record count */
}__attribute__((__packed__));
/* export stat record containing path and stat counters */
struct nfs_export_stat_rec {
char path[RPCMNT_PATHLEN + 1];
uint64_t ops; /* Count of NFS Requests received for this export */
uint64_t bytes_read; /* Count of bytes read from this export */
uint64_t bytes_written; /* Count of bytes written to this export */
}__attribute__((__packed__));
/* Active user list stat buffer descriptor */
struct nfs_user_stat_desc {
uint32_t rec_vers; /* version of active user stat records */
uint32_t rec_count; /* total record count */
}__attribute__((__packed__));
/* Active user list user stat record format */
struct nfs_user_stat_user_rec {
u_char rec_type;
uid_t uid;
struct sockaddr_storage sock;
uint64_t ops;
uint64_t bytes_read;
uint64_t bytes_written;
time_t tm_start;
time_t tm_last;
}__attribute__((__packed__));
/* Active user list path record format */
struct nfs_user_stat_path_rec {
u_char rec_type;
char path[RPCMNT_PATHLEN + 1];
}__attribute__((__packed__));
/* Defines for rec_type field of
* nfs_user_stat_rec & nfs_user_stat_rec
* data structures
*/
#define NFS_USER_STAT_USER_REC 0
#define NFS_USER_STAT_PATH_REC 1
struct nfs_exportfs;
struct nfs_export_options {
uint32_t nxo_flags; /* export options */
kauth_cred_t nxo_cred; /* mapped credential */
struct nfs_sec nxo_sec; /* security mechanism flavors */
};
/* Network address lookup element and individual export options */
struct nfs_netopt {
struct radix_node no_rnodes[2]; /* radix tree glue */
struct nfs_export_options no_opt; /* export options */
struct sockaddr *no_addr; /* net address to which exported */
struct sockaddr *no_mask; /* mask for net address */
};
/* statistic counters for each exported directory
*
* Since 64-bit atomic operations are not available on 32-bit platforms,
* 64-bit counters are implemented using 32-bit integers and 32-bit
* atomic operations
*/
typedef struct nfsstatcount64 {
uint32_t hi;
uint32_t lo;
} nfsstatcount64;
struct nfs_export_stat_counters {
struct nfsstatcount64 ops; /* Count of NFS Requests received for this export */
struct nfsstatcount64 bytes_read; /* Count of bytes read from this export */
struct nfsstatcount64 bytes_written; /* Count of bytes written to his export */
};
/* Macro for updating nfs export stat counters */
#define NFSStatAdd64(PTR, VAL) \
do { \
uint32_t NFSSA_OldValue = \
OSAddAtomic((VAL), &(PTR)->lo); \
if ((NFSSA_OldValue + (VAL)) < NFSSA_OldValue) \
OSAddAtomic(1, &(PTR)->hi); \
} while (0)
/* Some defines for dealing with active user list stats */
#define NFSRV_USER_STAT_DEF_MAX_NODES 1024 /* default active user list size limit */
#define NFSRV_USER_STAT_DEF_IDLE_SEC 7200 /* default idle seconds (node no longer considered active) */
/* active user list globals */
extern uint32_t nfsrv_user_stat_enabled; /* enable/disable active user list */
extern uint32_t nfsrv_user_stat_node_count; /* current count of user stat nodes */
extern uint32_t nfsrv_user_stat_max_idle_sec; /* idle seconds (node no longer considered active) */
extern uint32_t nfsrv_user_stat_max_nodes; /* active user list size limit */
extern lck_grp_t nfsrv_active_user_mutex_group;
/* An active user node represented in the kernel */
struct nfs_user_stat_node {
TAILQ_ENTRY(nfs_user_stat_node) lru_link;
LIST_ENTRY(nfs_user_stat_node) hash_link;
uid_t uid;
struct sockaddr_storage sock;
uint64_t ops;
uint64_t bytes_read;
uint64_t bytes_written;
time_t tm_start;
time_t tm_last;
};
/* Hash table for active user nodes */
#define NFS_USER_STAT_HASH_SIZE 16 /* MUST be a power of 2 */
#define NFS_USER_STAT_HASH(userhashtbl, uid) \
&((userhashtbl)[(uid) & (NFS_USER_STAT_HASH_SIZE - 1)])
TAILQ_HEAD(nfs_user_stat_lru_head, nfs_user_stat_node);
LIST_HEAD(nfs_user_stat_hashtbl_head, nfs_user_stat_node);
/* Active user list data structure */
/* One per exported directory */
struct nfs_active_user_list {
struct nfs_user_stat_lru_head user_lru;
struct nfs_user_stat_hashtbl_head user_hashtbl[NFS_USER_STAT_HASH_SIZE];
uint32_t node_count;
lck_mtx_t user_mutex;
};
/* Network export information */
/* one of these for each exported directory */
struct nfs_export {
LIST_ENTRY(nfs_export) nx_next; /* FS export list */
LIST_ENTRY(nfs_export) nx_hash; /* export hash chain */
struct nfs_export *nx_parent; /* parent export */
uint32_t nx_id; /* export ID */
uint32_t nx_flags; /* export flags */
struct nfs_exportfs *nx_fs; /* exported file system */
char *nx_path; /* exported file system sub-path */
struct nfs_filehandle nx_fh; /* export root file handle */
struct nfs_export_options nx_defopt; /* default options */
uint32_t nx_expcnt; /* # exports in table */
struct radix_node_head *nx_rtable[AF_MAX + 1]; /* table of exports (netopts) */
struct nfs_export_stat_counters nx_stats; /* statistic counters for this exported directory */
struct nfs_active_user_list nx_user_list; /* Active User List for this exported directory */
struct timeval nx_exptime; /* time of export for write verifier */
};
/* NFS exported file system info */
/* one of these for each exported file system */
struct nfs_exportfs {
LIST_ENTRY(nfs_exportfs) nxfs_next; /* exported file system list */
uint32_t nxfs_id; /* exported file system ID */
char *nxfs_path; /* exported file system path */
LIST_HEAD(, nfs_export) nxfs_exports; /* list of exports for this file system */
};
extern LIST_HEAD(nfsrv_expfs_list, nfs_exportfs) nfsrv_exports;
extern lck_rw_t nfsrv_export_rwlock; // lock for export data structures
#define NFSRVEXPHASHSZ 64
#define NFSRVEXPHASHVAL(FSID, EXPID) \
(((FSID) >> 24) ^ ((FSID) >> 16) ^ ((FSID) >> 8) ^ (EXPID))
#define NFSRVEXPHASH(FSID, EXPID) \
(&nfsrv_export_hashtbl[NFSRVEXPHASHVAL((FSID),(EXPID)) & nfsrv_export_hash])
extern LIST_HEAD(nfsrv_export_hashhead, nfs_export) * nfsrv_export_hashtbl;
extern u_long nfsrv_export_hash;
#if CONFIG_FSE
/*
* NFS server file mod fsevents
*/
struct nfsrv_fmod {
LIST_ENTRY(nfsrv_fmod) fm_link;
vnode_t fm_vp;
struct vfs_context fm_context;
uint64_t fm_deadline;
};
#define NFSRVFMODHASHSZ 128
#define NFSRVFMODHASH(vp) (((uintptr_t) vp) & nfsrv_fmod_hash)
extern LIST_HEAD(nfsrv_fmod_hashhead, nfsrv_fmod) * nfsrv_fmod_hashtbl;
extern u_long nfsrv_fmod_hash;
extern lck_mtx_t nfsrv_fmod_mutex;
extern int nfsrv_fmod_pending, nfsrv_fsevents_enabled;
#endif
extern int nfsrv_async, nfsrv_export_hash_size,
nfsrv_reqcache_size, nfsrv_sock_max_rec_queue_length;
extern uint32_t nfsrv_gss_context_ttl;
extern struct nfsclntstats nfsclntstats;
extern struct nfsrvstats nfsrvstats;
#define NFS_UC_Q_DEBUG
#ifdef NFS_UC_Q_DEBUG
extern int nfsrv_uc_use_proxy;
extern uint32_t nfsrv_uc_queue_limit;
extern uint32_t nfsrv_uc_queue_max_seen;
extern volatile uint32_t nfsrv_uc_queue_count;
#endif
/*
* XXX to allow amd to include nfs.h without nfsproto.h
*/
#ifdef NFS_NPROCS
/*
* Stats structure
*/
struct nfsclntstats {
uint64_t attrcache_hits;
uint64_t attrcache_misses;
uint64_t lookupcache_hits;
uint64_t lookupcache_misses;
uint64_t direofcache_hits;
uint64_t direofcache_misses;
uint64_t biocache_reads;
uint64_t read_bios;
uint64_t read_physios;
uint64_t biocache_writes;
uint64_t write_bios;
uint64_t write_physios;
uint64_t biocache_readlinks;
uint64_t readlink_bios;
uint64_t biocache_readdirs;
uint64_t readdir_bios;
uint64_t rpccntv3[NFS_NPROCS];
uint64_t opcntv4[NFS_OP_COUNT];
uint64_t rpcretries;
uint64_t rpcrequests;
uint64_t rpctimeouts;
uint64_t rpcunexpected;
uint64_t rpcinvalid;
uint64_t pageins;
uint64_t pageouts;
};
struct nfsrvstats {
uint64_t srvrpccntv3[NFS_NPROCS];
uint64_t srvrpc_errs;
uint64_t srv_errs;
uint64_t srvcache_inproghits;
uint64_t srvcache_idemdonehits;
uint64_t srvcache_nonidemdonehits;
uint64_t srvcache_misses;
uint64_t srvvop_writes;
};
#endif
/*
* Flags for nfssvc() system call.
*/
#define NFSSVC_NFSD 0x004
#define NFSSVC_ADDSOCK 0x008
#define NFSSVC_EXPORTSTATS 0x010 /* gets exported directory stats */
#define NFSSVC_USERSTATS 0x020 /* gets exported directory active user stats */
#define NFSSVC_USERCOUNT 0x040 /* gets current count of active nfs users */
#define NFSSVC_ZEROSTATS 0x080 /* zero nfs server statistics */
#define NFSSVC_SRVSTATS 0x100 /* struct: struct nfsrvstats */
#define NFSSVC_EXPORT 0x200
/*
* Flags for nfsclnt() system call.
*/
#define NFSCLNT_LOCKDANS 0x200
#define NFSCLNT_LOCKDNOTIFY 0x400
#define NFSCLNT_TESTIDMAP 0x001
/* nfsclnt() system call character device */
#define NFSCLNT_DEVICE "nfsclnt"
#include <sys/_types/_guid_t.h> /* for guid_t below */
#define MAXIDNAMELEN 1024
struct nfs_testmapid {
uint32_t ntm_lookup; /* lookup name 2 id or id 2 name */
uint32_t ntm_grpflag; /* Is this a group or user maping */
uint32_t ntm_id; /* id to map or return */
uint32_t pad;
guid_t ntm_guid; /* intermidiate guid used in conversion */
char ntm_name[MAXIDNAMELEN]; /* name to map or return */
};
#define NTM_ID2NAME 0
#define NTM_NAME2ID 1
#define NTM_NAME2GUID 2
#define NTM_GUID2NAME 3
/*
* fs.nfs sysctl(3) identifiers
*/
#define NFS_NFSSTATS 1 /* struct: struct nfsclntstats */
#define NFS_MOUNTINFO 6 /* gets information about an NFS mount */
#define NFS_NFSZEROSTATS 7 /* zero nfs client statistics */
#ifndef NFS_WDELAYHASHSIZ
#define NFS_WDELAYHASHSIZ 16 /* and with this */
#endif
#include <sys/kernel_types.h>
#include <kern/thread_call.h>
#include <sys/kdebug.h>
#define NFS_KERNEL_DEBUG KERNEL_DEBUG
/* kernel debug trace macros */
#define FSDBG(A, B, C, D, E) \
NFS_KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, (A))) | DBG_FUNC_NONE, \
(int)(B), (int)(C), (int)(D), (int)(E), 0)
#define FSDBG_TOP(A, B, C, D, E) \
NFS_KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, (A))) | DBG_FUNC_START, \
(int)(B), (int)(C), (int)(D), (int)(E), 0)
#define FSDBG_BOT(A, B, C, D, E) \
NFS_KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, (A))) | DBG_FUNC_END, \
(int)(B), (int)(C), (int)(D), (int)(E), 0)
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_NFSMNT);
MALLOC_DECLARE(M_NFSBIO);
MALLOC_DECLARE(M_NFSDIROFF);
MALLOC_DECLARE(M_NFSRVDESC);
MALLOC_DECLARE(M_NFSD);
MALLOC_DECLARE(M_NFSBIGFH);
MALLOC_DECLARE(M_FHANDLE);
#endif
struct vnode_attr; struct nameidata; struct dqblk; struct sockaddr_in; /* XXX */
struct nfsbuf;
struct nfs_vattr;
struct nfs_fsattr;
struct nfsnode;
typedef struct nfsnode * nfsnode_t;
struct nfs_open_owner;
struct nfs_open_file;
struct nfs_lock_owner;
struct nfs_file_lock;
struct nfsreq;
struct nfs_rpc_record_state;
struct nfs_fs_locations;
struct nfs_location_index;
struct nfs_socket;
struct nfs_socket_search;
struct nfsrv_uc_arg;
struct direntry;
/*
* The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
* What should be in this set is open to debate, but I believe that since
* I/O system calls on ufs are never interrupted by signals the set should
* be minimal. My reasoning is that many current programs that use signals
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
sigmask(SIGHUP)|sigmask(SIGQUIT))
extern size_t nfs_mbuf_mhlen, nfs_mbuf_minclsize;
/*
* NFS mbuf chain structure used for managing the building/dissection of RPCs
*/
struct nfsm_chain {
mbuf_t nmc_mhead; /* mbuf chain head */
mbuf_t nmc_mcur; /* current mbuf */
caddr_t nmc_ptr; /* pointer into current mbuf */
size_t nmc_left; /* bytes remaining in current mbuf */
uint32_t nmc_flags; /* flags for this nfsm_chain */
};
#define NFSM_CHAIN_FLAG_ADD_CLUSTERS 0x1 /* always add mbuf clusters */
/*
* Each retransmission of an RPCSEC_GSS request
* has an additional sequence number.
*/
struct gss_seq {
SLIST_ENTRY(gss_seq) gss_seqnext;
uint32_t gss_seqnum;
};
/**
* nfsreq callback args
*/
struct nfsreq_cbargs {
off_t offset;
size_t length;
uint32_t stategenid;
};
/*
* async NFS request callback info
*/
struct nfsreq_cbinfo {
void (*rcb_func)(struct nfsreq *); /* async request callback function */
struct nfsbuf *rcb_bp; /* buffer I/O RPC is for */
struct nfsreq_cbargs rcb_args; /* nfsreq callback args */
};
/*
* Arguments to use if a request needs to call SECINFO to handle a WRONGSEC error
*
* If only node is set, use the parent file handle and this node's name; otherwise,
* use any file handle and name provided.
*/
struct nfsreq_secinfo_args {
nfsnode_t rsia_np; /* the node */
const char *rsia_name; /* alternate name string */
u_char *rsia_fh; /* alternate file handle */
uint32_t rsia_namelen; /* length of string */
uint32_t rsia_fhsize; /* length of fh */
};
#define NFSREQ_SECINFO_SET(SI, NP, FH, FHSIZE, NAME, NAMELEN) \
do { \
(SI)->rsia_np = (NP); \
(SI)->rsia_fh = (FH); \
(SI)->rsia_fhsize = (FHSIZE); \
(SI)->rsia_name = (NAME); \
(SI)->rsia_namelen = (NAMELEN); \
} while (0)
/*
* NFS outstanding request list element
*/
struct nfsreq {
lck_mtx_t r_mtx; /* NFS request mutex */
TAILQ_ENTRY(nfsreq) r_chain; /* request queue chain */
TAILQ_ENTRY(nfsreq) r_achain; /* mount's async I/O request queue chain */
TAILQ_ENTRY(nfsreq) r_rchain; /* mount's async I/O resend queue chain */
TAILQ_ENTRY(nfsreq) r_cchain; /* mount's cwnd queue chain */
mbuf_t r_mrest; /* request body mbufs */
mbuf_t r_mhead; /* request header mbufs */
struct nfsm_chain r_nmrep; /* reply mbufs */
nfsnode_t r_np; /* NFS node */
struct nfsmount *r_nmp; /* NFS mount point */
uint64_t r_xid; /* RPC transaction ID */
uint32_t r_procnum; /* NFS procedure number */
size_t r_mreqlen; /* request length */
int r_flags; /* flags on request, see below */
int r_lflags; /* flags protected by list mutex, see below */
int r_refs; /* # outstanding references */
uint8_t r_delay; /* delay to use for jukebox error */
uint32_t r_retry; /* max retransmission count */
uint8_t r_rexmit; /* current retrans count */
int r_rtt; /* RTT for rpc */
thread_t r_thread; /* thread that did I/O system call */
kauth_cred_t r_cred; /* credential used for request */
time_t r_start; /* request start time */
time_t r_lastmsg; /* time of last tprintf */
time_t r_resendtime; /* time of next jukebox error resend */
struct nfs_gss_clnt_ctx *r_gss_ctx; /* RPCSEC_GSS context */
SLIST_HEAD(, gss_seq) r_gss_seqlist; /* RPCSEC_GSS sequence numbers */
size_t r_gss_argoff; /* RPCSEC_GSS offset to args */
uint32_t r_gss_arglen; /* RPCSEC_GSS arg length */
uint32_t r_auth; /* security flavor request sent with */
uint32_t *r_wrongsec; /* wrongsec: other flavors to try */
int r_error; /* request error */
struct nfsreq_cbinfo r_callback; /* callback info */
struct nfsreq_secinfo_args r_secinfo; /* secinfo args */
};
/*
* Queue head for nfsreq's
*/
TAILQ_HEAD(nfs_reqqhead, nfsreq);
extern struct nfs_reqqhead nfs_reqq;
extern lck_grp_t nfs_request_grp;
#define R_XID32(x) ((x) & 0xffffffff)
#define NFSNOLIST ((void *)0x0badcafe) /* sentinel value for nfs lists */
#define NFSREQNOLIST NFSNOLIST /* sentinel value for nfsreq lists */
/* Flag values for r_flags */
#define R_TIMING 0x00000001 /* timing request (in mntp) */
#define R_CWND 0x00000002 /* request accounted for in congestion window */
#define R_SOFTTERM 0x00000004 /* request terminated (e.g. soft mnt) */
#define R_RESTART 0x00000008 /* RPC should be restarted. */
#define R_INITTED 0x00000010 /* request has been initialized */
#define R_TPRINTFMSG 0x00000020 /* Did a tprintf msg. */
#define R_MUSTRESEND 0x00000040 /* Must resend request */
#define R_ALLOCATED 0x00000080 /* request was allocated */
#define R_SENT 0x00000100 /* request has been sent */
#define R_WAITSENT 0x00000200 /* someone is waiting for request to be sent */
#define R_RESENDERR 0x00000400 /* resend failed */
#define R_JBTPRINTFMSG 0x00000800 /* Did a tprintf msg for jukebox error */
#define R_ASYNC 0x00001000 /* async request */
#define R_ASYNCWAIT 0x00002000 /* async request now being waited on */
#define R_RESENDQ 0x00004000 /* async request currently on resendq */
#define R_SENDING 0x00008000 /* request currently being sent */
#define R_SOFT 0x00010000 /* request is soft - don't retry or reconnect */
#define R_IOD 0x00020000 /* request is being managed by an IOD */
#define R_NOINTR 0x20000000 /* request should not be interupted by a signal */
#define R_RECOVER 0x40000000 /* a state recovery RPC - during NFSSTA_RECOVER */
#define R_SETUP 0x80000000 /* a setup RPC - during (re)connection */
#define R_OPTMASK 0xe0000000 /* mask of all RPC option flags */
/* Flag values for r_lflags */
#define RL_BUSY 0x0001 /* Locked. */
#define RL_WAITING 0x0002 /* Someone waiting for lock. */
#define RL_QUEUED 0x0004 /* request is on the queue */
extern u_int64_t nfs_xid, nfs_xidwrap;
extern int nfs_iosize, nfs_allow_async, nfs_statfs_rate_limit;
extern int nfs_access_cache_timeout, nfs_access_delete, nfs_access_dotzfs, nfs_access_for_getattr;
extern int nfs_lockd_mounts, nfs_lockd_request_sent;
extern int nfs_tprintf_initial_delay, nfs_tprintf_delay;
extern int nfsiod_thread_count, nfsiod_thread_max, nfs_max_async_writes;
extern int nfs_idmap_ctrl, nfs_callback_port, nfs_split_open_owner;
extern int nfs_is_mobile, nfs_readlink_nocache, nfs_root_steals_ctx;
extern int nfs_mount_timeout, nfs_mount_quick_timeout;
extern uint32_t nfs_tcp_sockbuf;
extern uint32_t nfs_squishy_flags;
extern uint32_t nfsclnt_debug_ctl, nfsrv_debug_ctl;
/* bits for nfs_idmap_ctrl: */
#define NFS_IDMAP_CTRL_USE_IDMAP_SERVICE 0x00000001 /* use the ID mapping service */
#define NFS_IDMAP_CTRL_FALLBACK_NO_COMMON_IDS 0x00000002 /* fallback should NOT handle common IDs like "root" and "nobody" */
#define NFS_IDMAP_CTRL_LOG_FAILED_MAPPINGS 0x00000020 /* log failed ID mapping attempts */
#define NFS_IDMAP_CTRL_LOG_SUCCESSFUL_MAPPINGS 0x00000040 /* log successful ID mapping attempts */
#define NFSIOD_MAX (MIN(nfsiod_thread_max, NFS_MAXASYNCTHREAD))
struct nfs_dulookup {
int du_flags; /* state of ._ lookup */
#define NFS_DULOOKUP_DOIT 0x1
#define NFS_DULOOKUP_INPROG 0x2
struct componentname du_cn; /* ._ name being looked up */
struct nfsreq du_req; /* NFS request for lookup */
char du_smallname[48]; /* buffer for small names */
};
/*
* One nfsrv_sock structure is maintained for each socket the
* server is servicing requests on.
*/
struct nfsrv_sock {
TAILQ_ENTRY(nfsrv_sock) ns_chain; /* List of all nfsrv_sock's */
TAILQ_ENTRY(nfsrv_sock) ns_svcq; /* List of sockets needing servicing */
TAILQ_ENTRY(nfsrv_sock) ns_wgq; /* List of sockets with a pending write gather */
struct nfsrv_uc_arg *ns_ua; /* Opaque pointer to upcall */
lck_rw_t ns_rwlock; /* lock for most fields */
socket_t ns_so;
mbuf_t ns_nam;
mbuf_t ns_raw;
mbuf_t ns_rawend;
mbuf_t ns_rec;
mbuf_t ns_recend;
mbuf_t ns_frag;
int ns_flag;
int ns_sotype;
size_t ns_cc;
size_t ns_reclen;
int ns_reccnt;
int ns_sobufsize;
u_int32_t ns_sref;
time_t ns_timestamp; /* socket timestamp */
lck_mtx_t ns_wgmutex; /* mutex for write gather fields */
time_t ns_wgtime; /* next Write deadline (usec) */
LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
LIST_HEAD(nfsrv_wg_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
};
/* Bits for "ns_flag" */
#define SLP_VALID 0x0001 /* nfs sock valid */
#define SLP_DOREC 0x0002 /* nfs sock has received data to process */
#define SLP_NEEDQ 0x0004 /* network socket has data to receive */
#define SLP_DISCONN 0x0008 /* socket needs to be zapped */
#define SLP_GETSTREAM 0x0010 /* currently in nfsrv_getstream() */
#define SLP_LASTFRAG 0x0020 /* on last fragment of RPC record */
#define SLP_DOWRITES 0x0040 /* nfs sock has gathered writes to service */
#define SLP_WORKTODO 0x004e /* mask of all "work to do" flags */
#define SLP_ALLFLAGS 0x007f
#define SLP_WAITQ 0x4000 /* nfs sock is on the wait queue */
#define SLP_WORKQ 0x8000 /* nfs sock is on the work queue */
#define SLP_QUEUED 0xc000 /* nfs sock is on a queue */
#define SLPNOLIST ((struct nfsrv_sock *)0xdeadbeef) /* sentinel value for sockets not in the nfsrv_sockwg list */
extern struct nfsrv_sock *nfsrv_udpsock, *nfsrv_udp6sock;
/*
* global NFS server socket lists:
*
* nfsrv_socklist - list of all sockets (ns_chain)
* nfsrv_sockwait - sockets w/new data waiting to be worked on (ns_svcq)
* nfsrv_sockwork - sockets being worked on which may have more work to do (ns_svcq)
* nfsrv_sockwg - sockets with pending write gather input (ns_wgq)
*/
extern TAILQ_HEAD(nfsrv_sockhead, nfsrv_sock) nfsrv_socklist, nfsrv_sockwg,
nfsrv_sockwait, nfsrv_sockwork;
/* lock groups for nfsrv_sock's */
extern lck_grp_t nfsrv_slp_rwlock_group;
extern lck_grp_t nfsrv_slp_mutex_group;
/*
* One of these structures is allocated for each nfsd.
*/
struct nfsd {
TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
TAILQ_ENTRY(nfsd) nfsd_queue; /* List of waiting nfsd's */
int nfsd_flag; /* NFSD_ flags */
struct nfsrv_sock *nfsd_slp; /* Current socket */
struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
};
/* Bits for "nfsd_flag" */
#define NFSD_WAITING 0x01
#define NFSD_REQINPROG 0x02
/*
* This structure is used by the server for describing each request.
* Some fields are used only when write request gathering is performed.
*/
struct nfsrv_descript {
time_t nd_time; /* Write deadline (usec) */
off_t nd_off; /* Start byte offset */
off_t nd_eoff; /* and end byte offset */
LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
LIST_HEAD(, nfsrv_descript) nd_coalesce; /* coalesced writes */
struct nfsm_chain nd_nmreq; /* Request mbuf chain */
mbuf_t nd_mrep; /* Reply mbuf list (WG) */
mbuf_t nd_nam; /* and socket addr */
mbuf_t nd_nam2; /* return socket addr */
u_int32_t nd_procnum; /* RPC # */
int nd_stable; /* storage type */
int nd_vers; /* NFS version */
int nd_len; /* Length of this write */
int nd_repstat; /* Reply status */
u_int32_t nd_retxid; /* Reply xid */
struct timeval nd_starttime; /* Time RPC initiated */
struct nfs_filehandle nd_fh; /* File handle */
uint32_t nd_sec; /* Security flavor */
struct nfs_gss_svc_ctx *nd_gss_context;/* RPCSEC_GSS context */
uint32_t nd_gss_seqnum; /* RPCSEC_GSS seq num */
mbuf_t nd_gss_mb; /* RPCSEC_GSS results mbuf */
kauth_cred_t nd_cr; /* Credentials */
};
extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head, nfsd_queue;
typedef int (*nfsrv_proc_t)(struct nfsrv_descript *, struct nfsrv_sock *,
vfs_context_t, mbuf_t *);
/* mutex for nfs server */
extern lck_mtx_t nfsd_mutex;
extern int nfsd_thread_count, nfsd_thread_max;
/* request list mutex */
extern lck_mtx_t nfs_request_mutex;
extern int nfs_request_timer_on;
/* mutex for nfs client globals */
extern lck_mtx_t nfs_global_mutex;
#if CONFIG_NFS4
/* NFSv4 callback globals */
extern int nfs4_callback_timer_on;
extern in_port_t nfs4_cb_port, nfs4_cb_port6;
/* nfs 4 default domain for user mapping */
extern char nfs4_default_domain[MAXPATHLEN];
/* nfs 4 timer call structure */
extern thread_call_t nfs4_callback_timer_call;
#endif
/* nfs timer call structures */
extern thread_call_t nfs_request_timer_call;
extern thread_call_t nfs_buf_timer_call;
extern thread_call_t nfsrv_idlesock_timer_call;
#if CONFIG_FSE
extern thread_call_t nfsrv_fmod_timer_call;
#endif
__BEGIN_DECLS
nfstype vtonfs_type(enum vtype, int);
enum vtype nfstov_type(nfstype, int);
int vtonfsv2_mode(enum vtype, mode_t);
void nfs_mbuf_init(void);
void nfs_nhinit_finish(void);
u_long nfs_hash(u_char *, int);
/* nfsclnt() system call character device setup */
int nfsclnt_device_add(void);
#if CONFIG_NFS4
int nfs4_init_clientid(struct nfsmount *);
int nfs4_setclientid(struct nfsmount *);
int nfs4_renew(struct nfsmount *, int);
void nfs4_renew_timer(void *, void *);
void nfs4_mount_callback_setup(struct nfsmount *);
void nfs4_mount_callback_shutdown(struct nfsmount *);
void nfs4_cb_accept(socket_t, void *, int);
void nfs4_cb_rcv(socket_t, void *, int);
void nfs4_callback_timer(void *, void *);
int nfs4_secinfo_rpc(struct nfsmount *, struct nfsreq_secinfo_args *, kauth_cred_t, uint32_t *, int *);
int nfs4_get_fs_locations(struct nfsmount *, nfsnode_t, u_char *, int, const char *, vfs_context_t, struct nfs_fs_locations *);
void nfs4_default_attrs_for_referral_trigger(nfsnode_t, char *, int, struct nfs_vattr *, fhandle_t *);
#endif
void nfs_fs_locations_cleanup(struct nfs_fs_locations *);
int nfs_sockaddr_cmp(struct sockaddr *, struct sockaddr *);
int nfs_connect(struct nfsmount *, int, int);
void nfs_disconnect(struct nfsmount *);
void nfs_need_reconnect(struct nfsmount *);
void nfs_mount_sock_thread_wake(struct nfsmount *);
int nfs_mount_check_dead_timeout(struct nfsmount *);
int nfs_mount_gone(struct nfsmount *);
void nfs_mount_rele(struct nfsmount *);
void nfs_mount_zombie(struct nfsmount *, int);
void nfs_mount_make_zombie(struct nfsmount *);
void nfs_rpc_record_state_init(struct nfs_rpc_record_state *);
void nfs_rpc_record_state_cleanup(struct nfs_rpc_record_state *);
int nfs_rpc_record_read(socket_t, struct nfs_rpc_record_state *, int, int *, mbuf_t *);
int nfs_getattr(nfsnode_t, struct nfs_vattr *, vfs_context_t, int);
int nfs_getattrcache(nfsnode_t, struct nfs_vattr *, int);
int nfs_loadattrcache(nfsnode_t, struct nfs_vattr *, u_int64_t *, int);
long nfs_attrcachetimeout(nfsnode_t);
int nfs_buf_page_inval_internal(vnode_t vp, off_t offset);
int nfs_vinvalbuf1(vnode_t, int, vfs_context_t, int);
int nfs_vinvalbuf2(vnode_t, int, thread_t, kauth_cred_t, int);
int nfs_vinvalbuf_internal(nfsnode_t, int, thread_t, kauth_cred_t, int, int);
void nfs_wait_bufs(nfsnode_t);
int nfs_request_create(nfsnode_t, mount_t, struct nfsm_chain *, int, thread_t, kauth_cred_t, struct nfsreq **);
void nfs_request_destroy(struct nfsreq *);
void nfs_request_ref(struct nfsreq *, int);
void nfs_request_rele(struct nfsreq *);
int nfs_request_add_header(struct nfsreq *);
int nfs_request_send(struct nfsreq *, int);
void nfs_request_wait(struct nfsreq *);
int nfs_request_finish(struct nfsreq *, struct nfsm_chain *, int *);
int nfs_request(nfsnode_t, mount_t, struct nfsm_chain *, int, vfs_context_t, struct nfsreq_secinfo_args *, struct nfsm_chain *, u_int64_t *, int *);
int nfs_request2(nfsnode_t, mount_t, struct nfsm_chain *, int, thread_t, kauth_cred_t, struct nfsreq_secinfo_args *, int, struct nfsm_chain *, u_int64_t *, int *);
int nfs_request_gss(mount_t, struct nfsm_chain *, thread_t, kauth_cred_t, int, struct nfs_gss_clnt_ctx *, struct nfsm_chain *, int *);
int nfs_request_async(nfsnode_t, mount_t, struct nfsm_chain *, int, thread_t, kauth_cred_t, struct nfsreq_secinfo_args *, int, struct nfsreq_cbinfo *, struct nfsreq **);
int nfs_request_async_finish(struct nfsreq *, struct nfsm_chain *, u_int64_t *, int *);
void nfs_request_async_cancel(struct nfsreq *);
void nfs_request_timer(void *, void *);
int nfs_request_using_gss(struct nfsreq *);
void nfs_get_xid(uint64_t *);
int nfs_sigintr(struct nfsmount *, struct nfsreq *, thread_t, int);
int nfs_noremotehang(thread_t);
int nfs_send(struct nfsreq *, int);
int nfs_sndlock(struct nfsreq *);
void nfs_sndunlock(struct nfsreq *);
int nfs_uaddr2sockaddr(const char *, struct sockaddr *);
int nfs_aux_request(struct nfsmount *, thread_t, struct sockaddr *, socket_t, int, mbuf_t, uint32_t, int, int, struct nfsm_chain *);
int nfs_portmap_lookup(struct nfsmount *, vfs_context_t, struct sockaddr *, socket_t, uint32_t, uint32_t, uint32_t, int);
void nfs_location_next(struct nfs_fs_locations *, struct nfs_location_index *);
int nfs_location_index_cmp(struct nfs_location_index *, struct nfs_location_index *);
void nfs_location_mntfromname(struct nfs_fs_locations *, struct nfs_location_index, char *, size_t, int);
int nfs_socket_create(struct nfsmount *, struct sockaddr *, uint8_t, in_port_t, uint32_t, uint32_t, int, struct nfs_socket **);
void nfs_socket_destroy(struct nfs_socket *);
void nfs_socket_options(struct nfsmount *, struct nfs_socket *);
void nfs_connect_upcall(socket_t, void *, int);
int nfs_connect_error_class(int);
int nfs_connect_search_loop(struct nfsmount *, struct nfs_socket_search *);
void nfs_socket_search_update_error(struct nfs_socket_search *, int);
void nfs_socket_search_cleanup(struct nfs_socket_search *);
void nfs_mount_connect_thread(void *, __unused wait_result_t);
int nfs_lookitup(nfsnode_t, char *, int, vfs_context_t, nfsnode_t *);
void nfs_dulookup_init(struct nfs_dulookup *, nfsnode_t, const char *, int, vfs_context_t);
void nfs_dulookup_start(struct nfs_dulookup *, nfsnode_t, vfs_context_t);
void nfs_dulookup_finish(struct nfs_dulookup *, nfsnode_t, vfs_context_t);
int nfs_dir_buf_cache_lookup(nfsnode_t, nfsnode_t *, struct componentname *, vfs_context_t, int, int *);
int nfs_dir_buf_search(struct nfsbuf *, struct componentname *, fhandle_t *, struct nfs_vattr *, uint64_t *, time_t *, daddr64_t *, int);
void nfs_name_cache_purge(nfsnode_t, nfsnode_t, struct componentname *, vfs_context_t);
#if CONFIG_NFS4
uint32_t nfs4_ace_nfstype_to_vfstype(uint32_t, int *);
uint32_t nfs4_ace_vfstype_to_nfstype(uint32_t, int *);
uint32_t nfs4_ace_nfsflags_to_vfsflags(uint32_t);
uint32_t nfs4_ace_vfsflags_to_nfsflags(uint32_t);
uint32_t nfs4_ace_nfsmask_to_vfsrights(uint32_t);
uint32_t nfs4_ace_vfsrights_to_nfsmask(uint32_t);
int nfs4_id2guid(char *, guid_t *, int);
int nfs4_guid2id(guid_t *, char *, size_t *, int);
int nfs4_parsefattr(struct nfsm_chain *, struct nfs_fsattr *, struct nfs_vattr *, fhandle_t *, struct dqblk *, struct nfs_fs_locations *);
#endif
int nfs_parsefattr(struct nfsmount *nmp, struct nfsm_chain *, int,
struct nfs_vattr *);
void nfs_vattr_set_supported(uint32_t *, struct vnode_attr *);
void nfs_vattr_set_bitmap(struct nfsmount *, uint32_t *, struct vnode_attr *);
void nfs3_pathconf_cache(struct nfsmount *, struct nfs_fsattr *);
int nfs3_check_lockmode(struct nfsmount *, struct sockaddr *, int, int);
int nfs3_mount_rpc(struct nfsmount *, struct sockaddr *, int, int, char *, vfs_context_t, int, fhandle_t *, struct nfs_sec *);
void nfs3_umount_rpc(struct nfsmount *, vfs_context_t, int);
void nfs_rdirplus_update_node_attrs(nfsnode_t, struct direntry *, fhandle_t *, struct nfs_vattr *, uint64_t *);
int nfs_node_access_slot(nfsnode_t, uid_t, int);
void nfs_vnode_notify(nfsnode_t, uint32_t);
void nfs_avoid_needless_id_setting_on_create(nfsnode_t, struct vnode_attr *, vfs_context_t);
int nfs_open_state_set_busy(nfsnode_t, thread_t);
void nfs_open_state_clear_busy(nfsnode_t);
struct nfs_open_owner *nfs_open_owner_find(struct nfsmount *, kauth_cred_t, proc_t, int);
void nfs_open_owner_destroy(struct nfs_open_owner *);
void nfs_open_owner_ref(struct nfs_open_owner *);
void nfs_open_owner_rele(struct nfs_open_owner *);
int nfs_open_owner_set_busy(struct nfs_open_owner *, thread_t);
void nfs_open_owner_clear_busy(struct nfs_open_owner *);
void nfs_owner_seqid_increment(struct nfs_open_owner *, struct nfs_lock_owner *, int);
int nfs_open_file_find(nfsnode_t, struct nfs_open_owner *, struct nfs_open_file **, uint32_t, uint32_t, int);
int nfs_open_file_find_internal(nfsnode_t, struct nfs_open_owner *, struct nfs_open_file **, uint32_t, uint32_t, int);
void nfs_open_file_destroy(struct nfs_open_file *);
int nfs_open_file_set_busy(struct nfs_open_file *, thread_t);
void nfs_open_file_clear_busy(struct nfs_open_file *);
void nfs_open_file_add_open(struct nfs_open_file *, uint32_t, uint32_t, int);
void nfs_open_file_remove_open_find(struct nfs_open_file *, uint32_t, uint32_t, uint8_t *, uint8_t *, int *);
void nfs_open_file_remove_open(struct nfs_open_file *, uint32_t, uint32_t);
void nfs_get_stateid(nfsnode_t, thread_t, kauth_cred_t, nfs_stateid *, int);
int nfs_check_for_locks(struct nfs_open_owner *, struct nfs_open_file *);
int nfs_close(nfsnode_t, struct nfs_open_file *, uint32_t, uint32_t, vfs_context_t);
void nfs_release_open_state_for_node(nfsnode_t, int);
void nfs_revoke_open_state_for_node(nfsnode_t);
struct nfs_lock_owner *nfs_lock_owner_find(nfsnode_t, proc_t, caddr_t, int);
void nfs_lock_owner_destroy(struct nfs_lock_owner *);
void nfs_lock_owner_ref(struct nfs_lock_owner *);
void nfs_lock_owner_rele(nfsnode_t, struct nfs_lock_owner *, thread_t, kauth_cred_t);
int nfs_lock_owner_set_busy(struct nfs_lock_owner *, thread_t);
void nfs_lock_owner_clear_busy(struct nfs_lock_owner *);
void nfs_lock_owner_insert_held_lock(struct nfs_lock_owner *, struct nfs_file_lock *);
struct nfs_file_lock *nfs_file_lock_alloc(struct nfs_lock_owner *);
void nfs_file_lock_destroy(nfsnode_t, struct nfs_file_lock *, thread_t, kauth_cred_t);
int nfs_file_lock_conflict(struct nfs_file_lock *, struct nfs_file_lock *, int *);
int nfs_unlock_rpc(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, thread_t, kauth_cred_t, int);
int nfs_advlock_getlock(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t);
int nfs_advlock_setlock(nfsnode_t, struct nfs_open_file *, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, short, vfs_context_t);
int nfs_advlock_unlock(nfsnode_t, struct nfs_open_file *, struct nfs_lock_owner *, uint64_t, uint64_t, int, vfs_context_t);
#if CONFIG_NFS4
int nfs4_release_lockowner_rpc(nfsnode_t, struct nfs_lock_owner *, thread_t, kauth_cred_t);
int nfs4_create_rpc(vfs_context_t, nfsnode_t, struct componentname *, struct vnode_attr *, int, char *, nfsnode_t *);
int nfs4_open(nfsnode_t, struct nfs_open_file *, uint32_t, uint32_t, vfs_context_t);
int nfs4_open_delegated(nfsnode_t, struct nfs_open_file *, uint32_t, uint32_t, vfs_context_t);
int nfs4_reopen(struct nfs_open_file *, thread_t);
int nfs4_open_rpc(struct nfs_open_file *, vfs_context_t, struct componentname *, struct vnode_attr *, vnode_t, vnode_t *, int, int, int);
int nfs4_open_rpc_internal(struct nfs_open_file *, vfs_context_t, thread_t, kauth_cred_t, struct componentname *, struct vnode_attr *, vnode_t, vnode_t *, int, int, int);
int nfs4_open_confirm_rpc(struct nfsmount *, nfsnode_t, u_char *, int, struct nfs_open_owner *, nfs_stateid *, thread_t, kauth_cred_t, struct nfs_vattr *, uint64_t *);
int nfs4_open_reopen_rpc(struct nfs_open_file *, thread_t, kauth_cred_t, struct componentname *, vnode_t, vnode_t *, int, int);
int nfs4_open_reclaim_rpc(struct nfs_open_file *, int, int);
int nfs4_claim_delegated_open_rpc(struct nfs_open_file *, int, int, int);
int nfs4_claim_delegated_state_for_open_file(struct nfs_open_file *, int);
int nfs4_claim_delegated_state_for_node(nfsnode_t, int);
int nfs4_open_downgrade_rpc(nfsnode_t, struct nfs_open_file *, vfs_context_t);
int nfs4_close_rpc(nfsnode_t, struct nfs_open_file *, thread_t, kauth_cred_t, int);
void nfs4_delegation_return_enqueue(nfsnode_t);
int nfs4_delegation_return(nfsnode_t, int, thread_t, kauth_cred_t);
int nfs4_lock_rpc(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t);
int nfs4_delegreturn_rpc(struct nfsmount *, u_char *, int, struct nfs_stateid *, int, thread_t, kauth_cred_t);
nfsnode_t nfs4_named_attr_dir_get(nfsnode_t, int, vfs_context_t);
int nfs4_named_attr_get(nfsnode_t, struct componentname *, uint32_t, int, vfs_context_t, nfsnode_t *, struct nfs_open_file **);
int nfs4_named_attr_remove(nfsnode_t, nfsnode_t, const char *, vfs_context_t);
#endif
int nfs_mount_state_in_use_start(struct nfsmount *, thread_t);
int nfs_mount_state_in_use_end(struct nfsmount *, int);
int nfs_mount_state_error_should_restart(int);
int nfs_mount_state_error_delegation_lost(int);
uint nfs_mount_state_max_restarts(struct nfsmount *);
int nfs_mount_state_wait_for_recovery(struct nfsmount *);
void nfs_need_recover(struct nfsmount *nmp, int error);
void nfs_recover(struct nfsmount *);
int nfs_vnop_access(struct vnop_access_args *);
int nfs_vnop_remove(struct vnop_remove_args *);
int nfs_vnop_read(struct vnop_read_args *);
int nfs_vnop_write(struct vnop_write_args *);
int nfs_vnop_open(struct vnop_open_args *);
int nfs_vnop_close(struct vnop_close_args *);
int nfs_vnop_advlock(struct vnop_advlock_args *);
int nfs_vnop_mmap(struct vnop_mmap_args *);
int nfs_vnop_mmap_check(struct vnop_mmap_check_args *ap);
int nfs_vnop_mnomap(struct vnop_mnomap_args *);
#if CONFIG_NFS4
int nfs4_vnop_create(struct vnop_create_args *);
int nfs4_vnop_mknod(struct vnop_mknod_args *);
int nfs4_vnop_close(struct vnop_close_args *);
int nfs4_vnop_getattr(struct vnop_getattr_args *);
int nfs4_vnop_link(struct vnop_link_args *);
int nfs4_vnop_mkdir(struct vnop_mkdir_args *);
int nfs4_vnop_rmdir(struct vnop_rmdir_args *);
int nfs4_vnop_symlink(struct vnop_symlink_args *);
int nfs4_vnop_getxattr(struct vnop_getxattr_args *);
int nfs4_vnop_setxattr(struct vnop_setxattr_args *);
int nfs4_vnop_removexattr(struct vnop_removexattr_args *);
int nfs4_vnop_listxattr(struct vnop_listxattr_args *);
#if NAMEDSTREAMS
int nfs4_vnop_getnamedstream(struct vnop_getnamedstream_args *);
int nfs4_vnop_makenamedstream(struct vnop_makenamedstream_args *);
int nfs4_vnop_removenamedstream(struct vnop_removenamedstream_args *);
#endif
int nfs4_access_rpc(nfsnode_t, u_int32_t *, int, vfs_context_t);
int nfs4_getattr_rpc(nfsnode_t, mount_t, u_char *, size_t, int, vfs_context_t, struct nfs_vattr *, u_int64_t *);
int nfs4_setattr_rpc(nfsnode_t, struct vnode_attr *, vfs_context_t);
int nfs4_read_rpc_async(nfsnode_t, off_t, size_t, thread_t, kauth_cred_t, struct nfsreq_cbinfo *, struct nfsreq **);
int nfs4_read_rpc_async_finish(nfsnode_t, struct nfsreq *, uio_t, size_t *, int *);
int nfs4_write_rpc_async(nfsnode_t, uio_t, size_t, thread_t, kauth_cred_t, int, struct nfsreq_cbinfo *, struct nfsreq **);
int nfs4_write_rpc_async_finish(nfsnode_t, struct nfsreq *, int *, size_t *, uint64_t *);
int nfs4_readdir_rpc(nfsnode_t, struct nfsbuf *, vfs_context_t);
int nfs4_readlink_rpc(nfsnode_t, char *, size_t *, vfs_context_t);
int nfs4_commit_rpc(nfsnode_t, uint64_t, uint64_t, kauth_cred_t, uint64_t);
int nfs4_lookup_rpc_async(nfsnode_t, char *, int, vfs_context_t, struct nfsreq **);
int nfs4_lookup_rpc_async_finish(nfsnode_t, char *, int, vfs_context_t, struct nfsreq *, u_int64_t *, fhandle_t *, struct nfs_vattr *);
int nfs4_remove_rpc(nfsnode_t, char *, int, thread_t, kauth_cred_t);
int nfs4_rename_rpc(nfsnode_t, char *, int, nfsnode_t, char *, int, vfs_context_t);
int nfs4_pathconf_rpc(nfsnode_t, struct nfs_fsattr *, vfs_context_t);
int nfs4_setlock_rpc(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t);
int nfs4_unlock_rpc(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, thread_t, kauth_cred_t);
int nfs4_getlock_rpc(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t);
#endif
int nfs_read_rpc(nfsnode_t, uio_t, vfs_context_t);
int nfs_write_rpc(nfsnode_t, uio_t, vfs_context_t, int *, uint64_t *);
int nfs_write_rpc2(nfsnode_t, uio_t, thread_t, kauth_cred_t, int *, uint64_t *);
int nfs3_access_rpc(nfsnode_t, u_int32_t *, int, vfs_context_t);
int nfs3_getattr_rpc(nfsnode_t, mount_t, u_char *, size_t, int, vfs_context_t, struct nfs_vattr *, u_int64_t *);
int nfs3_setattr_rpc(nfsnode_t, struct vnode_attr *, vfs_context_t);
int nfs3_read_rpc_async(nfsnode_t, off_t, size_t, thread_t, kauth_cred_t, struct nfsreq_cbinfo *, struct nfsreq **);
int nfs3_read_rpc_async_finish(nfsnode_t, struct nfsreq *, uio_t, size_t *, int *);
int nfs3_write_rpc_async(nfsnode_t, uio_t, size_t, thread_t, kauth_cred_t, int, struct nfsreq_cbinfo *, struct nfsreq **);
int nfs3_write_rpc_async_finish(nfsnode_t, struct nfsreq *, int *, size_t *, uint64_t *);
int nfs3_readdir_rpc(nfsnode_t, struct nfsbuf *, vfs_context_t);
int nfs3_readlink_rpc(nfsnode_t, char *, size_t *, vfs_context_t);
int nfs3_commit_rpc(nfsnode_t, uint64_t, uint64_t, kauth_cred_t, uint64_t);
int nfs3_lookup_rpc_async(nfsnode_t, char *, int, vfs_context_t, struct nfsreq **);
int nfs3_lookup_rpc_async_finish(nfsnode_t, char *, int, vfs_context_t, struct nfsreq *, u_int64_t *, fhandle_t *, struct nfs_vattr *);
int nfs3_remove_rpc(nfsnode_t, char *, int, thread_t, kauth_cred_t);
int nfs3_rename_rpc(nfsnode_t, char *, int, nfsnode_t, char *, int, vfs_context_t);
int nfs3_pathconf_rpc(nfsnode_t, struct nfs_fsattr *, vfs_context_t);
int nfs3_setlock_rpc(nfsnode_t, struct nfs_open_file *, struct nfs_file_lock *, int, int, thread_t, kauth_cred_t);
int nfs3_unlock_rpc(nfsnode_t, struct nfs_lock_owner *, int, uint64_t, uint64_t, int, thread_t, kauth_cred_t);
int nfs3_getlock_rpc(nfsnode_t, struct nfs_lock_owner *, struct flock *, uint64_t, uint64_t, vfs_context_t);
void nfsrv_active_user_list_reclaim(void);
void nfsrv_cleancache(void);
void nfsrv_cleanup(void);
int nfsrv_credcheck(struct nfsrv_descript *, vfs_context_t, struct nfs_export *,
struct nfs_export_options *);
void nfsrv_idlesock_timer(void *, void *);
int nfsrv_dorec(struct nfsrv_sock *, struct nfsd *, struct nfsrv_descript **);
int nfsrv_errmap(struct nfsrv_descript *, int);
int nfsrv_export(struct user_nfs_export_args *, vfs_context_t);
int nfsrv_fhmatch(struct nfs_filehandle *, struct nfs_filehandle *);
int nfsrv_fhtovp(struct nfs_filehandle *, struct nfsrv_descript *, vnode_t *,
struct nfs_export **, struct nfs_export_options **);
int nfsrv_check_exports_allow_address(mbuf_t);
#if CONFIG_FSE
void nfsrv_fmod_timer(void *, void *);
#endif
int nfsrv_getcache(struct nfsrv_descript *, struct nfsrv_sock *, mbuf_t *);
void nfsrv_group_sort(gid_t *, int);
void nfsrv_init(void);
void nfsrv_initcache(void);
int nfsrv_is_initialized(void);
int nfsrv_namei(struct nfsrv_descript *, vfs_context_t, struct nameidata *,
struct nfs_filehandle *, vnode_t *,
struct nfs_export **, struct nfs_export_options **);
void nfsrv_rcv(socket_t, void *, int);
void nfsrv_rcv_locked(socket_t, struct nfsrv_sock *, int);
int nfsrv_rephead(struct nfsrv_descript *, struct nfsrv_sock *, struct nfsm_chain *, size_t);
int nfsrv_send(struct nfsrv_sock *, mbuf_t, mbuf_t);
void nfsrv_updatecache(struct nfsrv_descript *, int, mbuf_t);
void nfsrv_update_user_stat(struct nfs_export *, struct nfsrv_descript *, uid_t, u_int, u_int, u_int);
int nfsrv_vptofh(struct nfs_export *, int, struct nfs_filehandle *,
vnode_t, vfs_context_t, struct nfs_filehandle *);
void nfsrv_wakenfsd(struct nfsrv_sock *);
void nfsrv_wg_timer(void *, void *);
int nfsrv_writegather(struct nfsrv_descript **, struct nfsrv_sock *,
vfs_context_t, mbuf_t *);
int nfsrv_access(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_commit(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_create(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_fsinfo(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_getattr(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_link(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_lookup(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_mkdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_mknod(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_noop(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_null(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_pathconf(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_read(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_readdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_readdirplus(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_readlink(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_remove(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_rename(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_rmdir(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_setattr(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_statfs(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_symlink(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
int nfsrv_write(struct nfsrv_descript *, struct nfsrv_sock *, vfs_context_t, mbuf_t *);
void nfs_interval_timer_start(thread_call_t, time_t);
int nfs_use_cache(struct nfsmount *);
void nfs_up(struct nfsmount *, thread_t, int, const char *);
void nfs_down(struct nfsmount *, thread_t, int, int, const char *, int);
int nfs_msg(thread_t, const char *, const char *, int);
int nfs_maperr(const char *, int);
#define NFS_MAPERR(ERR) nfs_maperr(__FUNCTION__, (ERR))
int nfs_mountroot(void);
struct nfs_diskless;
int nfs_boot_init(struct nfs_diskless *);
int nfs_boot_getfh(struct nfs_diskless *, int, int);
#if CONFIG_TRIGGERS
resolver_result_t nfs_mirror_mount_trigger_resolve(vnode_t, const struct componentname *, enum path_operation, int, void *, vfs_context_t);
resolver_result_t nfs_mirror_mount_trigger_unresolve(vnode_t, int, void *, vfs_context_t);
resolver_result_t nfs_mirror_mount_trigger_rearm(vnode_t, int, void *, vfs_context_t);
int nfs_mirror_mount_domount(vnode_t, vnode_t, vfs_context_t);
void nfs_ephemeral_mount_harvester_start(void);
void nfs_ephemeral_mount_harvester(__unused void *arg, __unused wait_result_t wr);
#endif
/* socket upcall interfaces */
void nfsrv_uc_init(void);
void nfsrv_uc_cleanup(void);
void nfsrv_uc_addsock(struct nfsrv_sock *, int);
void nfsrv_uc_dequeue(struct nfsrv_sock *);
/* Debug support */
#define __NFS_DEBUG_LEVEL(dbgctl) ((dbgctl) & 0xf)
#define __NFS_DEBUG_FACILITY(dbgctl) (((dbgctl) >> 4) & 0xfff)
#define __NFS_DEBUG_FLAGS(dbgctl) (((dbgctl) >> 16) & 0xf)
#define __NFS_DEBUG_VALUE(dbgctl) (((dbgctl) >> 20) & 0xfff)
#define __NFS_IS_DBG(dbgctl, fac, lev) (__builtin_expect((__NFS_DEBUG_FACILITY(dbgctl) & (fac)) && ((lev) <= __NFS_DEBUG_LEVEL(dbgctl)), 0))
#define __NFS_DBG(dbgctl, fac, lev, fmt, ...) nfs_printf((dbgctl), (fac), (lev), "%s: %d: " fmt, __func__, __LINE__, ## __VA_ARGS__)
void nfs_printf(unsigned int, unsigned int, unsigned int, const char *, ...) __printflike(4, 5);
void nfs_dump_mbuf(const char *, int, const char *, mbuf_t);
int nfs_mountopts(struct nfsmount *, char *, int);
/* Client debug support */
#define NFSCLNT_FAC_SOCK 0x001
#define NFSCLNT_FAC_STATE 0x002
#define NFSCLNT_FAC_NODE 0x004
#define NFSCLNT_FAC_VNOP 0x008
#define NFSCLNT_FAC_BIO 0x010
#define NFSCLNT_FAC_GSS 0x020
#define NFSCLNT_FAC_VFS 0x040
#define NFSCLNT_FAC_SRV 0x080
#define NFSCLNT_DEBUG_LEVEL __NFS_DEBUG_LEVEL(nfsclnt_debug_ctl)
#define NFSCLNT_DEBUG_FACILITY __NFS_DEBUG_FACILITY(nfsclnt_debug_ctl)
#define NFSCLNT_DEBUG_FLAGS __NFS_DEBUG_FLAGS(nfsclnt_debug_ctl)
#define NFSCLNT_DEBUG_VALUE __NFS_DEBUG_VALUE(nfsclnt_debug_ctl)
#define NFSCLNT_IS_DBG(fac, lev) __NFS_IS_DBG(nfsclnt_debug_ctl, fac, lev)
#define NFSCLNT_DBG(fac, lev, fmt, ...) __NFS_DBG(nfsclnt_debug_ctl, fac, lev, fmt, ## __VA_ARGS__)
/* Server debug support */
#define NFSRV_FAC_GSS 0x001
#define NFSRV_FAC_SRV 0x002
#define NFSRV_DEBUG_LEVEL __NFS_DEBUG_LEVEL(nfsrv_debug_ctl)
#define NFSRV_DEBUG_FACILITY __NFS_DEBUG_FACILITY(nfsrv_debug_ctl)
#define NFSRV_DEBUG_FLAGS __NFS_DEBUG_FLAGS(nfsrv_debug_ctl)
#define NFSRV_DEBUG_VALUE __NFS_DEBUG_VALUE(nfsrv_debug_ctl)
#define NFSRV_IS_DBG(fac, lev) __NFS_IS_DBG(nfsrv_debug_ctl, fac, lev)
#define NFSRV_DBG(fac, lev, fmt, ...) __NFS_DBG(nfsrv_debug_ctl, fac, lev, fmt, ## __VA_ARGS__)
__END_DECLS
#endif /* __APPLE_API_PRIVATE */
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/nfs/nfsproto.h | /*
* Copyright (c) 2000-2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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.
*
* @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
* FreeBSD-Id: nfsproto.h,v 1.3 1997/02/22 09:42:50 peter Exp $
*/
#ifndef _NFS_NFSPROTO_H_
#define _NFS_NFSPROTO_H_
#include <sys/appleapiopts.h>
#ifdef __APPLE_API_PRIVATE
/*
* NFS definitions per the various NFS protocol specs:
* Version 2 (RFC 1094), Version 3 (RFC 1813), and Version 4 (RFC 3530)
* and various protocol-related implementation definitions.
*/
/* Only define these if nfs_prot.h hasn't been included */
#ifndef NFS_PROGRAM
#define NFS_PORT 2049
#define NFS_PROG 100003
#define NFS_VER2 2
#define NFS_VER3 3
#define NFS_VER4 4
#define NFS_V2MAXDATA 8192
#define NFS_MAXDGRAMDATA 16384
#define NFS_PREFDGRAMDATA 8192
#define NFS_MAXDATA (8 * 64 * PAGE_SIZE) /* Same as NFS_MAXBSIZE from nfsnode.h */
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
#define NFS_MAXPACKET (16 * 1024 * 1024)
#define NFS_UDPSOCKBUF (224 * 1024)
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
#define NFSRV_MAXDATA NFS_MAXDATA
#define NFSRV_TCPSOCKBUF (2 * NFSRV_MAXDATA)
#define NFS4_CALLBACK_PROG 0x4E465343 /* "NFSC" */
#define NFS4_CALLBACK_PROG_VERSION 1
/* Stat numbers for NFS RPC returns */
#define NFS_OK 0
#define NFSERR_PERM 1
#define NFSERR_NOENT 2
#define NFSERR_IO 5
#define NFSERR_NXIO 6
#define NFSERR_ACCES 13
#define NFSERR_EXIST 17
#define NFSERR_XDEV 18 /* Version 3 only */
#define NFSERR_NODEV 19
#define NFSERR_NOTDIR 20
#define NFSERR_ISDIR 21
#define NFSERR_INVAL 22 /* Version 3 only */
#define NFSERR_FBIG 27
#define NFSERR_NOSPC 28
#define NFSERR_ROFS 30
#define NFSERR_MLINK 31 /* Version 3 only */
#define NFSERR_NAMETOL 63
#define NFSERR_NOTEMPTY 66
#define NFSERR_DQUOT 69
#define NFSERR_STALE 70
#define NFSERR_REMOTE 71 /* Version 3 only */
#define NFSERR_WFLUSH 99 /* Version 2 only */
#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
#define NFSERR_NOT_SYNC 10002
#define NFSERR_BAD_COOKIE 10003
#define NFSERR_NOTSUPP 10004
#define NFSERR_TOOSMALL 10005
#define NFSERR_SERVERFAULT 10006
#define NFSERR_BADTYPE 10007
#define NFSERR_JUKEBOX 10008
#define NFSERR_TRYLATER NFSERR_JUKEBOX
#define NFSERR_DELAY NFSERR_JUKEBOX
#define NFSERR_SAME 10009 /* The rest Version 4 only */
#define NFSERR_DENIED 10010
#define NFSERR_EXPIRED 10011
#define NFSERR_LOCKED 10012
#define NFSERR_GRACE 10013
#define NFSERR_FHEXPIRED 10014
#define NFSERR_SHARE_DENIED 10015
#define NFSERR_WRONGSEC 10016
#define NFSERR_CLID_INUSE 10017
#define NFSERR_RESOURCE 10018
#define NFSERR_MOVED 10019
#define NFSERR_NOFILEHANDLE 10020
#define NFSERR_MINOR_VERS_MISMATCH 10021
#define NFSERR_STALE_CLIENTID 10022
#define NFSERR_STALE_STATEID 10023
#define NFSERR_OLD_STATEID 10024
#define NFSERR_BAD_STATEID 10025
#define NFSERR_BAD_SEQID 10026
#define NFSERR_NOT_SAME 10027
#define NFSERR_LOCK_RANGE 10028
#define NFSERR_SYMLINK 10029
#define NFSERR_RESTOREFH 10030
#define NFSERR_LEASE_MOVED 10031
#define NFSERR_ATTRNOTSUPP 10032
#define NFSERR_NO_GRACE 10033
#define NFSERR_RECLAIM_BAD 10034
#define NFSERR_RECLAIM_CONFLICT 10035
#define NFSERR_BADXDR 10036
#define NFSERR_LOCKS_HELD 10037
#define NFSERR_OPENMODE 10038
#define NFSERR_BADOWNER 10039
#define NFSERR_BADCHAR 10040
#define NFSERR_BADNAME 10041
#define NFSERR_BAD_RANGE 10042
#define NFSERR_LOCK_NOTSUPP 10043
#define NFSERR_OP_ILLEGAL 10044
#define NFSERR_DEADLOCK 10045
#define NFSERR_FILE_OPEN 10046
#define NFSERR_ADMIN_REVOKED 10047
#define NFSERR_CB_PATH_DOWN 10048
#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
#define NFSERR_DIRBUFDROPPED 30002 /* Fake return for nfs*_readdir_rpc() */
/*
* For gss we would like to return EAUTH when we don't have or can't get credentials,
* but some callers don't know what to do with it, so we define our own version
* of EAUTH to be EACCES
*/
#define NFSERR_EAUTH EACCES
#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
#endif /* !NFS_PROGRAM */
/* Sizes in bytes of various nfs rpc components */
#define NFSX_UNSIGNED 4
/* specific to NFS Version 2 */
#define NFSX_V2FH 32
#define NFSX_V2FATTR 68
#define NFSX_V2SATTR 32
#define NFSX_V2COOKIE 4
#define NFSX_V2STATFS 20
/* specific to NFS Version 3 */
#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
#define NFSX_V3FATTR 84
#define NFSX_V3SATTR 60 /* max. all fields filled in */
#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
#define NFSX_V3COOKIEVERF 8
#define NFSX_V3WRITEVERF 8
#define NFSX_V3CREATEVERF 8
#define NFSX_V3STATFS 52
#define NFSX_V3FSINFO 48
#define NFSX_V3PATHCONF 24
/* specific to NFS Version 4 */
#define NFS4_FHSIZE 128
#define NFS4_VERIFIER_SIZE 8
#define NFS4_OPAQUE_LIMIT 1024
/* variants for multiple versions */
#define NFSX_FH(V) (((V) == NFS_VER2) ? NFSX_V2FH : (NFSX_UNSIGNED + \
(((V) == NFS_VER3) ? NFSX_V3FHMAX : NFS4_FHSIZE)))
#define NFSX_SRVFH(V, FH) (((V) == NFS_VER2) ? NFSX_V2FH : (FH)->nfh_len)
#define NFSX_FATTR(V) (((V) == NFS_VER3) ? NFSX_V3FATTR : NFSX_V2FATTR)
#define NFSX_PREOPATTR(V) (((V) == NFS_VER3) ? (7 * NFSX_UNSIGNED) : 0)
#define NFSX_POSTOPATTR(V) (((V) == NFS_VER3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
#define NFSX_POSTOPORFATTR(V) (((V) == NFS_VER3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : NFSX_V2FATTR)
#define NFSX_WCCDATA(V) (((V) == NFS_VER3) ? NFSX_V3WCCDATA : 0)
#define NFSX_WCCORFATTR(V) (((V) == NFS_VER3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
#define NFSX_SATTR(V) (((V) == NFS_VER3) ? NFSX_V3SATTR : NFSX_V2SATTR)
#define NFSX_COOKIEVERF(V) (((V) == NFS_VER3) ? NFSX_V3COOKIEVERF : 0)
#define NFSX_WRITEVERF(V) (((V) == NFS_VER3) ? NFSX_V3WRITEVERF : 0)
#define NFSX_READDIR(V) (((V) == NFS_VER3) ? (5 * NFSX_UNSIGNED) : \
(2 * NFSX_UNSIGNED))
#define NFSX_STATFS(V) (((V) == NFS_VER3) ? NFSX_V3STATFS : NFSX_V2STATFS)
/* Only define these if nfs_prot.h hasn't been included */
#ifndef NFS_PROGRAM
/* nfs rpc procedure numbers (before version mapping) */
#define NFSPROC_NULL 0
#define NFSPROC_GETATTR 1
#define NFSPROC_SETATTR 2
#define NFSPROC_LOOKUP 3
#define NFSPROC_ACCESS 4
#define NFSPROC_READLINK 5
#define NFSPROC_READ 6
#define NFSPROC_WRITE 7
#define NFSPROC_CREATE 8
#define NFSPROC_MKDIR 9
#define NFSPROC_SYMLINK 10
#define NFSPROC_MKNOD 11
#define NFSPROC_REMOVE 12
#define NFSPROC_RMDIR 13
#define NFSPROC_RENAME 14
#define NFSPROC_LINK 15
#define NFSPROC_READDIR 16
#define NFSPROC_READDIRPLUS 17
#define NFSPROC_FSSTAT 18
#define NFSPROC_FSINFO 19
#define NFSPROC_PATHCONF 20
#define NFSPROC_COMMIT 21
#endif /* !NFS_PROGRAM */
#define NFSPROC_NOOP 22
#define NFS_NPROCS 23
/* Actual Version 2 procedure numbers */
#define NFSV2PROC_NULL 0
#define NFSV2PROC_GETATTR 1
#define NFSV2PROC_SETATTR 2
#define NFSV2PROC_NOOP 3
#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
#define NFSV2PROC_LOOKUP 4
#define NFSV2PROC_READLINK 5
#define NFSV2PROC_READ 6
#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
#define NFSV2PROC_WRITE 8
#define NFSV2PROC_CREATE 9
#define NFSV2PROC_REMOVE 10
#define NFSV2PROC_RENAME 11
#define NFSV2PROC_LINK 12
#define NFSV2PROC_SYMLINK 13
#define NFSV2PROC_MKDIR 14
#define NFSV2PROC_RMDIR 15
#define NFSV2PROC_READDIR 16
#define NFSV2PROC_STATFS 17
/*
* Constants used by the Version 3 protocol for various RPCs
*/
#define NFSV3FSINFO_LINK 0x01
#define NFSV3FSINFO_SYMLINK 0x02
#define NFSV3FSINFO_HOMOGENEOUS 0x08
#define NFSV3FSINFO_CANSETTIME 0x10
/* time setting constants */
#define NFS_TIME_DONT_CHANGE 0
#define NFS_TIME_SET_TO_SERVER 1
#define NFS_TIME_SET_TO_CLIENT 2
#define NFS4_TIME_SET_TO_SERVER 0
#define NFS4_TIME_SET_TO_CLIENT 1
/* access() constants */
#define NFS_ACCESS_READ 0x01
#define NFS_ACCESS_LOOKUP 0x02
#define NFS_ACCESS_MODIFY 0x04
#define NFS_ACCESS_EXTEND 0x08
#define NFS_ACCESS_DELETE 0x10
#define NFS_ACCESS_EXECUTE 0x20
#define NFS_ACCESS_ALL (NFS_ACCESS_READ | NFS_ACCESS_MODIFY \
| NFS_ACCESS_EXTEND | NFS_ACCESS_EXECUTE \
| NFS_ACCESS_DELETE | NFS_ACCESS_LOOKUP)
/* NFS WRITE how constants */
#define NFS_WRITE_UNSTABLE 0
#define NFS_WRITE_DATASYNC 1
#define NFS_WRITE_FILESYNC 2
/* NFS CREATE types */
#define NFS_CREATE_UNCHECKED 0
#define NFS_CREATE_GUARDED 1
#define NFS_CREATE_EXCLUSIVE 2
/* Only define these if nfs_prot.h hasn't been included */
#ifndef NFS_PROGRAM
/* NFS object types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
NFSOCK=6, NFFIFO=7, NFATTRDIR=8, NFNAMEDATTR=9 } nfstype;
#endif /* !NFS_PROGRAM */
/*
* File Handle (32 bytes for version 2), variable up to 64 for version 3
* and variable up to 128 bytes for version 4.
* File Handles of up to NFS_SMALLFH in size are stored directly in the
* nfs node, whereas larger ones are malloc'd. (This never happens when
* NFS_SMALLFH is set to the largest size.)
* NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
*/
#ifndef NFS_SMALLFH
#define NFS_SMALLFH 64
#endif
/*
* NFS attribute management stuff
*/
#define NFS_ATTR_BITMAP_LEN 2
#define NFS_BITMAP_SET(B, I) (((uint32_t *)(B))[(I)/32] |= 1U<<((I)%32))
#define NFS_BITMAP_CLR(B, I) (((uint32_t *)(B))[(I)/32] &= ~(1U<<((I)%32)))
#define NFS_BITMAP_ISSET(B, I) (((uint32_t *)(B))[(I)/32] & (1U<<((I)%32)))
#define NFS_BITMAP_COPY_ATTR(FROM, TO, WHICH, ATTR) \
do { \
if (NFS_BITMAP_ISSET(((FROM)->nva_bitmap), (NFS_FATTR_##WHICH))) { \
(TO)->nva_##ATTR = (FROM)->nva_##ATTR; \
NFS_BITMAP_SET(((TO)->nva_bitmap), (NFS_FATTR_##WHICH)); \
} \
} while (0)
#define NFS_BITMAP_COPY_TIME(FROM, TO, WHICH, ATTR) \
do { \
if (NFS_BITMAP_ISSET(((FROM)->nva_bitmap), (NFS_FATTR_TIME_##WHICH))) { \
(TO)->nva_timesec[NFSTIME_##ATTR] = (FROM)->nva_timesec[NFSTIME_##ATTR]; \
(TO)->nva_timensec[NFSTIME_##ATTR] = (FROM)->nva_timensec[NFSTIME_##ATTR]; \
NFS_BITMAP_SET(((TO)->nva_bitmap), (NFS_FATTR_TIME_##WHICH)); \
} \
} while (0)
#define NFS_BITMAP_ZERO(B, L) \
do { \
int __i; \
for (__i=0; __i < (L); __i++) \
((uint32_t*)(B))[__i] = 0; \
} while (0)
extern uint32_t nfs_fs_attr_bitmap[NFS_ATTR_BITMAP_LEN];
extern uint32_t nfs_object_attr_bitmap[NFS_ATTR_BITMAP_LEN];
extern uint32_t nfs_getattr_bitmap[NFS_ATTR_BITMAP_LEN];
extern uint32_t nfs4_getattr_write_bitmap[NFS_ATTR_BITMAP_LEN];
#define NFS_CLEAR_ATTRIBUTES(A) NFS_BITMAP_ZERO((A), NFS_ATTR_BITMAP_LEN)
#define NFS_COPY_ATTRIBUTES(SRC, DST) \
do { \
int __i; \
for (__i=0; __i < NFS_ATTR_BITMAP_LEN; __i++) \
((uint32_t*)(DST))[__i] = ((uint32_t*)(SRC))[__i]; \
} while (0)
/* NFS attributes */
#define NFS_FATTR_SUPPORTED_ATTRS 0
#define NFS_FATTR_TYPE 1
#define NFS_FATTR_FH_EXPIRE_TYPE 2
#define NFS_FATTR_CHANGE 3
#define NFS_FATTR_SIZE 4
#define NFS_FATTR_LINK_SUPPORT 5
#define NFS_FATTR_SYMLINK_SUPPORT 6
#define NFS_FATTR_NAMED_ATTR 7
#define NFS_FATTR_FSID 8
#define NFS_FATTR_UNIQUE_HANDLES 9
#define NFS_FATTR_LEASE_TIME 10
#define NFS_FATTR_RDATTR_ERROR 11
#define NFS_FATTR_FILEHANDLE 19
#define NFS_FATTR_ACL 12
#define NFS_FATTR_ACLSUPPORT 13
#define NFS_FATTR_ARCHIVE 14
#define NFS_FATTR_CANSETTIME 15
#define NFS_FATTR_CASE_INSENSITIVE 16
#define NFS_FATTR_CASE_PRESERVING 17
#define NFS_FATTR_CHOWN_RESTRICTED 18
#define NFS_FATTR_FILEID 20
#define NFS_FATTR_FILES_AVAIL 21
#define NFS_FATTR_FILES_FREE 22
#define NFS_FATTR_FILES_TOTAL 23
#define NFS_FATTR_FS_LOCATIONS 24
#define NFS_FATTR_HIDDEN 25
#define NFS_FATTR_HOMOGENEOUS 26
#define NFS_FATTR_MAXFILESIZE 27
#define NFS_FATTR_MAXLINK 28
#define NFS_FATTR_MAXNAME 29
#define NFS_FATTR_MAXREAD 30
#define NFS_FATTR_MAXWRITE 31
#define NFS_FATTR_MIMETYPE 32
#define NFS_FATTR_MODE 33
#define NFS_FATTR_NO_TRUNC 34
#define NFS_FATTR_NUMLINKS 35
#define NFS_FATTR_OWNER 36
#define NFS_FATTR_OWNER_GROUP 37
#define NFS_FATTR_QUOTA_AVAIL_HARD 38
#define NFS_FATTR_QUOTA_AVAIL_SOFT 39
#define NFS_FATTR_QUOTA_USED 40
#define NFS_FATTR_RAWDEV 41
#define NFS_FATTR_SPACE_AVAIL 42
#define NFS_FATTR_SPACE_FREE 43
#define NFS_FATTR_SPACE_TOTAL 44
#define NFS_FATTR_SPACE_USED 45
#define NFS_FATTR_SYSTEM 46
#define NFS_FATTR_TIME_ACCESS 47
#define NFS_FATTR_TIME_ACCESS_SET 48
#define NFS_FATTR_TIME_BACKUP 49
#define NFS_FATTR_TIME_CREATE 50
#define NFS_FATTR_TIME_DELTA 51
#define NFS_FATTR_TIME_METADATA 52
#define NFS_FATTR_TIME_MODIFY 53
#define NFS_FATTR_TIME_MODIFY_SET 54
#define NFS_FATTR_MOUNTED_ON_FILEID 55
#define NFS4_ALL_ATTRIBUTES(A) \
do { \
/* required: */ \
NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
/* optional: */ \
NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); \
NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); \
NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); \
NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); \
NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
} while (0)
#define NFS4_PER_OBJECT_ATTRIBUTES(A) \
do { \
/* required: */ \
NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); \
NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); \
/* optional: */ \
NFS_BITMAP_SET((A), NFS_FATTR_ACL); \
NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
} while (0)
#define NFS4_PER_FS_ATTRIBUTES(A) \
do { \
/* required: */ \
NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
/* optional: */ \
NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); \
NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); \
NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); \
} while (0)
#define NFS4_DEFAULT_ATTRIBUTES(A) \
do { \
/* required: */ \
NFS_BITMAP_SET((A), NFS_FATTR_SUPPORTED_ATTRS); \
NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_FH_EXPIRE_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
NFS_BITMAP_SET((A), NFS_FATTR_LINK_SUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_SYMLINK_SUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_NAMED_ATTR); \
NFS_BITMAP_SET((A), NFS_FATTR_FSID); \
NFS_BITMAP_SET((A), NFS_FATTR_UNIQUE_HANDLES); \
NFS_BITMAP_SET((A), NFS_FATTR_LEASE_TIME); \
/* NFS_BITMAP_SET((A), NFS_FATTR_RDATTR_ERROR); */ \
/* NFS_BITMAP_SET((A), NFS_FATTR_FILEHANDLE); */ \
/* optional: */ \
/* NFS_BITMAP_SET((A), NFS_FATTR_ACL); */ \
NFS_BITMAP_SET((A), NFS_FATTR_ACLSUPPORT); \
NFS_BITMAP_SET((A), NFS_FATTR_ARCHIVE); \
/* NFS_BITMAP_SET((A), NFS_FATTR_CANSETTIME); */ \
NFS_BITMAP_SET((A), NFS_FATTR_CASE_INSENSITIVE); \
NFS_BITMAP_SET((A), NFS_FATTR_CASE_PRESERVING); \
NFS_BITMAP_SET((A), NFS_FATTR_CHOWN_RESTRICTED); \
NFS_BITMAP_SET((A), NFS_FATTR_FILEID); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
/* NFS_BITMAP_SET((A), NFS_FATTR_FS_LOCATIONS); */ \
NFS_BITMAP_SET((A), NFS_FATTR_HIDDEN); \
NFS_BITMAP_SET((A), NFS_FATTR_HOMOGENEOUS); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXFILESIZE); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXLINK); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXNAME); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXREAD); \
NFS_BITMAP_SET((A), NFS_FATTR_MAXWRITE); \
/* NFS_BITMAP_SET((A), NFS_FATTR_MIMETYPE); */ \
NFS_BITMAP_SET((A), NFS_FATTR_MODE); \
NFS_BITMAP_SET((A), NFS_FATTR_NO_TRUNC); \
NFS_BITMAP_SET((A), NFS_FATTR_NUMLINKS); \
NFS_BITMAP_SET((A), NFS_FATTR_OWNER); \
NFS_BITMAP_SET((A), NFS_FATTR_OWNER_GROUP); \
/* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_HARD); */ \
/* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_AVAIL_SOFT); */ \
/* NFS_BITMAP_SET((A), NFS_FATTR_QUOTA_USED); */ \
NFS_BITMAP_SET((A), NFS_FATTR_RAWDEV); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_USED); \
/* NFS_BITMAP_SET((A), NFS_FATTR_SYSTEM); */ \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS); \
/* NFS_BITMAP_SET((A), NFS_FATTR_TIME_ACCESS_SET); */ \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_BACKUP); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_CREATE); \
/* NFS_BITMAP_SET((A), NFS_FATTR_TIME_DELTA); */ \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
/* NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY_SET); */ \
NFS_BITMAP_SET((A), NFS_FATTR_MOUNTED_ON_FILEID); \
} while (0)
/*
* NFSv4 WRITE RPCs contain partial GETATTR requests - only type, change, size, metadatatime and modifytime are requested.
* In such cases, we do not update the time stamp - but the requested attributes.
*/
#define NFS4_DEFAULT_WRITE_ATTRIBUTES(A) \
do { \
/* required: */ \
NFS_BITMAP_SET((A), NFS_FATTR_TYPE); \
NFS_BITMAP_SET((A), NFS_FATTR_CHANGE); \
NFS_BITMAP_SET((A), NFS_FATTR_SIZE); \
/* optional: */ \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_METADATA); \
NFS_BITMAP_SET((A), NFS_FATTR_TIME_MODIFY); \
} while (0)
/* attributes requested when we want to do a "statfs" */
#define NFS4_STATFS_ATTRIBUTES(A) \
do { \
/* optional: */ \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_FILES_TOTAL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_AVAIL); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_FREE); \
NFS_BITMAP_SET((A), NFS_FATTR_SPACE_TOTAL); \
} while (0)
/*
* NFS OPEN constants
*/
/* open type */
#define NFS_OPEN_NOCREATE 0
#define NFS_OPEN_CREATE 1
/* delegation space limit */
#define NFS_LIMIT_SIZE 1
#define NFS_LIMIT_BLOCKS 2
/* access/deny modes */
#define NFS_OPEN_SHARE_ACCESS_NONE 0x00000000
#define NFS_OPEN_SHARE_ACCESS_READ 0x00000001
#define NFS_OPEN_SHARE_ACCESS_WRITE 0x00000002
#define NFS_OPEN_SHARE_ACCESS_BOTH 0x00000003
#define NFS_OPEN_SHARE_DENY_NONE 0x00000000
#define NFS_OPEN_SHARE_DENY_READ 0x00000001
#define NFS_OPEN_SHARE_DENY_WRITE 0x00000002
#define NFS_OPEN_SHARE_DENY_BOTH 0x00000003
/* delegation types */
#define NFS_OPEN_DELEGATE_NONE 0
#define NFS_OPEN_DELEGATE_READ 1
#define NFS_OPEN_DELEGATE_WRITE 2
/* delegation claim types */
#define NFS_CLAIM_NULL 0
#define NFS_CLAIM_PREVIOUS 1
#define NFS_CLAIM_DELEGATE_CUR 2
#define NFS_CLAIM_DELEGATE_PREV 3
/* open result flags */
#define NFS_OPEN_RESULT_CONFIRM 0x00000002
#define NFS_OPEN_RESULT_LOCKTYPE_POSIX 0x00000004
/* NFS lock types */
#define NFS_LOCK_TYPE_READ 1
#define NFS_LOCK_TYPE_WRITE 2
#define NFS_LOCK_TYPE_READW 3 /* "blocking" */
#define NFS_LOCK_TYPE_WRITEW 4 /* "blocking" */
/* NFSv4 RPC procedures */
#define NFSPROC4_NULL 0
#define NFSPROC4_COMPOUND 1
#define NFSPROC4_CB_NULL 0
#define NFSPROC4_CB_COMPOUND 1
/* NFSv4 opcodes */
#define NFS_OP_ACCESS 3
#define NFS_OP_CLOSE 4
#define NFS_OP_COMMIT 5
#define NFS_OP_CREATE 6
#define NFS_OP_DELEGPURGE 7
#define NFS_OP_DELEGRETURN 8
#define NFS_OP_GETATTR 9
#define NFS_OP_GETFH 10
#define NFS_OP_LINK 11
#define NFS_OP_LOCK 12
#define NFS_OP_LOCKT 13
#define NFS_OP_LOCKU 14
#define NFS_OP_LOOKUP 15
#define NFS_OP_LOOKUPP 16
#define NFS_OP_NVERIFY 17
#define NFS_OP_OPEN 18
#define NFS_OP_OPENATTR 19
#define NFS_OP_OPEN_CONFIRM 20
#define NFS_OP_OPEN_DOWNGRADE 21
#define NFS_OP_PUTFH 22
#define NFS_OP_PUTPUBFH 23
#define NFS_OP_PUTROOTFH 24
#define NFS_OP_READ 25
#define NFS_OP_READDIR 26
#define NFS_OP_READLINK 27
#define NFS_OP_REMOVE 28
#define NFS_OP_RENAME 29
#define NFS_OP_RENEW 30
#define NFS_OP_RESTOREFH 31
#define NFS_OP_SAVEFH 32
#define NFS_OP_SECINFO 33
#define NFS_OP_SETATTR 34
#define NFS_OP_SETCLIENTID 35
#define NFS_OP_SETCLIENTID_CONFIRM 36
#define NFS_OP_VERIFY 37
#define NFS_OP_WRITE 38
#define NFS_OP_RELEASE_LOCKOWNER 39
#define NFS_OP_ILLEGAL 10044
#define NFS_OP_COUNT 40
/* NFSv4 callback opcodes */
#define NFS_OP_CB_GETATTR 3
#define NFS_OP_CB_RECALL 4
#define NFS_OP_CB_ILLEGAL 10044
/* NFSv4 file handle type flags */
#define NFS_FH_PERSISTENT 0x00000000
#define NFS_FH_NOEXPIRE_WITH_OPEN 0x00000001
#define NFS_FH_VOLATILE_ANY 0x00000002
#define NFS_FH_VOL_MIGRATION 0x00000004
#define NFS_FH_VOL_RENAME 0x00000008
/*
* NFSv4 ACL constants
*/
/* ACE support mask bits */
#define NFS_ACL_SUPPORT_ALLOW_ACL 0x00000001
#define NFS_ACL_SUPPORT_DENY_ACL 0x00000002
#define NFS_ACL_SUPPORT_AUDIT_ACL 0x00000004
#define NFS_ACL_SUPPORT_ALARM_ACL 0x00000008
/* ACE types */
#define NFS_ACE_ACCESS_ALLOWED_ACE_TYPE 0x00000000
#define NFS_ACE_ACCESS_DENIED_ACE_TYPE 0x00000001
#define NFS_ACE_SYSTEM_AUDIT_ACE_TYPE 0x00000002
#define NFS_ACE_SYSTEM_ALARM_ACE_TYPE 0x00000003
/* ACE flags */
#define NFS_ACE_FILE_INHERIT_ACE 0x00000001
#define NFS_ACE_DIRECTORY_INHERIT_ACE 0x00000002
#define NFS_ACE_NO_PROPAGATE_INHERIT_ACE 0x00000004
#define NFS_ACE_INHERIT_ONLY_ACE 0x00000008
#define NFS_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
#define NFS_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020
#define NFS_ACE_IDENTIFIER_GROUP 0x00000040
#define NFS_ACE_INHERITED_ACE 0x00000080
/* ACE mask flags */
#define NFS_ACE_READ_DATA 0x00000001
#define NFS_ACE_LIST_DIRECTORY 0x00000001
#define NFS_ACE_WRITE_DATA 0x00000002
#define NFS_ACE_ADD_FILE 0x00000002
#define NFS_ACE_APPEND_DATA 0x00000004
#define NFS_ACE_ADD_SUBDIRECTORY 0x00000004
#define NFS_ACE_READ_NAMED_ATTRS 0x00000008
#define NFS_ACE_WRITE_NAMED_ATTRS 0x00000010
#define NFS_ACE_EXECUTE 0x00000020
#define NFS_ACE_DELETE_CHILD 0x00000040
#define NFS_ACE_READ_ATTRIBUTES 0x00000080
#define NFS_ACE_WRITE_ATTRIBUTES 0x00000100
#define NFS_ACE_DELETE 0x00010000
#define NFS_ACE_READ_ACL 0x00020000
#define NFS_ACE_WRITE_ACL 0x00040000
#define NFS_ACE_WRITE_OWNER 0x00080000
#define NFS_ACE_SYNCHRONIZE 0x00100000
#define NFS_ACE_GENERIC_READ 0x00120081
#define NFS_ACE_GENERIC_WRITE 0x00160106
#define NFS_ACE_GENERIC_EXECUTE 0x001200A0
/*
* Quads are defined as arrays of 2 32-bit values to ensure dense packing
* for the protocol and to facilitate xdr conversion.
*/
struct nfs_uquad {
u_int32_t nfsuquad[2];
};
typedef struct nfs_uquad nfsuint64;
/*
* Used to convert between two u_int32_ts and a u_quad_t.
*/
union nfs_quadconvert {
u_int32_t lval[2];
u_quad_t qval;
};
typedef union nfs_quadconvert nfsquad_t;
/*
* special data/attribute associated with NFBLK/NFCHR
*/
struct nfs_specdata {
uint32_t specdata1; /* major device number */
uint32_t specdata2; /* minor device number */
};
typedef struct nfs_specdata nfs_specdata;
/*
* an "fsid" large enough to hold an NFSv4 fsid.
*/
struct nfs_fsid {
uint64_t major;
uint64_t minor;
};
typedef struct nfs_fsid nfs_fsid;
/*
* NFSv4 stateid structure
*/
struct nfs_stateid {
uint32_t seqid;
uint32_t other[3];
};
typedef struct nfs_stateid nfs_stateid;
#endif /* __APPLE_API_PRIVATE */
#endif /* _NFS_NFSPROTO_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/queue.h | /*
* Copyright (c) 2000-2009 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 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 [email protected]
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon rights
* to redistribute these changes.
*/
/*
*/
/*
* File: queue.h
* Author: Avadis Tevanian, Jr.
* Date: 1985
*
* Type definitions for generic queues.
*
*/
#ifndef _KERN_QUEUE_H_
#define _KERN_QUEUE_H_
#if DRIVERKIT_FRAMEWORK_INCLUDE
#include <DriverKit/macro_help.h>
#else
#include <mach/mach_types.h>
#include <kern/macro_help.h>
#endif /* DRIVERKIT_FRAMEWORK_INCLUDE */
#include <sys/cdefs.h>
#include <string.h>
__BEGIN_DECLS
/*
* Queue Management APIs
*
* There are currently two subtly different methods of maintining
* a queue of objects. Both APIs are contained in this file, and
* unfortunately overlap.
* (there is also a third way maintained in bsd/sys/queue.h)
*
* Both methods use a common queue head and linkage pattern:
* The head of a queue is declared as:
* queue_head_t q_head;
*
* Elements in this queue are chained together using
* struct queue_entry objects embedded within a structure:
* struct some_data {
* int field1;
* int field2;
* ...
* queue_chain_t link;
* ...
* int last_field;
* };
* struct some_data is referred to as the queue "element."
* (note that queue_chain_t is typedef'd to struct queue_entry)
*
* IMPORTANT: The two queue iteration methods described below are not
* compatible with one another. You must choose one and be careful
* to use only the supported APIs for that method.
*
* Method 1: chaining of queue_chain_t (linkage chains)
* This method uses the next and prev pointers of the struct queue_entry
* linkage object embedded in a queue element to point to the next or
* previous queue_entry structure in the chain. The head of the queue
* (the queue_head_t object) will point to the first and last
* struct queue_entry object, and both the next and prev pointer will
* point back to the head if the queue is empty.
*
* This method is the most flexible method of chaining objects together
* as it allows multiple chains through a given object, by embedding
* multiple queue_chain_t objects in the structure, while simultaneously
* providing fast removal and insertion into the queue using only
* struct queue_entry object pointers.
*
* ++ Valid APIs for this style queue ++
* -------------------------------------
* [C] queue_init
* [C] queue_first
* [C] queue_next
* [C] queue_last
* [C] queue_prev
* [C] queue_end
* [C] queue_empty
*
* [1] enqueue
* [1] dequeue
* [1] enqueue_head
* [1] enqueue_tail
* [1] dequeue_head
* [1] dequeue_tail
* [1] remqueue
* [1] insque
* [1] remque
* [1] re_queue_head
* [1] re_queue_tail
* [1] movqueue
* [1] qe_element
* [1] qe_foreach
* [1] qe_foreach_safe
* [1] qe_foreach_element
* [1] qe_foreach_element_safe
*
* Method 2: chaining of elements (element chains)
* This method uses the next and prev pointers of the struct queue_entry
* linkage object embedded in a queue element to point to the next or
* previous queue element (not another queue_entry). The head of the
* queue will point to the first and last queue element (struct some_data
* from the above example) NOT the embedded queue_entry structure. The
* first queue element will have a prev pointer that points to the
* queue_head_t, and the last queue element will have a next pointer
* that points to the queue_head_t.
*
* This method requires knowledge of the queue_head_t of the queue on
* which an element resides in order to remove the element. Iterating
* through the elements of the queue is also more cumbersome because
* a check against the head pointer plus a cast then offset operation
* must be performed at each step of the iteration.
*
* ++ Valid APIs for this style queue ++
* -------------------------------------
* [C] queue_init
* [C] queue_first
* [C] queue_next
* [C] queue_last
* [C] queue_prev
* [C] queue_end
* [C] queue_empty
*
* [2] queue_enter
* [2] queue_enter_first
* [2] queue_insert_before
* [2] queue_insert_after
* [2] queue_field
* [2] queue_remove
* [2] queue_remove_first
* [2] queue_remove_last
* [2] queue_assign
* [2] queue_new_head
* [2] queue_iterate
*
* Legend:
* [C] -> API common to both methods
* [1] -> API used only in method 1 (linkage chains)
* [2] -> API used only in method 2 (element chains)
*/
/*
* A generic doubly-linked list (queue).
*/
struct queue_entry {
struct queue_entry *next; /* next element */
struct queue_entry *prev; /* previous element */
#if __arm__ && (__BIGGEST_ALIGNMENT__ > 4)
/* For the newer ARMv7k ABI where 64-bit types are 64-bit aligned, but pointers
* are 32-bit:
* Since this type is so often cast to various 64-bit aligned types
* aligning it to 64-bits will avoid -wcast-align without needing
* to disable it entirely. The impact on memory footprint should be
* negligible.
*/
} __attribute__ ((aligned(8)));
#else
};
#endif
typedef struct queue_entry *queue_t;
typedef struct queue_entry queue_head_t;
typedef struct queue_entry queue_chain_t;
typedef struct queue_entry *queue_entry_t;
/*
* enqueue puts "elt" on the "queue".
* dequeue returns the first element in the "queue".
* remqueue removes the specified "elt" from its queue.
*/
#if !DRIVERKIT_FRAMEWORK_INCLUDE
#define enqueue(queue, elt) enqueue_tail(queue, elt)
#define dequeue(queue) dequeue_head(queue)
#endif
#if defined(XNU_KERNEL_PRIVATE) || DRIVERKIT_FRAMEWORK_INCLUDE
#if !DRIVERKIT_FRAMEWORK_INCLUDE
#include <kern/debug.h>
#endif /* !DRIVERKIT_FRAMEWORK_INCLUDE */
static inline void
__QUEUE_ELT_VALIDATE(queue_entry_t elt)
{
queue_entry_t elt_next, elt_prev;
if (__improbable(elt == (queue_entry_t)NULL)) {
panic("Invalid queue element %p", elt);
}
elt_next = elt->next;
elt_prev = elt->prev;
if (__improbable(elt_next == (queue_entry_t)NULL || elt_prev == (queue_entry_t)NULL)) {
panic("Invalid queue element pointers for %p: next %p prev %p", elt, elt_next, elt_prev);
}
if (__improbable(elt_next->prev != elt || elt_prev->next != elt)) {
panic("Invalid queue element linkage for %p: next %p next->prev %p prev %p prev->next %p",
elt, elt_next, elt_next->prev, elt_prev, elt_prev->next);
}
}
static inline void
__DEQUEUE_ELT_CLEANUP(queue_entry_t elt)
{
(elt)->next = (queue_entry_t)NULL;
(elt)->prev = (queue_entry_t)NULL;
}
#else
#define __QUEUE_ELT_VALIDATE(elt) do { } while (0)
#define __DEQUEUE_ELT_CLEANUP(elt) do { } while(0)
#endif /* !(XNU_KERNEL_PRIVATE || DRIVERKIT_FRAMEWORK_INCLUDE)*/
static __inline__ void
enqueue_head(
queue_t que,
queue_entry_t elt)
{
queue_entry_t old_head;
__QUEUE_ELT_VALIDATE((queue_entry_t)que);
old_head = que->next;
elt->next = old_head;
elt->prev = que;
old_head->prev = elt;
que->next = elt;
}
static __inline__ void
enqueue_tail(
queue_t que,
queue_entry_t elt)
{
queue_entry_t old_tail;
__QUEUE_ELT_VALIDATE((queue_entry_t)que);
old_tail = que->prev;
elt->next = que;
elt->prev = old_tail;
old_tail->next = elt;
que->prev = elt;
}
static __inline__ queue_entry_t
dequeue_head(
queue_t que)
{
queue_entry_t elt = (queue_entry_t)NULL;
queue_entry_t new_head;
if (que->next != que) {
elt = que->next;
__QUEUE_ELT_VALIDATE(elt);
new_head = elt->next; /* new_head may point to que if elt was the only element */
new_head->prev = que;
que->next = new_head;
__DEQUEUE_ELT_CLEANUP(elt);
}
return elt;
}
static __inline__ queue_entry_t
dequeue_tail(
queue_t que)
{
queue_entry_t elt = (queue_entry_t)NULL;
queue_entry_t new_tail;
if (que->prev != que) {
elt = que->prev;
__QUEUE_ELT_VALIDATE(elt);
new_tail = elt->prev; /* new_tail may point to queue if elt was the only element */
new_tail->next = que;
que->prev = new_tail;
__DEQUEUE_ELT_CLEANUP(elt);
}
return elt;
}
static __inline__ void
remqueue(
queue_entry_t elt)
{
queue_entry_t next_elt, prev_elt;
__QUEUE_ELT_VALIDATE(elt);
next_elt = elt->next;
prev_elt = elt->prev; /* next_elt may equal prev_elt (and the queue head) if elt was the only element */
next_elt->prev = prev_elt;
prev_elt->next = next_elt;
__DEQUEUE_ELT_CLEANUP(elt);
}
static __inline__ void
insque(
queue_entry_t entry,
queue_entry_t pred)
{
queue_entry_t successor;
__QUEUE_ELT_VALIDATE(pred);
successor = pred->next;
entry->next = successor;
entry->prev = pred;
successor->prev = entry;
pred->next = entry;
}
static __inline__ void
remque(
queue_entry_t elt)
{
remqueue(elt);
}
/*
* Function: re_queue_head
* Parameters:
* queue_t que : queue onto which elt will be pre-pended
* queue_entry_t elt : element to re-queue
* Description:
* Remove elt from its current queue and put it onto the
* head of a new queue
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
static __inline__ void
re_queue_head(queue_t que, queue_entry_t elt)
{
queue_entry_t n_elt, p_elt;
__QUEUE_ELT_VALIDATE(elt);
__QUEUE_ELT_VALIDATE((queue_entry_t)que);
/* remqueue */
n_elt = elt->next;
p_elt = elt->prev; /* next_elt may equal prev_elt (and the queue head) if elt was the only element */
n_elt->prev = p_elt;
p_elt->next = n_elt;
/* enqueue_head */
n_elt = que->next;
elt->next = n_elt;
elt->prev = que;
n_elt->prev = elt;
que->next = elt;
}
/*
* Function: re_queue_tail
* Parameters:
* queue_t que : queue onto which elt will be appended
* queue_entry_t elt : element to re-queue
* Description:
* Remove elt from its current queue and put it onto the
* end of a new queue
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
static __inline__ void
re_queue_tail(queue_t que, queue_entry_t elt)
{
queue_entry_t n_elt, p_elt;
__QUEUE_ELT_VALIDATE(elt);
__QUEUE_ELT_VALIDATE((queue_entry_t)que);
/* remqueue */
n_elt = elt->next;
p_elt = elt->prev; /* next_elt may equal prev_elt (and the queue head) if elt was the only element */
n_elt->prev = p_elt;
p_elt->next = n_elt;
/* enqueue_tail */
p_elt = que->prev;
elt->next = que;
elt->prev = p_elt;
p_elt->next = elt;
que->prev = elt;
}
/*
* Macro: qe_element
* Function:
* Convert a queue_entry_t to a queue element pointer.
* Get a pointer to the user-defined element containing
* a given queue_entry_t
* Header:
* <type> * qe_element(queue_entry_t qe, <type>, field)
* qe - queue entry to convert
* <type> - what's in the queue (e.g., struct some_data)
* <field> - is the chain field in <type>
* Note:
* Do not use pointer types for <type>
*/
#define qe_element(qe, type, field) __container_of(qe, type, field)
/*
* Macro: qe_foreach
* Function:
* Iterate over each queue_entry_t structure.
* Generates a 'for' loop, setting 'qe' to
* each queue_entry_t in the queue.
* Header:
* qe_foreach(queue_entry_t qe, queue_t head)
* qe - iteration variable
* head - pointer to queue_head_t (head of queue)
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define qe_foreach(qe, head) \
for (qe = (head)->next; qe != (head); qe = (qe)->next)
/*
* Macro: qe_foreach_safe
* Function:
* Safely iterate over each queue_entry_t structure.
*
* Use this iterator macro if you plan to remove the
* queue_entry_t, qe, from the queue during the
* iteration.
* Header:
* qe_foreach_safe(queue_entry_t qe, queue_t head)
* qe - iteration variable
* head - pointer to queue_head_t (head of queue)
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define qe_foreach_safe(qe, head) \
for (queue_entry_t _ne = ((head)->next)->next, \
__ ## qe ## _unused_shadow __unused = (qe = (head)->next); \
qe != (head); \
qe = _ne, _ne = (qe)->next)
/*
* Macro: qe_foreach_element
* Function:
* Iterate over each _element_ in a queue
* where each queue_entry_t points to another
* queue_entry_t, i.e., managed by the [de|en]queue_head/
* [de|en]queue_tail / remqueue / etc. function.
* Header:
* qe_foreach_element(<type> *elt, queue_t head, <field>)
* elt - iteration variable
* <type> - what's in the queue (e.g., struct some_data)
* <field> - is the chain field in <type>
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define qe_foreach_element(elt, head, field) \
for (elt = qe_element((head)->next, typeof(*(elt)), field); \
&((elt)->field) != (head); \
elt = qe_element((elt)->field.next, typeof(*(elt)), field))
/*
* Macro: qe_foreach_element_safe
* Function:
* Safely iterate over each _element_ in a queue
* where each queue_entry_t points to another
* queue_entry_t, i.e., managed by the [de|en]queue_head/
* [de|en]queue_tail / remqueue / etc. function.
*
* Use this iterator macro if you plan to remove the
* element, elt, from the queue during the iteration.
* Header:
* qe_foreach_element_safe(<type> *elt, queue_t head, <field>)
* elt - iteration variable
* <type> - what's in the queue (e.g., struct some_data)
* <field> - is the chain field in <type>
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define qe_foreach_element_safe(elt, head, field) \
for (typeof(*(elt)) *_nelt = qe_element(((head)->next)->next, typeof(*(elt)), field), \
*__ ## elt ## _unused_shadow __unused = \
(elt = qe_element((head)->next, typeof(*(elt)), field)); \
&((elt)->field) != (head); \
elt = _nelt, _nelt = qe_element((elt)->field.next, typeof(*(elt)), field)) \
/*
* Macro: QUEUE_HEAD_INITIALIZER()
* Function:
* Static queue head initializer
*/
#define QUEUE_HEAD_INITIALIZER(name) \
{ &name, &name }
/*
* Macro: queue_init
* Function:
* Initialize the given queue.
* Header:
* void queue_init(q)
* queue_t q; \* MODIFIED *\
*/
#define queue_init(q) \
MACRO_BEGIN \
(q)->next = (q);\
(q)->prev = (q);\
MACRO_END
/*
* Macro: queue_head_init
* Function:
* Initialize the given queue head
* Header:
* void queue_head_init(q)
* queue_head_t q; \* MODIFIED *\
*/
#define queue_head_init(q) \
queue_init(&(q))
/*
* Macro: queue_chain_init
* Function:
* Initialize the given queue chain element
* Header:
* void queue_chain_init(q)
* queue_chain_t q; \* MODIFIED *\
*/
#define queue_chain_init(q) \
queue_init(&(q))
/*
* Macro: queue_first
* Function:
* Returns the first entry in the queue,
* Header:
* queue_entry_t queue_first(q)
* queue_t q; \* IN *\
*/
#define queue_first(q) ((q)->next)
/*
* Macro: queue_next
* Function:
* Returns the entry after an item in the queue.
* Header:
* queue_entry_t queue_next(qc)
* queue_t qc;
*/
#define queue_next(qc) ((qc)->next)
/*
* Macro: queue_last
* Function:
* Returns the last entry in the queue.
* Header:
* queue_entry_t queue_last(q)
* queue_t q; \* IN *\
*/
#define queue_last(q) ((q)->prev)
/*
* Macro: queue_prev
* Function:
* Returns the entry before an item in the queue.
* Header:
* queue_entry_t queue_prev(qc)
* queue_t qc;
*/
#define queue_prev(qc) ((qc)->prev)
/*
* Macro: queue_end
* Function:
* Tests whether a new entry is really the end of
* the queue.
* Header:
* boolean_t queue_end(q, qe)
* queue_t q;
* queue_entry_t qe;
*/
#define queue_end(q, qe) ((q) == (qe))
/*
* Macro: queue_empty
* Function:
* Tests whether a queue is empty.
* Header:
* boolean_t queue_empty(q)
* queue_t q;
*/
#define queue_empty(q) queue_end((q), queue_first(q))
/*
* Function: movqueue
* Parameters:
* queue_t _old : head of a queue whose items will be moved
* queue_t _new : new queue head onto which items will be moved
* Description:
* Rebase queue items in _old onto _new then re-initialize
* the _old object to an empty queue.
* Equivalent to the queue_new_head Method 2 macro
* Note:
* Similar to the queue_new_head macro, this macros is intented
* to function as an initializer method for '_new' and thus may
* leak any list items that happen to be on the '_new' list.
* This should only be used with Method 1 queue iteration (linkage chains)
*/
static __inline__ void
movqueue(queue_t _old, queue_t _new)
{
queue_entry_t next_elt, prev_elt;
__QUEUE_ELT_VALIDATE((queue_entry_t)_old);
if (queue_empty(_old)) {
queue_init(_new);
return;
}
/*
* move the queue at _old to _new
* and re-initialize _old
*/
next_elt = _old->next;
prev_elt = _old->prev;
_new->next = next_elt;
_new->prev = prev_elt;
next_elt->prev = _new;
prev_elt->next = _new;
queue_init(_old);
}
/*----------------------------------------------------------------*/
/*
* Macros that operate on generic structures. The queue
* chain may be at any location within the structure, and there
* may be more than one chain.
*/
/*
* Macro: queue_enter
* Function:
* Insert a new element at the tail of the queue.
* Header:
* void queue_enter(q, elt, type, field)
* queue_t q;
* <type> elt;
* <type> is what's in our queue
* <field> is the chain field in (*<type>)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*
* We insert a compiler barrier after setting the fields in the element
* to ensure that the element is updated before being added to the queue,
* which is especially important because stackshot, which operates from
* debugger context, iterates several queues that use this macro (the tasks
* lists and threads lists) without locks. Without this barrier, the
* compiler may re-order the instructions for this macro in a way that
* could cause stackshot to trip over an inconsistent queue during
* iteration.
*/
#define queue_enter(head, elt, type, field) \
MACRO_BEGIN \
queue_entry_t __prev; \
\
__prev = (head)->prev; \
(elt)->field.prev = __prev; \
(elt)->field.next = head; \
__compiler_barrier(); \
if ((head) == __prev) { \
(head)->next = (queue_entry_t) (elt); \
} \
else { \
((type)(void *)__prev)->field.next = \
(queue_entry_t)(elt); \
} \
(head)->prev = (queue_entry_t) elt; \
MACRO_END
/*
* Macro: queue_enter_first
* Function:
* Insert a new element at the head of the queue.
* Header:
* void queue_enter_first(q, elt, type, field)
* queue_t q;
* <type> elt;
* <type> is what's in our queue
* <field> is the chain field in (*<type>)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_enter_first(head, elt, type, field) \
MACRO_BEGIN \
queue_entry_t __next; \
\
__next = (head)->next; \
if ((head) == __next) { \
(head)->prev = (queue_entry_t) (elt); \
} \
else { \
((type)(void *)__next)->field.prev = \
(queue_entry_t)(elt); \
} \
(elt)->field.next = __next; \
(elt)->field.prev = head; \
(head)->next = (queue_entry_t) elt; \
MACRO_END
/*
* Macro: queue_insert_before
* Function:
* Insert a new element before a given element.
* Header:
* void queue_insert_before(q, elt, cur, type, field)
* queue_t q;
* <type> elt;
* <type> cur;
* <type> is what's in our queue
* <field> is the chain field in (*<type>)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_insert_before(head, elt, cur, type, field) \
MACRO_BEGIN \
queue_entry_t __prev; \
\
if ((head) == (queue_entry_t)(cur)) { \
(elt)->field.next = (head); \
if ((head)->next == (head)) { /* only element */ \
(elt)->field.prev = (head); \
(head)->next = (queue_entry_t)(elt); \
} else { /* last element */ \
__prev = (elt)->field.prev = (head)->prev; \
((type)(void *)__prev)->field.next = \
(queue_entry_t)(elt); \
} \
(head)->prev = (queue_entry_t)(elt); \
} else { \
(elt)->field.next = (queue_entry_t)(cur); \
if ((head)->next == (queue_entry_t)(cur)) { \
/* first element */ \
(elt)->field.prev = (head); \
(head)->next = (queue_entry_t)(elt); \
} else { /* middle element */ \
__prev = (elt)->field.prev = (cur)->field.prev; \
((type)(void *)__prev)->field.next = \
(queue_entry_t)(elt); \
} \
(cur)->field.prev = (queue_entry_t)(elt); \
} \
MACRO_END
/*
* Macro: queue_insert_after
* Function:
* Insert a new element after a given element.
* Header:
* void queue_insert_after(q, elt, cur, type, field)
* queue_t q;
* <type> elt;
* <type> cur;
* <type> is what's in our queue
* <field> is the chain field in (*<type>)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_insert_after(head, elt, cur, type, field) \
MACRO_BEGIN \
queue_entry_t __next; \
\
if ((head) == (queue_entry_t)(cur)) { \
(elt)->field.prev = (head); \
if ((head)->next == (head)) { /* only element */ \
(elt)->field.next = (head); \
(head)->prev = (queue_entry_t)(elt); \
} else { /* first element */ \
__next = (elt)->field.next = (head)->next; \
((type)(void *)__next)->field.prev = \
(queue_entry_t)(elt); \
} \
(head)->next = (queue_entry_t)(elt); \
} else { \
(elt)->field.prev = (queue_entry_t)(cur); \
if ((head)->prev == (queue_entry_t)(cur)) { \
/* last element */ \
(elt)->field.next = (head); \
(head)->prev = (queue_entry_t)(elt); \
} else { /* middle element */ \
__next = (elt)->field.next = (cur)->field.next; \
((type)(void *)__next)->field.prev = \
(queue_entry_t)(elt); \
} \
(cur)->field.next = (queue_entry_t)(elt); \
} \
MACRO_END
/*
* Macro: queue_field [internal use only]
* Function:
* Find the queue_chain_t (or queue_t) for the
* given element (thing) in the given queue (head)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_field(head, thing, type, field) \
(((head) == (thing)) ? (head) : &((type)(void *)(thing))->field)
/*
* Macro: queue_remove
* Function:
* Remove an arbitrary item from the queue.
* Header:
* void queue_remove(q, qe, type, field)
* arguments as in queue_enter
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_remove(head, elt, type, field) \
MACRO_BEGIN \
queue_entry_t __next, __prev; \
\
__next = (elt)->field.next; \
__prev = (elt)->field.prev; \
\
if ((head) == __next) \
(head)->prev = __prev; \
else \
((type)(void *)__next)->field.prev = __prev; \
\
if ((head) == __prev) \
(head)->next = __next; \
else \
((type)(void *)__prev)->field.next = __next; \
\
(elt)->field.next = NULL; \
(elt)->field.prev = NULL; \
MACRO_END
/*
* Macro: queue_remove_first
* Function:
* Remove and return the entry at the head of
* the queue.
* Header:
* queue_remove_first(head, entry, type, field)
* entry is returned by reference
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_remove_first(head, entry, type, field) \
MACRO_BEGIN \
queue_entry_t __next; \
\
(entry) = (type)(void *) ((head)->next); \
__next = (entry)->field.next; \
\
if ((head) == __next) \
(head)->prev = (head); \
else \
((type)(void *)(__next))->field.prev = (head); \
(head)->next = __next; \
\
(entry)->field.next = NULL; \
(entry)->field.prev = NULL; \
MACRO_END
/*
* Macro: queue_remove_last
* Function:
* Remove and return the entry at the tail of
* the queue.
* Header:
* queue_remove_last(head, entry, type, field)
* entry is returned by reference
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_remove_last(head, entry, type, field) \
MACRO_BEGIN \
queue_entry_t __prev; \
\
(entry) = (type)(void *) ((head)->prev); \
__prev = (entry)->field.prev; \
\
if ((head) == __prev) \
(head)->next = (head); \
else \
((type)(void *)(__prev))->field.next = (head); \
(head)->prev = __prev; \
\
(entry)->field.next = NULL; \
(entry)->field.prev = NULL; \
MACRO_END
/*
* Macro: queue_assign
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_assign(to, from, type, field) \
MACRO_BEGIN \
((type)(void *)((from)->prev))->field.next = (to); \
((type)(void *)((from)->next))->field.prev = (to); \
*to = *from; \
MACRO_END
/*
* Macro: queue_new_head
* Function:
* rebase old queue to new queue head
* Header:
* queue_new_head(old, new, type, field)
* queue_t old;
* queue_t new;
* <type> is what's in our queue
* <field> is the chain field in (*<type>)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_new_head(old, new, type, field) \
MACRO_BEGIN \
if (!queue_empty(old)) { \
*(new) = *(old); \
((type)(void *)((new)->next))->field.prev = \
(new); \
((type)(void *)((new)->prev))->field.next = \
(new); \
} else { \
queue_init(new); \
} \
MACRO_END
/*
* Macro: queue_iterate
* Function:
* iterate over each item in the queue.
* Generates a 'for' loop, setting elt to
* each item in turn (by reference).
* Header:
* queue_iterate(q, elt, type, field)
* queue_t q;
* <type> elt;
* <type> is what's in our queue
* <field> is the chain field in (*<type>)
* Note:
* This should only be used with Method 2 queue iteration (element chains)
*/
#define queue_iterate(head, elt, type, field) \
for ((elt) = (type)(void *) queue_first(head); \
!queue_end((head), (queue_entry_t)(elt)); \
(elt) = (type)(void *) queue_next(&(elt)->field))
__END_DECLS
#endif /* _KERN_QUEUE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/ticket_lock.h | /*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_TICKET_LOCK_H_
#define _KERN_TICKET_LOCK_H_
#ifndef __ASSEMBLER__
#include <kern/lock_types.h>
#include <kern/lock_group.h>
#endif /* __ASSEMBLER__ */
/*
* TODO <rdar://problem/72157773>. We do not need to make
* the header available only to KERNEL_PRIVATE.
*/
#error header not supported
#endif /* _KERN_TICKET_LOCK_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/exc_resource.h | /*
* Copyright (c) 2011-2012 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1989 Carnegie-Mellon University
* Copyright (c) 1988 Carnegie-Mellon University
* Copyright (c) 1987 Carnegie-Mellon University
* All rights reserved. The CMU software License Agreement specifies
* the terms and conditions for use and redistribution.
*/
/*
* EXC_RESOURCE related macros, namespace etc.
*/
#ifndef _EXC_RESOURCE_H_
#define _EXC_RESOURCE_H_
/*
* Generic exception code format:
*
* code:
* +----------------------------------------------------------+
* |[63:61] type | [60:58] flavor | [57:0] type-specific data |
* +----------------------------------------------------------+
*/
/* EXC_RESOURCE type and flavor decoding routines */
#define EXC_RESOURCE_DECODE_RESOURCE_TYPE(code) \
(((code) >> 61) & 0x7ULL)
#define EXC_RESOURCE_DECODE_FLAVOR(code) \
(((code) >> 58) & 0x7ULL)
/* EXC_RESOURCE Types */
#define RESOURCE_TYPE_CPU 1
#define RESOURCE_TYPE_WAKEUPS 2
#define RESOURCE_TYPE_MEMORY 3
#define RESOURCE_TYPE_IO 4
#define RESOURCE_TYPE_THREADS 5
#define RESOURCE_TYPE_PORTS 6
/* RESOURCE_TYPE_CPU flavors */
#define FLAVOR_CPU_MONITOR 1
#define FLAVOR_CPU_MONITOR_FATAL 2
/*
* RESOURCE_TYPE_CPU exception code & subcode.
*
* This is sent by the kernel when the CPU usage monitor
* is tripped. [See proc_set_cpumon_params()]
*
* code:
* +-----------------------------------------------+
* |[63:61] RESOURCE |[60:58] FLAVOR_CPU_ |[57:32] |
* |_TYPE_CPU |MONITOR[_FATAL] |Unused |
* +-----------------------------------------------+
* |[31:7] Interval (sec) | [6:0] CPU limit (%)|
* +-----------------------------------------------+
*
* subcode:
* +-----------------------------------------------+
* | | [6:0] % of CPU |
* | | actually consumed |
* +-----------------------------------------------+
*
*/
/* RESOURCE_TYPE_CPU decoding macros */
#define EXC_RESOURCE_CPUMONITOR_DECODE_INTERVAL(code) \
(((code) >> 7) & 0x1FFFFFFULL)
#define EXC_RESOURCE_CPUMONITOR_DECODE_PERCENTAGE(code) \
((code) & 0x7FULL)
#define EXC_RESOURCE_CPUMONITOR_DECODE_PERCENTAGE_OBSERVED(subcode) \
((subcode) & 0x7FULL)
/* RESOURCE_TYPE_WAKEUPS flavors */
#define FLAVOR_WAKEUPS_MONITOR 1
/*
* RESOURCE_TYPE_WAKEUPS exception code & subcode.
*
* This is sent by the kernel when the platform idle
* wakeups monitor is tripped.
* [See proc_set_wakeupsmon_params()]
*
* code:
* +-----------------------------------------------+
* |[63:61] RESOURCE |[60:58] FLAVOR_ |[57:32] |
* |_TYPE_WAKEUPS |WAKEUPS_MONITOR |Unused |
* +-----------------------------------------------+
* | [31:20] Observation | [19:0] # of wakeups |
* | interval (sec) | permitted (per sec) |
* +-----------------------------------------------+
*
* subcode:
* +-----------------------------------------------+
* | | [19:0] # of wakeups |
* | | observed (per sec) |
* +-----------------------------------------------+
*
*/
#define EXC_RESOURCE_CPUMONITOR_DECODE_WAKEUPS_PERMITTED(code) \
((code) & 0xFFFULL)
#define EXC_RESOURCE_CPUMONITOR_DECODE_OBSERVATION_INTERVAL(code) \
(((code) >> 20) & 0xFFFFFULL)
#define EXC_RESOURCE_CPUMONITOR_DECODE_WAKEUPS_OBSERVED(subcode) \
((subcode) & 0xFFFFFULL)
/* RESOURCE_TYPE_MEMORY flavors */
#define FLAVOR_HIGH_WATERMARK 1
/*
* RESOURCE_TYPE_MEMORY / FLAVOR_HIGH_WATERMARK
* exception code & subcode.
*
* This is sent by the kernel when a task crosses its high
* watermark memory limit.
*
* code:
* +------------------------------------------------+
* |[63:61] RESOURCE |[60:58] FLAVOR_HIGH_ |[57:32] |
* |_TYPE_MEMORY |WATERMARK |Unused |
* +------------------------------------------------+
* | | [12:0] HWM limit (MB)|
* +------------------------------------------------+
*
* subcode:
* +------------------------------------------------+
* | unused |
* +------------------------------------------------+
*
*/
#define EXC_RESOURCE_HWM_DECODE_LIMIT(code) \
((code) & 0x1FFFULL)
/* RESOURCE_TYPE_IO flavors */
#define FLAVOR_IO_PHYSICAL_WRITES 1
#define FLAVOR_IO_LOGICAL_WRITES 2
/*
* RESOURCE_TYPE_IO exception code & subcode.
*
* This is sent by the kernel when a task crosses its
* I/O limits.
*
* code:
* +-----------------------------------------------+
* |[63:61] RESOURCE |[60:58] FLAVOR_IO_ |[57:32] |
* |_TYPE_IO |PHYSICAL/LOGICAL |Unused |
* +-----------------------------------------------+
* |[31:15] Interval (sec) | [14:0] Limit (MB) |
* +-----------------------------------------------+
*
* subcode:
* +-----------------------------------------------+
* | | [14:0] I/O Count |
* | | (in MB) |
* +-----------------------------------------------+
*
*/
/* RESOURCE_TYPE_IO decoding macros */
#define EXC_RESOURCE_IO_DECODE_INTERVAL(code) \
(((code) >> 15) & 0x1FFFFULL)
#define EXC_RESOURCE_IO_DECODE_LIMIT(code) \
((code) & 0x7FFFULL)
#define EXC_RESOURCE_IO_OBSERVED(subcode) \
((subcode) & 0x7FFFULL)
/*
* RESOURCE_TYPE_THREADS exception code & subcode
*
* This is sent by the kernel when a task crosses its
* thread limit.
*/
#define EXC_RESOURCE_THREADS_DECODE_THREADS(code) \
((code) & 0x7FFFULL)
/* RESOURCE_TYPE_THREADS flavors */
#define FLAVOR_THREADS_HIGH_WATERMARK 1
/* RESOURCE_TYPE_PORTS flavors */
#define FLAVOR_PORT_SPACE_FULL 1
/*
* RESOURCE_TYPE_PORTS exception code & subcode.
*
* This is sent by the kernel when the process is
* leaking ipc ports and has filled its port space
*
* code:
* +-----------------------------------------------+
* |[63:61] RESOURCE |[60:58] FLAVOR_ |[57:32] |
* |_TYPE_PORTS |PORT_SPACE_FULL |Unused |
* +-----------------------------------------------+
* | [31:24] Unused | [23:0] # of ports |
* | | allocated |
* +-----------------------------------------------+
*
* subcode:
* +-----------------------------------------------+
* | | Unused |
* | | |
* +-----------------------------------------------+
*
*/
#define EXC_RESOURCE_THREADS_DECODE_PORTS(code) \
((code) & 0xFFFFFFULL)
/* EXC_RESOURCE type and flavor encoding macros */
#define EXC_RESOURCE_ENCODE_TYPE(code, type) \
((code) |= (((uint64_t)(type) & 0x7ULL) << 61))
#define EXC_RESOURCE_ENCODE_FLAVOR(code, flavor) \
((code) |= (((uint64_t)(flavor) & 0x7ULL) << 58))
/* RESOURCE_TYPE_CPU::FLAVOR_CPU_MONITOR specific encoding macros */
#define EXC_RESOURCE_CPUMONITOR_ENCODE_INTERVAL(code, interval) \
((code) |= (((uint64_t)(interval) & 0x1FFFFFFULL) << 7))
#define EXC_RESOURCE_CPUMONITOR_ENCODE_PERCENTAGE(code, percentage) \
((code) |= (((uint64_t)(percentage) & 0x7FULL)))
/* RESOURCE_TYPE_WAKEUPS::FLAVOR_WAKEUPS_MONITOR specific encoding macros */
#define EXC_RESOURCE_CPUMONITOR_ENCODE_WAKEUPS_PERMITTED(code, num) \
((code) |= ((uint64_t)(num) & 0xFFFFFULL))
#define EXC_RESOURCE_CPUMONITOR_ENCODE_OBSERVATION_INTERVAL(code, num) \
((code) |= (((uint64_t)(num) & 0xFFFULL) << 20))
#define EXC_RESOURCE_CPUMONITOR_ENCODE_WAKEUPS_OBSERVED(subcode, num) \
((subcode) |= ((uint64_t)(num) & 0xFFFFFULL))
/* RESOURCE_TYPE_MEMORY::FLAVOR_HIGH_WATERMARK specific encoding macros */
#define EXC_RESOURCE_HWM_ENCODE_LIMIT(code, num) \
((code) |= ((uint64_t)(num) & 0x1FFFULL))
/* RESOURCE_TYPE_IO::FLAVOR_IO_PHYSICAL_WRITES/FLAVOR_IO_LOGICAL_WRITES specific encoding macros */
#define EXC_RESOURCE_IO_ENCODE_INTERVAL(code, interval) \
((code) |= (((uint64_t)(interval) & 0x1FFFFULL) << 15))
#define EXC_RESOURCE_IO_ENCODE_LIMIT(code, limit) \
((code) |= (((uint64_t)(limit) & 0x7FFFULL)))
#define EXC_RESOURCE_IO_ENCODE_OBSERVED(subcode, num) \
((subcode) |= (((uint64_t)(num) & 0x7FFFULL)))
/* RESOURCE_TYPE_THREADS specific encoding macros */
#define EXC_RESOURCE_THREADS_ENCODE_THREADS(code, threads) \
((code) |= (((uint64_t)(threads) & 0x7FFFULL)))
/* RESOURCE_TYPE_PORTS::FLAVOR_PORT_SPACE_FULL specific encoding macros */
#define EXC_RESOURCE_PORTS_ENCODE_PORTS(code, num) \
((code) |= ((uint64_t)(num) & 0xFFFFFFULL))
#endif /* _EXC_RESOURCE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/cambria_layout.h | /*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef KERN_CAMBRIA_LAYOUT_H
#define KERN_CAMBRIA_LAYOUT_H
/*
* xnu's current understanding of Cambria's structure layout. Cambria
* should include static_asserts to check that these values are accurate.
*/
#define KCAMBRIA_THCTX_RSP_OFFSET (96)
#define KCAMBRIA_THCTX_RBP_OFFSET (104)
#define KCAMBRIA_THCTX_LR_OFFSET (344)
#endif /* !defined(KERN_CAMBRIA_LAYOUT_H) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/timer_call.h | /*
* Copyright (c) 1993-1995, 1999-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* The timer_call system is responsible for manipulating timers that call
* callbacks at a given deadline (with or without some leeway for coalescing).
*
* Call timer_call_setup once on a timer_call structure to register the callback
* function and a context parameter that's passed to it (param0).
*
* To arm the timer to fire at a deadline, call any of the timer_call_enter
* functions. If the function used accepts a parameter, it will be passed to
* the callback function when it fires.
*
* If the timer needs to be cancelled (like if the timer_call has been armed but
* now needs to be deallocated), call timer_call_cancel.
*/
#ifndef _KERN_TIMER_CALL_H_
#define _KERN_TIMER_CALL_H_
#include <mach/mach_types.h>
#include <kern/kern_types.h>
#endif /* _KERN_TIMER_CALL_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/coalition.h | /*
* Copyright (c) 2013 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_COALITION_H_
#define _KERN_COALITION_H_
/* only kernel-private interfaces */
#endif /* _KERN_COALITION_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/sched_prim.h | /*
* Copyright (c) 2000-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 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 [email protected]
* 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.
*/
/*
*/
/*
* File: sched_prim.h
* Author: David Golub
*
* Scheduling primitive definitions file
*
*/
#ifndef _KERN_SCHED_PRIM_H_
#define _KERN_SCHED_PRIM_H_
#include <sys/cdefs.h>
#include <mach/boolean.h>
#include <mach/machine/vm_types.h>
#include <mach/kern_return.h>
#include <kern/clock.h>
#include <kern/kern_types.h>
#include <kern/percpu.h>
#include <kern/thread.h>
#include <kern/block_hint.h>
extern int thread_get_current_cpuid(void);
__BEGIN_DECLS
/* Context switch */
extern wait_result_t thread_block(
thread_continue_t continuation);
extern wait_result_t thread_block_parameter(
thread_continue_t continuation,
void *parameter);
/* Declare thread will wait on a particular event */
extern wait_result_t assert_wait(
event_t event,
wait_interrupt_t interruptible);
/* Assert that the thread intends to wait with a timeout */
extern wait_result_t assert_wait_timeout(
event_t event,
wait_interrupt_t interruptible,
uint32_t interval,
uint32_t scale_factor);
/* Assert that the thread intends to wait with an urgency, timeout and leeway */
extern wait_result_t assert_wait_timeout_with_leeway(
event_t event,
wait_interrupt_t interruptible,
wait_timeout_urgency_t urgency,
uint32_t interval,
uint32_t leeway,
uint32_t scale_factor);
extern wait_result_t assert_wait_deadline(
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
/* Assert that the thread intends to wait with an urgency, deadline, and leeway */
extern wait_result_t assert_wait_deadline_with_leeway(
event_t event,
wait_interrupt_t interruptible,
wait_timeout_urgency_t urgency,
uint64_t deadline,
uint64_t leeway);
/* Wake up thread (or threads) waiting on a particular event */
extern kern_return_t thread_wakeup_prim(
event_t event,
boolean_t one_thread,
wait_result_t result);
#define thread_wakeup(x) \
thread_wakeup_prim((x), FALSE, THREAD_AWAKENED)
#define thread_wakeup_with_result(x, z) \
thread_wakeup_prim((x), FALSE, (z))
#define thread_wakeup_one(x) \
thread_wakeup_prim((x), TRUE, THREAD_AWAKENED)
/* Wakeup the specified thread if it is waiting on this event */
extern kern_return_t thread_wakeup_thread(event_t event, thread_t thread);
extern boolean_t preemption_enabled(void);
__END_DECLS
#endif /* _KERN_SCHED_PRIM_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/ipc_mig.h | /*
* Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _KERN_IPC_MIG_H_
#define _KERN_IPC_MIG_H_
#include <mach/mig.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <kern/kern_types.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Send a message from the kernel */
extern mach_msg_return_t mach_msg_send_from_kernel_proper(
mach_msg_header_t *msg,
mach_msg_size_t send_size);
#define mach_msg_send_from_kernel mach_msg_send_from_kernel_proper
extern mach_msg_return_t mach_msg_rpc_from_kernel_proper(
mach_msg_header_t *msg,
mach_msg_size_t send_size,
mach_msg_size_t rcv_size);
#define mach_msg_rpc_from_kernel mach_msg_rpc_from_kernel_proper
extern void mach_msg_destroy_from_kernel_proper(
mach_msg_header_t *msg);
#define mach_msg_destroy_from_kernel mach_msg_destroy_from_kernel_proper
__END_DECLS
#endif /* _KERN_IPC_MIG_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/turnstile.h | /*
* Copyright (c) 2017 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _TURNSTILE_H_
#define _TURNSTILE_H_
#include <mach/mach_types.h>
#include <mach/kern_return.h>
#include <sys/cdefs.h>
#endif /* _TURNSTILE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/btlog.h | /*
* Copyright (c) 2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_BTLOG_H_
#define _KERN_BTLOG_H_
#include <kern/kern_types.h>
#include <kern/debug.h>
#include <sys/cdefs.h>
#include <stdint.h>
#include <mach_debug/zone_info.h>
#endif /* _KERN_BTLOG_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/exc_guard.h | /*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1989 Carnegie-Mellon University
* Copyright (c) 1988 Carnegie-Mellon University
* Copyright (c) 1987 Carnegie-Mellon University
* All rights reserved. The CMU software License Agreement specifies
* the terms and conditions for use and redistribution.
*/
/*
* EXC_GUARD related macros, namespace etc.
*/
#ifndef _EXC_GUARD_H_
#define _EXC_GUARD_H_
/*
* EXC_GUARD exception code namespace.
*
* code:
* +-------------------+----------------+--------------+
* |[63:61] guard type | [60:32] flavor | [31:0] target|
* +-------------------+----------------+--------------+
*
* subcode:
* +---------------------------------------------------+
* |[63:0] guard identifier |
* +---------------------------------------------------+
*/
#define EXC_GUARD_DECODE_GUARD_TYPE(code) \
((((uint64_t)(code)) >> 61) & 0x7ull)
#define EXC_GUARD_DECODE_GUARD_FLAVOR(code) \
((((uint64_t)(code)) >> 32) & 0x1fffffff)
#define EXC_GUARD_DECODE_GUARD_TARGET(code) \
((uint32_t)(code))
/* EXC_GUARD types */
#define GUARD_TYPE_NONE 0x0
/*
* Mach port guards use the exception codes like this:
*
* code:
* +-----------------------------+----------------+-----------------+
* |[63:61] GUARD_TYPE_MACH_PORT | [60:32] flavor | [31:0] port name|
* +-----------------------------+----------------+-----------------+
*
* subcode:
* +----------------------------------------------------------------+
* |[63:0] guard identifier |
* +----------------------------------------------------------------+
*/
#define GUARD_TYPE_MACH_PORT 0x1 /* guarded mach port */
/*
* File descriptor guards use the exception codes this:
*
* code:
* +-----------------------------+----------------+-----------------+
* |[63:61] GUARD_TYPE_FD | [60:32] flavor | [31:0] fd |
* +-----------------------------+----------------+-----------------+
*
* subcode:
* +----------------------------------------------------------------+
* |[63:0] guard identifier |
* +----------------------------------------------------------------+
*/
#define GUARD_TYPE_FD 0x2 /* guarded file descriptor */
/*
* User generated guards use the exception codes this:
*
* code:
* +-----------------------------+----------------+-----------------+
* |[63:61] GUARD_TYPE_USER | [60:32] unused | [31:0] namespc |
* +-----------------------------+----------------+-----------------+
*
* subcode:
* +----------------------------------------------------------------+
* |[63:0] reason_code |
* +----------------------------------------------------------------+
*/
#define GUARD_TYPE_USER 0x3 /* Userland assertions */
/*
* Vnode guards use the exception codes like this:
*
* code:
* +-----------------------------+----------------+-----------------+
* |[63:61] GUARD_TYPE_VN | [60:32] flavor | [31:0] pid |
* +-----------------------------+----------------+-----------------+
*
* subcode:
* +----------------------------------------------------------------+
* |[63:0] guard identifier |
* +----------------------------------------------------------------+
*/
#define GUARD_TYPE_VN 0x4 /* guarded vnode */
/*
* VM guards use the exception codes like this:
*
* code:
* +-------------------------------+----------------+-----------------+
* |[63:61] GUARD_TYPE_VIRT_MEMORY | [60:32] flavor | [31:0] unused |
* +-------------------------------+----------------+-----------------+
*
* subcode:
* +----------------------------------------------------------------+
* |[63:0] offset |
* +----------------------------------------------------------------+
*/
#define GUARD_TYPE_VIRT_MEMORY 0x5 /* VM operation violating guard */
/*
* Rejected syscalls use the exception codes like this:
*
* code:
* +-------------------------------+----------------+------------------+
* |[63:61] GUARD_TYPE_REJECTED_SC | [60:32] unused | [31:0] mach_trap |
* +-------------------------------+----------------+------------------+
*
* subcode:
* +----------------------------------------------------------------+
* |[63:0] syscall (if mach_trap field is 0), or mach trap number |
* +----------------------------------------------------------------+
*/
#define GUARD_TYPE_REJECTED_SC 0x6 /* rejected system call trap */
#define EXC_GUARD_ENCODE_TYPE(code, type) \
((code) |= (((uint64_t)(type) & 0x7ull) << 61))
#define EXC_GUARD_ENCODE_FLAVOR(code, flavor) \
((code) |= (((uint64_t)(flavor) & 0x1fffffffull) << 32))
#define EXC_GUARD_ENCODE_TARGET(code, target) \
((code) |= (((uint64_t)(target) & 0xffffffffull)))
#endif /* _EXC_GUARD_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/ledger.h | /*
* Copyright (c) 2010-2018 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _KERN_LEDGER_H_
#define _KERN_LEDGER_H_
#include <mach/mach_types.h> /* ledger_t */
#define LEDGER_INFO 0
#define LEDGER_ENTRY_INFO 1
#define LEDGER_TEMPLATE_INFO 2
#define LEDGER_LIMIT 3
/* LEDGER_MAX_CMD always tracks the index of the last ledger command. */
#define LEDGER_MAX_CMD LEDGER_LIMIT
#define LEDGER_NAME_MAX 32
struct ledger_info {
char li_name[LEDGER_NAME_MAX];
int64_t li_id;
int64_t li_entries;
};
struct ledger_template_info {
char lti_name[LEDGER_NAME_MAX];
char lti_group[LEDGER_NAME_MAX];
char lti_units[LEDGER_NAME_MAX];
};
struct ledger_entry_info {
int64_t lei_balance;
int64_t lei_credit;
int64_t lei_debit;
uint64_t lei_limit;
uint64_t lei_refill_period; /* In nanoseconds */
uint64_t lei_last_refill; /* Time since last refill */
};
struct ledger_limit_args {
char lla_name[LEDGER_NAME_MAX];
uint64_t lla_limit;
uint64_t lla_refill_period;
};
#endif /* _KERN_LEDGER_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/thread.h | /*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_FREE_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 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 [email protected]
* 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.
*/
/*
*/
/*
* File: thread.h
* Author: Avadis Tevanian, Jr.
*
* This file contains the structure definitions for threads.
*
*/
/*
* Copyright (c) 1993 The University of Utah and
* the Computer Systems Laboratory (CSL). 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.
*
* THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
* IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
* ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* CSL requests users of this software to return to [email protected] any
* improvements that they make and grant CSL redistribution rights.
*
*/
#ifndef _KERN_THREAD_H_
#define _KERN_THREAD_H_
#include <mach/kern_return.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/boolean.h>
#include <mach/vm_param.h>
#include <mach/thread_info.h>
#include <mach/thread_status.h>
#include <mach/exception_types.h>
#include <kern/kern_types.h>
#include <vm/vm_kern.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
extern void thread_mtx_lock(thread_t thread);
extern void thread_mtx_unlock(thread_t thread);
extern thread_t current_thread(void) __attribute__((const));
extern void thread_reference(
thread_t thread);
extern void thread_deallocate(
thread_t thread);
__END_DECLS
__BEGIN_DECLS
extern uint64_t thread_tid(thread_t thread);
__END_DECLS
__BEGIN_DECLS
/*! @function thread_has_thread_name
* @abstract Checks if a thread has a name.
* @discussion This function takes one input, a thread, and returns a boolean value indicating if that thread already has a name associated with it.
* @param th The thread to inspect.
* @result TRUE if the thread has a name, FALSE otherwise.
*/
extern boolean_t thread_has_thread_name(thread_t th);
/*! @function thread_set_thread_name
* @abstract Set a thread's name.
* @discussion This function takes two input parameters: a thread to name, and the name to apply to the thread. The name will be copied over to the thread in order to better identify the thread. If the name is longer than MAXTHREADNAMESIZE - 1, it will be truncated.
* @param th The thread to be named.
* @param name The name to apply to the thread.
*/
extern void thread_set_thread_name(thread_t th, const char* name);
/*! @function kernel_thread_start
* @abstract Create a kernel thread.
* @discussion This function takes three input parameters, namely reference to the function that the thread should execute, caller specified data and a reference which is used to return the newly created kernel thread. The function returns KERN_SUCCESS on success or an appropriate kernel code type indicating the error. It may be noted that the caller is responsible for explicitly releasing the reference to the created thread when no longer needed. This should be done by calling thread_deallocate(new_thread).
* @param continuation A C-function pointer where the thread will begin execution.
* @param parameter Caller specified data to be passed to the new thread.
* @param new_thread Reference to the new thread is returned in this parameter.
* @result Returns KERN_SUCCESS on success or an appropriate kernel code type.
*/
extern kern_return_t kernel_thread_start(
thread_continue_t continuation,
void *parameter,
thread_t *new_thread);
__END_DECLS
#endif /* _KERN_THREAD_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/extmod_statistics.h | /*
* Copyright (c) 2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* kern/extmod_statistics.h
*
* Definitions for statistics related to external
* modification of a task by another agent on the system.
*
*/
#ifndef _KERN_EXTMOD_STATISTICS_H_
#define _KERN_EXTMOD_STATISTICS_H_
#include <kern/task.h>
#include <mach/vm_types.h>
extern void extmod_statistics_incr_task_for_pid(task_t target);
extern void extmod_statistics_incr_thread_set_state(thread_t target);
extern void extmod_statistics_incr_thread_create(task_t target);
#endif /* _KERN_EXTMOD_STATISTICS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/cs_blobs.h | /*
* Copyright (c) 2017 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_CODESIGN_H_
#define _KERN_CODESIGN_H_
#include <stdint.h>
/* code signing attributes of a process */
#define CS_VALID 0x00000001 /* dynamically valid */
#define CS_ADHOC 0x00000002 /* ad hoc signed */
#define CS_GET_TASK_ALLOW 0x00000004 /* has get-task-allow entitlement */
#define CS_INSTALLER 0x00000008 /* has installer entitlement */
#define CS_FORCED_LV 0x00000010 /* Library Validation required by Hardened System Policy */
#define CS_INVALID_ALLOWED 0x00000020 /* (macOS Only) Page invalidation allowed by task port policy */
#define CS_HARD 0x00000100 /* don't load invalid pages */
#define CS_KILL 0x00000200 /* kill process if it becomes invalid */
#define CS_CHECK_EXPIRATION 0x00000400 /* force expiration checking */
#define CS_RESTRICT 0x00000800 /* tell dyld to treat restricted */
#define CS_ENFORCEMENT 0x00001000 /* require enforcement */
#define CS_REQUIRE_LV 0x00002000 /* require library validation */
#define CS_ENTITLEMENTS_VALIDATED 0x00004000 /* code signature permits restricted entitlements */
#define CS_NVRAM_UNRESTRICTED 0x00008000 /* has com.apple.rootless.restricted-nvram-variables.heritable entitlement */
#define CS_RUNTIME 0x00010000 /* Apply hardened runtime policies */
#define CS_LINKER_SIGNED 0x00020000 /* Automatically signed by the linker */
#define CS_ALLOWED_MACHO (CS_ADHOC | CS_HARD | CS_KILL | CS_CHECK_EXPIRATION | \
CS_RESTRICT | CS_ENFORCEMENT | CS_REQUIRE_LV | CS_RUNTIME | CS_LINKER_SIGNED)
#define CS_EXEC_SET_HARD 0x00100000 /* set CS_HARD on any exec'ed process */
#define CS_EXEC_SET_KILL 0x00200000 /* set CS_KILL on any exec'ed process */
#define CS_EXEC_SET_ENFORCEMENT 0x00400000 /* set CS_ENFORCEMENT on any exec'ed process */
#define CS_EXEC_INHERIT_SIP 0x00800000 /* set CS_INSTALLER on any exec'ed process */
#define CS_KILLED 0x01000000 /* was killed by kernel for invalidity */
#define CS_NO_UNTRUSTED_HELPERS 0x02000000 /* kernel did not load a non-platform-binary dyld or Rosetta runtime */
#define CS_DYLD_PLATFORM CS_NO_UNTRUSTED_HELPERS /* old name */
#define CS_PLATFORM_BINARY 0x04000000 /* this is a platform binary */
#define CS_PLATFORM_PATH 0x08000000 /* platform binary by the fact of path (osx only) */
#define CS_DEBUGGED 0x10000000 /* process is currently or has previously been debugged and allowed to run with invalid pages */
#define CS_SIGNED 0x20000000 /* process has a signature (may have gone invalid) */
#define CS_DEV_CODE 0x40000000 /* code is dev signed, cannot be loaded into prod signed code (will go away with rdar://problem/28322552) */
#define CS_DATAVAULT_CONTROLLER 0x80000000 /* has Data Vault controller entitlement */
#define CS_ENTITLEMENT_FLAGS (CS_GET_TASK_ALLOW | CS_INSTALLER | CS_DATAVAULT_CONTROLLER | CS_NVRAM_UNRESTRICTED)
/* executable segment flags */
#define CS_EXECSEG_MAIN_BINARY 0x1 /* executable segment denotes main binary */
#define CS_EXECSEG_ALLOW_UNSIGNED 0x10 /* allow unsigned pages (for debugging) */
#define CS_EXECSEG_DEBUGGER 0x20 /* main binary is debugger */
#define CS_EXECSEG_JIT 0x40 /* JIT enabled */
#define CS_EXECSEG_SKIP_LV 0x80 /* OBSOLETE: skip library validation */
#define CS_EXECSEG_CAN_LOAD_CDHASH 0x100 /* can bless cdhash for execution */
#define CS_EXECSEG_CAN_EXEC_CDHASH 0x200 /* can execute blessed cdhash */
/*
* Magic numbers used by Code Signing
*/
enum {
CSMAGIC_REQUIREMENT = 0xfade0c00, /* single Requirement blob */
CSMAGIC_REQUIREMENTS = 0xfade0c01, /* Requirements vector (internal requirements) */
CSMAGIC_CODEDIRECTORY = 0xfade0c02, /* CodeDirectory blob */
CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0, /* embedded form of signature data */
CSMAGIC_EMBEDDED_SIGNATURE_OLD = 0xfade0b02, /* XXX */
CSMAGIC_EMBEDDED_ENTITLEMENTS = 0xfade7171, /* embedded entitlements */
CSMAGIC_EMBEDDED_DER_ENTITLEMENTS = 0xfade7172, /* embedded DER encoded entitlements */
CSMAGIC_DETACHED_SIGNATURE = 0xfade0cc1, /* multi-arch collection of embedded signatures */
CSMAGIC_BLOBWRAPPER = 0xfade0b01, /* CMS Signature, among other things */
CS_SUPPORTSSCATTER = 0x20100,
CS_SUPPORTSTEAMID = 0x20200,
CS_SUPPORTSCODELIMIT64 = 0x20300,
CS_SUPPORTSEXECSEG = 0x20400,
CS_SUPPORTSRUNTIME = 0x20500,
CS_SUPPORTSLINKAGE = 0x20600,
CSSLOT_CODEDIRECTORY = 0, /* slot index for CodeDirectory */
CSSLOT_INFOSLOT = 1,
CSSLOT_REQUIREMENTS = 2,
CSSLOT_RESOURCEDIR = 3,
CSSLOT_APPLICATION = 4,
CSSLOT_ENTITLEMENTS = 5,
CSSLOT_DER_ENTITLEMENTS = 7,
CSSLOT_ALTERNATE_CODEDIRECTORIES = 0x1000, /* first alternate CodeDirectory, if any */
CSSLOT_ALTERNATE_CODEDIRECTORY_MAX = 5, /* max number of alternate CD slots */
CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT = CSSLOT_ALTERNATE_CODEDIRECTORIES + CSSLOT_ALTERNATE_CODEDIRECTORY_MAX, /* one past the last */
CSSLOT_SIGNATURESLOT = 0x10000, /* CMS Signature */
CSSLOT_IDENTIFICATIONSLOT = 0x10001,
CSSLOT_TICKETSLOT = 0x10002,
CSTYPE_INDEX_REQUIREMENTS = 0x00000002, /* compat with amfi */
CSTYPE_INDEX_ENTITLEMENTS = 0x00000005, /* compat with amfi */
CS_HASHTYPE_SHA1 = 1,
CS_HASHTYPE_SHA256 = 2,
CS_HASHTYPE_SHA256_TRUNCATED = 3,
CS_HASHTYPE_SHA384 = 4,
CS_SHA1_LEN = 20,
CS_SHA256_LEN = 32,
CS_SHA256_TRUNCATED_LEN = 20,
CS_CDHASH_LEN = 20, /* always - larger hashes are truncated */
CS_HASH_MAX_SIZE = 48, /* max size of the hash we'll support */
/*
* Currently only to support Legacy VPN plugins, and Mac App Store
* but intended to replace all the various platform code, dev code etc. bits.
*/
CS_SIGNER_TYPE_UNKNOWN = 0,
CS_SIGNER_TYPE_LEGACYVPN = 5,
CS_SIGNER_TYPE_MAC_APP_STORE = 6,
CS_SUPPL_SIGNER_TYPE_UNKNOWN = 0,
CS_SUPPL_SIGNER_TYPE_TRUSTCACHE = 7,
CS_SUPPL_SIGNER_TYPE_LOCAL = 8,
};
#define KERNEL_HAVE_CS_CODEDIRECTORY 1
#define KERNEL_CS_CODEDIRECTORY_HAVE_PLATFORM 1
/*
* C form of a CodeDirectory.
*/
typedef struct __CodeDirectory {
uint32_t magic; /* magic number (CSMAGIC_CODEDIRECTORY) */
uint32_t length; /* total length of CodeDirectory blob */
uint32_t version; /* compatibility version */
uint32_t flags; /* setup and mode flags */
uint32_t hashOffset; /* offset of hash slot element at index zero */
uint32_t identOffset; /* offset of identifier string */
uint32_t nSpecialSlots; /* number of special hash slots */
uint32_t nCodeSlots; /* number of ordinary (code) hash slots */
uint32_t codeLimit; /* limit to main image signature range */
uint8_t hashSize; /* size of each hash in bytes */
uint8_t hashType; /* type of hash (cdHashType* constants) */
uint8_t platform; /* platform identifier; zero if not platform binary */
uint8_t pageSize; /* log2(page size in bytes); 0 => infinite */
uint32_t spare2; /* unused (must be zero) */
char end_earliest[0];
/* Version 0x20100 */
uint32_t scatterOffset; /* offset of optional scatter vector */
char end_withScatter[0];
/* Version 0x20200 */
uint32_t teamOffset; /* offset of optional team identifier */
char end_withTeam[0];
/* Version 0x20300 */
uint32_t spare3; /* unused (must be zero) */
uint64_t codeLimit64; /* limit to main image signature range, 64 bits */
char end_withCodeLimit64[0];
/* Version 0x20400 */
uint64_t execSegBase; /* offset of executable segment */
uint64_t execSegLimit; /* limit of executable segment */
uint64_t execSegFlags; /* executable segment flags */
char end_withExecSeg[0];
/* Version 0x20500 */
uint32_t runtime;
uint32_t preEncryptOffset;
char end_withPreEncryptOffset[0];
/* Version 0x20600 */
uint8_t linkageHashType;
uint8_t linkageTruncated;
uint16_t spare4;
uint32_t linkageOffset;
uint32_t linkageSize;
char end_withLinkage[0];
/* followed by dynamic content as located by offset fields above */
} CS_CodeDirectory
__attribute__ ((aligned(1)));
/*
* Structure of an embedded-signature SuperBlob
*/
typedef struct __BlobIndex {
uint32_t type; /* type of entry */
uint32_t offset; /* offset of entry */
} CS_BlobIndex
__attribute__ ((aligned(1)));
typedef struct __SC_SuperBlob {
uint32_t magic; /* magic number */
uint32_t length; /* total length of SuperBlob */
uint32_t count; /* number of index entries following */
CS_BlobIndex index[]; /* (count) entries */
/* followed by Blobs in no particular order as indicated by offsets in index */
} CS_SuperBlob
__attribute__ ((aligned(1)));
#define KERNEL_HAVE_CS_GENERICBLOB 1
typedef struct __SC_GenericBlob {
uint32_t magic; /* magic number */
uint32_t length; /* total length of blob */
char data[];
} CS_GenericBlob
__attribute__ ((aligned(1)));
typedef struct __SC_Scatter {
uint32_t count; // number of pages; zero for sentinel (only)
uint32_t base; // first page number
uint64_t targetOffset; // offset in target
uint64_t spare; // reserved
} SC_Scatter
__attribute__ ((aligned(1)));
#endif /* _KERN_CODESIGN_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/lock_types.h | /*
* Copyright (c) 2021 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_LOCK_TYPES_H
#define _KERN_LOCK_TYPES_H
#include <kern/kern_types.h>
__BEGIN_DECLS
/*!
* @enum lck_sleep_action_t
*
* @abstract
* An action to pass to the @c lck_*_sleep* family of functions.
*/
__options_decl(lck_sleep_action_t, unsigned int, {
LCK_SLEEP_DEFAULT = 0x00, /**< Release the lock while waiting for the event, then reclaim */
LCK_SLEEP_UNLOCK = 0x01, /**< Release the lock and return unheld */
LCK_SLEEP_SHARED = 0x02, /**< Reclaim the lock in shared mode (RW only) */
LCK_SLEEP_EXCLUSIVE = 0x04, /**< Reclaim the lock in exclusive mode (RW only) */
LCK_SLEEP_SPIN = 0x08, /**< Reclaim the lock in spin mode (mutex only) */
LCK_SLEEP_PROMOTED_PRI = 0x10, /**< Sleep at a promoted priority */
LCK_SLEEP_SPIN_ALWAYS = 0x20, /**< Reclaim the lock in spin-always mode (mutex only) */
});
#define LCK_SLEEP_MASK 0x3f /* Valid actions */
__options_decl(lck_wake_action_t, unsigned int, {
LCK_WAKE_DEFAULT = 0x00, /* If waiters are present, transfer their push to the wokenup thread */
LCK_WAKE_DO_NOT_TRANSFER_PUSH = 0x01, /* Do not transfer waiters push when waking up */
});
__END_DECLS
#endif /* _KERN_LOCK_TYPES_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/block_hint.h | /*
* Copyright (c) 2000-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_BLOCK_HINT_H_
#define _KERN_BLOCK_HINT_H_
typedef enum thread_snapshot_wait_flags {
kThreadWaitNone = 0x00,
kThreadWaitKernelMutex = 0x01,
kThreadWaitPortReceive = 0x02,
kThreadWaitPortSetReceive = 0x03,
kThreadWaitPortSend = 0x04,
kThreadWaitPortSendInTransit = 0x05,
kThreadWaitSemaphore = 0x06,
kThreadWaitKernelRWLockRead = 0x07,
kThreadWaitKernelRWLockWrite = 0x08,
kThreadWaitKernelRWLockUpgrade = 0x09,
kThreadWaitUserLock = 0x0a,
kThreadWaitPThreadMutex = 0x0b,
kThreadWaitPThreadRWLockRead = 0x0c,
kThreadWaitPThreadRWLockWrite = 0x0d,
kThreadWaitPThreadCondVar = 0x0e,
kThreadWaitParkedWorkQueue = 0x0f,
kThreadWaitWorkloopSyncWait = 0x10,
kThreadWaitOnProcess = 0x11,
kThreadWaitSleepWithInheritor = 0x12,
kThreadWaitEventlink = 0x13,
kThreadWaitCompressor = 0x14,
} __attribute__((packed)) block_hint_t;
_Static_assert(sizeof(block_hint_t) <= sizeof(short),
"block_hint_t must fit within a short");
#endif /* !_KERN_BLOCK_HINT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/mpqueue.h | #ifndef _KERN_MPQUEUE_H
#define _KERN_MPQUEUE_H
#include <kern/locks.h>
__BEGIN_DECLS
__END_DECLS
#endif /* _KERN_QUEUE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/trustcache.h | /*
* Copyright (c) 2018 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_TRUSTCACHE_H_
#define _KERN_TRUSTCACHE_H_
#include <stdint.h>
#include <kern/cs_blobs.h>
#include <uuid/uuid.h>
/* Version 1 trust caches: Always sorted by cdhash, added hash type and flags field.
* Suitable for all trust caches. */
struct trust_cache_entry1 {
uint8_t cdhash[CS_CDHASH_LEN];
uint8_t hash_type;
uint8_t flags;
} __attribute__((__packed__));
struct trust_cache_module1 {
uint32_t version;
uuid_t uuid;
uint32_t num_entries;
struct trust_cache_entry1 entries[];
} __attribute__((__packed__));
// Trust Cache Entry Flags
#define CS_TRUST_CACHE_AMFID 0x1 // valid cdhash for amfid
/* Trust Cache lookup functions return their result as a 32bit value
* comprised of subfields, for straightforward passing through layers.
*
* Format:
*
* 0xXXCCBBAA
*
* AA: 0-7: lookup result
* bit 0: TC_LOOKUP_FOUND: set if any entry found
* bit 1: (obsolete) TC_LOOKUP_FALLBACK: set if found in legacy static trust cache
* bit 2-7: reserved
* BB: 8-15: entry flags pass-through, see "Trust Cache Entry Flags" above
* CC: 16-23: code directory hash type of entry, see CS_HASHTYPE_* in cs_blobs.h
* XX: 24-31: reserved
*/
#define TC_LOOKUP_HASH_TYPE_SHIFT 16
#define TC_LOOKUP_HASH_TYPE_MASK 0xff0000L;
#define TC_LOOKUP_FLAGS_SHIFT 8
#define TC_LOOKUP_FLAGS_MASK 0xff00L
#define TC_LOOKUP_RESULT_SHIFT 0
#define TC_LOOKUP_RESULT_MASK 0xffL
#define TC_LOOKUP_FOUND 1
#endif /* _KERN_TRUSTCACHE_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/arithmetic_128.h | /*
* Copyright (c) 1999, 2003, 2006, 2007, 2010 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Code duplicated from Libc/gen/nanosleep.c
*/
#ifndef _ARITHMETIC_128_H_
#define _ARITHMETIC_128_H_
#include <stdint.h>
#if __LP64__
static __inline uint64_t
multi_overflow(uint64_t a, uint64_t b)
{
__uint128_t prod;
prod = (__uint128_t)a * (__uint128_t)b;
return (uint64_t) (prod >> 64);
}
#else
typedef struct {
uint64_t high;
uint64_t low;
} uint128_data_t;
/* 128-bit addition: acc += add */
static __inline void
add128_128(uint128_data_t *acc, uint128_data_t *add)
{
acc->high += add->high;
acc->low += add->low;
if (acc->low < add->low) {
acc->high++; // carry
}
}
/* 64x64 -> 128 bit multiplication */
static __inline void
mul64x64(uint64_t x, uint64_t y, uint128_data_t *prod)
{
uint128_data_t add;
/*
* Split the two 64-bit multiplicands into 32-bit parts:
* x => 2^32 * x1 + x2
* y => 2^32 * y1 + y2
*/
uint32_t x1 = (uint32_t)(x >> 32);
uint32_t x2 = (uint32_t)x;
uint32_t y1 = (uint32_t)(y >> 32);
uint32_t y2 = (uint32_t)y;
/*
* direct multiplication:
* x * y => 2^64 * (x1 * y1) + 2^32 (x1 * y2 + x2 * y1) + (x2 * y2)
* The first and last terms are direct assignmenet into the uint128_t
* structure. Then we add the middle two terms separately, to avoid
* 64-bit overflow. (We could use the Karatsuba algorithm to save
* one multiply, but it is harder to deal with 64-bit overflows.)
*/
prod->high = (uint64_t)x1 * (uint64_t)y1;
prod->low = (uint64_t)x2 * (uint64_t)y2;
add.low = (uint64_t)x1 * (uint64_t)y2;
add.high = (add.low >> 32);
add.low <<= 32;
add128_128(prod, &add);
add.low = (uint64_t)x2 * (uint64_t)y1;
add.high = (add.low >> 32);
add.low <<= 32;
add128_128(prod, &add);
}
static __inline uint64_t
multi_overflow(uint64_t a, uint64_t b)
{
uint128_data_t prod;
mul64x64(a, b, &prod);
return prod.high;
}
#endif /* __LP64__ */
#endif /* _ARITHMETIC_128_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/kpc.h | /*
* Copyright (c) 2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef KERN_KPC_H
#define KERN_KPC_H
/* Kernel interfaces to KPC PMC infrastructure. */
#include <machine/machine_kpc.h>
#include <kern/thread.h> /* thread_* */
__BEGIN_DECLS
/* cross-platform class constants */
#define KPC_CLASS_FIXED (0)
#define KPC_CLASS_CONFIGURABLE (1)
#define KPC_CLASS_POWER (2)
#define KPC_CLASS_RAWPMU (3)
#define KPC_CLASS_FIXED_MASK (1u << KPC_CLASS_FIXED)
#define KPC_CLASS_CONFIGURABLE_MASK (1u << KPC_CLASS_CONFIGURABLE)
#define KPC_CLASS_POWER_MASK (1u << KPC_CLASS_POWER)
#define KPC_CLASS_RAWPMU_MASK (1u << KPC_CLASS_RAWPMU)
#define KPC_PMU_ERROR (0)
#define KPC_PMU_INTEL_V3 (1)
#define KPC_PMU_ARM_APPLE (2)
#define KPC_PMU_INTEL_V2 (3)
#define KPC_PMU_ARM_V2 (4)
#define KPC_ALL_CPUS (1u << 31)
/* action id setters/getters */
#define FIXED_ACTIONID(ctr) (kpc_actionid[(ctr)])
#define CONFIGURABLE_ACTIONID(ctr) (kpc_actionid[(ctr) + kpc_fixed_count()])
/* reload counter setters/getters */
#define FIXED_RELOAD(ctr) (current_cpu_datap()->cpu_kpc_reload[(ctr)])
#define FIXED_RELOAD_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_reload[(ctr)])
#define CONFIGURABLE_RELOAD(ctr) (current_cpu_datap()->cpu_kpc_reload[(ctr) + kpc_fixed_count()])
#define CONFIGURABLE_RELOAD_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_reload[(ctr) + kpc_fixed_count()])
/* shadow counter setters/getters */
#define FIXED_SHADOW(ctr) (current_cpu_datap()->cpu_kpc_shadow[(ctr)])
#define FIXED_SHADOW_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_shadow[(ctr)])
#define CONFIGURABLE_SHADOW(ctr) (current_cpu_datap()->cpu_kpc_shadow[(ctr) + kpc_fixed_count()])
#define CONFIGURABLE_SHADOW_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_shadow[(ctr) + kpc_fixed_count()])
/**
* Callback for notification when PMCs are acquired/released by a task. The
* argument is equal to TRUE if the Power Manager (PM) can use its reserved PMCs.
* Otherwise, the argument is equal to FALSE.
*/
typedef void (*kpc_pm_handler_t)(boolean_t);
struct cpu_data;
extern boolean_t kpc_register_cpu(struct cpu_data *cpu_data);
extern void kpc_unregister_cpu(struct cpu_data *cpu_data);
extern bool kpc_supported;
/* bootstrap */
extern void kpc_init(void);
/* Architecture specific initialisation */
extern void kpc_arch_init(void);
/* Get the bitmask of available classes */
extern uint32_t kpc_get_classes(void);
/* Get the bitmask of currently running counter classes */
extern uint32_t kpc_get_running(void);
/* Get the version of KPC that's being run */
extern int kpc_get_pmu_version(void);
/* Set the bitmask of currently running counter classes. Specify
* classes = 0 to stop counters
*/
extern int kpc_set_running(uint32_t classes);
/* Read CPU counters */
extern int kpc_get_cpu_counters(boolean_t all_cpus, uint32_t classes,
int *curcpu, uint64_t *buf);
/* Read shadow counters */
extern int kpc_get_shadow_counters( boolean_t all_cpus, uint32_t classes,
int *curcpu, uint64_t *buf );
/* Read current thread's counter accumulations */
extern int kpc_get_curthread_counters(uint32_t *inoutcount, uint64_t *buf);
/* Given a config, how many counters and config registers there are */
extern uint32_t kpc_get_counter_count(uint32_t classes);
extern uint32_t kpc_get_config_count(uint32_t classes);
/* enable/disable thread counting */
extern uint32_t kpc_get_thread_counting(void);
extern int kpc_set_thread_counting(uint32_t classes);
/* get and set config registers */
extern int kpc_get_config(uint32_t classes, kpc_config_t *current_config);
extern int kpc_set_config(uint32_t classes, kpc_config_t *new_config);
/* get and set PMI period */
extern int kpc_get_period(uint32_t classes, uint64_t *period);
extern int kpc_set_period(uint32_t classes, uint64_t *period);
/* get and set kperf actionid */
extern int kpc_get_actionid(uint32_t classes, uint32_t *actionid);
extern int kpc_set_actionid(uint32_t classes, uint32_t *actionid);
/* hooks on thread create and delete */
extern void kpc_thread_create(thread_t thread);
extern void kpc_thread_destroy(thread_t thread);
/* allocate a buffer big enough for all counters */
extern uint64_t *kpc_counterbuf_alloc(void);
extern void kpc_counterbuf_free(uint64_t*);
extern uint32_t kpc_get_counterbuf_size(void);
/* whether we're currently accounting into threads */
extern int kpc_threads_counting;
/* AST callback for KPC */
extern void kpc_thread_ast_handler( thread_t thread );
/* acquire/release the counters used by the Power Manager */
extern int kpc_force_all_ctrs( task_t task, int val );
extern int kpc_get_force_all_ctrs( void );
/* arch-specific routine for acquire/release the counters used by the Power Manager */
extern int kpc_force_all_ctrs_arch( task_t task, int val );
extern int kpc_set_sw_inc( uint32_t mask );
/* disable/enable whitelist of allowed events */
extern int kpc_get_whitelist_disabled( void );
extern int kpc_disable_whitelist( int val );
/*
* Register the Power Manager as a PMCs user.
*
* This is a deprecated function used by old Power Managers, new Power Managers
* should use the @em kpc_reserve_pm_counters() function. This function actually
* calls @em kpc_reserve_pm_counters() with the following arguments:
* - handler = handler
* - pmc_mask = 0x83
* - custom_config = TRUE
*
* See @em kpc_reserve_pm_counters() for more details about the return value.
*/
extern boolean_t kpc_register_pm_handler(void (*handler)(boolean_t));
/*
* Register the Power Manager as a PMCs user.
*
* @param handler
* Notification callback to use when PMCs are acquired/released by a task.
* Power management must acknowledge the change using kpc_pm_acknowledge.
*
* @param pmc_mask
* Bitmask of the configurable PMCs used by the Power Manager. The number of bits
* set must less or equal than the number of configurable counters
* available on the SoC.
*
* @param custom_config
* If custom_config=TRUE, the legacy sharing mode is enabled, otherwise the
* Modern Sharing mode is enabled. These modes are explained in more details in
* the kperf documentation.
*
* @return
* FALSE if a task has acquired all the PMCs, otherwise TRUE and the Power
* Manager can start using the reserved PMCs.
*/
extern boolean_t kpc_reserve_pm_counters(uint64_t pmc_mask, kpc_pm_handler_t handler,
boolean_t custom_config);
/*
* Unregister the Power Manager as a PMCs user, and release the previously
* reserved counters.
*/
extern void kpc_release_pm_counters(void);
/*
* Acknowledge the callback that PMCs are available to power management.
*
* @param available_to_pm Whether the counters were made available to power
* management in the callback. Pass in whatever was passed into the handler
* function. After this point, power management is able to use POWER_CLASS
* counters.
*/
extern void kpc_pm_acknowledge(boolean_t available_to_pm);
/*
* Is the PMU used by both the power manager and userspace?
*
* This is true when the power manager has been registered. It disables certain
* counter configurations (like RAWPMU) that are incompatible with sharing
* counters.
*/
extern boolean_t kpc_multiple_clients(void);
/*
* Is kpc controlling the fixed counters?
*
* This returns false when the power manager has requested custom configuration
* control.
*/
extern boolean_t kpc_controls_fixed_counters(void);
/*
* Is kpc controlling a specific PMC ?
*/
extern boolean_t kpc_controls_counter(uint32_t ctr);
extern void kpc_idle(void);
extern void kpc_idle_exit(void);
/*
* KPC PRIVATE
*/
extern uint32_t kpc_actionid[KPC_MAX_COUNTERS];
/* handler for mp operations */
struct kpc_config_remote {
uint32_t classes;
kpc_config_t *configv;
uint64_t pmc_mask;
};
/* handler for mp operations */
struct kpc_running_remote {
uint32_t classes; /* classes to run */
uint64_t cfg_target_mask; /* configurable counters selected */
uint64_t cfg_state_mask; /* configurable counters new state */
};
/* handler for mp operations */
struct kpc_get_counters_remote {
uint32_t classes;
uint32_t nb_counters;
uint32_t buf_stride;
uint64_t *buf;
};
int kpc_get_all_cpus_counters(uint32_t classes, int *curcpu, uint64_t *buf);
int kpc_get_curcpu_counters(uint32_t classes, int *curcpu, uint64_t *buf);
int kpc_get_fixed_counters(uint64_t *counterv);
int kpc_get_configurable_counters(uint64_t *counterv, uint64_t pmc_mask);
boolean_t kpc_is_running_fixed(void);
boolean_t kpc_is_running_configurable(uint64_t pmc_mask);
uint32_t kpc_fixed_count(void);
uint32_t kpc_configurable_count(void);
uint32_t kpc_fixed_config_count(void);
uint32_t kpc_configurable_config_count(uint64_t pmc_mask);
uint32_t kpc_rawpmu_config_count(void);
int kpc_get_fixed_config(kpc_config_t *configv);
int kpc_get_configurable_config(kpc_config_t *configv, uint64_t pmc_mask);
int kpc_get_rawpmu_config(kpc_config_t *configv);
uint64_t kpc_fixed_max(void);
uint64_t kpc_configurable_max(void);
int kpc_set_config_arch(struct kpc_config_remote *mp_config);
int kpc_set_period_arch(struct kpc_config_remote *mp_config);
__options_decl(kperf_kpc_flags_t, uint16_t, {
KPC_KERNEL_PC = 0x01, // the PC is a kernel address
KPC_KERNEL_COUNTING = 0x02, // the counter counts while running in the kernel
KPC_USER_COUNTING = 0x04, // the counter counts while running in user space
KPC_CAPTURED_PC = 0x08, // the PC was captured by hardware
});
void kpc_sample_kperf(uint32_t actionid, uint32_t counter, uint64_t config,
uint64_t count, uintptr_t pc, kperf_kpc_flags_t flags);
int kpc_set_running_arch(struct kpc_running_remote *mp_config);
/*
* Helpers
*/
/* count the number of bits set */
extern uint8_t kpc_popcount(uint64_t value);
/* for a set of classes, retrieve the configurable PMCs mask */
extern uint64_t kpc_get_configurable_pmc_mask(uint32_t classes);
/* Interface for kexts to publish a kpc interface */
struct kpc_driver {
uint32_t (*get_classes)(void);
uint32_t (*get_running)(void);
int (*set_running)(uint32_t classes);
int (*get_cpu_counters)(boolean_t all_cpus, uint32_t classes,
int *curcpu, uint64_t *buf);
int (*get_curthread_counters)(uint32_t *inoutcount, uint64_t *buf);
uint32_t (*get_counter_count)(uint32_t classes);
uint32_t (*get_config_count)(uint32_t classes);
int (*get_config)(uint32_t classes, kpc_config_t *current_config);
int (*set_config)(uint32_t classes, kpc_config_t *new_config);
int (*get_period)(uint32_t classes, uint64_t *period);
int (*set_period)(uint32_t classes, uint64_t *period);
};
__END_DECLS
#endif /* !definde(KERN_KPC_H) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/sfi.h | /*
* Copyright (c) 2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_SFI_H_
#define _KERN_SFI_H_
#include <stdint.h>
#include <mach/mach_types.h>
#include <mach/kern_return.h>
#include <mach/sfi_class.h>
#include <kern/ast.h>
#include <kern/kern_types.h>
#include <kern/ledger.h>
extern void sfi_init(void);
extern sfi_class_id_t sfi_get_ledger_alias_for_class(sfi_class_id_t class_id);
extern int sfi_ledger_entry_add(ledger_template_t template, sfi_class_id_t class_id);
kern_return_t sfi_set_window(uint64_t window_usecs);
kern_return_t sfi_window_cancel(void);
kern_return_t sfi_get_window(uint64_t *window_usecs);
kern_return_t sfi_set_class_offtime(sfi_class_id_t class_id, uint64_t offtime_usecs);
kern_return_t sfi_class_offtime_cancel(sfi_class_id_t class_id);
kern_return_t sfi_get_class_offtime(sfi_class_id_t class_id, uint64_t *offtime_usecs);
#endif /* _KERN_SFI_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/debug.h | /*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_DEBUG_H_
#define _KERN_DEBUG_H_
#include <kern/kcdata.h>
#include <sys/cdefs.h>
#include <stdint.h>
#include <stdarg.h>
#include <uuid/uuid.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/vm_types.h>
#include <TargetConditionals.h>
__BEGIN_DECLS
#ifdef __APPLE_API_PRIVATE
#ifdef __APPLE_API_UNSTABLE
struct thread_snapshot {
uint32_t snapshot_magic;
uint32_t nkern_frames;
uint32_t nuser_frames;
uint64_t wait_event;
uint64_t continuation;
uint64_t thread_id;
uint64_t user_time;
uint64_t system_time;
int32_t state;
int32_t priority; /* static priority */
int32_t sched_pri; /* scheduled (current) priority */
int32_t sched_flags; /* scheduler flags */
char ss_flags;
char ts_qos; /* effective qos */
char ts_rqos; /* requested qos */
char ts_rqos_override; /* requested qos override */
char io_tier;
char _reserved[3]; /* pad for 4 byte alignement packing */
/*
* I/O Statistics
* XXX: These fields must be together
*/
uint64_t disk_reads_count;
uint64_t disk_reads_size;
uint64_t disk_writes_count;
uint64_t disk_writes_size;
uint64_t io_priority_count[STACKSHOT_IO_NUM_PRIORITIES];
uint64_t io_priority_size[STACKSHOT_IO_NUM_PRIORITIES];
uint64_t paging_count;
uint64_t paging_size;
uint64_t non_paging_count;
uint64_t non_paging_size;
uint64_t data_count;
uint64_t data_size;
uint64_t metadata_count;
uint64_t metadata_size;
/* XXX: I/O Statistics end */
uint64_t voucher_identifier; /* obfuscated voucher identifier */
uint64_t total_syscalls;
char pth_name[STACKSHOT_MAX_THREAD_NAME_SIZE];
} __attribute__((packed));
/* old, non kcdata format */
struct task_snapshot {
uint32_t snapshot_magic;
int32_t pid;
uint64_t uniqueid;
uint64_t user_time_in_terminated_threads;
uint64_t system_time_in_terminated_threads;
uint8_t shared_cache_identifier[16];
uint64_t shared_cache_slide;
uint32_t nloadinfos;
int suspend_count;
int task_size; /* pages */
int faults; /* number of page faults */
int pageins; /* number of actual pageins */
int cow_faults; /* number of copy-on-write faults */
uint32_t ss_flags;
uint64_t p_start_sec; /* from the bsd proc struct */
uint64_t p_start_usec; /* from the bsd proc struct */
/*
* We restrict ourselves to a statically defined
* (current as of 2009) length for the
* p_comm string, due to scoping issues (osfmk/bsd and user/kernel
* binary compatibility).
*/
char p_comm[17];
uint32_t was_throttled;
uint32_t did_throttle;
uint32_t latency_qos;
/*
* I/O Statistics
* XXX: These fields must be together.
*/
uint64_t disk_reads_count;
uint64_t disk_reads_size;
uint64_t disk_writes_count;
uint64_t disk_writes_size;
uint64_t io_priority_count[STACKSHOT_IO_NUM_PRIORITIES];
uint64_t io_priority_size[STACKSHOT_IO_NUM_PRIORITIES];
uint64_t paging_count;
uint64_t paging_size;
uint64_t non_paging_count;
uint64_t non_paging_size;
uint64_t data_count;
uint64_t data_size;
uint64_t metadata_count;
uint64_t metadata_size;
/* XXX: I/O Statistics end */
uint32_t donating_pid_count;
} __attribute__ ((packed));
struct micro_snapshot {
uint32_t snapshot_magic;
uint32_t ms_cpu; /* cpu number this snapshot was recorded on */
uint64_t ms_time; /* time at sample (seconds) */
uint64_t ms_time_microsecs;
uint8_t ms_flags;
uint16_t ms_opaque_flags; /* managed by external entity, e.g. fdrmicrod */
} __attribute__ ((packed));
/*
* mirrors the dyld_cache_header struct defined in dyld_cache_format.h from dyld source code
*/
struct _dyld_cache_header {
char magic[16]; // e.g. "dyld_v0 i386"
uint32_t mappingOffset; // file offset to first dyld_cache_mapping_info
uint32_t mappingCount; // number of dyld_cache_mapping_info entries
uint32_t imagesOffset; // file offset to first dyld_cache_image_info
uint32_t imagesCount; // number of dyld_cache_image_info entries
uint64_t dyldBaseAddress; // base address of dyld when cache was built
uint64_t codeSignatureOffset;// file offset of code signature blob
uint64_t codeSignatureSize; // size of code signature blob (zero means to end of file)
uint64_t slideInfoOffset; // file offset of kernel slid info
uint64_t slideInfoSize; // size of kernel slid info
uint64_t localSymbolsOffset; // file offset of where local symbols are stored
uint64_t localSymbolsSize; // size of local symbols information
uint8_t uuid[16]; // unique value for each shared cache file
uint64_t cacheType; // 0 for development, 1 for production
uint32_t branchPoolsOffset; // file offset to table of uint64_t pool addresses
uint32_t branchPoolsCount; // number of uint64_t entries
uint64_t accelerateInfoAddr; // (unslid) address of optimization info
uint64_t accelerateInfoSize; // size of optimization info
uint64_t imagesTextOffset; // file offset to first dyld_cache_image_text_info
uint64_t imagesTextCount; // number of dyld_cache_image_text_info entries
uint64_t dylibsImageGroupAddr;// (unslid) address of ImageGroup for dylibs in this cache
uint64_t dylibsImageGroupSize;// size of ImageGroup for dylibs in this cache
uint64_t otherImageGroupAddr;// (unslid) address of ImageGroup for other OS dylibs
uint64_t otherImageGroupSize;// size of oImageGroup for other OS dylibs
uint64_t progClosuresAddr; // (unslid) address of list of program launch closures
uint64_t progClosuresSize; // size of list of program launch closures
uint64_t progClosuresTrieAddr;// (unslid) address of trie of indexes into program launch closures
uint64_t progClosuresTrieSize;// size of trie of indexes into program launch closures
uint32_t platform; // platform number (macOS=1, etc)
uint32_t formatVersion : 8,// dyld3::closure::kFormatVersion
dylibsExpectedOnDisk : 1, // dyld should expect the dylib exists on disk and to compare inode/mtime to see if cache is valid
simulator : 1, // for simulator of specified platform
locallyBuiltCache : 1, // 0 for B&I built cache, 1 for locally built cache
padding : 21; // TBD
};
/*
* mirrors the dyld_cache_image_text_info struct defined in dyld_cache_format.h from dyld source code
*/
struct _dyld_cache_image_text_info {
uuid_t uuid;
uint64_t loadAddress; // unslid address of start of __TEXT
uint32_t textSegmentSize;
uint32_t pathOffset; // offset from start of cache file
};
#if CONFIG_X86_64_COMPAT
/*
* mirrors the AotCacheHeader struct defined in SharedCacheMetadata.h from cambria source code
*/
#define CAMBRIA_VERSION_INFO_SIZE 32
struct _aot_cache_header {
char magic[8];
uint8_t uuid[16];
uint8_t x86_uuid[16];
uint8_t cambria_version[CAMBRIA_VERSION_INFO_SIZE];
uint64_t code_signature_offset;
uint64_t code_signature_size;
uint32_t num_code_fragments;
uint32_t header_size;
// shared_file_mapping_np mappings is omitted here
};
#endif /* CONFIG_X86_64_COMPAT */
enum micro_snapshot_flags {
kInterruptRecord = 0x1,
kTimerArmingRecord = 0x2,
kUserMode = 0x4, /* interrupted usermode, or armed by usermode */
kIORecord = 0x8,
kPMIRecord = 0x10,
kMACFRecord = 0x20, /* armed by MACF policy */
};
/*
* Flags used in the following assortment of snapshots.
*/
enum generic_snapshot_flags {
kUser64_p = 0x1, /* Userspace uses 64 bit pointers */
kKernel64_p = 0x2 /* The kernel uses 64 bit pointers */
};
#define VM_PRESSURE_TIME_WINDOW 5 /* seconds */
__options_decl(stackshot_flags_t, uint64_t, {
STACKSHOT_GET_DQ = 0x01,
STACKSHOT_SAVE_LOADINFO = 0x02,
STACKSHOT_GET_GLOBAL_MEM_STATS = 0x04,
STACKSHOT_SAVE_KEXT_LOADINFO = 0x08,
/*
* 0x10, 0x20, 0x40 and 0x80 are reserved.
*
* See microstackshot_flags_t whose members used to be part of this
* declaration.
*/
STACKSHOT_ACTIVE_KERNEL_THREADS_ONLY = 0x100,
STACKSHOT_GET_BOOT_PROFILE = 0x200,
STACKSHOT_DO_COMPRESS = 0x400,
STACKSHOT_SAVE_IMP_DONATION_PIDS = 0x2000,
STACKSHOT_SAVE_IN_KERNEL_BUFFER = 0x4000,
STACKSHOT_RETRIEVE_EXISTING_BUFFER = 0x8000,
STACKSHOT_KCDATA_FORMAT = 0x10000,
STACKSHOT_ENABLE_BT_FAULTING = 0x20000,
STACKSHOT_COLLECT_DELTA_SNAPSHOT = 0x40000,
/* Include the layout of the system shared cache */
STACKSHOT_COLLECT_SHAREDCACHE_LAYOUT = 0x80000,
/*
* Kernel consumers of stackshot (via stack_snapshot_from_kernel) can ask
* that we try to take the stackshot lock, and fail if we don't get it.
*/
STACKSHOT_TRYLOCK = 0x100000,
STACKSHOT_ENABLE_UUID_FAULTING = 0x200000,
STACKSHOT_FROM_PANIC = 0x400000,
STACKSHOT_NO_IO_STATS = 0x800000,
/* Report owners of and pointers to kernel objects that threads are blocked on */
STACKSHOT_THREAD_WAITINFO = 0x1000000,
STACKSHOT_THREAD_GROUP = 0x2000000,
STACKSHOT_SAVE_JETSAM_COALITIONS = 0x4000000,
STACKSHOT_INSTRS_CYCLES = 0x8000000,
STACKSHOT_ASID = 0x10000000,
STACKSHOT_PAGE_TABLES = 0x20000000,
STACKSHOT_DISABLE_LATENCY_INFO = 0x40000000,
}); // Note: Add any new flags to kcdata.py (stackshot_in_flags)
__options_decl(microstackshot_flags_t, uint32_t, {
STACKSHOT_GET_MICROSTACKSHOT = 0x10,
STACKSHOT_GLOBAL_MICROSTACKSHOT_ENABLE = 0x20,
STACKSHOT_GLOBAL_MICROSTACKSHOT_DISABLE = 0x40,
STACKSHOT_SET_MICROSTACKSHOT_MARK = 0x80,
});
#define STACKSHOT_THREAD_SNAPSHOT_MAGIC 0xfeedface
#define STACKSHOT_TASK_SNAPSHOT_MAGIC 0xdecafbad
#define STACKSHOT_MEM_AND_IO_SNAPSHOT_MAGIC 0xbfcabcde
#define STACKSHOT_MICRO_SNAPSHOT_MAGIC 0x31c54011
#define STACKSHOT_PAGETABLES_MASK_ALL ~0
#define KF_INITIALIZED (0x1)
#define KF_SERIAL_OVRD (0x2)
#define KF_PMAPV_OVRD (0x4)
#define KF_MATV_OVRD (0x8)
#define KF_STACKSHOT_OVRD (0x10)
#define KF_COMPRSV_OVRD (0x20)
#define KF_INTERRUPT_MASKED_DEBUG_OVRD (0x40)
#define KF_TRAPTRACE_OVRD (0x80)
#define KF_IOTRACE_OVRD (0x100)
#define KF_INTERRUPT_MASKED_DEBUG_STACKSHOT_OVRD (0x200)
#define KF_INTERRUPT_MASKED_DEBUG_PMC_OVRD (0x400)
#define KF_RW_LOCK_DEBUG_OVRD (0x800)
#define KF_MADVISE_FREE_DEBUG_OVRD (0x1000)
boolean_t kern_feature_override(uint32_t fmask);
#define EMBEDDED_PANIC_HEADER_OSVERSION_LEN 32
/*
* Any updates to this header should be also updated in astris as it can not
* grab this header from the SDK.
*
* NOTE: DO NOT REMOVE OR CHANGE THE MEANING OF ANY FIELDS FROM THIS STRUCTURE.
* Any modifications should add new fields at the end, bump the version number
* and be done alongside astris and DumpPanic changes.
*/
struct embedded_panic_header {
uint32_t eph_magic; /* EMBEDDED_PANIC_MAGIC if valid */
uint32_t eph_crc; /* CRC of everything following the ph_crc in the header and the contents */
uint32_t eph_version; /* embedded_panic_header version */
uint64_t eph_panic_flags; /* Flags indicating any state or relevant details */
uint32_t eph_panic_log_offset; /* Offset of the beginning of the panic log from the beginning of the header */
uint32_t eph_panic_log_len; /* length of the panic log */
uint32_t eph_stackshot_offset; /* Offset of the beginning of the panic stackshot from the beginning of the header */
uint32_t eph_stackshot_len; /* length of the panic stackshot (0 if not valid ) */
uint32_t eph_other_log_offset; /* Offset of the other log (any logging subsequent to the stackshot) from the beginning of the header */
uint32_t eph_other_log_len; /* length of the other log */
union {
struct {
uint64_t eph_x86_power_state:8,
eph_x86_efi_boot_state:8,
eph_x86_system_state:8,
eph_x86_unused_bits:40;
}; // anonymous struct to group the bitfields together.
uint64_t eph_x86_do_not_use; /* Used for offsetof/sizeof when parsing header */
};
char eph_os_version[EMBEDDED_PANIC_HEADER_OSVERSION_LEN];
char eph_macos_version[EMBEDDED_PANIC_HEADER_OSVERSION_LEN];
} __attribute__((packed));
#define EMBEDDED_PANIC_HEADER_FLAG_COREDUMP_COMPLETE 0x01
#define EMBEDDED_PANIC_HEADER_FLAG_STACKSHOT_SUCCEEDED 0x02
#define EMBEDDED_PANIC_HEADER_FLAG_STACKSHOT_FAILED_DEBUGGERSYNC 0x04
#define EMBEDDED_PANIC_HEADER_FLAG_STACKSHOT_FAILED_ERROR 0x08
#define EMBEDDED_PANIC_HEADER_FLAG_STACKSHOT_FAILED_INCOMPLETE 0x10
#define EMBEDDED_PANIC_HEADER_FLAG_STACKSHOT_FAILED_NESTED 0x20
#define EMBEDDED_PANIC_HEADER_FLAG_NESTED_PANIC 0x40
#define EMBEDDED_PANIC_HEADER_FLAG_BUTTON_RESET_PANIC 0x80
#define EMBEDDED_PANIC_HEADER_FLAG_COPROC_INITIATED_PANIC 0x100
#define EMBEDDED_PANIC_HEADER_FLAG_COREDUMP_FAILED 0x200
#define EMBEDDED_PANIC_HEADER_FLAG_COMPRESS_FAILED 0x400
#define EMBEDDED_PANIC_HEADER_FLAG_STACKSHOT_DATA_COMPRESSED 0x800
#define EMBEDDED_PANIC_HEADER_FLAG_ENCRYPTED_COREDUMP_SKIPPED 0x1000
#define EMBEDDED_PANIC_HEADER_CURRENT_VERSION 2
#define EMBEDDED_PANIC_MAGIC 0x46554E4B /* FUNK */
struct macos_panic_header {
uint32_t mph_magic; /* MACOS_PANIC_MAGIC if valid */
uint32_t mph_crc; /* CRC of everything following mph_crc in the header and the contents */
uint32_t mph_version; /* macos_panic_header version */
uint32_t mph_padding; /* unused */
uint64_t mph_panic_flags; /* Flags indicating any state or relevant details */
uint32_t mph_panic_log_offset; /* Offset of the panic log from the beginning of the header */
uint32_t mph_panic_log_len; /* length of the panic log */
uint32_t mph_stackshot_offset; /* Offset of the panic stackshot from the beginning of the header */
uint32_t mph_stackshot_len; /* length of the panic stackshot */
uint32_t mph_other_log_offset; /* Offset of the other log (any logging subsequent to the stackshot) from the beginning of the header */
uint32_t mph_other_log_len; /* length of the other log */
char mph_data[]; /* panic data -- DO NOT ACCESS THIS FIELD DIRECTLY. Use the offsets above relative to the beginning of the header */
} __attribute__((packed));
#define MACOS_PANIC_HEADER_CURRENT_VERSION 2
#define MACOS_PANIC_MAGIC 0x44454544 /* DEED */
#define MACOS_PANIC_HEADER_FLAG_NESTED_PANIC 0x01
#define MACOS_PANIC_HEADER_FLAG_COPROC_INITIATED_PANIC 0x02
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_SUCCEEDED 0x04
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_DATA_COMPRESSED 0x08
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_FAILED_DEBUGGERSYNC 0x10
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_FAILED_ERROR 0x20
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_FAILED_INCOMPLETE 0x40
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_FAILED_NESTED 0x80
#define MACOS_PANIC_HEADER_FLAG_COREDUMP_COMPLETE 0x100
#define MACOS_PANIC_HEADER_FLAG_COREDUMP_FAILED 0x200
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_KERNEL_ONLY 0x400
#define MACOS_PANIC_HEADER_FLAG_STACKSHOT_FAILED_COMPRESS 0x800
#define MACOS_PANIC_HEADER_FLAG_ENCRYPTED_COREDUMP_SKIPPED 0x1000
/*
* Any change to the below structure should mirror the structure defined in MacEFIFirmware
* (and vice versa)
*/
struct efi_aurr_panic_header {
uint32_t efi_aurr_magic;
uint32_t efi_aurr_crc;
uint32_t efi_aurr_version;
uint32_t efi_aurr_reset_cause;
uint32_t efi_aurr_reset_log_offset;
uint32_t efi_aurr_reset_log_len;
char efi_aurr_panic_data[];
} __attribute__((packed));
/*
* EXTENDED_/DEBUG_BUF_SIZE can't grow without updates to SMC and iBoot to store larger panic logs on co-processor systems
*/
#define EXTENDED_DEBUG_BUF_SIZE 0x0013ff80
#define EFI_AURR_PANIC_STRING_MAX_LEN 112
#define EFI_AURR_EXTENDED_LOG_SIZE (EXTENDED_DEBUG_BUF_SIZE - sizeof(struct efi_aurr_panic_header) - EFI_AURR_PANIC_STRING_MAX_LEN)
struct efi_aurr_extended_panic_log {
char efi_aurr_extended_log_buf[EFI_AURR_EXTENDED_LOG_SIZE];
uint32_t efi_aurr_log_tail; /* Circular buffer indices */
uint32_t efi_aurr_log_head; /* ditto.. */
} __attribute__((packed));
#endif /* __APPLE_API_UNSTABLE */
#endif /* __APPLE_API_PRIVATE */
__abortlike __printflike(1, 2)
extern void panic(const char *string, ...);
__END_DECLS
#endif /* _KERN_DEBUG_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/processor.h | /*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 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 [email protected]
* 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.
*/
/*
*/
/*
* processor.h: Processor and processor-related definitions.
*/
#ifndef _KERN_PROCESSOR_H_
#define _KERN_PROCESSOR_H_
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <kern/kern_types.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
extern void pset_deallocate(
processor_set_t pset);
extern void pset_reference(
processor_set_t pset);
__END_DECLS
#endif /* _KERN_PROCESSOR_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/lock_stat.h | /*
* Copyright (c) 2018 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_LOCKSTAT_H
#define _KERN_LOCKSTAT_H
#include <machine/locks.h>
#include <machine/atomic.h>
#include <kern/lock_group.h>
/*
* N.B.: On x86, statistics are currently recorded for all indirect mutexes.
* Also, only the acquire attempt count (GRP_MTX_STAT_UTIL) is maintained
* as a 64-bit quantity (the new x86 specific statistics are also maintained
* as 32-bit quantities).
*
*
* Enable this preprocessor define to record the first miss alone
* By default, we count every miss, hence multiple misses may be
* recorded for a single lock acquire attempt via lck_mtx_lock
*/
#undef LOG_FIRST_MISS_ALONE
/*
* This preprocessor define controls whether the R-M-W update of the
* per-group statistics elements are atomic (LOCK-prefixed)
* Enabled by default.
*/
#define ATOMIC_STAT_UPDATES 1
/*
* DTrace lockstat probe definitions
*
*/
enum lockstat_probe_id {
/* Spinlocks */
LS_LCK_SPIN_LOCK_ACQUIRE,
LS_LCK_SPIN_LOCK_SPIN,
LS_LCK_SPIN_UNLOCK_RELEASE,
/*
* Mutexes can also have interlock-spin events, which are
* unique to our lock implementation.
*/
LS_LCK_MTX_LOCK_ACQUIRE,
LS_LCK_MTX_LOCK_BLOCK,
LS_LCK_MTX_LOCK_SPIN,
LS_LCK_MTX_LOCK_ILK_SPIN,
LS_LCK_MTX_TRY_LOCK_ACQUIRE,
LS_LCK_MTX_TRY_SPIN_LOCK_ACQUIRE,
LS_LCK_MTX_UNLOCK_RELEASE,
LS_LCK_MTX_LOCK_SPIN_ACQUIRE,
/*
* Provide a parallel set for indirect mutexes
*/
LS_LCK_MTX_EXT_LOCK_ACQUIRE,
LS_LCK_MTX_EXT_LOCK_BLOCK,
LS_LCK_MTX_EXT_LOCK_SPIN,
LS_LCK_MTX_EXT_LOCK_ILK_SPIN,
LS_LCK_MTX_EXT_UNLOCK_RELEASE,
/*
* Reader-writer locks support a blocking upgrade primitive, as
* well as the possibility of spinning on the interlock.
*/
LS_LCK_RW_LOCK_SHARED_ACQUIRE,
LS_LCK_RW_LOCK_SHARED_BLOCK,
LS_LCK_RW_LOCK_SHARED_SPIN,
LS_LCK_RW_LOCK_EXCL_ACQUIRE,
LS_LCK_RW_LOCK_EXCL_BLOCK,
LS_LCK_RW_LOCK_EXCL_SPIN,
LS_LCK_RW_DONE_RELEASE,
LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE,
LS_LCK_RW_TRY_LOCK_SHARED_SPIN,
LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE,
LS_LCK_RW_TRY_LOCK_EXCL_ILK_SPIN,
LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE,
LS_LCK_RW_LOCK_SHARED_TO_EXCL_SPIN,
LS_LCK_RW_LOCK_SHARED_TO_EXCL_BLOCK,
LS_LCK_RW_LOCK_EXCL_TO_SHARED_DOWNGRADE,
LS_LCK_RW_LOCK_EXCL_TO_SHARED_ILK_SPIN,
/* Ticket lock */
LS_LCK_TICKET_LOCK_ACQUIRE,
LS_LCK_TICKET_LOCK_RELEASE,
LS_LCK_TICKET_LOCK_SPIN,
LS_NPROBES
};
#if CONFIG_DTRACE
extern uint32_t lockstat_probemap[LS_NPROBES];
extern void dtrace_probe(uint32_t, uint64_t, uint64_t,
uint64_t, uint64_t, uint64_t);
/*
* Macros to record lockstat probes.
*/
#define LOCKSTAT_RECORD4(probe, lp, arg0, arg1, arg2, arg3) \
{ \
uint32_t id; \
if (__improbable(id = lockstat_probemap[(probe)])) { \
dtrace_probe(id, (uintptr_t)(lp), (arg0), \
(arg1), (arg2), (arg3)); \
} \
}
#define LOCKSTAT_RECORD_(probe, lp, arg0, arg1, arg2, arg3, ...) LOCKSTAT_RECORD4(probe, lp, arg0, arg1, arg2, arg3)
#define LOCKSTAT_RECORD__(probe, lp, arg0, arg1, arg2, arg3, ...) LOCKSTAT_RECORD_(probe, lp, arg0, arg1, arg2, arg3)
#define LOCKSTAT_RECORD(probe, lp, ...) LOCKSTAT_RECORD__(probe, lp, ##__VA_ARGS__, 0, 0, 0, 0)
#else
#define LOCKSTAT_RECORD()
#endif /* CONFIG_DTRACE */
/*
* Time threshold before dtrace lockstat spin
* probes are triggered
*/
extern machine_timeout32_t dtrace_spin_threshold;
#if CONFIG_DTRACE
void lockprof_invoke(lck_grp_t*, lck_grp_stat_t*, uint64_t);
#endif /* CONFIG_DTRACE */
static inline void
lck_grp_stat_enable(lck_grp_stat_t *stat)
{
stat->lgs_enablings++;
}
static inline void
lck_grp_stat_disable(lck_grp_stat_t *stat)
{
stat->lgs_enablings--;
}
#endif /* _KERN_LOCKSTAT_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/ecc.h | #if !defined(_KERN_ECC_H)
#define _KERN_ECC_H
#include <sys/cdefs.h>
__BEGIN_DECLS
/*
* Copyright (c) 2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#define ECC_EVENT_INFO_DATA_ENTRIES 8
struct ecc_event {
uint8_t id; // ID of memory (e.g. L2C), platform-specific
uint8_t count; // Of uint64_t's used, starting at index 0
uint64_t data[ECC_EVENT_INFO_DATA_ENTRIES] __attribute__((aligned(8))); // Event-specific data
};
__END_DECLS
#endif /* !defined(_KERN_ECC_H) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/hvg_hypercall.h | /*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_HVG_HYPERCALL_H_
#define _KERN_HVG_HYPERCALL_H_
#include <os/base.h>
#include <stdint.h>
/* Architecture-independent definitions (exported to userland) */
/*
* Apple Hypercall arguments
*/
typedef struct hvg_hcall_args {
uint64_t args[6];
} hvg_hcall_args_t;
/*
* Apple Hypercall return output
*/
typedef struct hvg_hcall_output {
uint64_t regs[7];
} hvg_hcall_output_t;
/*
* Apple Hypercall return code
*/
OS_CLOSED_ENUM(hvg_hcall_return, uint32_t,
HVG_HCALL_SUCCESS = 0x0000, /* The call succeeded */
HVG_HCALL_ACCESS_DENIED = 0x0001, /* Invalid access right */
HVG_HCALL_INVALID_CODE = 0x0002, /* Hypercall code not recognized */
HVG_HCALL_INVALID_PARAMETER = 0x0003, /* Specified register value not valid */
HVG_HCALL_IO_FAILED = 0x0004, /* Input/output error */
HVG_HCALL_FEAT_DISABLED = 0x0005, /* Feature not available */
HVG_HCALL_UNSUPPORTED = 0x0006, /* Hypercall not supported */
);
/*
* Apple Hypercall call code
*/
OS_CLOSED_ENUM(hvg_hcall_code, uint32_t,
HVG_HCALL_TRIGGER_DUMP = 0x0001, /* Collect guest dump */
HVG_HCALL_SET_COREDUMP_DATA = 0x0002, /* Set necessary info for reliable coredump */
);
/*
* Options for collecting kernel vmcore
*/
OS_CLOSED_OPTIONS(hvg_hcall_dump_option, uint32_t,
HVG_HCALL_DUMP_OPTION_REGULAR = 0x0001 /* Regular dump-guest-memory */
);
typedef struct hvg_hcall_vmcore_file {
char tag[57]; /* 7 64-bit registers plus 1 byte for '\0' */
} hvg_hcall_vmcore_file_t;
extern hvg_hcall_return_t
hvg_hcall_trigger_dump(hvg_hcall_vmcore_file_t *vmcore,
const hvg_hcall_dump_option_t dump_option);
extern void
hvg_hcall_set_coredump_data(void);
#endif /* _KERN_HV_HYPERCALL_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/hv_support_kext.h | /*
* Copyright (c) 2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_HV_SUPPORT_KEXT_H_
#define _KERN_HV_SUPPORT_KEXT_H_
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdint.h>
#include <kern/kern_types.h>
#include <mach/kern_return.h>
#include <kern/hv_io_notifier.h>
typedef enum {
HV_DEBUG_STATE
} hv_volatile_state_t;
typedef enum {
HV_TASK_TRAP = 0,
HV_THREAD_TRAP = 1
} hv_trap_type_t;
typedef kern_return_t (*hv_trap_t) (void *target, uint64_t arg);
typedef struct {
const hv_trap_t *traps;
unsigned trap_count;
} hv_trap_table_t;
typedef struct {
void (*dispatch)(void *vcpu);
void (*preempt)(void *vcpu);
void (*suspend)(void);
void (*thread_destroy)(void *vcpu);
void (*task_destroy)(void *vm);
void (*volatile_state)(void *vcpu, int state);
#define HV_CALLBACKS_RESUME_DEFINED 1
void (*resume)(void);
void (*memory_pressure)(void);
} hv_callbacks_t;
extern hv_callbacks_t hv_callbacks;
extern int hv_support_available;
extern void hv_support_init(void);
extern int hv_get_support(void);
extern void hv_set_task_target(void *target);
extern void hv_set_thread_target(void *target);
extern void *hv_get_task_target(void);
extern void *hv_get_thread_target(void);
extern int hv_get_volatile_state(hv_volatile_state_t state);
extern kern_return_t hv_set_traps(hv_trap_type_t trap_type,
const hv_trap_t *traps, unsigned trap_count);
extern void hv_release_traps(hv_trap_type_t trap_type);
extern kern_return_t hv_set_callbacks(hv_callbacks_t callbacks);
extern void hv_release_callbacks(void);
extern void hv_suspend(void);
extern void hv_resume(void);
extern kern_return_t hv_task_trap(uint64_t index, uint64_t arg);
extern kern_return_t hv_thread_trap(uint64_t index, uint64_t arg);
extern boolean_t hv_ast_pending(void);
extern void hv_trace_guest_enter(uint32_t vcpu_id, uint64_t *vcpu_regs);
extern void hv_trace_guest_exit(uint32_t vcpu_id, uint64_t *vcpu_regs,
uint32_t reason);
extern void hv_trace_guest_error(uint32_t vcpu_id, uint64_t *vcpu_regs,
uint32_t failure, uint32_t error);
#if defined(__cplusplus)
}
#endif
#endif /* _KERN_HV_SUPPORT_KEXT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/kext_alloc.h | /*
* Copyright (c) 2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KEXT_ALLOC_H_
#define _KEXT_ALLOC_H_
#include <mach/kern_return.h>
#include <mach/vm_types.h>
__BEGIN_DECLS
vm_offset_t get_address_from_kext_map(vm_size_t fsize);
void kext_alloc_init(void);
kern_return_t kext_alloc(vm_offset_t *addr, vm_size_t size, boolean_t fixed);
void kext_free(vm_offset_t addr, vm_size_t size);
kern_return_t kext_receipt(void **addrp, size_t *sizep);
kern_return_t kext_receipt_set_queried(void);
__END_DECLS
#endif /* _KEXT_ALLOC_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/assert.h | /*
* Copyright (c) 2000-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 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 [email protected]
* 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.
*/
/*
*/
#ifndef _KERN_ASSERT_H_
#define _KERN_ASSERT_H_
/* assert.h 4.2 85/01/21 */
#include <kern/macro_help.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Assert error */
#if !CONFIG_NONFATAL_ASSERTS
__abortlike
#endif
extern void Assert(
const char *file,
int line,
const char *expression) __attribute__((noinline));
extern int kext_assertions_enable;
#ifndef __FILE_NAME__
#define __FILE_NAME__ __FILE__
#endif
#define __Panic(fmt, args...) (panic)(fmt, ##args)
__END_DECLS
#ifndef APPLE_KEXT_ASSERTIONS
#define APPLE_KEXT_ASSERTIONS 0
#endif
#if MACH_ASSERT
#define assert(ex) \
(__builtin_expect(!!((ex)), 1L) ? (void)0 : Assert(__FILE_NAME__, __LINE__, # ex))
#define assertf(ex, fmt, args...) \
(__builtin_expect(!!((ex)), 1L) ? (void)0 : __Panic("%s:%d Assertion failed: %s : " fmt, __FILE_NAME__, __LINE__, # ex, ##args))
/*
* Each of the following three macros takes three arguments instead of one for
* the assertion. The suffixes, 's', u' and 'p' indicate the type of arguments
* expected: 'signed', 'unsigned' or 'pointer' respectively.
*
* assert(a > b) -> file.c:123 Assertion failed: a > b
* assert3u(a, >, b) -> file.c:124 Assertion failed: a > b (1 >= 10)
*
*/
#define assert3u(a, op, b) \
do { \
const unsigned long long a_ = (a); \
const unsigned long long b_ = (b); \
\
if (__builtin_expect(!(a_ op b_), 0L)) { \
__Panic("%s:%d Assertion failed: %s (0x%llx %s 0x%llx)", \
__FILE_NAME__, __LINE__, #a " " #op " " #b, a_, #op, b_); \
} \
} while (0)
#define assert3s(a, op, b) \
do { \
const signed long long a_ = (a); \
const signed long long b_ = (b); \
\
if (__builtin_expect(!(a_ op b_), 0L)) { \
__Panic("%s:%d Assertion failed: %s (0x%llx %s 0x%llx)", \
__FILE_NAME__, __LINE__, #a " " #op " " #b, a_, #op, b_); \
} \
} while (0)
#define assert3p(a, op, b) \
do { \
const void *a_ = (a); \
const void *b_ = (b); \
\
if (__builtin_expect(!(a_ op b_), 0L)) { \
__Panic("%s:%d Assertion failed: %s (0x%p %s 0x%p)", \
__FILE_NAME__, __LINE__, #a " " #op " " #b, a_, #op, b_); \
} \
} while (0)
#define __assert_only
#elif APPLE_KEXT_ASSERTIONS && !XNU_KERNEL_PRIVATE /* MACH_ASSERT */
#define assert(ex) \
(__builtin_expect(!!(((!kext_assertions_enable) || (ex))), 1L) ? (void)0 : Assert(__FILE_NAME__, __LINE__, # ex))
#define assertf(ex, fmt, args...) \
(__builtin_expect(!!(((!kext_assertions_enable) || (ex))), 1L) ? (void)0 : __Panic("%s:%d Assertion failed: %s : " fmt, __FILE_NAME__, __LINE__, # ex, ##args))
#define __assert_only
#else /* APPLE_KEXT_ASSERTIONS && !XNU_KERNEL_PRIVATE */
#define assert(ex) ((void)0)
#define assertf(ex, fmt, args...) ((void)0)
#define __assert_only __unused
#define assert3s(a, op, b) ((void)0)
#define assert3u(a, op, b) ((void)0)
#define assert3p(a, op, b) ((void)0)
#endif /* MACH_ASSERT */
/*
* static_assert is a C11 / C++0x / C++1z feature.
*
* Beginning with C++0x, it is a keyword and should not be #defined
*
* static_assert is not disabled by MACH_ASSERT or NDEBUG
*/
#ifndef __cplusplus
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define _STATIC_ASSERT_OVERLOADED_MACRO(_1, _2, NAME, ...) NAME
#define static_assert(...) _STATIC_ASSERT_OVERLOADED_MACRO(__VA_ARGS__, _static_assert_2_args, _static_assert_1_arg)(__VA_ARGS__)
#define _static_assert_2_args(ex, str) _Static_assert((ex), str)
#define _static_assert_1_arg(ex) _Static_assert((ex), #ex)
#endif
#else
#if !defined(__cpp_static_assert)
/* pre C++11 support */
#define _STATIC_ASSERT_OVERLOADED_MACRO(_1, _2, NAME, ...) NAME
#define static_assert(...) _STATIC_ASSERT_OVERLOADED_MACRO(__VA_ARGS__, _static_assert_2_args, _static_assert_1_arg)(__VA_ARGS__)
#define _static_assert_2_args(ex, str) _Static_assert((ex), str)
#define _static_assert_1_arg(ex) _Static_assert((ex), #ex)
#else
/*
* C++11 only supports the 2 argument version of static_assert.
* C++1z has added support for the 1 argument version.
*/
#define _static_assert_1_arg(ex) static_assert((ex), #ex)
#endif
#endif
#endif /* _KERN_ASSERT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/socd_client.h | /*
* Copyright (c) 2021 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* socd_client.h: machine-independent API for interfacing with soc diagnostics data pipeline.
* NOTE: this file is included by socd parser and should not declare any symbols nor
* include kernel specific headers. Use socd_client_kern.h for kernel specifics.
*/
#ifndef _KERN_SOCD_CLIENT_H_
#define _KERN_SOCD_CLIENT_H_
#include <stdint.h>
#include <sys/cdefs.h>
#include <uuid/uuid.h>
#include <sys/kdebug.h>
__BEGIN_DECLS
/* socd trace event id format within kdebug code */
#define SOCD_TRACE_CLASS_MASK (0x3c00)
#define SOCD_TRACE_CLASS_SMASK (0xf)
#define SOCD_TRACE_CLASS_OFFSET (10)
#define SOCD_TRACE_CODE_MASK (0x3ff)
#define SOCD_TRACE_CODE_SMASK (SOCD_TRACE_CODE_MASK)
#define SOCD_TRACE_CODE_OFFSET (0)
#define SOCD_TRACE_EXTRACT_EVENTID(debugid) (KDBG_EXTRACT_CODE(debugid))
#define SOCD_TRACE_EXTRACT_CLASS(debugid) ((SOCD_TRACE_EXTRACT_EVENTID(debugid) & SOCD_TRACE_CLASS_MASK) >> SOCD_TRACE_CLASS_OFFSET)
#define SOCD_TRACE_EXTRACT_CODE(debugid) ((SOCD_TRACE_EXTRACT_EVENTID(debugid) & SOCD_TRACE_CODE_MASK) >> SOCD_TRACE_CODE_OFFSET)
/* Generate an eventid corresponding to Class, Code. */
#define SOCD_TRACE_EVENTID(class, code) \
(((unsigned)((class) & SOCD_TRACE_CLASS_SMASK) << SOCD_TRACE_CLASS_OFFSET) | \
((unsigned)((code) & SOCD_TRACE_CODE_SMASK) << SOCD_TRACE_CODE_OFFSET))
/* SOCD_TRACE_GEN_STR is used by socd parser to symbolicate trace classes & codes */
#define SOCD_TRACE_GEN_STR(entry) #entry,
#define SOCD_TRACE_GEN_CLASS_ENUM(entry) SOCD_TRACE_CLASS_##entry,
#define SOCD_TRACE_GEN_CODE_ENUM(entry) SOCD_TRACE_CODE_##entry,
/* List of socd trace classes */
#define SOCD_TRACE_FOR_EACH_CLASS(iter) \
iter(XNU) \
iter(WDT)
/* List of xnu trace codes */
#define SOCD_TRACE_FOR_EACH_XNU_CODE(iter) \
iter(XNU_PANIC) \
iter(XNU_START_IOKIT) \
iter(XNU_PLATFORM_ACTION) \
iter(XNU_PM_SET_POWER_STATE) \
iter(XNU_PM_INFORM_POWER_CHANGE) \
iter(XNU_STACKSHOT) \
iter(XNU_PM_SET_POWER_STATE_ACK) \
iter(XNU_PM_INFORM_POWER_CHANGE_ACK) \
iter(XNU_PANIC_ASYNC)
typedef enum {
SOCD_TRACE_FOR_EACH_CLASS(SOCD_TRACE_GEN_CLASS_ENUM)
SOCD_TRACE_CLASS_MAX
} socd_client_trace_class_t;
typedef enum {
SOCD_TRACE_FOR_EACH_XNU_CODE(SOCD_TRACE_GEN_CODE_ENUM)
SOCD_TRACE_CODE_XNU_MAX
} socd_client_trace_code_xnu_t;
typedef struct {
uint32_t version;
uint64_t boot_time;
uuid_t kernel_uuid;
uuid_t primary_kernelcache_uuid;
} __attribute__((packed)) socd_client_hdr_t;
typedef uint64_t socd_client_trace_arg_t;
typedef struct {
uint64_t timestamp;
uint32_t debugid;
socd_client_trace_arg_t arg1;
socd_client_trace_arg_t arg2;
socd_client_trace_arg_t arg3;
socd_client_trace_arg_t arg4;
} __attribute ((packed)) socd_client_trace_entry_t;
__END_DECLS
#include <kern/socd_client_kern.h>
#endif /* !defined(_KERN_SOCD_CLIENT_H_) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/hv_io_notifier.h | /*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#pragma once
#include <mach/port.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
kHV_ION_NONE = (0u << 0),
kHV_ION_ANY_VALUE = (1u << 1),
kHV_ION_ANY_SIZE = (1u << 2),
kHV_ION_EXIT_FULL = (1u << 3),
};
#ifdef __cplusplus
}
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/clock.h | /*
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
*/
#ifndef _KERN_CLOCK_H_
#define _KERN_CLOCK_H_
#include <stdint.h>
#include <mach/mach_types.h>
#include <mach/clock_types.h>
#include <mach/message.h>
#include <mach/mach_time.h>
#include <mach/boolean.h>
#include <kern/kern_types.h>
#include <sys/cdefs.h>
#ifdef __LP64__
typedef unsigned long clock_sec_t;
typedef unsigned int clock_usec_t, clock_nsec_t;
#else /* __LP64__ */
typedef uint32_t clock_sec_t;
typedef uint32_t clock_usec_t, clock_nsec_t;
#endif /* __LP64__ */
__BEGIN_DECLS
extern void clock_get_calendar_microtime(
clock_sec_t *secs,
clock_usec_t *microsecs);
extern void clock_get_calendar_absolute_and_microtime(
clock_sec_t *secs,
clock_usec_t *microsecs,
uint64_t *abstime);
extern void clock_get_calendar_nanotime(
clock_sec_t *secs,
clock_nsec_t *nanosecs);
extern void clock_get_system_microtime(
clock_sec_t *secs,
clock_usec_t *microsecs);
extern void clock_get_system_nanotime(
clock_sec_t *secs,
clock_nsec_t *nanosecs);
extern void clock_timebase_info(
mach_timebase_info_t info);
extern void clock_get_uptime(
uint64_t *result);
extern void clock_interval_to_deadline(
uint32_t interval,
uint32_t scale_factor,
uint64_t *result);
extern void nanoseconds_to_deadline(
uint64_t interval,
uint64_t *result);
extern void clock_interval_to_absolutetime_interval(
uint32_t interval,
uint32_t scale_factor,
uint64_t *result);
extern void clock_absolutetime_interval_to_deadline(
uint64_t abstime,
uint64_t *result);
extern void clock_continuoustime_interval_to_deadline(
uint64_t abstime,
uint64_t *result);
extern void clock_delay_until(
uint64_t deadline);
extern void absolutetime_to_nanoseconds(
uint64_t abstime,
uint64_t *result);
extern void nanoseconds_to_absolutetime(
uint64_t nanoseconds,
uint64_t *result);
/*
* Absolute <-> Continuous Time conversion routines
*
* It is the caller's responsibility to ensure that these functions are
* synchronized with respect to updates to the continuous timebase. The
* returned value is only valid until the next update to the continuous
* timebase.
*
* If the value to be returned by continuoustime_to_absolutetime would be
* negative, zero is returned. This occurs when the provided continuous time
* is less the amount of the time the system spent asleep and /must/ be
* handled.
*/
extern uint64_t absolutetime_to_continuoustime(
uint64_t abstime);
extern uint64_t continuoustime_to_absolutetime(
uint64_t conttime);
extern uint64_t mach_absolutetime_asleep;
extern uint64_t mach_absolutetime_last_sleep;
#if HIBERNATION && HAS_CONTINUOUS_HWCLOCK
extern uint64_t hwclock_conttime_offset;
#endif
__END_DECLS
#endif /* _KERN_CLOCK_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/telemetry.h | /*
* Copyright (c) 2012-2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERNEL_TELEMETRY_H_
#define _KERNEL_TELEMETRY_H_
#include <stdint.h>
#include <sys/cdefs.h>
#include <mach/mach_types.h>
#include <kern/thread.h>
__BEGIN_DECLS
#define TELEMETRY_CMD_TIMER_EVENT 1
#define TELEMETRY_CMD_VOUCHER_NAME 2
#define TELEMETRY_CMD_VOUCHER_STAIN TELEMETRY_CMD_VOUCHER_NAME
enum telemetry_pmi {
TELEMETRY_PMI_NONE,
TELEMETRY_PMI_INSTRS,
TELEMETRY_PMI_CYCLES,
};
#define TELEMETRY_CMD_PMI_SETUP 3
__END_DECLS
#endif /* _KERNEL_TELEMETRY_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/energy_perf.h | /*
* Copyright (c) 2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Interfaces for non-kernel managed devices to inform the kernel of their
* energy and performance relevant activity and resource utilisation, typically
* on a per-thread or task basis.
*/
#ifndef _KERN_ENERGY_PERF_H_
#define _KERN_ENERGY_PERF_H_
#include <stdint.h>
__BEGIN_DECLS
typedef struct {
uint32_t gpu_id;
uint32_t gpu_max_domains;
} gpu_descriptor;
typedef gpu_descriptor *gpu_descriptor_t;
/* The GPU is expected to describe itself with this interface prior to reporting
* resource usage.
*/
void gpu_describe(gpu_descriptor_t);
#define GPU_SCOPE_CURRENT_THREAD (0x1)
#define GPU_SCOPE_MISC (0x2)
/* GPU utilisation update for the current thread. */
uint64_t gpu_accumulate_time(uint32_t scope, uint32_t gpu_id, uint32_t gpu_domain, uint64_t gpu_accumulated_ns, uint64_t gpu_tstamp_ns);
/* Interfaces for the block storage driver to advise the perf. controller of
* recent IOs
*/
/* Target medium for this set of IOs. Updates can occur in parallel if
* multiple devices exist, hence consumers must synchronize internally, ideally
* in a low-overhead fashion such as per-CPU counters, as this may be invoked
* within the IO path.
*/
#define IO_MEDIUM_ROTATING (0x0ULL)
#define IO_MEDIUM_SOLID_STATE (0x1ULL)
/* As there are several priority bands whose nature is evolving, we rely on the
* block storage driver to classify non-performance-critical IOs as "low"
* priority. Separate updates are expected for low/high priority IOs.
*/
#define IO_PRIORITY_LOW (0x1ULL << 8)
/* Reserved for estimates of bursts of future IOs; could possibly benefit from
* a time horizon, but it's unclear if it will be specifiable by any layer with
* reasonable accuracy
*/
#define IO_PRIORITY_PREDICTIVE (0x1ULL << 16)
uint64_t io_rate_update(
uint64_t io_rate_flags, /* Rotating/NAND, IO priority level */
uint64_t read_ops_delta,
uint64_t write_ops_delta,
uint64_t read_bytes_delta,
uint64_t write_bytes_delta);
typedef uint64_t (*io_rate_update_callback_t) (uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
void io_rate_update_register(io_rate_update_callback_t);
/* Interfaces for integrated GPUs to supply command submission telemetry.
*/
#define GPU_NCMDS_VALID (0x1)
#define GPU_NOUTSTANDING_VALID (0x2)
#define GPU_BUSY_VALID (0x4)
#define GPU_CYCLE_COUNT_VALID (0x8)
#define GPU_MISC_VALID (0x10)
void gpu_submission_telemetry(
uint64_t gpu_ncmds_total,
uint64_t gpu_noutstanding,
uint64_t gpu_busy_ns_total,
uint64_t gpu_cycles,
uint64_t gpu_telemetry_valid_flags,
uint64_t gpu_telemetry_misc);
typedef uint64_t (*gpu_set_fceiling_t) (uint32_t gpu_fceiling_ratio, uint64_t gpu_fceiling_param);
void gpu_fceiling_cb_register(gpu_set_fceiling_t);
__END_DECLS
#endif /* _KERN_ENERGY_PERF_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/backtrace.h | // Copyright (c) 2016-2021 Apple Inc. All rights reserved.
//
// @APPLE_OSREFERENCE_LICENSE_HEADER_START@
//
// This file contains Original Code and/or Modifications of Original Code
// as defined in and that are subject to the Apple Public Source License
// Version 2.0 (the 'License'). You may not use this file except in
// compliance with the License. The rights granted to you under the License
// may not be used to create, or enable the creation or redistribution of,
// unlawful or unlicensed copies of an Apple operating system, or to
// circumvent, violate, or enable the circumvention or violation of, any
// terms of an Apple operating system software license agreement.
//
// Please obtain a copy of the License at
// http://www.opensource.apple.com/apsl/ and read it before using this file.
//
// The Original Code and all software distributed under the License are
// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
// Please see the License for the specific language governing rights and
// limitations under the License.
//
// @APPLE_OSREFERENCE_LICENSE_HEADER_END@
#ifndef KERN_BACKTRACE_H
#define KERN_BACKTRACE_H
// Kernel and user space backtracing (call stack walking) functions.
//
// For the current kernel stack, call backtrace from any context:
//
// ```c
// #define MAX_STK_LEN (8)
//
// void *ret_addrs[MAX_STK_LEN] = { 0 };
// backtrace_info_t info = BTI_NONE;
// unsigned int stk_len = backtrace(ret_addrs, MAX_STK_LEN, NULL, &info);
// for (unsigned int i = 0; i < stk_len; i++) {
// printf("%p -> ", ret_addrs[i]);
// }
// printf("%s\n", (info & BTI_TRUNCATED) ? "TRUNC" : "NULL");
// ```
//
// For user stacks, call backtrace_user from a faultable context:
//
// ```c
// uintptr_t ret_addrs[MAX_STK_LEN] = { 0 };
// struct backtrace_user_info info = BTUINFO_INIT;
// unsigned int stk_len = backtrace_user(ret_addrs, MAX_STK_LEN, NULL, &info);
// if (info.btui_error != 0) {
// printf("user space%s stack is %u frames deep\n",
// (info->btui_info & BTI_TRUNCATED) ? " truncated" : "", stk_len);
// }
// ```
//
// Refer to documentation in backtrace(9) for more information.
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/cdefs.h>
// XXX Surgically include just the errno_t definition, so this can still be used
// by Mach.
#include <sys/_types/_errno_t.h>
__BEGIN_DECLS
// backtrace_flags_t change how the backtraces are recorded.
__options_decl(backtrace_flags_t, uint32_t, {
BTF_NONE = 0x0,
// BTF_KERN_INTERRUPTED backtraces the interrupted kernel stack.
BTF_KERN_INTERRUPTED = 0x1,
});
// The copy function is used to copy call stack frame and other information from
// the target call stack. If an error is returned, the backtrace is aborted.
typedef errno_t (*backtrace_user_copy_fn)(void *ctx, void *dst, user_addr_t src,
size_t size);
// This copy function returns an error when a copy attempt is made, effectively
// limiting the user backtrace to the PC.
errno_t backtrace_user_copy_error(void *ctx, void *dst, user_addr_t src,
size_t size);
// Parameters that control how the backtrace is taken.
struct backtrace_control {
backtrace_flags_t btc_flags;
// The frame address to start backtracing from; set to 0 to start from the
// calling frame.
uintptr_t btc_frame_addr;
// A thread to backtrace user stacks of; must be either the current thread
// or one which has been suspended.
void *btc_user_thread;
// A functions to call instead of the default copyin routine for
// user space backtracing.
backtrace_user_copy_fn btc_user_copy;
// A context to pass to the user copy routine.
void *btc_user_copy_context;
// Apply an offset to each address stored by the backtracer.
int64_t btc_addr_offset;
};
// Use this offset when walking an async stack, so symbolicators that subtract 1
// from each address to find the call site see valid symbols, instead of
// whatever function is at a lower address than the function pointer.
#define BTCTL_ASYNC_ADDR_OFFSET ((int64_t)1)
#define BTCTL_INIT \
((struct backtrace_control){ \
.btc_flags = BTF_NONE, \
.btc_frame_addr = 0, \
.btc_user_thread = NULL, \
.btc_user_copy = NULL, \
.btc_user_copy_context = NULL, \
.btc_addr_offset = 0, \
})
// backtrace_info_t provides information about the backtrace.
__options_decl(backtrace_info_t, uint32_t, {
BTI_NONE = 0x0,
// BTI_64_BIT is set when the backtrace is made up of 64-bit addresses.
BTI_64_BIT = 0x1,
// BTI_TRUNCATED is set when the backtrace has been truncated, either due
// to an error copying data, an invalid frame pointer, or running out of
// buffer space.
BTI_TRUNCATED = 0x2,
});
// Backtrace the current thread's kernel stack.
unsigned int backtrace(uintptr_t *bt, unsigned int btlen,
struct backtrace_control *ctl, backtrace_info_t *info_out)
__attribute__((noinline));
// backtrace_user_info describes a user backtrace.
struct backtrace_user_info {
backtrace_info_t btui_info;
errno_t btui_error;
// The index where the start of the async call stack was found.
unsigned int btui_async_start_index;
// The frame address that can be backtraced to follow the async call stack.
uintptr_t btui_async_frame_addr;
// The frame address to use to resume the backtrace when the call stack is
// truncated by the size of the passed-in buffer.
uintptr_t btui_next_frame_addr;
};
#define BTUINFO_INIT \
((struct backtrace_user_info){ \
.btui_error = 0, \
.btui_info = BTI_NONE, \
.btui_async_start_index = 0, \
.btui_async_frame_addr = 0, \
.btui_next_frame_addr = 0, \
})
// Backtrace a thread's user stack.
unsigned int backtrace_user(uintptr_t *bt, unsigned int btlen,
const struct backtrace_control *ctl, struct backtrace_user_info *info_out);
__END_DECLS
#endif // !defined(KERN_BACKTRACE_H)
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/priority_queue.h | /*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_PRIORITY_QUEUE_H_
#define _KERN_PRIORITY_QUEUE_H_
#include <kern/kern_types.h>
#include <kern/macro_help.h>
#include <kern/assert.h>
#include <stdbool.h>
#include <sys/cdefs.h>
#pragma GCC visibility push(hidden)
__BEGIN_DECLS
/*
* A generic priorty ordered queue implementation based on pairing heaps.
*
* Reference Papers:
* - A Back-to-Basics Empirical Study of Priority Queues (https://arxiv.org/abs/1403.0252)
* - The Pairing Heap: A New Form of Self-Adjusting Heap
* (https://www.cs.cmu.edu/~sleator/papers/pairing-heaps.pdf)
*
* The XNU implementation is a basic version of the pairing heap.
* It allows for O(1) insertion and amortized O(log n) deletion.
*
* It is not a stable data structure by default since adding stability would
* need more pointers and hence more memory.
*
* Type of queues
*
* There are several types of priority queues, with types named:
*
* struct priority_queue_<subtype>_<min|max>
*
* In the rest of this header, `struct priority_queue` is used as
* a generic type to mean any priority_queue type.
*
* min/max refers to whether the priority queue is a min or a max heap.
*
* the subtype can be:
*
* - sched, in which case the key is built in the linkage and assumed to
* be a scheduler priority.
*
* - sched_stable, in which case the key is a combination of:
* * a scheduler priority
* * whether the entry was preempted or not
* * a timestamp.
*
* - generic, in which case a comparison function must be passed to
* the priority_queue_init.
*
* Element Linkage:
*
* Both types use a common queue head and linkage pattern.
* The head of a priority queue is declared as:
*
* struct priority_queue_<subtype>_<min|max> pq_head;
*
* Elements in this queue are linked together using one of the struct
* priority_queue_entry_<subtype> objects embedded within a structure:
*
* struct some_data {
* int field1;
* int field2;
* ...
* struct priority_queue_entry link;
* ...
* int last_field;
* };
* struct some_data is referred to as the queue "element"
*
* This method uses the next, prev and child pointers of the struct
* priority_queue_entry linkage object embedded in a queue element to
* point to other elements in the queue. The head of the priority queue
* (the priority_queue object) will point to the root of the pairing
* heap (NULL if heap is empty). This method allows multiple chains
* through a given object, by embedding multiple priority_queue_entry
* objects in the structure, while simultaneously providing fast removal
* and insertion into the heap using only priority_queue_entry object
* pointers.
*/
/*
* Priority keys maintained by the data structure.
* Since the priority is packed in the node itself, it restricts keys to be 16-bits only.
*/
#define PRIORITY_QUEUE_KEY_NONE 0
typedef uint16_t priority_queue_key_t;
#ifdef __LP64__
/*
* For 64-bit platforms, pack the priority key into the child pointer
* The packing/unpacking is done using a compiler trick to sign extend long.
* This avoids additional NULL checks which are needed in typical packing
* implementation. The idea is to define the packed location as a long and
* for unpacking simply cast it to a full pointer which sign extends it.
*/
#if CONFIG_KERNEL_TBI && KASAN_TBI
#define PRIORITY_QUEUE_ENTRY_CHILD_BITS 44
#define PRIORITY_QUEUE_ENTRY_TAG_BITS 4
#define PRIORITY_QUEUE_ENTRY_KEY_BITS 16
#else /* CONFIG_KERNEL_TBI && KASAN_TBI */
#define PRIORITY_QUEUE_ENTRY_CHILD_BITS 48
#define PRIORITY_QUEUE_ENTRY_KEY_BITS 16
#endif /* CONFIG_KERNEL_TBI && KASAN_TBI */
typedef struct priority_queue_entry {
struct priority_queue_entry *next;
struct priority_queue_entry *prev;
long __key: PRIORITY_QUEUE_ENTRY_KEY_BITS;
#if CONFIG_KERNEL_TBI && KASAN_TBI
unsigned long tag: PRIORITY_QUEUE_ENTRY_TAG_BITS;
#endif /* CONFIG_KERNEL_TBI && KASAN_TBI */
long child: PRIORITY_QUEUE_ENTRY_CHILD_BITS;
} *priority_queue_entry_t;
typedef struct priority_queue_entry_deadline {
struct priority_queue_entry_deadline *next;
struct priority_queue_entry_deadline *prev;
long __key: PRIORITY_QUEUE_ENTRY_KEY_BITS;
#if CONFIG_KERNEL_TBI && KASAN_TBI
unsigned long tag: PRIORITY_QUEUE_ENTRY_TAG_BITS;
#endif /* CONFIG_KERNEL_TBI && KASAN_TBI */
long child: PRIORITY_QUEUE_ENTRY_CHILD_BITS;
uint64_t deadline;
} *priority_queue_entry_deadline_t;
typedef struct priority_queue_entry_sched {
struct priority_queue_entry_sched *next;
struct priority_queue_entry_sched *prev;
long key: PRIORITY_QUEUE_ENTRY_KEY_BITS;
#if CONFIG_KERNEL_TBI && KASAN_TBI
unsigned long tag: PRIORITY_QUEUE_ENTRY_TAG_BITS;
#endif /* CONFIG_KERNEL_TBI && KASAN_TBI */
long child: PRIORITY_QUEUE_ENTRY_CHILD_BITS;
} *priority_queue_entry_sched_t;
typedef struct priority_queue_entry_stable {
struct priority_queue_entry_stable *next;
struct priority_queue_entry_stable *prev;
long key: PRIORITY_QUEUE_ENTRY_KEY_BITS;
#if CONFIG_KERNEL_TBI && KASAN_TBI
unsigned long tag: PRIORITY_QUEUE_ENTRY_TAG_BITS;
#endif /* CONFIG_KERNEL_TBI && KASAN_TBI */
long child: PRIORITY_QUEUE_ENTRY_CHILD_BITS;
uint64_t stamp;
} *priority_queue_entry_stable_t;
#else /* __LP64__ */
typedef struct priority_queue_entry {
struct priority_queue_entry *next;
struct priority_queue_entry *prev;
long child;
} *priority_queue_entry_t;
typedef struct priority_queue_entry_deadline {
struct priority_queue_entry_deadline *next;
struct priority_queue_entry_deadline *prev;
long child;
uint64_t deadline;
} *priority_queue_entry_deadline_t;
/*
* For 32-bit platforms, use an extra field to store the key since child pointer packing
* is not an option. The child is maintained as a long to use the same packing/unpacking
* routines that work for 64-bit platforms.
*/
typedef struct priority_queue_entry_sched {
struct priority_queue_entry_sched *next;
struct priority_queue_entry_sched *prev;
long child;
priority_queue_key_t key;
} *priority_queue_entry_sched_t;
typedef struct priority_queue_entry_stable {
struct priority_queue_entry_stable *next;
struct priority_queue_entry_stable *prev;
long child;
priority_queue_key_t key;
uint64_t stamp;
} *priority_queue_entry_stable_t;
#endif /* __LP64__ */
/*
* Comparator block prototype
* Args:
* - elements to compare
* Return:
* comparision result to indicate relative ordering of elements according to the heap type
*/
typedef int (^priority_queue_compare_fn_t)(struct priority_queue_entry *e1,
struct priority_queue_entry *e2);
#define priority_heap_compare_ints(a, b) ((a) < (b) ? 1 : -1)
#define priority_heap_make_comparator(name1, name2, type, field, ...) \
(^int(priority_queue_entry_t __e1, priority_queue_entry_t __e2){ \
type *name1 = pqe_element_fast(__e1, type, field); \
type *name2 = pqe_element_fast(__e2, type, field); \
__VA_ARGS__; \
})
/*
* Type for any priority queue, only used for documentation purposes.
*/
struct priority_queue;
/*
* Type of generic heaps
*/
struct priority_queue_min {
struct priority_queue_entry *pq_root;
priority_queue_compare_fn_t pq_cmp_fn;
};
struct priority_queue_max {
struct priority_queue_entry *pq_root;
priority_queue_compare_fn_t pq_cmp_fn;
};
/*
* Type of deadline heaps
*/
struct priority_queue_deadline_min {
struct priority_queue_entry_deadline *pq_root;
};
struct priority_queue_deadline_max {
struct priority_queue_entry_deadline *pq_root;
};
/*
* Type of scheduler priority based heaps
*/
struct priority_queue_sched_min {
struct priority_queue_entry_sched *pq_root;
};
struct priority_queue_sched_max {
struct priority_queue_entry_sched *pq_root;
};
/*
* Type of scheduler priority based stable heaps
*/
struct priority_queue_sched_stable_min {
struct priority_queue_entry_stable *pq_root;
};
struct priority_queue_sched_stable_max {
struct priority_queue_entry_stable *pq_root;
};
#pragma mark generic interface
#define PRIORITY_QUEUE_INITIALIZER { .pq_root = NULL }
#define __pqueue_overloadable __attribute__((overloadable))
#define priority_queue_is_min_heap(pq) _Generic(pq, \
struct priority_queue_min *: true, \
struct priority_queue_max *: false, \
struct priority_queue_deadline_min *: true, \
struct priority_queue_deadline_max *: false, \
struct priority_queue_sched_min *: true, \
struct priority_queue_sched_max *: false, \
struct priority_queue_sched_stable_min *: true, \
struct priority_queue_sched_stable_max *: false)
#define priority_queue_is_max_heap(pq) \
(!priority_queue_is_min_heap(pq))
/*
* Macro: pqe_element_fast
* Function:
* Convert a priority_queue_entry_t to a queue element pointer.
* Get a pointer to the user-defined element containing
* a given priority_queue_entry_t
*
* The fast variant assumes that `qe` is not NULL
* Header:
* pqe_element_fast(qe, type, field)
* <priority_queue_entry_t> qe
* <type> type of element in priority queue
* <field> chain field in (*<type>)
* Returns:
* <type *> containing qe
*/
#define pqe_element_fast(qe, type, field) __container_of(qe, type, field)
/*
* Macro: pqe_element
* Function:
* Convert a priority_queue_entry_t to a queue element pointer.
* Get a pointer to the user-defined element containing
* a given priority_queue_entry_t
*
* The non fast variant handles NULL `qe`
* Header:
* pqe_element(qe, type, field)
* <priority_queue_entry_t> qe
* <type> type of element in priority queue
* <field> chain field in (*<type>)
* Returns:
* <type *> containing qe
*/
#define pqe_element(qe, type, field) ({ \
__auto_type _tmp_entry = (qe); \
_tmp_entry ? pqe_element_fast(_tmp_entry, type, field) : ((type *)NULL);\
})
/*
* Priority Queue functionality routines
*/
/*
* Macro: priority_queue_empty
* Function:
* Tests whether a priority queue is empty.
* Header:
* boolean_t priority_queue_empty(pq)
* <struct priority_queue *> pq
*/
#define priority_queue_empty(pq) ((pq)->pq_root == NULL)
/*
* Macro: priority_queue_init
* Function:
* Initialize a <struct priority_queue *>.
* Header:
* priority_queue_init(pq)
* <struct priority_queue *> pq
* (optional) <cmp_fn> comparator function
* Returns:
* None
*/
__pqueue_overloadable
extern void
priority_queue_init(struct priority_queue *pq, ...);
/*
* Macro: priority_queue_entry_init
* Function:
* Initialize a priority_queue_entry_t
* Header:
* priority_queue_entry_init(qe)
* <priority_queue_entry_t> qe
* Returns:
* None
*/
#define priority_queue_entry_init(qe) \
__builtin_bzero(qe, sizeof(*(qe)))
/*
* Macro: priority_queue_destroy
* Function:
* Destroy a priority queue safely. This routine accepts a callback
* to handle any cleanup for elements in the priority queue. The queue does
* not maintain its invariants while getting destroyed. The priority queue and
* the linkage nodes need to be re-initialized before re-using them.
* Header:
* priority_queue_destroy(pq, type, field, callback)
* <struct priority_queue *> pq
* <callback> callback for each element
*
* Returns:
* None
*/
#define priority_queue_destroy(pq, type, field, callback) \
MACRO_BEGIN \
void (^__callback)(type *) = (callback); /* type check */ \
_priority_queue_destroy(pq, offsetof(type, field), \
(void (^)(void *))(__callback)); \
MACRO_END
/*
* Macro: priority_queue_min
* Function:
* Lookup the minimum in a min-priority queue.
*
* Header:
* priority_queue_min(pq, type, field)
* <struct priority_queue *> pq
* <type> type of element in priority queue
* <field> chain field in (*<type>)
* Returns:
* <type *> root element
*/
#define priority_queue_min(pq, type, field) ({ \
static_assert(priority_queue_is_min_heap(pq), "queue is min heap"); \
pqe_element((pq)->pq_root, type, field); \
})
/*
* Macro: priority_queue_max
* Function:
* Lookup the maximum element in a max-priority queue.
*
* Header:
* priority_queue_max(pq, type, field)
* <struct priority_queue *> pq
* <type> type of element in priority queue
* <field> chain field in (*<type>)
* Returns:
* <type *> root element
*/
#define priority_queue_max(pq, type, field) ({ \
static_assert(priority_queue_is_max_heap(pq), "queue is max heap"); \
pqe_element((pq)->pq_root, type, field); \
})
/*
* Macro: priority_queue_insert
* Function:
* Insert an element into the priority queue
*
* The caller must have set the key prio to insertion
*
* Header:
* priority_queue_insert(pq, elt, new_key)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
* Returns:
* Whether the inserted element became the new root
*/
extern bool
priority_queue_insert(struct priority_queue *pq,
struct priority_queue_entry *elt) __pqueue_overloadable;
/*
* Macro: priority_queue_remove_min
* Function:
* Remove the minimum element in a min-heap priority queue.
* Header:
* priority_queue_remove_min(pq, type, field)
* <struct priority_queue *> pq
* <type> type of element in priority queue
* <field> chain field in (*<type>)
* Returns:
* <type *> max element
*/
#define priority_queue_remove_min(pq, type, field) ({ \
static_assert(priority_queue_is_min_heap(pq), "queue is min heap"); \
pqe_element(_priority_queue_remove_root(pq), type, field); \
})
/*
* Macro: priority_queue_remove_max
* Function:
* Remove the maximum element in a max-heap priority queue.
* Header:
* priority_queue_remove_max(pq, type, field)
* <struct priority_queue *> pq
* <type> type of element in priority queue
* <field> chain field in (*<type>)
* Returns:
* <type *> max element
*/
#define priority_queue_remove_max(pq, type, field) ({ \
static_assert(priority_queue_is_max_heap(pq), "queue is max heap"); \
pqe_element(_priority_queue_remove_root(pq), type, field); \
})
/*
* Macro: priority_queue_remove
* Function:
* Removes an element from the priority queue
* Header:
* priority_queue_remove(pq, elt)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
* Returns:
* Whether the removed element was the root
*/
extern bool
priority_queue_remove(struct priority_queue *pq,
struct priority_queue_entry *elt) __pqueue_overloadable;
/*
* Macro: priority_queue_entry_decreased
*
* Function:
* Signal the priority queue that the entry priority has decreased.
*
* The new value for the element priority must have been set
* prior to calling this function.
*
* Header:
* priority_queue_entry_decreased(pq, elt)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
* Returns:
* Whether the update caused the root or its key to change.
*/
extern bool
priority_queue_entry_decreased(struct priority_queue *pq,
struct priority_queue_entry *elt) __pqueue_overloadable;
/*
* Macro: priority_queue_entry_increased
*
* Function:
* Signal the priority queue that the entry priority has increased.
*
* The new value for the element priority must have been set
* prior to calling this function.
*
* Header:
* priority_queue_entry_increased(pq, elt, new_key)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
* Returns:
* Whether the update caused the root or its key to change.
*/
extern bool
priority_queue_entry_increased(struct priority_queue *pq,
struct priority_queue_entry *elt) __pqueue_overloadable;
#pragma mark priority_queue_sched_*
__enum_decl(priority_queue_entry_sched_modifier_t, uint8_t, {
PRIORITY_QUEUE_ENTRY_NONE = 0,
PRIORITY_QUEUE_ENTRY_PREEMPTED = 1,
});
#define priority_queue_is_sched_heap(pq) _Generic(pq, \
struct priority_queue_sched_min *: true, \
struct priority_queue_sched_max *: true, \
struct priority_queue_sched_stable_min *: true, \
struct priority_queue_sched_stable_max *: true, \
default: false)
/*
* Macro: priority_queue_entry_set_sched_pri
*
* Function:
* Sets the scheduler priority on an entry supporting this concept.
*
* The priority is expected to fit on 8 bits.
* An optional sorting modifier.
*
* Header:
* priority_queue_entry_set_sched_pri(pq, elt, pri, modifier)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
* <uint8_t> pri
* <priority_queue_entry_sched_modifier_t> modifier
*/
#define priority_queue_entry_set_sched_pri(pq, elt, pri, modifier) \
MACRO_BEGIN \
static_assert(priority_queue_is_sched_heap(pq), "is a sched heap"); \
(elt)->key = (priority_queue_key_t)(((pri) << 8) + (modifier)); \
MACRO_END
/*
* Macro: priority_queue_entry_sched_pri
*
* Function:
* Return the scheduler priority on an entry supporting this
* concept.
*
* Header:
* priority_queue_entry_sched_pri(pq, elt)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
*
* Returns:
* The scheduler priority of this entry
*/
#define priority_queue_entry_sched_pri(pq, elt) ({ \
static_assert(priority_queue_is_sched_heap(pq), "is a sched heap"); \
(priority_queue_key_t)((elt)->key >> 8); \
})
/*
* Macro: priority_queue_entry_sched_modifier
*
* Function:
* Return the scheduler modifier on an entry supporting this
* concept.
*
* Header:
* priority_queue_entry_sched_modifier(pq, elt)
* <struct priority_queue *> pq
* <priority_queue_entry_t> elt
*
* Returns:
* The scheduler priority of this entry
*/
#define priority_queue_entry_sched_modifier(pq, elt) ({ \
static_assert(priority_queue_is_sched_heap(pq), "is a sched heap"); \
(priority_queue_entry_sched_modifier_t)(elt)->key; \
})
/*
* Macro: priority_queue_min_sched_pri
*
* Function:
* Return the scheduler priority of the minimum element
* of a scheduler priority queue.
*
* Header:
* priority_queue_min_sched_pri(pq)
* <struct priority_queue *> pq
*
* Returns:
* The scheduler priority of this entry
*/
#define priority_queue_min_sched_pri(pq) ({ \
static_assert(priority_queue_is_min_heap(pq), "queue is min heap"); \
priority_queue_entry_sched_pri(pq, (pq)->pq_root); \
})
/*
* Macro: priority_queue_max_sched_pri
*
* Function:
* Return the scheduler priority of the maximum element
* of a scheduler priority queue.
*
* Header:
* priority_queue_max_sched_pri(pq)
* <struct priority_queue *> pq
*
* Returns:
* The scheduler priority of this entry
*/
#define priority_queue_max_sched_pri(pq) ({ \
static_assert(priority_queue_is_max_heap(pq), "queue is max heap"); \
priority_queue_entry_sched_pri(pq, (pq)->pq_root); \
})
#pragma mark implementation details
#define PRIORITY_QUEUE_MAKE_BASE(pqueue_t, pqelem_t) \
\
__pqueue_overloadable extern void \
_priority_queue_destroy(pqueue_t pq, uintptr_t offset, void (^cb)(void *)); \
\
__pqueue_overloadable extern bool \
priority_queue_insert(pqueue_t que, pqelem_t elt); \
\
__pqueue_overloadable extern pqelem_t \
_priority_queue_remove_root(pqueue_t que); \
\
__pqueue_overloadable extern bool \
priority_queue_remove(pqueue_t que, pqelem_t elt); \
\
__pqueue_overloadable extern bool \
priority_queue_entry_decreased(pqueue_t que, pqelem_t elt); \
\
__pqueue_overloadable extern bool \
priority_queue_entry_increased(pqueue_t que, pqelem_t elt)
#define PRIORITY_QUEUE_MAKE(pqueue_t, pqelem_t) \
__pqueue_overloadable \
static inline void \
priority_queue_init(pqueue_t que) \
{ \
__builtin_bzero(que, sizeof(*que)); \
} \
\
PRIORITY_QUEUE_MAKE_BASE(pqueue_t, pqelem_t)
#define PRIORITY_QUEUE_MAKE_CB(pqueue_t, pqelem_t) \
__pqueue_overloadable \
static inline void \
priority_queue_init(pqueue_t pq, priority_queue_compare_fn_t cmp_fn) \
{ \
pq->pq_root = NULL; \
pq->pq_cmp_fn = cmp_fn; \
} \
\
PRIORITY_QUEUE_MAKE_BASE(pqueue_t, pqelem_t)
PRIORITY_QUEUE_MAKE_CB(struct priority_queue_min *, priority_queue_entry_t);
PRIORITY_QUEUE_MAKE_CB(struct priority_queue_max *, priority_queue_entry_t);
PRIORITY_QUEUE_MAKE(struct priority_queue_deadline_min *, priority_queue_entry_deadline_t);
PRIORITY_QUEUE_MAKE(struct priority_queue_deadline_max *, priority_queue_entry_deadline_t);
PRIORITY_QUEUE_MAKE(struct priority_queue_sched_min *, priority_queue_entry_sched_t);
PRIORITY_QUEUE_MAKE(struct priority_queue_sched_max *, priority_queue_entry_sched_t);
PRIORITY_QUEUE_MAKE(struct priority_queue_sched_stable_min *, priority_queue_entry_stable_t);
PRIORITY_QUEUE_MAKE(struct priority_queue_sched_stable_max *, priority_queue_entry_stable_t);
__END_DECLS
#pragma GCC visibility pop
#endif /* _KERN_PRIORITY_QUEUE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/lock_attr.h | /*
* Copyright (c) 2021 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_LOCK_ATTR_H_
#define _KERN_LOCK_ATTR_H_
#include <kern/lock_types.h>
__BEGIN_DECLS
typedef struct __lck_attr__ lck_attr_t;
#define LCK_ATTR_NULL ((lck_attr_t *)NULL)
extern lck_attr_t *lck_attr_alloc_init(void);
extern void lck_attr_setdefault(
lck_attr_t *attr);
extern void lck_attr_setdebug(
lck_attr_t *attr);
extern void lck_attr_cleardebug(
lck_attr_t *attr);
extern void lck_attr_free(
lck_attr_t *attr);
__END_DECLS
#endif /* _KERN_LOCK_ATTR_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/circle_queue.h | /*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_CIRCLE_QUEUE_H_
#define _KERN_CIRCLE_QUEUE_H_
#include <kern/queue.h>
#include <kern/assert.h>
__BEGIN_DECLS
/*
* Circle Queue Management APIs
*
* These are similar to the queues from queue.h,
* but the circle queue head is a single pointer to the first element
* of the queue.
*/
typedef struct circle_queue_head {
queue_entry_t head;
} circle_queue_head_t, *circle_queue_t;
static inline bool
circle_queue_empty(circle_queue_t cq)
{
return cq->head == NULL;
}
static inline queue_entry_t
circle_queue_first(circle_queue_t cq)
{
return cq->head;
}
static inline queue_entry_t
circle_queue_last(circle_queue_t cq)
{
queue_entry_t elt = circle_queue_first(cq);
if (elt) {
__builtin_assume(elt->prev != NULL);
return elt->prev;
}
return NULL;
}
static inline queue_entry_t
circle_queue_next(circle_queue_t cq, queue_entry_t elt)
{
return elt->next == cq->head ? NULL : elt->next;
}
static inline size_t
circle_queue_length(circle_queue_t cq)
{
queue_entry_t elt = circle_queue_first(cq);
size_t n = 0;
for (; elt; elt = circle_queue_next(cq, elt)) {
n++;
}
return n;
}
static inline void
circle_enqueue_tail(circle_queue_t cq, queue_entry_t elt)
{
queue_entry_t head = circle_queue_first(cq);
queue_entry_t tail = circle_queue_last(cq);
if (head == NULL) {
cq->head = elt->next = elt->prev = elt;
} else {
elt->next = head;
elt->prev = tail;
tail->next = elt;
head->prev = elt;
}
}
static inline void
circle_enqueue_head(circle_queue_t cq, queue_entry_t elt)
{
circle_enqueue_tail(cq, elt);
cq->head = elt;
}
static inline void
circle_dequeue(circle_queue_t cq, queue_entry_t elt)
{
queue_entry_t elt_prev = elt->prev;
queue_entry_t elt_next = elt->next;
if (elt == elt_next) {
assert(cq->head == elt);
cq->head = NULL;
} else {
elt_prev->next = elt_next;
elt_next->prev = elt_prev;
if (cq->head == elt) {
cq->head = elt_next;
}
}
__DEQUEUE_ELT_CLEANUP(elt);
}
static inline queue_entry_t
circle_dequeue_head(circle_queue_t cq)
{
queue_entry_t elt = circle_queue_first(cq);
if (elt) {
circle_dequeue(cq, elt);
}
return elt;
}
static inline queue_entry_t
circle_dequeue_tail(circle_queue_t cq)
{
queue_entry_t elt = circle_queue_last(cq);
if (elt) {
circle_dequeue(cq, elt);
}
return elt;
}
static inline void
circle_queue_rotate_head_forward(circle_queue_t cq)
{
queue_entry_t first = circle_queue_first(cq);
if (first != NULL) {
cq->head = first->next;
}
}
static inline void
circle_queue_rotate_head_backward(circle_queue_t cq)
{
queue_entry_t last = circle_queue_last(cq);
if (last != NULL) {
cq->head = last;
}
}
/*
* Macro: cqe_element
* Function:
* Convert a cirle_queue_entry_t pointer to a queue element pointer.
* Get a pointer to the user-defined element containing
* a given cirle_queue_entry_t
* Header:
* <type> * cqe_element(cirle_queue_entry_t qe, <type>, field)
* qe - queue entry to convert
* <type> - what's in the queue (e.g., struct some_data)
* <field> - is the chain field in <type>
* Note:
* Do not use pointer types for <type>
*/
#define cqe_element(qe, type, field) __container_of(qe, type, field)
/*
* Macro: cqe_foreach
* Function:
* Iterate over each queue_entry_t structure.
* Generates a 'for' loop, setting 'qe' to
* each queue_entry_t in the queue.
* Header:
* cqe_foreach(queue_entry_t qe, queue_t head)
* qe - iteration variable
* head - pointer to queue_head_t (head of queue)
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define cqe_foreach(qe, head) \
for (qe = circle_queue_first(head); qe; qe = circle_queue_next(head, qe))
/*
* Macro: cqe_foreach_safe
* Function:
* Safely iterate over each queue_entry_t structure.
*
* Use this iterator macro if you plan to remove the
* queue_entry_t, qe, from the queue during the
* iteration.
* Header:
* cqe_foreach_safe(queue_entry_t qe, queue_t head)
* qe - iteration variable
* head - pointer to queue_head_t (head of queue)
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define cqe_foreach_safe(qe, head) \
for (queue_entry_t _ne, _qe = circle_queue_first(head); \
(qe = _qe) && (_ne = circle_queue_next(head, _qe), 1); \
_qe = _ne)
/*
* Macro: cqe_foreach_element
* Function:
* Iterate over each _element_ in a queue
* where each queue_entry_t points to another
* queue_entry_t, i.e., managed by the [de|en]queue_head/
* [de|en]queue_tail / remqueue / etc. function.
* Header:
* cqe_foreach_element(<type> *elt, queue_t head, <field>)
* elt - iteration variable
* <type> - what's in the queue (e.g., struct some_data)
* <field> - is the chain field in <type>
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define cqe_foreach_element(elt, head, field) \
for (queue_entry_t _qe = circle_queue_first(head); \
_qe && (elt = cqe_element(_qe, typeof(*(elt)), field), 1); \
_qe = circle_queue_next(head, _qe))
/*
* Macro: cqe_foreach_element_safe
* Function:
* Safely iterate over each _element_ in a queue
* where each queue_entry_t points to another
* queue_entry_t, i.e., managed by the [de|en]queue_head/
* [de|en]queue_tail / remqueue / etc. function.
*
* Use this iterator macro if you plan to remove the
* element, elt, from the queue during the iteration.
* Header:
* cqe_foreach_element_safe(<type> *elt, queue_t head, <field>)
* elt - iteration variable
* <type> - what's in the queue (e.g., struct some_data)
* <field> - is the chain field in <type>
* Note:
* This should only be used with Method 1 queue iteration (linkage chains)
*/
#define cqe_foreach_element_safe(elt, head, field) \
for (queue_entry_t _ne, _qe = circle_queue_first(head); \
_qe && (elt = cqe_element(_qe, typeof(*(elt)), field), \
_ne = circle_queue_next(head, _qe), 1); \
_qe = _ne)
/* Dequeue an element from head, or return NULL if the queue is empty */
#define cqe_dequeue_head(head, type, field) ({ \
queue_entry_t _tmp_entry = circle_dequeue_head((head)); \
type *_tmp_element = (type*) NULL; \
if (_tmp_entry != (queue_entry_t) NULL) \
_tmp_element = cqe_element(_tmp_entry, type, field); \
_tmp_element; \
})
/* Dequeue an element from tail, or return NULL if the queue is empty */
#define cqe_dequeue_tail(head, type, field) ({ \
queue_entry_t _tmp_entry = circle_dequeue_tail((head)); \
type *_tmp_element = (type*) NULL; \
if (_tmp_entry != (queue_entry_t) NULL) \
_tmp_element = cqe_element(_tmp_entry, type, field); \
_tmp_element; \
})
/* Peek at the first element, or return NULL if the queue is empty */
#define cqe_queue_first(head, type, field) ({ \
queue_entry_t _tmp_entry = circle_queue_first((head)); \
type *_tmp_element = (type*) NULL; \
if (_tmp_entry != (queue_entry_t) NULL) \
_tmp_element = cqe_element(_tmp_entry, type, field); \
_tmp_element; \
})
/* Peek at the next element, or return NULL if it is last */
#define cqe_queue_next(elt, head, type, field) ({ \
queue_entry_t _tmp_entry = circle_queue_next((head), (elt)); \
type *_tmp_element = (type*) NULL; \
if (_tmp_entry != (queue_entry_t) NULL) \
_tmp_element = cqe_element(_tmp_entry, type, field); \
_tmp_element; \
})
/* Peek at the tail element, or return NULL if the queue is empty */
#define cqe_queue_last(head, type, field) ({ \
queue_entry_t _tmp_entry = circle_queue_last((head)); \
type *_tmp_element = (type*) NULL; \
if (_tmp_entry != (queue_entry_t) NULL) \
_tmp_element = cqe_element(_tmp_entry, type, field); \
_tmp_element; \
})
/*
* Macro: circle_queue_init
* Function:
* Initialize the given circle queue.
* Header:
* void circle_queue_init(q)
* circle_queue_t q; \* MODIFIED *\
*/
#define circle_queue_init(q) \
MACRO_BEGIN \
(q)->head = NULL; \
MACRO_END
__END_DECLS
#endif /* _KERN_QUEUE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/policy_internal.h | /*
* Copyright (c) 2015-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_POLICY_INTERNAL_H_
#define _KERN_POLICY_INTERNAL_H_
/*
* Interfaces for functionality implemented in task_ or thread_policy subsystem
*/
#endif /* _KERN_POLICY_INTERNAL_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/lock_group.h | /*
* Copyright (c) 2018 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_LOCK_GROUP_H
#define _KERN_LOCK_GROUP_H
#include <kern/queue.h>
#include <kern/lock_types.h>
__BEGIN_DECLS
#define LCK_GRP_NULL (lck_grp_t *)NULL
typedef enum lck_type {
LCK_TYPE_SPIN,
LCK_TYPE_MTX,
LCK_TYPE_RW,
LCK_TYPE_TICKET
} lck_type_t;
typedef struct _lck_grp_ lck_grp_t;
#define LCK_GRP_ATTR_STAT 0x1
#define LCK_GRP_ATTR_TIME_STAT 0x2
typedef struct __lck_grp_attr__ lck_grp_attr_t;
#define LCK_GRP_ATTR_NULL (lck_grp_attr_t *)NULL
extern lck_grp_attr_t *lck_grp_attr_alloc_init(
void);
extern void lck_grp_attr_setdefault(
lck_grp_attr_t *attr);
extern void lck_grp_attr_setstat(
lck_grp_attr_t *attr);
extern void lck_grp_attr_free(
lck_grp_attr_t *attr);
extern lck_grp_t *lck_grp_alloc_init(
const char* grp_name,
lck_grp_attr_t *attr);
extern void lck_grp_free(
lck_grp_t *grp);
__END_DECLS
#endif /* _KERN_LOCK_GROUP_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/kcdata.h | /*
* Copyright (c) 2015 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
*
* THE KCDATA MANIFESTO
*
* Kcdata is a self-describing data serialization format. It is meant to get
* nested data structures out of xnu with minimum fuss, but also for that data
* to be easy to parse. It is also meant to allow us to add new fields and
* evolve the data format without breaking old parsers.
*
* Kcdata is a permanent data format suitable for long-term storage including
* in files. It is very important that we continue to be able to parse old
* versions of kcdata-based formats. To this end, there are several
* invariants you MUST MAINTAIN if you alter this file.
*
* * None of the magic numbers should ever be a byteswap of themselves or
* of any of the other magic numbers.
*
* * Never remove any type.
*
* * All kcdata structs must be packed, and must exclusively use fixed-size
* types.
*
* * Never change the definition of any type, except to add new fields to
* the end.
*
* * If you do add new fields to the end of a type, do not actually change
* the definition of the old structure. Instead, define a new structure
* with the new fields. See thread_snapshot_v3 as an example. This
* provides source compatibility for old readers, and also documents where
* the potential size cutoffs are.
*
* * If you change libkdd, or kcdata.py run the unit tests under libkdd.
*
* * If you add a type or extend an existing one, add a sample test to
* libkdd/tests so future changes to libkdd will always parse your struct
* correctly.
*
* For example to add a field to this:
*
* struct foobar {
* uint32_t baz;
* uint32_t quux;
* } __attribute__ ((packed));
*
* Make it look like this:
*
* struct foobar {
* uint32_t baz;
* uint32_t quux;
* ///////// end version 1 of foobar. sizeof(struct foobar) was 8 ////////
* uint32_t frozzle;
* } __attribute__ ((packed));
*
* If you are parsing kcdata formats, you MUST
*
* * Check the length field of each struct, including array elements. If the
* struct is longer than you expect, you must ignore the extra data.
*
* * Ignore any data types you do not understand.
*
* Additionally, we want to be as forward compatible as we can. Meaning old
* tools should still be able to use new data whenever possible. To this end,
* you should:
*
* * Try not to add new versions of types that supplant old ones. Instead
* extend the length of existing types or add supplemental types.
*
* * Try not to remove information from existing kcdata formats, unless
* removal was explicitly asked for. For example it is fine to add a
* stackshot flag to remove unwanted information, but you should not
* remove it from the default stackshot if the new flag is absent.
*
* * (TBD) If you do break old readers by removing information or
* supplanting old structs, then increase the major version number.
*
*
*
* The following is a description of the kcdata format.
*
*
* The format for data is setup in a generic format as follows
*
* Layout of data structure:
*
* | 8 - bytes |
* | type = MAGIC | LENGTH |
* | 0 |
* | type | size |
* | flags |
* | data |
* |___________data____________|
* | type | size |
* | flags |
* |___________data____________|
* | type = END | size=0 |
* | 0 |
*
*
* The type field describes what kind of data is passed. For example type = TASK_CRASHINFO_UUID means the following data is a uuid.
* These types need to be defined in task_corpses.h for easy consumption by userspace inspection tools.
*
* Some range of types is reserved for special types like ints, longs etc. A cool new functionality made possible with this
* extensible data format is that kernel can decide to put more information as required without requiring user space tools to
* re-compile to be compatible. The case of rusage struct versions could be introduced without breaking existing tools.
*
* Feature description: Generic data with description
* -------------------
* Further more generic data with description is very much possible now. For example
*
* - kcdata_add_uint64_with_description(cdatainfo, 0x700, "NUM MACH PORTS");
* - and more functions that allow adding description.
* The userspace tools can then look at the description and print the data even if they are not compiled with knowledge of the field apriori.
*
* Example data:
* 0000 57 f1 ad de 00 00 00 00 00 00 00 00 00 00 00 00 W...............
* 0010 01 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 ........0.......
* 0020 50 49 44 00 00 00 00 00 00 00 00 00 00 00 00 00 PID.............
* 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* 0040 9c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* 0050 01 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 ........0.......
* 0060 50 41 52 45 4e 54 20 50 49 44 00 00 00 00 00 00 PARENT PID......
* 0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* 0080 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* 0090 ed 58 91 f1
*
* Feature description: Container markers for compound data
* ------------------
* If a given kernel data type is complex and requires adding multiple optional fields inside a container
* object for a consumer to understand arbitrary data, we package it using container markers.
*
* For example, the stackshot code gathers information and describes the state of a given task with respect
* to many subsystems. It includes data such as io stats, vm counters, process names/flags and syscall counts.
*
* kcdata_add_container_marker(kcdata_p, KCDATA_TYPE_CONTAINER_BEGIN, STACKSHOT_KCCONTAINER_TASK, task_uniqueid);
* // add multiple data, or add_<type>_with_description()s here
*
* kcdata_add_container_marker(kcdata_p, KCDATA_TYPE_CONTAINER_END, STACKSHOT_KCCONTAINER_TASK, task_uniqueid);
*
* Feature description: Custom Data formats on demand
* --------------------
* With the self describing nature of format, the kernel provider can describe a data type (uniquely identified by a number) and use
* it in the buffer for sending data. The consumer can parse the type information and have knowledge of describing incoming data.
* Following is an example of how we can describe a kernel specific struct sample_disk_io_stats in buffer.
*
* struct sample_disk_io_stats {
* uint64_t disk_reads_count;
* uint64_t disk_reads_size;
* uint64_t io_priority_count[4];
* uint64_t io_priority_size;
* } __attribute__ ((packed));
*
*
* struct kcdata_subtype_descriptor disk_io_stats_def[] = {
* {KCS_SUBTYPE_FLAGS_NONE, KC_ST_UINT64, 0 * sizeof(uint64_t), sizeof(uint64_t), "disk_reads_count"},
* {KCS_SUBTYPE_FLAGS_NONE, KC_ST_UINT64, 1 * sizeof(uint64_t), sizeof(uint64_t), "disk_reads_size"},
* {KCS_SUBTYPE_FLAGS_ARRAY, KC_ST_UINT64, 2 * sizeof(uint64_t), KCS_SUBTYPE_PACK_SIZE(4, sizeof(uint64_t)), "io_priority_count"},
* {KCS_SUBTYPE_FLAGS_ARRAY, KC_ST_UINT64, (2 + 4) * sizeof(uint64_t), sizeof(uint64_t), "io_priority_size"},
* };
*
* Now you can add this custom type definition into the buffer as
* kcdata_add_type_definition(kcdata_p, KCTYPE_SAMPLE_DISK_IO_STATS, "sample_disk_io_stats",
* &disk_io_stats_def[0], sizeof(disk_io_stats_def)/sizeof(struct kcdata_subtype_descriptor));
*
* Feature description: Compression
* --------------------
* In order to avoid keeping large amunt of memory reserved for a panic stackshot, kcdata has support
* for compressing the buffer in a streaming fashion. New data pushed to the kcdata buffer will be
* automatically compressed using an algorithm selected by the API user (currently, we only support
* pass-through and zlib, in the future we plan to add WKDM support, see: 57913859).
*
* To start using compression, call:
* kcdata_init_compress(kcdata_p, hdr_tag, memcpy_f, comp_type);
* where:
* `kcdata_p` is the kcdata buffer that will be used
* `hdr_tag` is the usual header tag denoting what type of kcdata buffer this will be
* `memcpy_f` a memcpy(3) function to use to copy into the buffer, optional.
* `compy_type` is the compression type, see KCDCT_ZLIB for an example.
*
* Once compression is initialized:
* (1) all self-describing APIs will automatically compress
* (2) you can now use the following APIs to compress data into the buffer:
* (None of the following will compress unless kcdata_init_compress() has been called)
*
* - kcdata_push_data(kcdata_descriptor_t data, uint32_t type, uint32_t size, const void *input_data)
* Pushes the buffer of kctype @type at[@input_data, @input_data + @size]
* into the kcdata buffer @data, compressing if needed.
*
* - kcdata_push_array(kcdata_descriptor_t data, uint32_t type_of_element,
* uint32_t size_of_element, uint32_t count, const void *input_data)
* Pushes the array found at @input_data, with element type @type_of_element, where
* each element is of size @size_of_element and there are @count elements into the kcdata buffer
* at @data.
*
* - kcdata_compression_window_open/close(kcdata_descriptor_t data)
* In case the data you are trying to push to the kcdata buffer @data is difficult to predict,
* you can open a "compression window". Between an open and a close, no compression will be done.
* Once you clsoe the window, the underlying compression algorithm will compress the data into the buffer
* and automatically rewind the current end marker of the kcdata buffer.
* There is an ASCII art in kern_cdata.c to aid the reader in understanding
* this.
*
* - kcdata_finish_compression(kcdata_descriptor_t data)
* Must be called at the end to flush any underlying buffers used by the compression algorithms.
* This function will also add some statistics about the compression to the buffer which helps with
* decompressing later.
*
* Once you are done with the kcdata buffer, call kcdata_deinit_compress to
* free any buffers that may have been allocated internal to the compression
* algorithm.
*/
#ifndef _KCDATA_H_
#define _KCDATA_H_
#include <stdint.h>
#include <string.h>
#include <uuid/uuid.h>
#define KCDATA_DESC_MAXLEN 32 /* including NULL byte at end */
#define KCDATA_FLAGS_STRUCT_PADDING_MASK 0xf
#define KCDATA_FLAGS_STRUCT_HAS_PADDING 0x80
/*
* kcdata aligns elements to 16 byte boundaries.
*/
#define KCDATA_ALIGNMENT_SIZE 0x10
struct kcdata_item {
uint32_t type;
uint32_t size; /* len(data) */
/* flags.
*
* For structures:
* padding = flags & 0xf
* has_padding = (flags & 0x80) >> 7
*
* has_padding is needed to disambiguate cases such as
* thread_snapshot_v2 and thread_snapshot_v3. Their
* respective sizes are 0x68 and 0x70, and thread_snapshot_v2
* was emmitted by old kernels *before* we started recording
* padding. Since legacy thread_snapsht_v2 and modern
* thread_snapshot_v3 will both record 0 for the padding
* flags, we need some other bit which will be nonzero in the
* flags to disambiguate.
*
* This is why we hardcode a special case for
* STACKSHOT_KCTYPE_THREAD_SNAPSHOT into the iterator
* functions below. There is only a finite number of such
* hardcodings which will ever be needed. They can occur
* when:
*
* * We have a legacy structure that predates padding flags
*
* * which we want to extend without changing the kcdata type
*
* * by only so many bytes as would fit in the space that
* was previously unused padding.
*
* For containers:
* container_id = flags
*
* For arrays:
* element_count = flags & UINT32_MAX
* element_type = (flags >> 32) & UINT32_MAX
*/
uint64_t flags;
char data[]; /* must be at the end */
};
typedef struct kcdata_item * kcdata_item_t;
enum KCDATA_SUBTYPE_TYPES { KC_ST_CHAR = 1, KC_ST_INT8, KC_ST_UINT8, KC_ST_INT16, KC_ST_UINT16, KC_ST_INT32, KC_ST_UINT32, KC_ST_INT64, KC_ST_UINT64 };
typedef enum KCDATA_SUBTYPE_TYPES kctype_subtype_t;
/*
* A subtype description structure that defines
* how a compound data is laid out in memory. This
* provides on the fly definition of types and consumption
* by the parser.
*/
struct kcdata_subtype_descriptor {
uint8_t kcs_flags;
#define KCS_SUBTYPE_FLAGS_NONE 0x0
#define KCS_SUBTYPE_FLAGS_ARRAY 0x1
/* Force struct type even if only one element.
*
* Normally a kcdata_type_definition is treated as a structure if it has
* more than one subtype descriptor. Otherwise it is treated as a simple
* type. For example libkdd will represent a simple integer 42 as simply
* 42, but it will represent a structure containing an integer 42 as
* {"field_name": 42}..
*
* If a kcdata_type_definition has only single subtype, then it will be
* treated as a structure iff KCS_SUBTYPE_FLAGS_STRUCT is set. If it has
* multiple subtypes, it will always be treated as a structure.
*
* KCS_SUBTYPE_FLAGS_MERGE has the opposite effect. If this flag is used then
* even if there are multiple elements, they will all be treated as individual
* properties of the parent dictionary.
*/
#define KCS_SUBTYPE_FLAGS_STRUCT 0x2 /* force struct type even if only one element */
#define KCS_SUBTYPE_FLAGS_MERGE 0x4 /* treat as multiple elements of parents instead of struct */
uint8_t kcs_elem_type; /* restricted to kctype_subtype_t */
uint16_t kcs_elem_offset; /* offset in struct where data is found */
uint32_t kcs_elem_size; /* size of element (or) packed state for array type */
char kcs_name[KCDATA_DESC_MAXLEN]; /* max 31 bytes for name of field */
};
typedef struct kcdata_subtype_descriptor * kcdata_subtype_descriptor_t;
/*
* In case of array of basic c types in kctype_subtype_t,
* size is packed in lower 16 bits and
* count is packed in upper 16 bits of kcs_elem_size field.
*/
#define KCS_SUBTYPE_PACK_SIZE(e_count, e_size) (((e_count)&0xffffu) << 16 | ((e_size)&0xffffu))
static inline uint32_t
kcs_get_elem_size(kcdata_subtype_descriptor_t d)
{
if (d->kcs_flags & KCS_SUBTYPE_FLAGS_ARRAY) {
/* size is composed as ((count &0xffff)<<16 | (elem_size & 0xffff)) */
return (uint32_t)((d->kcs_elem_size & 0xffff) * ((d->kcs_elem_size & 0xffff0000) >> 16));
}
return d->kcs_elem_size;
}
static inline uint32_t
kcs_get_elem_count(kcdata_subtype_descriptor_t d)
{
if (d->kcs_flags & KCS_SUBTYPE_FLAGS_ARRAY) {
return (d->kcs_elem_size >> 16) & 0xffff;
}
return 1;
}
static inline int
kcs_set_elem_size(kcdata_subtype_descriptor_t d, uint32_t size, uint32_t count)
{
if (count > 1) {
/* means we are setting up an array */
if (size > 0xffff || count > 0xffff) {
return -1; //invalid argument
}
d->kcs_elem_size = ((count & 0xffff) << 16 | (size & 0xffff));
} else {
d->kcs_elem_size = size;
}
return 0;
}
struct kcdata_type_definition {
uint32_t kct_type_identifier;
uint32_t kct_num_elements;
char kct_name[KCDATA_DESC_MAXLEN];
struct kcdata_subtype_descriptor kct_elements[];
};
/* chunk type definitions. 0 - 0x7ff are reserved and defined here
* NOTE: Please update kcdata/libkdd/kcdtypes.c if you make any changes
* in STACKSHOT_KCTYPE_* types.
*/
/*
* Types with description value.
* these will have KCDATA_DESC_MAXLEN-1 length string description
* and rest of kcdata_iter_size() - KCDATA_DESC_MAXLEN bytes as data
*/
#define KCDATA_TYPE_INVALID 0x0u
#define KCDATA_TYPE_STRING_DESC 0x1u
#define KCDATA_TYPE_UINT32_DESC 0x2u
#define KCDATA_TYPE_UINT64_DESC 0x3u
#define KCDATA_TYPE_INT32_DESC 0x4u
#define KCDATA_TYPE_INT64_DESC 0x5u
#define KCDATA_TYPE_BINDATA_DESC 0x6u
/*
* Compound type definitions
*/
#define KCDATA_TYPE_ARRAY 0x11u /* Array of data OBSOLETE DONT USE THIS*/
#define KCDATA_TYPE_TYPEDEFINTION 0x12u /* Meta type that describes a type on the fly. */
#define KCDATA_TYPE_CONTAINER_BEGIN \
0x13u /* Container type which has corresponding CONTAINER_END header. \
* KCDATA_TYPE_CONTAINER_BEGIN has type in the data segment. \
* Both headers have (uint64_t) ID for matching up nested data. \
*/
#define KCDATA_TYPE_CONTAINER_END 0x14u
#define KCDATA_TYPE_ARRAY_PAD0 0x20u /* Array of data with 0 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD1 0x21u /* Array of data with 1 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD2 0x22u /* Array of data with 2 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD3 0x23u /* Array of data with 3 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD4 0x24u /* Array of data with 4 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD5 0x25u /* Array of data with 5 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD6 0x26u /* Array of data with 6 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD7 0x27u /* Array of data with 7 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD8 0x28u /* Array of data with 8 byte of padding*/
#define KCDATA_TYPE_ARRAY_PAD9 0x29u /* Array of data with 9 byte of padding*/
#define KCDATA_TYPE_ARRAY_PADa 0x2au /* Array of data with a byte of padding*/
#define KCDATA_TYPE_ARRAY_PADb 0x2bu /* Array of data with b byte of padding*/
#define KCDATA_TYPE_ARRAY_PADc 0x2cu /* Array of data with c byte of padding*/
#define KCDATA_TYPE_ARRAY_PADd 0x2du /* Array of data with d byte of padding*/
#define KCDATA_TYPE_ARRAY_PADe 0x2eu /* Array of data with e byte of padding*/
#define KCDATA_TYPE_ARRAY_PADf 0x2fu /* Array of data with f byte of padding*/
/*
* Generic data types that are most commonly used
*/
#define KCDATA_TYPE_LIBRARY_LOADINFO 0x30u /* struct dyld_uuid_info_32 */
#define KCDATA_TYPE_LIBRARY_LOADINFO64 0x31u /* struct dyld_uuid_info_64 */
#define KCDATA_TYPE_TIMEBASE 0x32u /* struct mach_timebase_info */
#define KCDATA_TYPE_MACH_ABSOLUTE_TIME 0x33u /* uint64_t */
#define KCDATA_TYPE_TIMEVAL 0x34u /* struct timeval64 */
#define KCDATA_TYPE_USECS_SINCE_EPOCH 0x35u /* time in usecs uint64_t */
#define KCDATA_TYPE_PID 0x36u /* int32_t */
#define KCDATA_TYPE_PROCNAME 0x37u /* char * */
#define KCDATA_TYPE_NESTED_KCDATA 0x38u /* nested kcdata buffer */
#define KCDATA_TYPE_LIBRARY_AOTINFO 0x39u /* struct user64_dyld_aot_info */
#define KCDATA_TYPE_BUFFER_END 0xF19158EDu
/* MAGIC numbers defined for each class of chunked data
*
* To future-proof against big-endian arches, make sure none of these magic
* numbers are byteswaps of each other
*/
#define KCDATA_BUFFER_BEGIN_CRASHINFO 0xDEADF157u /* owner: corpses/task_corpse.h */
/* type-range: 0x800 - 0x8ff */
#define KCDATA_BUFFER_BEGIN_STACKSHOT 0x59a25807u /* owner: sys/stackshot.h */
/* type-range: 0x900 - 0x93f */
#define KCDATA_BUFFER_BEGIN_COMPRESSED 0x434f4d50u /* owner: sys/stackshot.h */
/* type-range: 0x900 - 0x93f */
#define KCDATA_BUFFER_BEGIN_DELTA_STACKSHOT 0xDE17A59Au /* owner: sys/stackshot.h */
/* type-range: 0x940 - 0x9ff */
#define KCDATA_BUFFER_BEGIN_OS_REASON 0x53A20900u /* owner: sys/reason.h */
/* type-range: 0x1000-0x103f */
#define KCDATA_BUFFER_BEGIN_XNUPOST_CONFIG 0x1e21c09fu /* owner: osfmk/tests/kernel_tests.c */
/* type-range: 0x1040-0x105f */
/* next type range number available 0x1060 */
/**************** definitions for XNUPOST *********************/
#define XNUPOST_KCTYPE_TESTCONFIG 0x1040
/**************** definitions for stackshot *********************/
/* This value must always match IO_NUM_PRIORITIES defined in thread_info.h */
#define STACKSHOT_IO_NUM_PRIORITIES 4
/* This value must always match MAXTHREADNAMESIZE used in bsd */
#define STACKSHOT_MAX_THREAD_NAME_SIZE 64
/*
* NOTE: Please update kcdata/libkdd/kcdtypes.c if you make any changes
* in STACKSHOT_KCTYPE_* types.
*/
#define STACKSHOT_KCTYPE_IOSTATS 0x901u /* io_stats_snapshot */
#define STACKSHOT_KCTYPE_GLOBAL_MEM_STATS 0x902u /* struct mem_and_io_snapshot */
#define STACKSHOT_KCCONTAINER_TASK 0x903u
#define STACKSHOT_KCCONTAINER_THREAD 0x904u
#define STACKSHOT_KCTYPE_TASK_SNAPSHOT 0x905u /* task_snapshot_v2 */
#define STACKSHOT_KCTYPE_THREAD_SNAPSHOT 0x906u /* thread_snapshot_v2, thread_snapshot_v3 */
#define STACKSHOT_KCTYPE_DONATING_PIDS 0x907u /* int[] */
#define STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO 0x908u /* dyld_shared_cache_loadinfo */
#define STACKSHOT_KCTYPE_THREAD_NAME 0x909u /* char[] */
#define STACKSHOT_KCTYPE_KERN_STACKFRAME 0x90Au /* struct stack_snapshot_frame32 */
#define STACKSHOT_KCTYPE_KERN_STACKFRAME64 0x90Bu /* struct stack_snapshot_frame64 */
#define STACKSHOT_KCTYPE_USER_STACKFRAME 0x90Cu /* struct stack_snapshot_frame32 */
#define STACKSHOT_KCTYPE_USER_STACKFRAME64 0x90Du /* struct stack_snapshot_frame64 */
#define STACKSHOT_KCTYPE_BOOTARGS 0x90Eu /* boot args string */
#define STACKSHOT_KCTYPE_OSVERSION 0x90Fu /* os version string */
#define STACKSHOT_KCTYPE_KERN_PAGE_SIZE 0x910u /* kernel page size in uint32_t */
#define STACKSHOT_KCTYPE_JETSAM_LEVEL 0x911u /* jetsam level in uint32_t */
#define STACKSHOT_KCTYPE_DELTA_SINCE_TIMESTAMP 0x912u /* timestamp used for the delta stackshot */
#define STACKSHOT_KCTYPE_KERN_STACKLR 0x913u /* uint32_t */
#define STACKSHOT_KCTYPE_KERN_STACKLR64 0x914u /* uint64_t */
#define STACKSHOT_KCTYPE_USER_STACKLR 0x915u /* uint32_t */
#define STACKSHOT_KCTYPE_USER_STACKLR64 0x916u /* uint64_t */
#define STACKSHOT_KCTYPE_NONRUNNABLE_TIDS 0x917u /* uint64_t */
#define STACKSHOT_KCTYPE_NONRUNNABLE_TASKS 0x918u /* uint64_t */
#define STACKSHOT_KCTYPE_CPU_TIMES 0x919u /* struct stackshot_cpu_times or stackshot_cpu_times_v2 */
#define STACKSHOT_KCTYPE_STACKSHOT_DURATION 0x91au /* struct stackshot_duration */
#define STACKSHOT_KCTYPE_STACKSHOT_FAULT_STATS 0x91bu /* struct stackshot_fault_stats */
#define STACKSHOT_KCTYPE_KERNELCACHE_LOADINFO 0x91cu /* kernelcache UUID -- same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
#define STACKSHOT_KCTYPE_THREAD_WAITINFO 0x91du /* struct stackshot_thread_waitinfo */
#define STACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT 0x91eu /* struct thread_group_snapshot or thread_group_snapshot_v2 */
#define STACKSHOT_KCTYPE_THREAD_GROUP 0x91fu /* uint64_t */
#define STACKSHOT_KCTYPE_JETSAM_COALITION_SNAPSHOT 0x920u /* struct jetsam_coalition_snapshot */
#define STACKSHOT_KCTYPE_JETSAM_COALITION 0x921u /* uint64_t */
#define STACKSHOT_KCTYPE_THREAD_POLICY_VERSION 0x922u /* THREAD_POLICY_INTERNAL_STRUCT_VERSION in uint32 */
#define STACKSHOT_KCTYPE_INSTRS_CYCLES 0x923u /* struct instrs_cycles_snapshot */
#define STACKSHOT_KCTYPE_USER_STACKTOP 0x924u /* struct stack_snapshot_stacktop */
#define STACKSHOT_KCTYPE_ASID 0x925u /* uint32_t */
#define STACKSHOT_KCTYPE_PAGE_TABLES 0x926u /* uint64_t */
#define STACKSHOT_KCTYPE_SYS_SHAREDCACHE_LAYOUT 0x927u /* same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
#define STACKSHOT_KCTYPE_THREAD_DISPATCH_QUEUE_LABEL 0x928u /* dispatch queue label */
#define STACKSHOT_KCTYPE_THREAD_TURNSTILEINFO 0x929u /* struct stackshot_thread_turnstileinfo */
#define STACKSHOT_KCTYPE_TASK_CPU_ARCHITECTURE 0x92au /* struct stackshot_cpu_architecture */
#define STACKSHOT_KCTYPE_LATENCY_INFO 0x92bu /* struct stackshot_latency_collection */
#define STACKSHOT_KCTYPE_LATENCY_INFO_TASK 0x92cu /* struct stackshot_latency_task */
#define STACKSHOT_KCTYPE_LATENCY_INFO_THREAD 0x92du /* struct stackshot_latency_thread */
#define STACKSHOT_KCTYPE_LOADINFO64_TEXT_EXEC 0x92eu /* TEXT_EXEC load info -- same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
#define STACKSHOT_KCTYPE_AOTCACHE_LOADINFO 0x92fu /* struct dyld_aot_cache_uuid_info */
#define STACKSHOT_KCTYPE_TRANSITIONING_TASK_SNAPSHOT 0x930u /* transitioning_task_snapshot */
#define STACKSHOT_KCCONTAINER_TRANSITIONING_TASK 0x931u
#define STACKSHOT_KCTYPE_USER_ASYNC_START_INDEX 0x932u /* uint32_t index in user_stack of beginning of async stack */
#define STACKSHOT_KCTYPE_USER_ASYNC_STACKLR64 0x933u /* uint64_t async stack pointers */
#define STACKSHOT_KCTYPE_TASK_DELTA_SNAPSHOT 0x940u /* task_delta_snapshot_v2 */
#define STACKSHOT_KCTYPE_THREAD_DELTA_SNAPSHOT 0x941u /* thread_delta_snapshot_v* */
struct stack_snapshot_frame32 {
uint32_t lr;
uint32_t sp;
};
struct stack_snapshot_frame64 {
uint64_t lr;
uint64_t sp;
};
struct dyld_uuid_info_32 {
uint32_t imageLoadAddress; /* base address image is mapped at */
uuid_t imageUUID;
};
struct dyld_uuid_info_64 {
uint64_t imageLoadAddress; /* XXX image slide */
uuid_t imageUUID;
};
/*
* N.B.: Newer kernels output dyld_shared_cache_loadinfo structures
* instead of this, since the field names match their contents better.
*/
struct dyld_uuid_info_64_v2 {
uint64_t imageLoadAddress; /* XXX image slide */
uuid_t imageUUID;
/* end of version 1 of dyld_uuid_info_64. sizeof v1 was 24 */
uint64_t imageSlidBaseAddress; /* slid base address or slid first mapping of image */
};
/*
* This is the renamed version of dyld_uuid_info_64 with more accurate
* field names, for STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO. Any users
* must be aware of the dyld_uuid_info_64* version history and ensure
* the fields they are accessing are within the actual bounds.
*
* OLD_FIELD NEW_FIELD
* imageLoadAddress sharedCacheSlide
* imageUUID sharedCacheUUID
* imageSlidBaseAddress sharedCacheUnreliableSlidBaseAddress
* - sharedCacheSlidFirstMapping
*/
struct dyld_shared_cache_loadinfo {
uint64_t sharedCacheSlide; /* image slide value */
uuid_t sharedCacheUUID;
/* end of version 1 of dyld_uuid_info_64. sizeof v1 was 24 */
uint64_t sharedCacheUnreliableSlidBaseAddress; /* for backwards-compatibility; use sharedCacheSlidFirstMapping if available */
/* end of version 2 of dyld_uuid_info_64. sizeof v2 was 32 */
uint64_t sharedCacheSlidFirstMapping; /* slid base address of first mapping */
};
struct dyld_aot_cache_uuid_info {
uint64_t x86SlidBaseAddress; /* slid first mapping address of x86 shared cache */
uuid_t x86UUID; /* UUID of x86 shared cache */
uint64_t aotSlidBaseAddress; /* slide first mapping address of aot cache */
uuid_t aotUUID; /* UUID of aot shared cache */
};
struct user32_dyld_uuid_info {
uint32_t imageLoadAddress; /* base address image is mapped into */
uuid_t imageUUID; /* UUID of image */
};
struct user64_dyld_uuid_info {
uint64_t imageLoadAddress; /* base address image is mapped into */
uuid_t imageUUID; /* UUID of image */
};
#define DYLD_AOT_IMAGE_KEY_SIZE 32
struct user64_dyld_aot_info {
uint64_t x86LoadAddress;
uint64_t aotLoadAddress;
uint64_t aotImageSize;
uint8_t aotImageKey[DYLD_AOT_IMAGE_KEY_SIZE];
};
enum task_snapshot_flags {
/* k{User,Kernel}64_p (values 0x1 and 0x2) are defined in generic_snapshot_flags */
kTaskRsrcFlagged = 0x4, // In the EXC_RESOURCE danger zone?
kTerminatedSnapshot = 0x8,
kPidSuspended = 0x10, // true for suspended task
kFrozen = 0x20, // true for hibernated task (along with pidsuspended)
kTaskDarwinBG = 0x40,
kTaskExtDarwinBG = 0x80,
kTaskVisVisible = 0x100,
kTaskVisNonvisible = 0x200,
kTaskIsForeground = 0x400,
kTaskIsBoosted = 0x800,
kTaskIsSuppressed = 0x1000,
kTaskIsTimerThrottled = 0x2000, /* deprecated */
kTaskIsImpDonor = 0x4000,
kTaskIsLiveImpDonor = 0x8000,
kTaskIsDirty = 0x10000,
kTaskWqExceededConstrainedThreadLimit = 0x20000,
kTaskWqExceededTotalThreadLimit = 0x40000,
kTaskWqFlagsAvailable = 0x80000,
kTaskUUIDInfoFaultedIn = 0x100000, /* successfully faulted in some UUID info */
kTaskUUIDInfoMissing = 0x200000, /* some UUID info was paged out */
kTaskUUIDInfoTriedFault = 0x400000, /* tried to fault in UUID info */
kTaskSharedRegionInfoUnavailable = 0x800000, /* shared region info unavailable */
kTaskTALEngaged = 0x1000000,
/* 0x2000000 unused */
kTaskIsDirtyTracked = 0x4000000,
kTaskAllowIdleExit = 0x8000000,
kTaskIsTranslated = 0x10000000,
kTaskSharedRegionNone = 0x20000000, /* task doesn't have a shared region */
kTaskSharedRegionSystem = 0x40000000, /* task is attached to system shared region */
kTaskSharedRegionOther = 0x80000000, /* task is attached to a different shared region */
}; // Note: Add any new flags to kcdata.py (ts_ss_flags)
enum task_transition_type {
kTaskIsTerminated = 0x1,// Past LPEXIT
};
enum thread_snapshot_flags {
/* k{User,Kernel}64_p (values 0x1 and 0x2) are defined in generic_snapshot_flags */
kHasDispatchSerial = 0x4,
kStacksPCOnly = 0x8, /* Stack traces have no frame pointers. */
kThreadDarwinBG = 0x10, /* Thread is darwinbg */
kThreadIOPassive = 0x20, /* Thread uses passive IO */
kThreadSuspended = 0x40, /* Thread is suspended */
kThreadTruncatedBT = 0x80, /* Unmapped pages caused truncated backtrace */
kGlobalForcedIdle = 0x100, /* Thread performs global forced idle */
kThreadFaultedBT = 0x200, /* Some thread stack pages were faulted in as part of BT */
kThreadTriedFaultBT = 0x400, /* We tried to fault in thread stack pages as part of BT */
kThreadOnCore = 0x800, /* Thread was on-core when we entered debugger context */
kThreadIdleWorker = 0x1000, /* Thread is an idle libpthread worker thread */
kThreadMain = 0x2000, /* Thread is the main thread */
kThreadTruncKernBT = 0x4000, /* Unmapped pages caused truncated kernel BT */
kThreadTruncUserBT = 0x8000, /* Unmapped pages caused truncated user BT */
kThreadTruncUserAsyncBT = 0x10000, /* Unmapped pages caused truncated user async BT */
}; // Note: Add any new flags to kcdata.py (ths_ss_flags)
struct mem_and_io_snapshot {
uint32_t snapshot_magic;
uint32_t free_pages;
uint32_t active_pages;
uint32_t inactive_pages;
uint32_t purgeable_pages;
uint32_t wired_pages;
uint32_t speculative_pages;
uint32_t throttled_pages;
uint32_t filebacked_pages;
uint32_t compressions;
uint32_t decompressions;
uint32_t compressor_size;
int32_t busy_buffer_count;
uint32_t pages_wanted;
uint32_t pages_reclaimed;
uint8_t pages_wanted_reclaimed_valid; // did mach_vm_pressure_monitor succeed?
} __attribute__((packed));
/* SS_TH_* macros are for ths_state */
#define SS_TH_WAIT 0x01 /* queued for waiting */
#define SS_TH_SUSP 0x02 /* stopped or requested to stop */
#define SS_TH_RUN 0x04 /* running or on runq */
#define SS_TH_UNINT 0x08 /* waiting uninteruptibly */
#define SS_TH_TERMINATE 0x10 /* halted at termination */
#define SS_TH_TERMINATE2 0x20 /* added to termination queue */
#define SS_TH_IDLE 0x80 /* idling processor */
struct thread_snapshot_v2 {
uint64_t ths_thread_id;
uint64_t ths_wait_event;
uint64_t ths_continuation;
uint64_t ths_total_syscalls;
uint64_t ths_voucher_identifier;
uint64_t ths_dqserialnum;
uint64_t ths_user_time;
uint64_t ths_sys_time;
uint64_t ths_ss_flags;
uint64_t ths_last_run_time;
uint64_t ths_last_made_runnable_time;
uint32_t ths_state;
uint32_t ths_sched_flags;
int16_t ths_base_priority;
int16_t ths_sched_priority;
uint8_t ths_eqos;
uint8_t ths_rqos;
uint8_t ths_rqos_override;
uint8_t ths_io_tier;
} __attribute__((packed));
struct thread_snapshot_v3 {
uint64_t ths_thread_id;
uint64_t ths_wait_event;
uint64_t ths_continuation;
uint64_t ths_total_syscalls;
uint64_t ths_voucher_identifier;
uint64_t ths_dqserialnum;
uint64_t ths_user_time;
uint64_t ths_sys_time;
uint64_t ths_ss_flags;
uint64_t ths_last_run_time;
uint64_t ths_last_made_runnable_time;
uint32_t ths_state;
uint32_t ths_sched_flags;
int16_t ths_base_priority;
int16_t ths_sched_priority;
uint8_t ths_eqos;
uint8_t ths_rqos;
uint8_t ths_rqos_override;
uint8_t ths_io_tier;
uint64_t ths_thread_t;
} __attribute__((packed));
struct thread_snapshot_v4 {
uint64_t ths_thread_id;
uint64_t ths_wait_event;
uint64_t ths_continuation;
uint64_t ths_total_syscalls;
uint64_t ths_voucher_identifier;
uint64_t ths_dqserialnum;
uint64_t ths_user_time;
uint64_t ths_sys_time;
uint64_t ths_ss_flags;
uint64_t ths_last_run_time;
uint64_t ths_last_made_runnable_time;
uint32_t ths_state;
uint32_t ths_sched_flags;
int16_t ths_base_priority;
int16_t ths_sched_priority;
uint8_t ths_eqos;
uint8_t ths_rqos;
uint8_t ths_rqos_override;
uint8_t ths_io_tier;
uint64_t ths_thread_t;
uint64_t ths_requested_policy;
uint64_t ths_effective_policy;
} __attribute__((packed));
struct thread_group_snapshot {
uint64_t tgs_id;
char tgs_name[16];
} __attribute__((packed));
enum thread_group_flags {
kThreadGroupEfficient = 0x1,
kThreadGroupUIApp = 0x2
}; // Note: Add any new flags to kcdata.py (tgs_flags)
struct thread_group_snapshot_v2 {
uint64_t tgs_id;
char tgs_name[16];
uint64_t tgs_flags;
} __attribute__((packed));
enum coalition_flags {
kCoalitionTermRequested = 0x1,
kCoalitionTerminated = 0x2,
kCoalitionReaped = 0x4,
kCoalitionPrivileged = 0x8,
}; // Note: Add any new flags to kcdata.py (jcs_flags)
struct jetsam_coalition_snapshot {
uint64_t jcs_id;
uint64_t jcs_flags;
uint64_t jcs_thread_group;
uint64_t jcs_leader_task_uniqueid;
} __attribute__((packed));
struct instrs_cycles_snapshot {
uint64_t ics_instructions;
uint64_t ics_cycles;
} __attribute__((packed));
struct thread_delta_snapshot_v2 {
uint64_t tds_thread_id;
uint64_t tds_voucher_identifier;
uint64_t tds_ss_flags;
uint64_t tds_last_made_runnable_time;
uint32_t tds_state;
uint32_t tds_sched_flags;
int16_t tds_base_priority;
int16_t tds_sched_priority;
uint8_t tds_eqos;
uint8_t tds_rqos;
uint8_t tds_rqos_override;
uint8_t tds_io_tier;
} __attribute__ ((packed));
struct thread_delta_snapshot_v3 {
uint64_t tds_thread_id;
uint64_t tds_voucher_identifier;
uint64_t tds_ss_flags;
uint64_t tds_last_made_runnable_time;
uint32_t tds_state;
uint32_t tds_sched_flags;
int16_t tds_base_priority;
int16_t tds_sched_priority;
uint8_t tds_eqos;
uint8_t tds_rqos;
uint8_t tds_rqos_override;
uint8_t tds_io_tier;
uint64_t tds_requested_policy;
uint64_t tds_effective_policy;
} __attribute__ ((packed));
struct io_stats_snapshot {
/*
* I/O Statistics
* XXX: These fields must be together.
*/
uint64_t ss_disk_reads_count;
uint64_t ss_disk_reads_size;
uint64_t ss_disk_writes_count;
uint64_t ss_disk_writes_size;
uint64_t ss_io_priority_count[STACKSHOT_IO_NUM_PRIORITIES];
uint64_t ss_io_priority_size[STACKSHOT_IO_NUM_PRIORITIES];
uint64_t ss_paging_count;
uint64_t ss_paging_size;
uint64_t ss_non_paging_count;
uint64_t ss_non_paging_size;
uint64_t ss_data_count;
uint64_t ss_data_size;
uint64_t ss_metadata_count;
uint64_t ss_metadata_size;
/* XXX: I/O Statistics end */
} __attribute__ ((packed));
struct task_snapshot_v2 {
uint64_t ts_unique_pid;
uint64_t ts_ss_flags;
uint64_t ts_user_time_in_terminated_threads;
uint64_t ts_system_time_in_terminated_threads;
uint64_t ts_p_start_sec;
uint64_t ts_task_size;
uint64_t ts_max_resident_size;
uint32_t ts_suspend_count;
uint32_t ts_faults;
uint32_t ts_pageins;
uint32_t ts_cow_faults;
uint32_t ts_was_throttled;
uint32_t ts_did_throttle;
uint32_t ts_latency_qos;
int32_t ts_pid;
char ts_p_comm[32];
} __attribute__ ((packed));
struct transitioning_task_snapshot {
uint64_t tts_unique_pid;
uint64_t tts_ss_flags;
uint64_t tts_transition_type;
int32_t tts_pid;
char tts_p_comm[32];
} __attribute__ ((packed));
struct task_delta_snapshot_v2 {
uint64_t tds_unique_pid;
uint64_t tds_ss_flags;
uint64_t tds_user_time_in_terminated_threads;
uint64_t tds_system_time_in_terminated_threads;
uint64_t tds_task_size;
uint64_t tds_max_resident_size;
uint32_t tds_suspend_count;
uint32_t tds_faults;
uint32_t tds_pageins;
uint32_t tds_cow_faults;
uint32_t tds_was_throttled;
uint32_t tds_did_throttle;
uint32_t tds_latency_qos;
} __attribute__ ((packed));
struct stackshot_cpu_times {
uint64_t user_usec;
uint64_t system_usec;
} __attribute__((packed));
struct stackshot_cpu_times_v2 {
uint64_t user_usec;
uint64_t system_usec;
uint64_t runnable_usec;
} __attribute__((packed));
struct stackshot_duration {
uint64_t stackshot_duration;
uint64_t stackshot_duration_outer;
} __attribute__((packed));
struct stackshot_duration_v2 {
uint64_t stackshot_duration;
uint64_t stackshot_duration_outer;
uint64_t stackshot_duration_prior;
} __attribute__((packed));
struct stackshot_fault_stats {
uint32_t sfs_pages_faulted_in; /* number of pages faulted in using KDP fault path */
uint64_t sfs_time_spent_faulting; /* MATUs spent faulting */
uint64_t sfs_system_max_fault_time; /* MATUs fault time limit per stackshot */
uint8_t sfs_stopped_faulting; /* we stopped decompressing because we hit the limit */
} __attribute__((packed));
typedef struct stackshot_thread_waitinfo {
uint64_t owner; /* The thread that owns the object */
uint64_t waiter; /* The thread that's waiting on the object */
uint64_t context; /* A context uniquely identifying the object */
uint8_t wait_type; /* The type of object that the thread is waiting on */
} __attribute__((packed)) thread_waitinfo_t;
typedef struct stackshot_thread_turnstileinfo {
uint64_t waiter; /* The thread that's waiting on the object */
uint64_t turnstile_context; /* Associated data (either thread id, or workq addr) */
uint8_t turnstile_priority;
uint8_t number_of_hops;
#define STACKSHOT_TURNSTILE_STATUS_UNKNOWN 0x01 /* The final inheritor is unknown (bug?) */
#define STACKSHOT_TURNSTILE_STATUS_LOCKED_WAITQ 0x02 /* A waitq was found to be locked */
#define STACKSHOT_TURNSTILE_STATUS_WORKQUEUE 0x04 /* The final inheritor is a workqueue */
#define STACKSHOT_TURNSTILE_STATUS_THREAD 0x08 /* The final inheritor is a thread */
#define STACKSHOT_TURNSTILE_STATUS_BLOCKED_ON_TASK 0x10 /* blocked on task, dind't find thread */
#define STACKSHOT_TURNSTILE_STATUS_HELD_IPLOCK 0x20 /* the ip_lock was held */
uint64_t turnstile_flags; // Note: Add any new flags to kcdata.py (turnstile_flags)
} __attribute__((packed)) thread_turnstileinfo_t;
#define STACKSHOT_WAITOWNER_KERNEL (UINT64_MAX - 1)
#define STACKSHOT_WAITOWNER_PORT_LOCKED (UINT64_MAX - 2)
#define STACKSHOT_WAITOWNER_PSET_LOCKED (UINT64_MAX - 3)
#define STACKSHOT_WAITOWNER_INTRANSIT (UINT64_MAX - 4)
#define STACKSHOT_WAITOWNER_MTXSPIN (UINT64_MAX - 5)
#define STACKSHOT_WAITOWNER_THREQUESTED (UINT64_MAX - 6) /* workloop waiting for a new worker thread */
#define STACKSHOT_WAITOWNER_SUSPENDED (UINT64_MAX - 7) /* workloop is suspended */
struct stackshot_cpu_architecture {
int32_t cputype;
int32_t cpusubtype;
} __attribute__((packed));
struct stack_snapshot_stacktop {
uint64_t sp;
uint8_t stack_contents[8];
};
/* only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0 */
struct stackshot_latency_collection {
uint64_t latency_version;
uint64_t setup_latency;
uint64_t total_task_iteration_latency;
uint64_t total_terminated_task_iteration_latency;
} __attribute__((packed));
/* only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0 */
struct stackshot_latency_task {
uint64_t task_uniqueid;
uint64_t setup_latency;
uint64_t task_thread_count_loop_latency;
uint64_t task_thread_data_loop_latency;
uint64_t cur_tsnap_latency;
uint64_t pmap_latency;
uint64_t bsd_proc_ids_latency;
uint64_t misc_latency;
uint64_t misc2_latency;
uint64_t end_latency;
} __attribute__((packed));
/* only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0 */
struct stackshot_latency_thread {
uint64_t thread_id;
uint64_t cur_thsnap1_latency;
uint64_t dispatch_serial_latency;
uint64_t dispatch_label_latency;
uint64_t cur_thsnap2_latency;
uint64_t thread_name_latency;
uint64_t sur_times_latency;
uint64_t user_stack_latency;
uint64_t kernel_stack_latency;
uint64_t misc_latency;
} __attribute__((packed));
/**************** definitions for crashinfo *********************/
/*
* NOTE: Please update kcdata/libkdd/kcdtypes.c if you make any changes
* in TASK_CRASHINFO_* types.
*/
/* FIXME some of these types aren't clean (fixed width, packed, and defined *here*) */
struct crashinfo_proc_uniqidentifierinfo {
uint8_t p_uuid[16]; /* UUID of the main executable */
uint64_t p_uniqueid; /* 64 bit unique identifier for process */
uint64_t p_puniqueid; /* unique identifier for process's parent */
uint64_t p_reserve2; /* reserved for future use */
uint64_t p_reserve3; /* reserved for future use */
uint64_t p_reserve4; /* reserved for future use */
} __attribute__((packed));
#define MAX_TRIAGE_STRING_LEN (128)
struct kernel_triage_info_v1 {
char triage_string1[MAX_TRIAGE_STRING_LEN];
char triage_string2[MAX_TRIAGE_STRING_LEN];
char triage_string3[MAX_TRIAGE_STRING_LEN];
char triage_string4[MAX_TRIAGE_STRING_LEN];
char triage_string5[MAX_TRIAGE_STRING_LEN];
} __attribute__((packed));
#define TASK_CRASHINFO_BEGIN KCDATA_BUFFER_BEGIN_CRASHINFO
#define TASK_CRASHINFO_STRING_DESC KCDATA_TYPE_STRING_DESC
#define TASK_CRASHINFO_UINT32_DESC KCDATA_TYPE_UINT32_DESC
#define TASK_CRASHINFO_UINT64_DESC KCDATA_TYPE_UINT64_DESC
#define TASK_CRASHINFO_EXTMODINFO 0x801
#define TASK_CRASHINFO_BSDINFOWITHUNIQID 0x802 /* struct crashinfo_proc_uniqidentifierinfo */
#define TASK_CRASHINFO_TASKDYLD_INFO 0x803
#define TASK_CRASHINFO_UUID 0x804
#define TASK_CRASHINFO_PID 0x805
#define TASK_CRASHINFO_PPID 0x806
#define TASK_CRASHINFO_RUSAGE 0x807 /* struct rusage DEPRECATED do not use.
* This struct has longs in it */
#define TASK_CRASHINFO_RUSAGE_INFO 0x808 /* struct rusage_info_v3 from resource.h */
#define TASK_CRASHINFO_PROC_NAME 0x809 /* char * */
#define TASK_CRASHINFO_PROC_STARTTIME 0x80B /* struct timeval64 */
#define TASK_CRASHINFO_USERSTACK 0x80C /* uint64_t */
#define TASK_CRASHINFO_ARGSLEN 0x80D
#define TASK_CRASHINFO_EXCEPTION_CODES 0x80E /* mach_exception_data_t */
#define TASK_CRASHINFO_PROC_PATH 0x80F /* string of len MAXPATHLEN */
#define TASK_CRASHINFO_PROC_CSFLAGS 0x810 /* uint32_t */
#define TASK_CRASHINFO_PROC_STATUS 0x811 /* char */
#define TASK_CRASHINFO_UID 0x812 /* uid_t */
#define TASK_CRASHINFO_GID 0x813 /* gid_t */
#define TASK_CRASHINFO_PROC_ARGC 0x814 /* int */
#define TASK_CRASHINFO_PROC_FLAGS 0x815 /* unsigned int */
#define TASK_CRASHINFO_CPUTYPE 0x816 /* cpu_type_t */
#define TASK_CRASHINFO_WORKQUEUEINFO 0x817 /* struct proc_workqueueinfo */
#define TASK_CRASHINFO_RESPONSIBLE_PID 0x818 /* pid_t */
#define TASK_CRASHINFO_DIRTY_FLAGS 0x819 /* int */
#define TASK_CRASHINFO_CRASHED_THREADID 0x81A /* uint64_t */
#define TASK_CRASHINFO_COALITION_ID 0x81B /* uint64_t */
#define TASK_CRASHINFO_UDATA_PTRS 0x81C /* uint64_t */
#define TASK_CRASHINFO_MEMORY_LIMIT 0x81D /* uint64_t */
#define TASK_CRASHINFO_LEDGER_INTERNAL 0x81E /* uint64_t */
#define TASK_CRASHINFO_LEDGER_INTERNAL_COMPRESSED 0x81F /* uint64_t */
#define TASK_CRASHINFO_LEDGER_IOKIT_MAPPED 0x820 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_ALTERNATE_ACCOUNTING 0x821 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_ALTERNATE_ACCOUNTING_COMPRESSED 0x822 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_PURGEABLE_NONVOLATILE 0x823 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_PURGEABLE_NONVOLATILE_COMPRESSED 0x824 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_PAGE_TABLE 0x825 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_PHYS_FOOTPRINT 0x826 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_PHYS_FOOTPRINT_LIFETIME_MAX 0x827 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE 0x828 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE_COMPRESSED 0x829 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_WIRED_MEM 0x82A /* uint64_t */
#define TASK_CRASHINFO_PROC_PERSONA_ID 0x82B /* uid_t */
#define TASK_CRASHINFO_MEMORY_LIMIT_INCREASE 0x82C /* uint32_t */
#define TASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT 0x82D /* uint64_t */
#define TASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT_COMPRESSED 0x82E /* uint64_t */
#define TASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT 0x82F /* uint64_t */
#define TASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT_COMPRESSED 0x830 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT 0x831 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT_COMPRESSED 0x832 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT 0x833 /* uint64_t */
#define TASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT_COMPRESSED 0x834 /* uint64_t */
#define TASK_CRASHINFO_MEMORYSTATUS_EFFECTIVE_PRIORITY 0x835 /* int32_t */
#define TASK_CRASHINFO_KERNEL_TRIAGE_INFO_V1 0x836 /* struct kernel_triage_info_v1 */
#define TASK_CRASHINFO_TASK_IS_CORPSE_FORK 0x837 /* boolean_t */
#define TASK_CRASHINFO_EXCEPTION_TYPE 0x838 /* int */
#define TASK_CRASHINFO_END KCDATA_TYPE_BUFFER_END
/**************** definitions for os reasons *********************/
#define EXIT_REASON_SNAPSHOT 0x1001
#define EXIT_REASON_USER_DESC 0x1002 /* string description of reason */
#define EXIT_REASON_USER_PAYLOAD 0x1003 /* user payload data */
#define EXIT_REASON_CODESIGNING_INFO 0x1004
#define EXIT_REASON_WORKLOOP_ID 0x1005
#define EXIT_REASON_DISPATCH_QUEUE_NO 0x1006
struct exit_reason_snapshot {
uint32_t ers_namespace;
uint64_t ers_code;
/* end of version 1 of exit_reason_snapshot. sizeof v1 was 12 */
uint64_t ers_flags;
} __attribute__((packed));
#define EXIT_REASON_CODESIG_PATH_MAX 1024
struct codesigning_exit_reason_info {
uint64_t ceri_virt_addr;
uint64_t ceri_file_offset;
char ceri_pathname[EXIT_REASON_CODESIG_PATH_MAX];
char ceri_filename[EXIT_REASON_CODESIG_PATH_MAX];
uint64_t ceri_codesig_modtime_secs;
uint64_t ceri_codesig_modtime_nsecs;
uint64_t ceri_page_modtime_secs;
uint64_t ceri_page_modtime_nsecs;
uint8_t ceri_path_truncated;
uint8_t ceri_object_codesigned;
uint8_t ceri_page_codesig_validated;
uint8_t ceri_page_codesig_tainted;
uint8_t ceri_page_codesig_nx;
uint8_t ceri_page_wpmapped;
uint8_t ceri_page_slid;
uint8_t ceri_page_dirty;
uint32_t ceri_page_shadow_depth;
} __attribute__((packed));
#define EXIT_REASON_USER_DESC_MAX_LEN 1024
#define EXIT_REASON_PAYLOAD_MAX_LEN 2048
/**************** safe iterators *********************/
typedef struct kcdata_iter {
kcdata_item_t item;
void *end;
} kcdata_iter_t;
static inline
kcdata_iter_t
kcdata_iter(void *buffer, unsigned long size)
{
kcdata_iter_t iter;
iter.item = (kcdata_item_t) buffer;
iter.end = (void*) (((uintptr_t)buffer) + size);
return iter;
}
static inline
kcdata_iter_t kcdata_iter_unsafe(void *buffer) __attribute__((deprecated));
static inline
kcdata_iter_t
kcdata_iter_unsafe(void *buffer)
{
kcdata_iter_t iter;
iter.item = (kcdata_item_t) buffer;
iter.end = (void*) (uintptr_t) ~0;
return iter;
}
static const kcdata_iter_t kcdata_invalid_iter = { .item = NULL, .end = NULL };
static inline
int
kcdata_iter_valid(kcdata_iter_t iter)
{
return
((uintptr_t)iter.item + sizeof(struct kcdata_item) <= (uintptr_t)iter.end) &&
((uintptr_t)iter.item + sizeof(struct kcdata_item) + iter.item->size <= (uintptr_t)iter.end);
}
static inline
kcdata_iter_t
kcdata_iter_next(kcdata_iter_t iter)
{
iter.item = (kcdata_item_t) (((uintptr_t)iter.item) + sizeof(struct kcdata_item) + (iter.item->size));
return iter;
}
static inline uint32_t
kcdata_iter_type(kcdata_iter_t iter)
{
if ((iter.item->type & ~0xfu) == KCDATA_TYPE_ARRAY_PAD0) {
return KCDATA_TYPE_ARRAY;
} else {
return iter.item->type;
}
}
static inline uint32_t
kcdata_calc_padding(uint32_t size)
{
/* calculate number of bytes to add to size to get something divisible by 16 */
return (-size) & 0xf;
}
static inline uint32_t
kcdata_flags_get_padding(uint64_t flags)
{
return flags & KCDATA_FLAGS_STRUCT_PADDING_MASK;
}
/* see comment above about has_padding */
static inline int
kcdata_iter_is_legacy_item(kcdata_iter_t iter, uint32_t legacy_size)
{
uint32_t legacy_size_padded = legacy_size + kcdata_calc_padding(legacy_size);
return iter.item->size == legacy_size_padded &&
(iter.item->flags & (KCDATA_FLAGS_STRUCT_PADDING_MASK | KCDATA_FLAGS_STRUCT_HAS_PADDING)) == 0;
}
static inline uint32_t
kcdata_iter_size(kcdata_iter_t iter)
{
uint32_t legacy_size = 0;
switch (kcdata_iter_type(iter)) {
case KCDATA_TYPE_ARRAY:
case KCDATA_TYPE_CONTAINER_BEGIN:
return iter.item->size;
case STACKSHOT_KCTYPE_THREAD_SNAPSHOT: {
legacy_size = sizeof(struct thread_snapshot_v2);
if (kcdata_iter_is_legacy_item(iter, legacy_size)) {
return legacy_size;
}
goto not_legacy;
}
case STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO: {
legacy_size = sizeof(struct dyld_uuid_info_64);
if (kcdata_iter_is_legacy_item(iter, legacy_size)) {
return legacy_size;
}
goto not_legacy;
}
not_legacy:
default:
if (iter.item->size < kcdata_flags_get_padding(iter.item->flags)) {
return 0;
} else {
return iter.item->size - kcdata_flags_get_padding(iter.item->flags);
}
}
}
static inline uint64_t
kcdata_iter_flags(kcdata_iter_t iter)
{
return iter.item->flags;
}
static inline
void *
kcdata_iter_payload(kcdata_iter_t iter)
{
return &iter.item->data;
}
static inline
uint32_t
kcdata_iter_array_elem_type(kcdata_iter_t iter)
{
return (iter.item->flags >> 32) & UINT32_MAX;
}
static inline
uint32_t
kcdata_iter_array_elem_count(kcdata_iter_t iter)
{
return (iter.item->flags) & UINT32_MAX;
}
/* KCDATA_TYPE_ARRAY is ambiguous about the size of the array elements. Size is
* calculated as total_size / elements_count, but total size got padded out to a
* 16 byte alignment. New kernels will generate KCDATA_TYPE_ARRAY_PAD* instead
* to explicitly tell us how much padding was used. Here we have a fixed, never
* to be altered list of the sizes of array elements that were used before I
* discovered this issue. If you find a KCDATA_TYPE_ARRAY that is not one of
* these types, treat it as invalid data. */
static inline
uint32_t
kcdata_iter_array_size_switch(kcdata_iter_t iter)
{
switch (kcdata_iter_array_elem_type(iter)) {
case KCDATA_TYPE_LIBRARY_LOADINFO:
return sizeof(struct dyld_uuid_info_32);
case KCDATA_TYPE_LIBRARY_LOADINFO64:
return sizeof(struct dyld_uuid_info_64);
case STACKSHOT_KCTYPE_KERN_STACKFRAME:
case STACKSHOT_KCTYPE_USER_STACKFRAME:
return sizeof(struct stack_snapshot_frame32);
case STACKSHOT_KCTYPE_KERN_STACKFRAME64:
case STACKSHOT_KCTYPE_USER_STACKFRAME64:
return sizeof(struct stack_snapshot_frame64);
case STACKSHOT_KCTYPE_DONATING_PIDS:
return sizeof(int32_t);
case STACKSHOT_KCTYPE_THREAD_DELTA_SNAPSHOT:
return sizeof(struct thread_delta_snapshot_v2);
// This one is only here to make some unit tests work. It should be OK to
// remove.
case TASK_CRASHINFO_CRASHED_THREADID:
return sizeof(uint64_t);
default:
return 0;
}
}
static inline
int
kcdata_iter_array_valid(kcdata_iter_t iter)
{
if (!kcdata_iter_valid(iter)) {
return 0;
}
if (kcdata_iter_type(iter) != KCDATA_TYPE_ARRAY) {
return 0;
}
if (kcdata_iter_array_elem_count(iter) == 0) {
return iter.item->size == 0;
}
if (iter.item->type == KCDATA_TYPE_ARRAY) {
uint32_t elem_size = kcdata_iter_array_size_switch(iter);
if (elem_size == 0) {
return 0;
}
/* sizes get aligned to the nearest 16. */
return
kcdata_iter_array_elem_count(iter) <= iter.item->size / elem_size &&
iter.item->size % kcdata_iter_array_elem_count(iter) < 16;
} else {
return
(iter.item->type & 0xf) <= iter.item->size &&
kcdata_iter_array_elem_count(iter) <= iter.item->size - (iter.item->type & 0xf) &&
(iter.item->size - (iter.item->type & 0xf)) % kcdata_iter_array_elem_count(iter) == 0;
}
}
static inline
uint32_t
kcdata_iter_array_elem_size(kcdata_iter_t iter)
{
if (iter.item->type == KCDATA_TYPE_ARRAY) {
return kcdata_iter_array_size_switch(iter);
}
if (kcdata_iter_array_elem_count(iter) == 0) {
return 0;
}
return (iter.item->size - (iter.item->type & 0xf)) / kcdata_iter_array_elem_count(iter);
}
static inline
int
kcdata_iter_container_valid(kcdata_iter_t iter)
{
return
kcdata_iter_valid(iter) &&
kcdata_iter_type(iter) == KCDATA_TYPE_CONTAINER_BEGIN &&
iter.item->size >= sizeof(uint32_t);
}
static inline
uint32_t
kcdata_iter_container_type(kcdata_iter_t iter)
{
return *(uint32_t *) kcdata_iter_payload(iter);
}
static inline
uint64_t
kcdata_iter_container_id(kcdata_iter_t iter)
{
return iter.item->flags;
}
#define KCDATA_ITER_FOREACH(iter) for(; kcdata_iter_valid(iter) && iter.item->type != KCDATA_TYPE_BUFFER_END; iter = kcdata_iter_next(iter))
#define KCDATA_ITER_FOREACH_FAILED(iter) (!kcdata_iter_valid(iter) || (iter).item->type != KCDATA_TYPE_BUFFER_END)
static inline
kcdata_iter_t
kcdata_iter_find_type(kcdata_iter_t iter, uint32_t type)
{
KCDATA_ITER_FOREACH(iter)
{
if (kcdata_iter_type(iter) == type) {
return iter;
}
}
return kcdata_invalid_iter;
}
static inline
int
kcdata_iter_data_with_desc_valid(kcdata_iter_t iter, uint32_t minsize)
{
return
kcdata_iter_valid(iter) &&
kcdata_iter_size(iter) >= KCDATA_DESC_MAXLEN + minsize &&
((char*)kcdata_iter_payload(iter))[KCDATA_DESC_MAXLEN - 1] == 0;
}
static inline
char *
kcdata_iter_string(kcdata_iter_t iter, uint32_t offset)
{
if (offset > kcdata_iter_size(iter)) {
return NULL;
}
uint32_t maxlen = kcdata_iter_size(iter) - offset;
char *s = ((char*)kcdata_iter_payload(iter)) + offset;
if (strnlen(s, maxlen) < maxlen) {
return s;
} else {
return NULL;
}
}
static inline void
kcdata_iter_get_data_with_desc(kcdata_iter_t iter, char **desc_ptr, void **data_ptr, uint32_t *size_ptr)
{
if (desc_ptr) {
*desc_ptr = (char *)kcdata_iter_payload(iter);
}
if (data_ptr) {
*data_ptr = (void *)((uintptr_t)kcdata_iter_payload(iter) + KCDATA_DESC_MAXLEN);
}
if (size_ptr) {
*size_ptr = kcdata_iter_size(iter) - KCDATA_DESC_MAXLEN;
}
}
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/monotonic.h | /*
* Copyright (c) 2017-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef KERN_MONOTONIC_H
#define KERN_MONOTONIC_H
#if MONOTONIC
#include <stdbool.h>
#include <stdint.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
extern bool mt_debug;
extern _Atomic uint64_t mt_pmis;
extern _Atomic uint64_t mt_retrograde;
void mt_fixed_counts(uint64_t *counts);
void mt_cur_thread_fixed_counts(uint64_t *counts);
void mt_cur_task_fixed_counts(uint64_t *counts);
uint64_t mt_cur_cpu_instrs(void);
uint64_t mt_cur_cpu_cycles(void);
void mt_cur_cpu_cycles_instrs_speculative(uint64_t *cycles, uint64_t *instrs);
uint64_t mt_cur_thread_instrs(void);
uint64_t mt_cur_thread_cycles(void);
bool mt_acquire_counters(void);
bool mt_owns_counters(void);
void mt_ownership_change(bool available);
void mt_release_counters(void);
__END_DECLS
#endif /* MONOTONIC */
#endif /* !defined(KERN_MONOTONIC_H) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/thread_group.h | /*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Thread group support routines.
*/
#ifndef _KERN_THREAD_GROUP_H_
#define _KERN_THREAD_GROUP_H_
struct thread_group;
#include <mach/thread_status.h> /* for proc_reg.h / CONFIG_THREAD_GROUPS */
#ifndef CONFIG_THREAD_GROUPS
#error "The platform must define CONFIG_THREAD_GROUPS to 0 or 1"
#endif
#if CONFIG_THREAD_GROUPS
#include <kern/queue.h>
#include <machine/machine_routines.h>
#define THREAD_GROUP_MAX (CONFIG_TASK_MAX + 10)
#define THREAD_GROUP_MAXNAME (32)
#define THREAD_GROUP_SYSTEM 0 // kernel (-VM) + launchd
#define THREAD_GROUP_BACKGROUND 1 // background daemons
#define THREAD_GROUP_VM 3 // kernel VM threads
#define THREAD_GROUP_IO_STORAGE 4 // kernel io storage threads
#define THREAD_GROUP_PERF_CONTROLLER 5 // kernel CLPC threads
#define THREAD_GROUP_INVALID UINT64_MAX
/* Thread group flags */
#define THREAD_GROUP_FLAGS_EFFICIENT 0x1
#define THREAD_GROUP_FLAGS_UI_APP 0x2
#define THREAD_GROUP_FLAGS_SMP_RESTRICT 0x4
#define THREAD_GROUP_FLAGS_VALID (THREAD_GROUP_FLAGS_EFFICIENT | THREAD_GROUP_FLAGS_UI_APP | THREAD_GROUP_FLAGS_SMP_RESTRICT)
__BEGIN_DECLS
void thread_group_init(void);
void thread_group_resync(boolean_t create);
struct thread_group *thread_group_create_and_retain(boolean_t efficient);
void thread_group_init_thread(thread_t t, task_t task);
void thread_group_set_name(struct thread_group *tg, const char *name);
void thread_group_flags_update_lock(void);
void thread_group_flags_update_unlock(void);
void thread_group_set_flags(struct thread_group *tg, uint64_t flags);
uint32_t thread_group_get_flags(struct thread_group *);
void thread_group_clear_flags(struct thread_group *tg, uint64_t flags);
void thread_group_set_flags_locked(struct thread_group *tg, uint64_t flags);
void thread_group_clear_flags_locked(struct thread_group *tg, uint64_t flags);
struct thread_group *thread_group_find_by_name_and_retain(char *name);
struct thread_group *thread_group_find_by_id_and_retain(uint64_t id);
struct thread_group *thread_group_retain(struct thread_group *tg);
void thread_group_release(struct thread_group *tg);
void thread_group_release_live(struct thread_group *tg);
void thread_group_deallocate_safe(struct thread_group *tg);
struct thread_group *thread_group_get(thread_t t);
struct thread_group *thread_group_get_home_group(thread_t t);
void thread_group_set_bank(thread_t t, struct thread_group *tg);
uint64_t thread_group_get_id(struct thread_group *tg);
uint32_t thread_group_count(void);
const char * thread_group_get_name(struct thread_group *tg);
void * thread_group_get_machine_data(struct thread_group *tg);
uint32_t thread_group_machine_data_size(void);
boolean_t thread_group_uses_immediate_ipi(struct thread_group *tg);
cluster_type_t thread_group_recommendation(struct thread_group *tg);
typedef void (*thread_group_iterate_fn_t)(void*, int, struct thread_group *);
kern_return_t thread_group_iterate_stackshot(thread_group_iterate_fn_t callout, void *arg);
boolean_t thread_group_smp_restricted(struct thread_group *tg);
void thread_group_update_recommendation(struct thread_group *tg, cluster_type_t new_recommendation);
uint64_t thread_group_id(struct thread_group *tg);
void thread_set_work_interval_thread_group(thread_t t, struct thread_group *tg);
#if CONFIG_SCHED_AUTO_JOIN
void thread_set_autojoin_thread_group_locked(thread_t t, struct thread_group *tg);
#endif
#if CONFIG_PREADOPT_TG
void thread_set_preadopt_thread_group(thread_t t, struct thread_group *tg);
#endif
void thread_resolve_and_enforce_thread_group_hierarchy_if_needed(thread_t t);
__END_DECLS
#endif /* CONFIG_THREAD_GROUPS */
#endif // _KERN_THREAD_GROUP_H_
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/lock_sleep.h | /*
* Copyright (c) 2021 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_LOCK_SLEEP_H_
#define _KERN_LOCK_SLEEP_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
#error "include <kern/lock_types.h> instead"
__END_DECLS
#endif /* _KERN_LOCK_SLEEP_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/lock_rw.h | /*
* Copyright (c) 2021 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_RW_LOCK_H_
#define _KERN_RW_LOCK_H_
#include <kern/lock_types.h>
#include <kern/lock_group.h>
#include <kern/lock_attr.h>
__BEGIN_DECLS
typedef struct __lck_rw_t__ lck_rw_t;
#if DEVELOPMENT || DEBUG
#endif /* DEVELOPMENT || DEBUG */
typedef unsigned int lck_rw_type_t;
#define LCK_RW_TYPE_SHARED 0x01
#define LCK_RW_TYPE_EXCLUSIVE 0x02
#define decl_lck_rw_data(class, name) class lck_rw_t name
#if MACH_ASSERT
#define LCK_RW_ASSERT(lck, type) lck_rw_assert((lck),(type))
#else /* MACH_ASSERT */
#define LCK_RW_ASSERT(lck, type)
#endif /* MACH_ASSERT */
#if DEBUG
#define LCK_RW_ASSERT_DEBUG(lck, type) lck_rw_assert((lck),(type))
#else /* DEBUG */
#define LCK_RW_ASSERT_DEBUG(lck, type)
#endif /* DEBUG */
/*!
* @function lck_rw_alloc_init
*
* @abstract
* Allocates and initializes a rw_lock_t.
*
* @discussion
* The function can block. See lck_rw_init() for initialization details.
*
* @param grp lock group to associate with the lock.
* @param attr lock attribute to initialize the lock.
*
* @returns NULL or the allocated lock
*/
extern lck_rw_t *lck_rw_alloc_init(
lck_grp_t *grp,
lck_attr_t *attr);
/*!
* @function lck_rw_init
*
* @abstract
* Initializes a rw_lock_t.
*
* @discussion
* Usage statistics for the lock are going to be added to the lock group provided.
*
* The lock attribute can be LCK_ATTR_NULL or an attribute can be allocated with
* lck_attr_alloc_init. So far however none of the attribute settings are supported.
*
* @param lck lock to initialize.
* @param grp lock group to associate with the lock.
* @param attr lock attribute to initialize the lock.
*/
extern void lck_rw_init(
lck_rw_t *lck,
lck_grp_t *grp,
lck_attr_t *attr);
/*!
* @function lck_rw_free
*
* @abstract
* Frees a rw_lock previously allocated with lck_rw_alloc_init().
*
* @discussion
* The lock must be not held by any thread.
*
* @param lck rw_lock to free.
*/
extern void lck_rw_free(
lck_rw_t *lck,
lck_grp_t *grp);
/*!
* @function lck_rw_destroy
*
* @abstract
* Destroys a rw_lock previously initialized with lck_rw_init().
*
* @discussion
* The lock must be not held by any thread.
*
* @param lck rw_lock to destroy.
*/
extern void lck_rw_destroy(
lck_rw_t *lck,
lck_grp_t *grp);
/*!
* @function lck_rw_lock
*
* @abstract
* Locks a rw_lock with the specified type.
*
* @discussion
* See lck_rw_lock_shared() or lck_rw_lock_exclusive() for more details.
*
* @param lck rw_lock to lock.
* @param lck_rw_type LCK_RW_TYPE_SHARED or LCK_RW_TYPE_EXCLUSIVE
*/
extern void lck_rw_lock(
lck_rw_t *lck,
lck_rw_type_t lck_rw_type);
/*!
* @function lck_rw_try_lock
*
* @abstract
* Tries to locks a rw_lock with the specified type.
*
* @discussion
* This function will return and not wait/block in case the lock is already held.
* See lck_rw_try_lock_shared() or lck_rw_try_lock_exclusive() for more details.
*
* @param lck rw_lock to lock.
* @param lck_rw_type LCK_RW_TYPE_SHARED or LCK_RW_TYPE_EXCLUSIVE
*
* @returns TRUE if the lock is successfully acquired, FALSE in case it was already held.
*/
extern boolean_t lck_rw_try_lock(
lck_rw_t *lck,
lck_rw_type_t lck_rw_type);
/*!
* @function lck_rw_unlock
*
* @abstract
* Unlocks a rw_lock previously locked with lck_rw_type.
*
* @discussion
* The lock must be unlocked by the same thread it was locked from.
* The type of the lock/unlock have to match, unless an upgrade/downgrade was performed while
* holding the lock.
*
* @param lck rw_lock to unlock.
* @param lck_rw_type LCK_RW_TYPE_SHARED or LCK_RW_TYPE_EXCLUSIVE
*/
extern void lck_rw_unlock(
lck_rw_t *lck,
lck_rw_type_t lck_rw_type);
/*!
* @function lck_rw_lock_shared
*
* @abstract
* Locks a rw_lock in shared mode.
*
* @discussion
* This function can block.
* Multiple threads can acquire the lock in shared mode at the same time, but only one thread at a time
* can acquire it in exclusive mode.
* If the lock is held in shared mode and there are no writers waiting, a reader will be able to acquire
* the lock without waiting.
* If the lock is held in shared mode and there is at least a writer waiting, a reader will wait
* for all the writers to make progress.
* NOTE: the thread cannot return to userspace while the lock is held. Recursive locking is not supported.
*
* @param lck rw_lock to lock.
*/
extern void lck_rw_lock_shared(
lck_rw_t *lck);
/*!
* @function lck_rw_lock_shared_to_exclusive
*
* @abstract
* Upgrades a rw_lock held in shared mode to exclusive.
*
* @discussion
* This function can block.
* Only one reader at a time can upgrade to exclusive mode. If the upgrades fails the function will
* return with the lock not held.
* The caller needs to hold the lock in shared mode to upgrade it.
*
* @param lck rw_lock already held in shared mode to upgrade.
*
* @returns TRUE if the lock was upgraded, FALSE if it was not possible.
* If the function was not able to upgrade the lock, the lock will be dropped
* by the function.
*/
extern boolean_t lck_rw_lock_shared_to_exclusive(
lck_rw_t *lck);
/*!
* @function lck_rw_unlock_shared
*
* @abstract
* Unlocks a rw_lock previously locked in shared mode.
*
* @discussion
* The same thread that locked the lock needs to unlock it.
*
* @param lck rw_lock held in shared mode to unlock.
*/
extern void lck_rw_unlock_shared(
lck_rw_t *lck);
/*!
* @function lck_rw_lock_exclusive
*
* @abstract
* Locks a rw_lock in exclusive mode.
*
* @discussion
* This function can block.
* Multiple threads can acquire the lock in shared mode at the same time, but only one thread at a time
* can acquire it in exclusive mode.
* NOTE: the thread cannot return to userspace while the lock is held. Recursive locking is not supported.
*
* @param lck rw_lock to lock.
*/
extern void lck_rw_lock_exclusive(
lck_rw_t *lck);
/*!
* @function lck_rw_lock_exclusive_to_shared
*
* @abstract
* Downgrades a rw_lock held in exclusive mode to shared.
*
* @discussion
* The caller needs to hold the lock in exclusive mode to be able to downgrade it.
*
* @param lck rw_lock already held in exclusive mode to downgrade.
*/
extern void lck_rw_lock_exclusive_to_shared(
lck_rw_t *lck);
/*!
* @function lck_rw_unlock_exclusive
*
* @abstract
* Unlocks a rw_lock previously locked in exclusive mode.
*
* @discussion
* The same thread that locked the lock needs to unlock it.
*
* @param lck rw_lock held in exclusive mode to unlock.
*/
extern void lck_rw_unlock_exclusive(
lck_rw_t *lck);
/*!
* @function lck_rw_sleep
*
* @abstract
* Assert_wait on an event while holding the rw_lock.
*
* @discussion
* the flags can decide how to re-acquire the lock upon wake up
* (LCK_SLEEP_SHARED, or LCK_SLEEP_EXCLUSIVE, or LCK_SLEEP_UNLOCK)
* and if the priority needs to be kept boosted until the lock is
* re-acquired (LCK_SLEEP_PROMOTED_PRI).
*
* @param lck rw_lock to use to synch the assert_wait.
* @param lck_sleep_action flags.
* @param event event to assert_wait on.
* @param interruptible wait type.
*/
extern wait_result_t lck_rw_sleep(
lck_rw_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible);
/*!
* @function lck_rw_sleep_deadline
*
* @abstract
* Assert_wait_deadline on an event while holding the rw_lock.
*
* @discussion
* the flags can decide how to re-acquire the lock upon wake up
* (LCK_SLEEP_SHARED, or LCK_SLEEP_EXCLUSIVE, or LCK_SLEEP_UNLOCK)
* and if the priority needs to be kept boosted until the lock is
* re-acquired (LCK_SLEEP_PROMOTED_PRI).
*
* @param lck rw_lock to use to synch the assert_wait.
* @param lck_sleep_action flags.
* @param event event to assert_wait on.
* @param interruptible wait type.
* @param deadline maximum time after which being woken up
*/
extern wait_result_t lck_rw_sleep_deadline(
lck_rw_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
__END_DECLS
#endif /* _KERN_RW_LOCK_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/kern_types.h | /*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _KERN_KERN_TYPES_H_
#define _KERN_KERN_TYPES_H_
#include <stdint.h>
#include <mach/mach_types.h>
#include <mach/machine/vm_types.h>
typedef void *event_t; /* wait event */
#define NO_EVENT ((event_t) 0)
typedef uint64_t event64_t; /* 64 bit wait event */
#define NO_EVENT64 ((event64_t) 0)
#define CAST_EVENT64_T(a_ptr) ((event64_t)((uintptr_t)(a_ptr)))
/*
* Possible wait_result_t values.
*/
typedef int wait_result_t;
#define THREAD_WAITING -1 /* thread is waiting */
#define THREAD_AWAKENED 0 /* normal wakeup */
#define THREAD_TIMED_OUT 1 /* timeout expired */
#define THREAD_INTERRUPTED 2 /* aborted/interrupted */
#define THREAD_RESTART 3 /* restart operation entirely */
#define THREAD_NOT_WAITING 10 /* thread didn't need to wait */
typedef void (*thread_continue_t)(void *, wait_result_t);
#define THREAD_CONTINUE_NULL ((thread_continue_t) NULL)
/*
* Interruptible flag for waits.
*
* THREAD_UNINT: Uninterruptible wait
* Wait will only end when someone explicitly wakes up the thread, or if the
* wait timeout expires.
*
* Use this state if the system as a whole cannot recover from a thread being
* interrupted out of the wait.
*
* THREAD_INTERRUPTIBLE:
* Wait will end if someone explicitly wakes up the thread, the wait timeout
* expires, or the current thread is being terminated.
*
* This value can be used when your operation may not be cleanly restartable
* for the current process or thread (i.e. the loss of state would be only visible
* to the current client). Since the thread is exiting anyways, you're willing
* to cut the operation short. The system as a whole must be able to cleanly
* deal with the interruption (i.e. remain in a consistent and recoverable state).
*
* THREAD_ABORTSAFE:
* Wait will end if someone explicitly wakes up the thread, the wait timeout
* expires, the current thread is being terminated, if any signal arrives for
* the task, or thread_abort_safely() is called on the thread.
*
* Using this value means that you are willing to be interrupted in the face
* of any user signal, and safely rewind the thread back to the user/kernel
* boundary. Many syscalls will try to restart the operation they were performing
* after the signal has been handled.
*
* You must provide this value for any unbounded wait - otherwise you will
* pend user signals forever.
*
* THREAD_WAIT_NOREPORT:
* The scheduler has a callback (sched_call) that some subsystems use to
* decide whether more threads should be thrown at a given problem by trying
* to maintain a good level of concurrency.
*
* When the wait will not be helped by adding more threads (e.g. lock
* contention), using this flag as an argument to assert_wait* (or any of its
* wrappers) will prevent the next wait/block to cause thread creation.
*
* This comes in two flavors: THREAD_WAIT_NOREPORT_KERNEL, and
* THREAD_WAIT_NOREPORT_USER to prevent reporting about the wait for kernel
* and user threads respectively.
*
* Thread interrupt mask:
*
* The current maximum interruptible state for the thread, as set by
* thread_interrupt_level(), will limit the conditions that will cause a wake.
* This is useful for code that can't be interrupted to set before calling code
* that doesn't know that.
*
* Thread termination vs safe abort:
*
* Termination abort: thread_abort(), thread_terminate()
*
* A termination abort is sticky. Once a thread is marked for termination, every
* THREAD_INTERRUPTIBLE wait will return immediately with THREAD_INTERRUPTED
* until the thread successfully exits.
*
* Safe abort: thread_abort_safely()
*
* A safe abort is not sticky. The current wait, (or the next wait if the thread
* is not currently waiting) will be interrupted, but then the abort condition is cleared.
* The next wait will sleep as normal. Safe aborts only have a single effect.
*
* The path back to the user/kernel boundary must not make any further unbounded
* wait calls. The waiter should detect the THREAD_INTERRUPTED return code
* from an ABORTSAFE wait and return an error code that causes its caller
* to understand that the current operation has been interrupted, and its
* caller should return a similar error code, and so on until the
* user/kernel boundary is reached. For Mach, the error code is usually KERN_ABORTED,
* for BSD it is EINTR.
*
* Debuggers rely on the safe abort mechanism - a signaled thread must return to
* the AST at the user/kernel boundary for the debugger to finish attaching.
*
* No wait/block will ever disappear a thread out from under the waiter. The block
* call will always either return or call the passed in continuation.
*/
typedef int wait_interrupt_t;
#define THREAD_UNINT 0x00000000 /* not interruptible */
#define THREAD_INTERRUPTIBLE 0x00000001 /* may not be restartable */
#define THREAD_ABORTSAFE 0x00000002 /* abortable safely */
#define THREAD_WAIT_NOREPORT_KERNEL 0x80000000
#define THREAD_WAIT_NOREPORT_USER 0x40000000
#define THREAD_WAIT_NOREPORT (THREAD_WAIT_NOREPORT_KERNEL | THREAD_WAIT_NOREPORT_USER)
typedef int wait_timeout_urgency_t;
#define TIMEOUT_URGENCY_SYS_NORMAL 0x00 /* use default leeway thresholds for system */
#define TIMEOUT_URGENCY_SYS_CRITICAL 0x01 /* use critical leeway thresholds for system */
#define TIMEOUT_URGENCY_SYS_BACKGROUND 0x02 /* use background leeway thresholds for system */
#define TIMEOUT_URGENCY_USER_MASK 0x10 /* mask to identify user timeout urgency classes */
#define TIMEOUT_URGENCY_USER_NORMAL 0x10 /* use default leeway thresholds for user */
#define TIMEOUT_URGENCY_USER_CRITICAL 0x11 /* use critical leeway thresholds for user */
#define TIMEOUT_URGENCY_USER_BACKGROUND 0x12 /* use background leeway thresholds for user */
#define TIMEOUT_URGENCY_MASK 0x13 /* mask to identify timeout urgency */
#define TIMEOUT_URGENCY_LEEWAY 0x20 /* don't ignore provided leeway value */
#define TIMEOUT_URGENCY_FIRST_AVAIL 0x40 /* first available bit outside of urgency mask/leeway */
#define TIMEOUT_URGENCY_RATELIMITED 0x80
/*
* Timeout and deadline tokens for waits.
* The following tokens define common values for leeway and deadline parameters.
*/
#define TIMEOUT_NO_LEEWAY (0ULL)
#define TIMEOUT_WAIT_FOREVER (0ULL)
#endif /* _KERN_KERN_TYPES_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/task_ref.h | /*
* Copyright (c) 2000-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_TASK_REF_H_
#define _KERN_TASK_REF_H_
#include <mach/mach_types.h>
#include <stdint.h>
__BEGIN_DECLS
extern void task_reference(task_t);
extern void task_deallocate(task_t);
__END_DECLS
#endif /*_KERN_TASK_REF_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/percpu.h | /*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_PERCPU_H_
#define _KERN_PERCPU_H_
#include <mach/vm_types.h>
__BEGIN_DECLS
__END_DECLS
#endif /* _KERN_PERCPU_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/host.h | /*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 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 [email protected]
* 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.
*/
/*
* kern/host.h
*
* Definitions for host data structures.
*
*/
#ifndef _KERN_HOST_H_
#define _KERN_HOST_H_
#include <mach/mach_types.h>
#include <sys/cdefs.h>
/*
* Access routines for inside the kernel.
*/
__BEGIN_DECLS
extern host_t host_self(void);
extern host_priv_t host_priv_self(void);
__END_DECLS
#endif /* _KERN_HOST_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/restartable.h | /*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_RESTARTABLE_H_
#define _KERN_RESTARTABLE_H_
#include <sys/cdefs.h>
#include <mach/message.h>
#include <mach/task.h>
__BEGIN_DECLS
/*!
* @typedef task_restartable_range_t
*
* @brief
* Describes a userspace recoverable range.
*
* @field location
* The pointer to the beginning of a restartable section.
*
* @field length
* The length of the critical section anchored at location.
*
* @field recovery_offs
* The offset from the initial location that should be used for the recovery
* codepath.
*
* @field flags
* Currently unused, pass 0.
*/
typedef struct {
mach_vm_address_t location;
unsigned short length;
unsigned short recovery_offs;
unsigned int flags;
} task_restartable_range_t;
typedef task_restartable_range_t *task_restartable_range_array_t;
/*!
* @function task_restartable_ranges_register
*
* @brief
* Register a set of restartable ranges for the current task.
*
* @param task
* The task to operate on
*
* @param ranges
* An array of address ranges for which PC resets are performed.
*
* @param count
* The number of address ranges.
*
* @returns
* - KERN_SUCCESS on success
* - KERN_FAILURE if the task isn't the current one
* - KERN_INVALID_ARGUMENT for various invalid inputs
* - KERN_NOT_SUPPORTED the request is not supported (second registration on
* release kernels, registration when the task has gone wide)
* - KERN_RESOURCE_SHORTAGE if not enough memory
*/
extern kern_return_t task_restartable_ranges_register(
task_t task,
task_restartable_range_array_t ranges,
mach_msg_type_number_t count);
/*!
* @function task_restartable_ranges_synchronize
*
* @brief
* Require for all threads in the task to reset their PC
* if within a restartable range.
*
* @param task
* The task to operate on (needs to be current task)
*
* @returns
* - KERN_SUCCESS
* - KERN_FAILURE if the task isn't the current one
*/
extern kern_return_t task_restartable_ranges_synchronize(task_t task);
/*!
* @const TASK_RESTARTABLE_OFFSET_MAX
* The maximum value length / recovery_offs can have.
*/
#define TASK_RESTARTABLE_OFFSET_MAX 4096u
__END_DECLS
#endif /* _KERN_RESTARTABLE_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/hv_support.h | /*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_HV_SUPPORT_H_
#define _KERN_HV_SUPPORT_H_
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__x86_64__)
#include <kern/hv_support_kext.h>
#else
#error unsupported arch
#endif
extern int hv_disable;
#if defined(__cplusplus)
}
#endif
#endif /* _KERN_HV_SUPPORT_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/locks.h | /*
* Copyright (c) 2003-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_LOCKS_H_
#define _KERN_LOCKS_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
#include <sys/appleapiopts.h>
#include <mach/boolean.h>
#include <kern/kern_types.h>
#include <kern/lock_group.h>
#include <machine/locks.h>
#include <kern/lock_types.h>
#include <kern/lock_attr.h>
#include <kern/lock_rw.h>
#define decl_lck_spin_data(class, name) class lck_spin_t name
extern lck_spin_t *lck_spin_alloc_init(
lck_grp_t *grp,
lck_attr_t *attr);
extern void lck_spin_init(
lck_spin_t *lck,
lck_grp_t *grp,
lck_attr_t *attr);
extern void lck_spin_lock(
lck_spin_t *lck);
extern void lck_spin_lock_grp(
lck_spin_t *lck,
lck_grp_t *grp);
extern void lck_spin_unlock(
lck_spin_t *lck);
extern void lck_spin_destroy(
lck_spin_t *lck,
lck_grp_t *grp);
extern void lck_spin_free(
lck_spin_t *lck,
lck_grp_t *grp);
extern wait_result_t lck_spin_sleep(
lck_spin_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible);
extern wait_result_t lck_spin_sleep_grp(
lck_spin_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible,
lck_grp_t *grp);
extern wait_result_t lck_spin_sleep_deadline(
lck_spin_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
#define decl_lck_mtx_data(class, name) class lck_mtx_t name
extern lck_mtx_t *lck_mtx_alloc_init(
lck_grp_t *grp,
lck_attr_t *attr);
extern void lck_mtx_init(
lck_mtx_t *lck,
lck_grp_t *grp,
lck_attr_t *attr);
extern void lck_mtx_lock(
lck_mtx_t *lck);
extern void lck_mtx_unlock(
lck_mtx_t *lck);
extern void lck_mtx_destroy(
lck_mtx_t *lck,
lck_grp_t *grp);
extern void lck_mtx_free(
lck_mtx_t *lck,
lck_grp_t *grp);
extern wait_result_t lck_mtx_sleep(
lck_mtx_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible);
extern wait_result_t lck_mtx_sleep_deadline(
lck_mtx_t *lck,
lck_sleep_action_t lck_sleep_action,
event_t event,
wait_interrupt_t interruptible,
uint64_t deadline);
#if DEVELOPMENT || DEBUG
#define FULL_CONTENDED 0
#define HALF_CONTENDED 1
#define MAX_CONDENDED 2
extern void erase_all_test_mtx_stats(void);
extern int get_test_mtx_stats_string(char* buffer, int buffer_size);
extern void lck_mtx_test_init(void);
extern void lck_mtx_test_lock(void);
extern void lck_mtx_test_unlock(void);
extern int lck_mtx_test_mtx_uncontended(int iter, char* buffer, int buffer_size);
extern int lck_mtx_test_mtx_contended(int iter, char* buffer, int buffer_size, int type);
extern int lck_mtx_test_mtx_uncontended_loop_time(int iter, char* buffer, int buffer_size);
extern int lck_mtx_test_mtx_contended_loop_time(int iter, char* buffer, int buffer_size, int type);
#endif
extern void lck_mtx_assert(
lck_mtx_t *lck,
unsigned int type);
#if MACH_ASSERT
#define LCK_MTX_ASSERT(lck, type) lck_mtx_assert((lck),(type))
#define LCK_SPIN_ASSERT(lck, type) lck_spin_assert((lck),(type))
#else /* MACH_ASSERT */
#define LCK_MTX_ASSERT(lck, type)
#define LCK_SPIN_ASSERT(lck, type)
#endif /* MACH_ASSERT */
#if DEBUG
#define LCK_MTX_ASSERT_DEBUG(lck, type) lck_mtx_assert((lck),(type))
#define LCK_SPIN_ASSERT_DEBUG(lck, type) lck_spin_assert((lck),(type))
#else /* DEBUG */
#define LCK_MTX_ASSERT_DEBUG(lck, type)
#define LCK_SPIN_ASSERT_DEBUG(lck, type)
#endif /* DEBUG */
#define LCK_ASSERT_OWNED 1
#define LCK_ASSERT_NOTOWNED 2
#define LCK_MTX_ASSERT_OWNED LCK_ASSERT_OWNED
#define LCK_MTX_ASSERT_NOTOWNED LCK_ASSERT_NOTOWNED
__END_DECLS
#endif /* _KERN_LOCKS_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/remote_time.h | /*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef REMOTE_TIME_H
#define REMOTE_TIME_H
#include <sys/cdefs.h>
#include <stdint.h>
#include <os/overflow.h>
__BEGIN_DECLS
/* bt_params is an ABI for tracing tools */
struct bt_params {
double rate;
uint64_t base_local_ts;
uint64_t base_remote_ts;
};
/* local_ts_ns should be in nanoseconds */
static inline uint64_t
mach_bridge_compute_timestamp(uint64_t local_ts_ns, struct bt_params *params)
{
if (!params || params->rate == 0.0) {
return 0;
}
/*
* Formula to compute remote_timestamp
* remote_timestamp = (bt_params.rate * (local_ts_ns - bt_params.base_local_ts))
* + bt_params.base_remote_ts
*/
int64_t remote_ts = 0;
int64_t rate_prod = 0;
/* To avoid precision loss due to typecasting from int64_t to double */
if (params->rate != 1.0) {
rate_prod = (int64_t)(params->rate * (double)((int64_t)local_ts_ns - (int64_t)params->base_local_ts));
} else {
rate_prod = (int64_t)local_ts_ns - (int64_t)params->base_local_ts;
}
if (os_add_overflow((int64_t)params->base_remote_ts, rate_prod, &remote_ts)) {
return 0;
}
return (uint64_t)remote_ts;
}
uint64_t mach_bridge_remote_time(uint64_t);
__END_DECLS
#endif /* REMOTE_TIME_H */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/bits.h | /*
* Copyright (c) 2015-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*
* Bit manipulation functions
*/
#ifndef __BITS_H__
#define __BITS_H__
#include <kern/assert.h>
#include <kern/kalloc.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdatomic.h>
typedef unsigned int uint;
#define BIT(b) (1ULL << (b))
#define mask(width) (width >= 64 ? -1ULL : (BIT(width) - 1))
#define extract(x, shift, width) ((((uint64_t)(x)) >> (shift)) & mask(width))
#define bits(x, hi, lo) extract((x), (lo), (hi) - (lo) + 1)
#define bit_set(x, b) ((x) |= BIT(b))
#define bit_clear(x, b) ((x) &= ~BIT(b))
#define bit_test(x, b) ((bool)((x) & BIT(b)))
inline static uint64_t
bit_ror64(uint64_t bitmap, uint n)
{
#if defined(__arm64__)
uint64_t result;
uint64_t _n = (uint64_t)n;
asm volatile ("ror %0, %1, %2" : "=r" (result) : "r" (bitmap), "r" (_n));
return result;
#else
n = n & 63;
return (bitmap >> n) | (bitmap << (64 - n));
#endif
}
inline static uint64_t
bit_rol64(uint64_t bitmap, uint n)
{
#if defined(__arm64__)
return bit_ror64(bitmap, 64U - n);
#else
n = n & 63;
return (bitmap << n) | (bitmap >> (64 - n));
#endif
}
/* Non-atomically clear the bit and returns whether the bit value was changed */
#define bit_clear_if_set(bitmap, bit) \
({ \
int _n = (bit); \
__auto_type _map = &(bitmap); \
bool _bit_is_set = bit_test(*_map, _n); \
bit_clear(*_map, _n); \
_bit_is_set; \
})
/* Non-atomically set the bit and returns whether the bit value was changed */
#define bit_set_if_clear(bitmap, bit) \
({ \
int _n = (bit); \
__auto_type _map = &(bitmap); \
bool _bit_is_set = bit_test(*_map, _n); \
bit_set(*_map, _n); \
!_bit_is_set; \
})
/* Returns the most significant '1' bit, or -1 if all zeros */
inline static int
bit_first(uint64_t bitmap)
{
#if defined(__arm64__)
int64_t result;
asm volatile ("clz %0, %1" : "=r" (result) : "r" (bitmap));
return 63 - (int)result;
#else
return (bitmap == 0) ? -1 : 63 - __builtin_clzll(bitmap);
#endif
}
inline static int
__bit_next(uint64_t bitmap, int previous_bit)
{
uint64_t mask = previous_bit ? mask(previous_bit) : ~0ULL;
return bit_first(bitmap & mask);
}
/* Returns the most significant '1' bit that is less significant than previous_bit,
* or -1 if no such bit exists.
*/
inline static int
bit_next(uint64_t bitmap, int previous_bit)
{
if (previous_bit == 0) {
return -1;
} else {
return __bit_next(bitmap, previous_bit);
}
}
/* Returns the least significant '1' bit, or -1 if all zeros */
inline static int
lsb_first(uint64_t bitmap)
{
return __builtin_ffsll((long long)bitmap) - 1;
}
/* Returns the least significant '1' bit that is more significant than previous_bit,
* or -1 if no such bit exists.
* previous_bit may be -1, in which case this is equivalent to lsb_first()
*/
inline static int
lsb_next(uint64_t bitmap, int previous_bit)
{
uint64_t mask = mask(previous_bit + 1);
return lsb_first(bitmap & ~mask);
}
inline static int
bit_count(uint64_t x)
{
return __builtin_popcountll(x);
}
/* Return the highest power of 2 that is <= n, or -1 if n == 0 */
inline static int
bit_floor(uint64_t n)
{
return bit_first(n);
}
/* Return the lowest power of 2 that is >= n, or -1 if n == 0 */
inline static int
bit_ceiling(uint64_t n)
{
if (n == 0) {
return -1;
}
return bit_first(n - 1) + 1;
}
/* If n is a power of 2, bit_log2(n) == bit_floor(n) == bit_ceiling(n) */
#define bit_log2(n) bit_floor((uint64_t)(n))
typedef uint64_t bitmap_t;
inline static bool
atomic_bit_set(_Atomic bitmap_t *map, int n, int mem_order)
{
bitmap_t prev;
prev = __c11_atomic_fetch_or(map, BIT(n), mem_order);
return bit_test(prev, n);
}
inline static bool
atomic_bit_clear(_Atomic bitmap_t *map, int n, int mem_order)
{
bitmap_t prev;
prev = __c11_atomic_fetch_and(map, ~BIT(n), mem_order);
return bit_test(prev, n);
}
#define BITMAP_LEN(n) (((uint)(n) + 63) >> 6) /* Round to 64bit bitmap_t */
#define BITMAP_SIZE(n) (size_t)(BITMAP_LEN(n) << 3) /* Round to 64bit bitmap_t, then convert to bytes */
#define bitmap_bit(n) bits(n, 5, 0)
#define bitmap_index(n) bits(n, 63, 6)
inline static bitmap_t *
bitmap_zero(bitmap_t *map, uint nbits)
{
memset((void *)map, 0, BITMAP_SIZE(nbits));
return map;
}
inline static bitmap_t *
bitmap_full(bitmap_t *map, uint nbits)
{
uint i;
for (i = 0; i < bitmap_index(nbits - 1); i++) {
map[i] = ~((uint64_t)0);
}
uint nbits_filled = i * 64;
if (nbits > nbits_filled) {
map[i] = mask(nbits - nbits_filled);
}
return map;
}
inline static bool
bitmap_is_full(bitmap_t *map, uint nbits)
{
uint i;
for (i = 0; i < bitmap_index(nbits - 1); i++) {
if (map[i] != ~((uint64_t)0)) {
return false;
}
}
uint nbits_filled = i * 64;
if (nbits > nbits_filled) {
return map[i] == mask(nbits - nbits_filled);
}
return true;
}
inline static bitmap_t *
bitmap_alloc(uint nbits)
{
bitmap_t *map;
assert(nbits > 0);
map = (bitmap_t *)kalloc_data(BITMAP_SIZE(nbits), Z_WAITOK_ZERO);
return map;
}
inline static void
bitmap_free(bitmap_t *map, uint nbits)
{
assert(nbits > 0);
kfree_data(map, BITMAP_SIZE(nbits));
}
inline static void
bitmap_set(bitmap_t *map, uint n)
{
bit_set(map[bitmap_index(n)], bitmap_bit(n));
}
inline static void
bitmap_clear(bitmap_t *map, uint n)
{
bit_clear(map[bitmap_index(n)], bitmap_bit(n));
}
inline static bool
atomic_bitmap_set(_Atomic bitmap_t *map, uint n, int mem_order)
{
return atomic_bit_set(&map[bitmap_index(n)], bitmap_bit(n), mem_order);
}
inline static bool
atomic_bitmap_clear(_Atomic bitmap_t *map, uint n, int mem_order)
{
return atomic_bit_clear(&map[bitmap_index(n)], bitmap_bit(n), mem_order);
}
inline static bool
bitmap_test(const bitmap_t *map, uint n)
{
return bit_test(map[bitmap_index(n)], bitmap_bit(n));
}
inline static int
bitmap_first(bitmap_t *map, uint nbits)
{
for (int i = (int)bitmap_index(nbits - 1); i >= 0; i--) {
if (map[i] == 0) {
continue;
}
return (i << 6) + bit_first(map[i]);
}
return -1;
}
inline static void
bitmap_not(bitmap_t *out, const bitmap_t *in, uint nbits)
{
uint i;
for (i = 0; i < bitmap_index(nbits - 1); i++) {
out[i] = ~in[i];
}
uint nbits_complete = i * 64;
if (nbits > nbits_complete) {
out[i] = ~in[i] & mask(nbits - nbits_complete);
}
}
inline static void
bitmap_and(
bitmap_t *out,
const bitmap_t *in1,
const bitmap_t *in2,
uint nbits)
{
for (uint i = 0; i <= bitmap_index(nbits - 1); i++) {
out[i] = in1[i] & in2[i];
}
}
inline static void
bitmap_and_not(
bitmap_t *out,
const bitmap_t *in1,
const bitmap_t *in2,
uint nbits)
{
uint i;
for (i = 0; i <= bitmap_index(nbits - 1); i++) {
out[i] = in1[i] & ~in2[i];
}
}
inline static void
bitmap_or(
bitmap_t *out,
const bitmap_t *in1,
const bitmap_t *in2,
uint nbits)
{
for (uint i = 0; i <= bitmap_index(nbits - 1); i++) {
out[i] = in1[i] | in2[i];
}
}
inline static bool
bitmap_equal(const bitmap_t *in1, const bitmap_t *in2, uint nbits)
{
for (uint i = 0; i <= bitmap_index(nbits - 1); i++) {
if (in1[i] != in2[i]) {
return false;
}
}
return true;
}
inline static int
bitmap_and_not_mask_first(bitmap_t *map, const bitmap_t *mask, uint nbits)
{
for (int i = (int)bitmap_index(nbits - 1); i >= 0; i--) {
if ((map[i] & ~mask[i]) == 0) {
continue;
}
return (i << 6) + bit_first(map[i] & ~mask[i]);
}
return -1;
}
inline static int
bitmap_lsb_first(const bitmap_t *map, uint nbits)
{
for (uint i = 0; i <= bitmap_index(nbits - 1); i++) {
if (map[i] == 0) {
continue;
}
return (int)((i << 6) + (uint32_t)lsb_first(map[i]));
}
return -1;
}
inline static int
bitmap_next(const bitmap_t *map, uint prev)
{
if (prev == 0) {
return -1;
}
int64_t i = bitmap_index(prev - 1);
int res = __bit_next(map[i], bits(prev, 5, 0));
if (res >= 0) {
return (int)(res + (i << 6));
}
for (i = i - 1; i >= 0; i--) {
if (map[i] == 0) {
continue;
}
return (int)((i << 6) + bit_first(map[i]));
}
return -1;
}
inline static int
bitmap_lsb_next(const bitmap_t *map, uint nbits, uint prev)
{
if ((prev + 1) >= nbits) {
return -1;
}
uint64_t i = bitmap_index(prev + 1);
uint b = bits((prev + 1), 5, 0) - 1;
int32_t res = lsb_next((uint64_t)map[i], (int)b);
if (res >= 0) {
return (int)((uint64_t)res + (i << 6));
}
for (i = i + 1; i <= bitmap_index(nbits - 1); i++) {
if (map[i] == 0) {
continue;
}
return (int)((i << 6) + (uint64_t)lsb_first(map[i]));
}
return -1;
}
#endif
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/waitq.h | #ifndef _WAITQ_H_
#define _WAITQ_H_
/*
* Copyright (c) 2014-2015 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#endif /* _WAITQ_H_ */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/work_interval.h | /*
* Copyright (c) 2017 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _KERN_WORK_INTERVAL_H_
#define _KERN_WORK_INTERVAL_H_
#include <sys/cdefs.h>
#include <stdint.h>
#include <kern/kern_types.h>
#include <kern/thread_group.h>
__BEGIN_DECLS
struct work_interval;
struct kern_work_interval_args {
uint64_t work_interval_id;
uint64_t start;
uint64_t finish;
uint64_t deadline;
uint64_t next_start;
uint32_t notify_flags;
uint32_t create_flags;
uint16_t urgency;
};
struct kern_work_interval_create_args {
uint64_t wica_id; /* out param */
mach_port_name_t wica_port; /* out param */
uint32_t wica_create_flags;
};
/*
* Allocate/assign a single work interval ID for a thread,
* and support deallocating it.
*/
extern kern_return_t
kern_work_interval_create(thread_t thread, struct kern_work_interval_create_args *create_params);
extern kern_return_t
kern_work_interval_get_flags_from_port(mach_port_name_t port_name, uint32_t*flags);
extern kern_return_t
kern_work_interval_destroy(thread_t thread, uint64_t work_interval_id);
extern kern_return_t
kern_work_interval_join(thread_t thread, mach_port_name_t port_name);
extern kern_return_t
kern_work_interval_notify(thread_t thread, struct kern_work_interval_args* kwi_args);
__END_DECLS
#endif /* !defined(_KERN_WORK_INTERVAL_H_) */
|
0 | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers | repos/simulations/libs/system-sdk/macos12/System/Library/Frameworks/Kernel.framework/Headers/kern/thread_call.h | /*
* Copyright (c) 1993-1995, 1999-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*!
* @header thread_call.h
* @discussion Facilities for executing work asynchronously.
*/
#ifndef _KERN_THREAD_CALL_H_
#define _KERN_THREAD_CALL_H_
#include <mach/mach_types.h>
#include <kern/clock.h>
#include <sys/cdefs.h>
struct thread_call;
typedef struct thread_call *thread_call_t;
typedef void *thread_call_param_t;
typedef void (*thread_call_func_t)(
thread_call_param_t param0,
thread_call_param_t param1);
/*!
* @enum thread_call_priority_t
* @discussion Thread call priorities should not be assumed to have any specific
* numerical value; they should be interpreted as importances or roles for work
* items, priorities for which will be reasonably managed by the subsystem.
* @constant THREAD_CALL_PRIORITY_HIGH Importance above everything but realtime.
* Thread calls allocated with this priority execute at extremely high priority,
* above everything but realtime threads. They are generally executed in serial.
* Though they may execute concurrently under some circumstances, no fan-out is implied.
* These work items should do very small amounts of work or risk disrupting system
* responsiveness.
* @constant THREAD_CALL_PRIORITY_KERNEL Importance similar to that of normal kernel
* threads.
* @constant THREAD_CALL_PRIORITY_USER Importance similar to that of normal user threads.
* @constant THREAD_CALL_PRIORITY_LOW Very low importance.
* @constant THREAD_CALL_PRIORITY_KERNEL_HIGH Importance higher than most kernel
* threads.
*/
typedef enum {
THREAD_CALL_PRIORITY_HIGH = 0,
THREAD_CALL_PRIORITY_KERNEL = 1,
THREAD_CALL_PRIORITY_USER = 2,
THREAD_CALL_PRIORITY_LOW = 3,
THREAD_CALL_PRIORITY_KERNEL_HIGH = 4
} thread_call_priority_t;
enum {
/* if call is re-submitted while the call is executing on a call thread, then delay the re-enqueue until it returns */
THREAD_CALL_OPTIONS_ONCE = 0x00000001,
};
typedef uint32_t thread_call_options_t;
__BEGIN_DECLS
/*!
* @function thread_call_enter
* @abstract Submit a thread call work item for immediate execution.
* @discussion If the work item is already scheduled for delayed execution, and it has
* not yet begun to run, that delayed invocation will be cancelled. Note that if a
* thread call is rescheduled from its own callback, then multiple invocations of the
* callback may be in flight at the same time.
* @result TRUE if the call was already pending for either delayed or immediate
* execution, FALSE otherwise.
* @param call The thread call to execute.
*/
extern boolean_t thread_call_enter(
thread_call_t call);
/*!
* @function thread_call_enter1
* @abstract Submit a thread call work item for immediate execution, with an extra parameter.
* @discussion This routine is identical to thread_call_enter(), except that
* the second parameter to the callback is specified.
* @result TRUE if the call was already pending for either delayed or immediate
* execution, FALSE otherwise.
* @param call The thread call to execute.
* @param param1 Parameter to pass callback.
*/
extern boolean_t thread_call_enter1(
thread_call_t call,
thread_call_param_t param1);
/*!
* @function thread_call_enter_delayed
* @abstract Submit a thread call to be executed at some point in the future.
* @discussion If the work item is already scheduled for delayed or immediate execution,
* and it has not yet begun to run, that invocation will be cancelled in favor of execution
* at the newly specified time. Note that if a thread call is rescheduled from its own callback,
* then multiple invocations of the callback may be in flight at the same time.
* @result TRUE if the call was already pending for either delayed or immediate
* execution, FALSE otherwise.
* @param call The thread call to execute.
* @param deadline Time, in absolute time units, at which to execute callback.
*/
extern boolean_t thread_call_enter_delayed(
thread_call_t call,
uint64_t deadline);
/*!
* @function thread_call_enter1_delayed
* @abstract Submit a thread call to be executed at some point in the future, with an extra parameter.
* @discussion This routine is identical to thread_call_enter_delayed(),
* except that a second parameter to the callback is specified.
* @result TRUE if the call was already pending for either delayed or immediate
* execution, FALSE otherwise.
* @param call The thread call to execute.
* @param param1 Second parameter to callback.
* @param deadline Time, in absolute time units, at which to execute callback.
*/
extern boolean_t thread_call_enter1_delayed(
thread_call_t call,
thread_call_param_t param1,
uint64_t deadline);
/*!
* @function thread_call_cancel
* @abstract Attempt to cancel a pending invocation of a thread call.
* @discussion Attempt to cancel a thread call which has been scheduled
* for execution with a thread_call_enter* variant. If the call has not
* yet begun executing, the pending invocation will be cancelled and TRUE
* will be returned. If the work item has already begun executing,
* thread_call_cancel will return FALSE immediately; the callback may be
* about to run, currently running, or already done executing.
* @result TRUE if the call was successfully cancelled, FALSE otherwise.
*/
extern boolean_t thread_call_cancel(
thread_call_t call);
/*!
* @function thread_call_cancel_wait
* @abstract Attempt to cancel a pending invocation of a thread call.
* If unable to cancel, wait for current invocation to finish.
* @discussion Attempt to cancel a thread call which has been scheduled
* for execution with a thread_call_enter* variant. If the call has not
* yet begun executing, the pending invocation will be cancelled and TRUE
* will be returned. If the work item has already begun executing,
* thread_call_cancel_wait waits for the most recent invocation to finish. When
* called on a work item which has already finished, it will return FALSE immediately.
* Note that this routine can only be used on thread calls set up with either
* thread_call_allocate or thread_call_allocate_with_priority, and that invocations
* of the thread call <i>after</i> the current invocation may be in flight when
* thread_call_cancel_wait returns.
* @result TRUE if the call was successfully cancelled, FALSE otherwise.
*/
extern boolean_t thread_call_cancel_wait(
thread_call_t call);
/*!
* @function thread_call_allocate
* @abstract Allocate a thread call to execute with default (high) priority.
* @discussion Allocates a thread call that will run with properties of
* THREAD_CALL_PRIORITY_HIGH, binding the first parameter to the callback.
* @param func Callback to invoke when thread call is scheduled.
* @param param0 First argument ot pass to callback.
* @result Thread call which can be passed to thread_call_enter variants.
*/
extern thread_call_t thread_call_allocate(
thread_call_func_t func,
thread_call_param_t param0);
/*!
* @function thread_call_allocate_with_priority
* @abstract Allocate a thread call to execute with a specified priority.
* @discussion Identical to thread_call_allocate, except that priority
* is specified by caller.
* @param func Callback to invoke when thread call is scheduled.
* @param param0 First argument to pass to callback.
* @param pri Priority of item.
* @result Thread call which can be passed to thread_call_enter variants.
*/
extern thread_call_t thread_call_allocate_with_priority(
thread_call_func_t func,
thread_call_param_t param0,
thread_call_priority_t pri);
/*!
* @function thread_call_allocate_with_options
* @abstract Allocate a thread call to execute with a specified priority.
* @discussion Identical to thread_call_allocate, except that priority
* and options are specified by caller.
* @param func Callback to invoke when thread call is scheduled.
* @param param0 First argument to pass to callback.
* @param pri Priority of item.
* @param options Options for item.
* @result Thread call which can be passed to thread_call_enter variants.
*/
extern thread_call_t thread_call_allocate_with_options(
thread_call_func_t func,
thread_call_param_t param0,
thread_call_priority_t pri,
thread_call_options_t options);
/*!
* @function thread_call_free
* @abstract Release a thread call.
* @discussion Should only be used on thread calls allocated with thread_call_allocate
* or thread_call_allocate_with_priority. Once thread_call_free has been called,
* no other operations may be performed on a thread call. If the thread call is
* currently pending, thread_call_free will return FALSE and will have no effect.
* Calling thread_call_free from a thread call's own callback is safe; the work
* item is not considering "pending" at that point.
* @result TRUE if the thread call has been successfully released, else FALSE.
* @param call The thread call to release.
*/
extern boolean_t thread_call_free(
thread_call_t call);
/*!
* @function thread_call_isactive
* @abstract Determine whether a thread call is pending or currently executing.
* @param call Thread call to examine.
* @result TRUE if the thread call is either scheduled for execution (immediately
* or at some point in the future) or is currently executing.
*/
boolean_t thread_call_isactive(
thread_call_t call);
__END_DECLS
#endif /* _KERN_THREAD_CALL_H_ */
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.