libc: Update macOS headers to SDK 26.0

This commit is contained in:
Linus Groh 2025-09-16 21:15:13 +01:00
parent 70715ced95
commit 93218eacaa
65 changed files with 2271 additions and 858 deletions

View File

@ -1 +1 @@
{"MinimalDisplayName":"15.5"}
{"MinimalDisplayName":"26.0"}

File diff suppressed because it is too large Load Diff

View File

@ -469,6 +469,9 @@
* ios, iOSApplicationExtension, tvos, tvOSApplicationExtension, watchos,
* watchOSApplicationExtension, driverkit, visionos, visionOSApplicationExtension
*
* Within each platform a tuple of versions will represent the version the API was
* introduced in, followed by the version it was deperecated in.
*
* Examples:
*
* __API_DEPRECATED("Deprecated", macos(10.4, 10.8))
@ -487,6 +490,7 @@
#define __API_DEPRECATED_WITH_REPLACEMENT_END _Pragma("clang attribute pop")
#define __API_OBSOLETED(...) __API_OBSOLETED_MSG_GET_MACRO_93585900(__VA_ARGS__,__API_OBSOLETED_MSG15,__API_OBSOLETED_MSG14,__API_OBSOLETED_MSG13,__API_OBSOLETED_MSG12,__API_OBSOLETED_MSG11,__API_OBSOLETED_MSG10,__API_OBSOLETED_MSG9,__API_OBSOLETED_MSG8,__API_OBSOLETED_MSG7,__API_OBSOLETED_MSG6,__API_OBSOLETED_MSG5,__API_OBSOLETED_MSG4,__API_OBSOLETED_MSG3,__API_OBSOLETED_MSG2,__API_OBSOLETED_MSG1,__API_OBSOLETED_MSG0,0,0)(__VA_ARGS__)
#define __API_OBSOLETED_WITH_REPLACEMENT(...) __API_OBSOLETED_REP_GET_MACRO_93585900(__VA_ARGS__,__API_OBSOLETED_REP15,__API_OBSOLETED_REP14,__API_OBSOLETED_REP13,__API_OBSOLETED_REP12,__API_OBSOLETED_REP11,__API_OBSOLETED_REP10,__API_OBSOLETED_REP9,__API_OBSOLETED_REP8,__API_OBSOLETED_REP7,__API_OBSOLETED_REP6,__API_OBSOLETED_REP5,__API_OBSOLETED_REP4,__API_OBSOLETED_REP3,__API_OBSOLETED_REP2,__API_OBSOLETED_REP1,__API_OBSOLETED_REP0,0,0)(__VA_ARGS__)
@ -496,6 +500,7 @@
#define __API_OBSOLETED_WITH_REPLACEMENT_BEGIN(...) _Pragma("clang attribute push") __API_OBSOLETED_WITH_REPLACEMENT_BEGIN_GET_MACRO_93585900(__VA_ARGS__,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN15,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN14,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN13,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN12,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN11,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN10,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN9,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN8,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN7,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN6,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN5,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN4,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN3,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN2,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN1,__API_OBSOLETED_WITH_REPLACEMENT_BEGIN0,0,0)(__VA_ARGS__)
#define __API_OBSOLETED_WITH_REPLACEMENT_END _Pragma("clang attribute pop")
/*
* API Unavailability
* Use to specify that an API is unavailable for a particular platform.
@ -524,7 +529,7 @@
#endif
#ifndef __API_AVAILABLE_END
#define __API_AVAILABLE_END(...)
#define __API_AVAILABLE_END
#endif
#ifndef __API_DEPRECATED
@ -536,7 +541,7 @@
#endif
#ifndef __API_DEPRECATED_END
#define __API_DEPRECATED_END(...)
#define __API_DEPRECATED_END
#endif
#ifndef __API_DEPRECATED_WITH_REPLACEMENT
@ -548,7 +553,7 @@
#endif
#ifndef __API_DEPRECATED_WITH_REPLACEMENT_END
#define __API_DEPRECATED_WITH_REPLACEMENT_END(...)
#define __API_DEPRECATED_WITH_REPLACEMENT_END
#endif
#ifndef __API_OBSOLETED
@ -560,7 +565,7 @@
#endif
#ifndef __API_OBSOLETED_END
#define __API_OBSOLETED_END(...)
#define __API_OBSOLETED_END
#endif
#ifndef __API_OBSOLETED_WITH_REPLACEMENT
@ -572,7 +577,7 @@
#endif
#ifndef __API_OBSOLETED_WITH_REPLACEMENT_END
#define __API_OBSOLETED_WITH_REPLACEMENT_END(...)
#define __API_OBSOLETED_WITH_REPLACEMENT_END
#endif
#ifndef __API_UNAVAILABLE
@ -584,7 +589,7 @@
#endif
#ifndef __API_UNAVAILABLE_END
#define __API_UNAVAILABLE_END(...)
#define __API_UNAVAILABLE_END
#endif
/*
@ -600,7 +605,7 @@
#endif
#ifndef __SPI_AVAILABLE_END
#define __SPI_AVAILABLE_END(...)
#define __SPI_AVAILABLE_END
#endif
#ifndef __SPI_DEPRECATED

View File

@ -33,81 +33,93 @@
#include <AvailabilityVersions.h>
#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
#if defined(__has_builtin) && __has_builtin(__is_target_os)
#if __is_target_os(macos)
#define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_15_5
#endif
#elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_15_5
#endif /* __has_builtin(__is_target_os) && __is_target_os(macos) */
#if defined(__has_builtin)
#if __has_builtin(__is_target_os)
#if __is_target_os(macos)
#define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_26_0
#endif
#elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_26_0
#endif /* __has_builtin(__is_target_os) */
#endif /* defined(__has_builtin) */
#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */
#ifndef __IPHONE_OS_VERSION_MIN_REQUIRED
#if defined(__has_builtin) && __has_builtin(__is_target_os)
#if __is_target_os(ios)
#define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_18_5
#endif
#elif __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
#define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_18_5
#endif /* __has_builtin(__is_target_os) && __is_target_os(ios) */
#if defined(__has_builtin)
#if __has_builtin(__is_target_os)
#if __is_target_os(ios)
#define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_26_0
#endif
#elif __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
#define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_26_0
#endif /* __has_builtin(__is_target_os) */
#endif /* defined(__has_builtin) */
#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED */
#ifndef __WATCH_OS_VERSION_MIN_REQUIRED
#if defined(__has_builtin) && __has_builtin(__is_target_os)
#if __is_target_os(watchos)
#define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_11_5
#if defined(__has_builtin)
#if __has_builtin(__is_target_os)
#if __is_target_os(watchos)
#define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_26_0
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0
#endif
#elif __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_26_0
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0
#endif
#elif __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_11_5
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0
#endif /* __has_builtin(__is_target_os) && __is_target_os(watchos) */
#endif /* __has_builtin(__is_target_os) */
#endif /* defined(__has_builtin) */
#endif /* __WATCH_OS_VERSION_MIN_REQUIRED */
#ifndef __TV_OS_VERSION_MIN_REQUIRED
#if defined(__has_builtin) && __has_builtin(__is_target_os)
#if __is_target_os(tvos)
#define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MAX_ALLOWED __TVOS_18_5
#if defined(__has_builtin)
#if __has_builtin(__is_target_os)
#if __is_target_os(tvos)
#define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MAX_ALLOWED __TVOS_26_0
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0
#endif
#elif __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MAX_ALLOWED __TVOS_26_0
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0
#endif
#elif __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MAX_ALLOWED __TVOS_18_5
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_9_0
#endif /* __has_builtin(__is_target_os) && __is_target_os(tvos) */
#endif /* __has_builtin(__is_target_os) */
#endif /* defined(__has_builtin) */
#endif /* __TV_OS_VERSION_MIN_REQUIRED */
#ifndef __DRIVERKIT_VERSION_MIN_REQUIRED
#if defined(__has_builtin) && __has_builtin(__is_target_os)
#if __is_target_os(driverkit)
#define __DRIVERKIT_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __DRIVERKIT_VERSION_MAX_ALLOWED __DRIVERKIT_24_5
#endif
#endif /* __has_builtin(__is_target_os) && __is_target_os(driverkit) */
#if defined(__has_builtin)
#if __has_builtin(__is_target_os)
#if __is_target_os(driverkit)
#define __DRIVERKIT_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __DRIVERKIT_VERSION_MAX_ALLOWED __DRIVERKIT_25_0
#endif
#endif /* __has_builtin(__is_target_os) */
#endif /* defined(__has_builtin) */
#endif /* __DRIVERKIT_VERSION_MIN_REQUIRED */
#ifndef __VISION_OS_VERSION_MIN_REQUIRED
#if defined(__has_builtin) && __has_builtin(__is_target_os)
#if __is_target_os(visionos)
#define __VISION_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __VISION_OS_VERSION_MAX_ALLOWED __VISIONOS_2_5
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_17_1
#endif
#endif /* __has_builtin(__is_target_os) && __is_target_os(visionos) */
#if defined(__has_builtin)
#if __has_builtin(__is_target_os)
#if __is_target_os(visionos)
#define __VISION_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
#define __VISION_OS_VERSION_MAX_ALLOWED __VISIONOS_26_0
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_17_1
#endif
#endif /* __has_builtin(__is_target_os) */
#endif /* defined(__has_builtin) */
#endif /* __VISION_OS_VERSION_MIN_REQUIRED */

View File

@ -74,7 +74,6 @@
#define __MAC_12_7 120700
#define __MAC_13_0 130000
#define __MAC_13_1 130100
#define __MAC_13_1 130100
#define __MAC_13_2 130200
#define __MAC_13_3 130300
#define __MAC_13_4 130400
@ -95,6 +94,9 @@
#define __MAC_15_3 150300
#define __MAC_15_4 150400
#define __MAC_15_5 150500
#define __MAC_15_6 150600
#define __MAC_16_0 160000
#define __MAC_26_0 260000
/* __MAC__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __IPHONE_2_0 20000
@ -149,8 +151,6 @@
#define __IPHONE_14_2 140200
#define __IPHONE_14_3 140300
#define __IPHONE_14_5 140500
#define __IPHONE_14_4 140400
#define __IPHONE_14_5 140500
#define __IPHONE_14_6 140600
#define __IPHONE_14_7 140700
#define __IPHONE_14_8 140800
@ -185,6 +185,9 @@
#define __IPHONE_18_3 180300
#define __IPHONE_18_4 180400
#define __IPHONE_18_5 180500
#define __IPHONE_18_6 180600
#define __IPHONE_19_0 190000
#define __IPHONE_26_0 260000
/* __IPHONE__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __WATCHOS_1_0 10000
@ -242,6 +245,9 @@
#define __WATCHOS_11_3 110300
#define __WATCHOS_11_4 110400
#define __WATCHOS_11_5 110500
#define __WATCHOS_11_6 110600
#define __WATCHOS_12_0 120000
#define __WATCHOS_26_0 260000
/* __WATCHOS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __TVOS_9_0 90000
@ -299,6 +305,9 @@
#define __TVOS_18_3 180300
#define __TVOS_18_4 180400
#define __TVOS_18_5 180500
#define __TVOS_18_6 180600
#define __TVOS_19_0 190000
#define __TVOS_26_0 260000
/* __TVOS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __BRIDGEOS_2_0 20000
@ -317,7 +326,6 @@
#define __BRIDGEOS_6_6 60600
#define __BRIDGEOS_7_0 70000
#define __BRIDGEOS_7_1 70100
#define __BRIDGEOS_7_1 70100
#define __BRIDGEOS_7_2 70200
#define __BRIDGEOS_7_3 70300
#define __BRIDGEOS_7_4 70400
@ -335,6 +343,8 @@
#define __BRIDGEOS_9_3 90300
#define __BRIDGEOS_9_4 90400
#define __BRIDGEOS_9_5 90500
#define __BRIDGEOS_9_6 90600
#define __BRIDGEOS_10_0 100000
#define __DRIVERKIT_19_0 190000
@ -357,6 +367,8 @@
#define __DRIVERKIT_24_3 240300
#define __DRIVERKIT_24_4 240400
#define __DRIVERKIT_24_5 240500
#define __DRIVERKIT_24_6 240600
#define __DRIVERKIT_25_0 250000
/* __DRIVERKIT__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __VISIONOS_1_0 10000
@ -369,6 +381,9 @@
#define __VISIONOS_2_3 20300
#define __VISIONOS_2_4 20400
#define __VISIONOS_2_5 20500
#define __VISIONOS_2_6 20600
#define __VISIONOS_3_0 30000
#define __VISIONOS_26_0 260000
/* __VISIONOS__NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
@ -436,7 +451,6 @@
#define MAC_OS_VERSION_12_7 __MAC_12_7
#define MAC_OS_VERSION_13_0 __MAC_13_0
#define MAC_OS_VERSION_13_1 __MAC_13_1
#define MAC_OS_VERSION_13_1 __MAC_13_1
#define MAC_OS_VERSION_13_2 __MAC_13_2
#define MAC_OS_VERSION_13_3 __MAC_13_3
#define MAC_OS_VERSION_13_4 __MAC_13_4
@ -457,6 +471,9 @@
#define MAC_OS_VERSION_15_3 __MAC_15_3
#define MAC_OS_VERSION_15_4 __MAC_15_4
#define MAC_OS_VERSION_15_5 __MAC_15_5
#define MAC_OS_VERSION_15_6 __MAC_15_6
#define MAC_OS_VERSION_16_0 __MAC_16_0
#define MAC_OS_VERSION_26_0 __MAC_26_0
#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */

View File

@ -42,6 +42,8 @@
#define _LIBC_SINGLE_BY_DEFAULT() __ptrcheck_abi_assume_single()
#define _LIBC_PTRCHECK_REPLACED(R) __ptrcheck_unavailable_r(R)
#define _LIBC_FORGE_PTR(P, S) __unsafe_forge_bidi_indexable(__typeof__(*P) *, P, S)
#else /* _LIBC_ANNOTATE_BOUNDS */
#define _LIBC_COUNT(x)
@ -58,6 +60,8 @@
#define _LIBC_SINGLE_BY_DEFAULT()
#define _LIBC_PTRCHECK_REPLACED(R)
#define _LIBC_FORGE_PTR(P, S) (P)
#endif /* _LIBC_ANNOTATE_BOUNDS */
#endif /* _LIBC_BOUNDS_H_ */

View File

@ -27,13 +27,15 @@
#include <sys/cdefs.h>
#include <_bounds.h>
#ifndef _LIBC_COUNT__L_CTERMID
#define _LIBC_COUNT__L_CTERMID _LIBC_UNSAFE_INDEXABLE
#endif /* _LIBC_COUNT__L_CTERMID */
_LIBC_SINGLE_BY_DEFAULT()
__BEGIN_DECLS
#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
char *_LIBC_CSTR ctermid(char *_LIBC_COUNT_OR_NULL(L_ctermid));
char *_LIBC_CSTR ctermid(char *_LIBC_COUNT__L_CTERMID);
__END_DECLS

View File

@ -41,6 +41,10 @@
#include <_bounds.h>
#include <_types.h>
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE >= 200809L
#include <_locale_posix2008.h>
#endif
_LIBC_SINGLE_BY_DEFAULT()
struct lconv {
@ -72,33 +76,8 @@ struct lconv {
#include <sys/_types/_null.h>
#define LC_ALL_MASK ( LC_COLLATE_MASK \
| LC_CTYPE_MASK \
| LC_MESSAGES_MASK \
| LC_MONETARY_MASK \
| LC_NUMERIC_MASK \
| LC_TIME_MASK )
#define LC_COLLATE_MASK (1 << 0)
#define LC_CTYPE_MASK (1 << 1)
#define LC_MESSAGES_MASK (1 << 2)
#define LC_MONETARY_MASK (1 << 3)
#define LC_NUMERIC_MASK (1 << 4)
#define LC_TIME_MASK (1 << 5)
#define _LC_NUM_MASK 6
#define _LC_LAST_MASK (1 << (_LC_NUM_MASK - 1))
#define LC_GLOBAL_LOCALE ((locale_t)-1)
#define LC_C_LOCALE ((locale_t)NULL)
#include <_types/_locale_t.h>
__BEGIN_DECLS
locale_t duplocale(locale_t);
int freelocale(locale_t);
struct lconv *localeconv(void);
locale_t newlocale(int, __const char *, locale_t);
locale_t uselocale(locale_t);
__END_DECLS
#endif /* __LOCALE_H_ */

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2005 - 2025 Apple Computer, 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@
*/
#ifndef __LOCALE_POSIX2008_H_
#define __LOCALE_POSIX2008_H_
#include <sys/cdefs.h>
#include <_types.h>
_LIBC_SINGLE_BY_DEFAULT()
/*
* These definitions were all historically provided by <xlocale.h>, but they
* became standardized in POSIX.1-2008. We make them available via either
* <xlocale.h> or <locale.h> at the appropriate conformance level.
*/
#define LC_ALL_MASK ( LC_COLLATE_MASK \
| LC_CTYPE_MASK \
| LC_MESSAGES_MASK \
| LC_MONETARY_MASK \
| LC_NUMERIC_MASK \
| LC_TIME_MASK )
#define LC_COLLATE_MASK (1 << 0)
#define LC_CTYPE_MASK (1 << 1)
#define LC_MESSAGES_MASK (1 << 2)
#define LC_MONETARY_MASK (1 << 3)
#define LC_NUMERIC_MASK (1 << 4)
#define LC_TIME_MASK (1 << 5)
#define _LC_NUM_MASK 6
#define _LC_LAST_MASK (1 << (_LC_NUM_MASK - 1))
#define LC_GLOBAL_LOCALE ((locale_t)-1)
#define LC_C_LOCALE ((locale_t)NULL)
#include <_types/_locale_t.h>
__BEGIN_DECLS
locale_t duplocale(locale_t);
int freelocale(locale_t);
locale_t newlocale(int, __const char *, locale_t);
locale_t uselocale(locale_t);
__END_DECLS
#endif /* __LOCALE_POSIX2008_H_ */

View File

@ -308,6 +308,10 @@ __END_DECLS
#if __DARWIN_C_LEVEL >= 198808L
#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
#undef _LIBC_COUNT__L_CTERMID
#define _LIBC_COUNT__L_CTERMID _LIBC_COUNT_OR_NULL(L_ctermid)
#include <_ctermid.h>
__BEGIN_DECLS

View File

@ -123,18 +123,23 @@ typedef struct {
#define RAND_MAX 0x7fffffff
// When _USE_EXTENDED_LOCALES_ is enabled (by including xlocale.h),
// MB_CUR_MAX is defined by xlocale.h.
#if !defined(MB_CUR_MAX) && !defined(_USE_EXTENDED_LOCALES_)
#if __has_feature(modules)
// When clang modules are enabled, there can only be one definition of
// MB_CUR_MAX, and that needs to be the same one used by xlocale.h.
#include <_mb_cur_max.h>
#else
#else /* !__has_feature(modules) */
#ifndef MB_CUR_MAX
#ifdef _USE_EXTENDED_LOCALES_
#define MB_CUR_MAX (___mb_cur_max())
#ifndef MB_CUR_MAX_L
#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
#endif /* !MB_CUR_MAX_L */
#else /* !_USE_EXTENDED_LOCALES_ */
extern int __mb_cur_max;
#define MB_CUR_MAX __mb_cur_max
#endif /* _USE_EXTENDED_LOCALES_ */
#endif /* MB_CUR_MAX */
#endif /* __has_feature(modules) */
#endif /* !MB_CUR_MAX && !_USE_EXTENDED_LOCALES_ */
#include <malloc/_malloc.h>
#include <_abort.h>

View File

@ -100,7 +100,7 @@ char *_LIBC_CSTR
_LIBC_PTRCHECK_REPLACED(strlcat);
int strncmp(const char *_LIBC_UNSAFE_INDEXABLE __s1,
const char *_LIBC_UNSAFE_INDEXABLE __s2, size_t __n);
char *_LIBC_UNSAFE_INDEXABLE
char *_LIBC_COUNT(__n)
strncpy(char *_LIBC_COUNT(__n) __dst,
const char *_LIBC_UNSAFE_INDEXABLE __src, size_t __n)
_LIBC_PTRCHECK_REPLACED(strlcpy);
@ -155,7 +155,7 @@ __END_DECLS
__BEGIN_DECLS
char *_LIBC_CSTR
stpcpy(char *_LIBC_UNSAFE_INDEXABLE __dst, const char *__src) _LIBC_PTRCHECK_REPLACED(strlcpy);
char *_LIBC_CSTR
char *_LIBC_COUNT(__n)
stpncpy(char *_LIBC_UNSAFE_INDEXABLE __dst,
const char *_LIBC_UNSAFE_INDEXABLE __src, size_t __n)
__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)

View File

@ -32,6 +32,7 @@
#endif /* _USE_EXTENDED_LOCALES_ */
#include <_locale.h>
#include <_locale_posix2008.h>
#include <__xlocale.h>
_LIBC_SINGLE_BY_DEFAULT()

View File

@ -40,9 +40,6 @@
*/
#include <sys/cdefs.h>
#ifdef __cplusplus
#include <stdlib.h>
#endif /* __cplusplus */
/*
* Unlike other ANSI header files, <assert.h> may usefully be included

View File

@ -207,11 +207,12 @@ typedef struct vm_purgeable_info *host_purgable_info_t;
/* size of the latest version of the structure */
#define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT
#define HOST_VM_INFO64_REV1_COUNT HOST_VM_INFO64_LATEST_COUNT
#define HOST_VM_INFO64_REV2_COUNT HOST_VM_INFO64_COUNT
#define HOST_VM_INFO64_REV1_COUNT ((mach_msg_type_number_t) \
(offsetof(vm_statistics64_data_t, swapped_count) / sizeof(integer_t)))
/* previous versions: adjust the size according to what was added each time */
#define HOST_VM_INFO64_REV0_COUNT /* added compression and swapper info (14 ints) */ \
((mach_msg_type_number_t) \
(HOST_VM_INFO64_REV1_COUNT - 14))
#define HOST_VM_INFO64_REV0_COUNT ((mach_msg_type_number_t) \
(offsetof(vm_statistics64_data_t, decompressions) / sizeof(integer_t)))
/* in <mach/vm_statistics.h> */
/* vm_extmod_statistics */

View File

@ -501,7 +501,7 @@ kern_return_t mach_port_kobject
(
ipc_space_read_t task,
mach_port_name_t name,
natural_t *object_type,
ipc_info_object_type_t *object_type,
mach_vm_address_t *object_addr
);
@ -610,7 +610,7 @@ kern_return_t mach_port_kobject_description
(
ipc_space_read_t task,
mach_port_name_t name,
natural_t *object_type,
ipc_info_object_type_t *object_type,
mach_vm_address_t *object_addr,
kobject_description_t description
);
@ -1690,7 +1690,7 @@ union __RequestUnion__mach_port_subsystem {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
natural_t object_type;
ipc_info_object_type_t object_type;
mach_vm_address_t object_addr;
} __Reply__mach_port_kobject_t __attribute__((unused));
#ifdef __MigPackStructs
@ -1790,7 +1790,7 @@ union __RequestUnion__mach_port_subsystem {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
natural_t object_type;
ipc_info_object_type_t object_type;
mach_vm_address_t object_addr;
mach_msg_type_number_t descriptionOffset; /* MiG doesn't use it */
mach_msg_type_number_t descriptionCnt;

View File

@ -68,6 +68,7 @@
#include <stdint.h>
#include <mach/error.h>
#include <mach/std_types.h>
#include <mach/mach_types.h>
#include <mach/kern_return.h>
@ -296,6 +297,10 @@ extern kern_return_t debug_control_port_for_pid(
int pid,
mach_port_name_t *t);
extern mach_error_t mach_vm_reclaim_update_kernel_accounting_trap(
mach_port_name_t target_tport,
uint64_t *bytes_reclaimed);
__END_DECLS

View File

@ -332,6 +332,9 @@ typedef integer_t cpu_threadtype_t;
#define CPU_SUBTYPE_ARM_V7M ((cpu_subtype_t) 15) /* Not meant to be run under xnu */
#define CPU_SUBTYPE_ARM_V7EM ((cpu_subtype_t) 16) /* Not meant to be run under xnu */
#define CPU_SUBTYPE_ARM_V8M ((cpu_subtype_t) 17) /* Not meant to be run under xnu */
#define CPU_SUBTYPE_ARM_V8M_MAIN CPU_SUBTYPE_ARM_V8M /* Not meant to be run under xnu */
#define CPU_SUBTYPE_ARM_V8M_BASE ((cpu_subtype_t) 18) /* Not meant to be run under xnu */
#define CPU_SUBTYPE_ARM_V8_1M_MAIN ((cpu_subtype_t) 19) /* Not meant to be run under xnu */
/*
* ARM64 subtypes
@ -406,6 +409,8 @@ typedef integer_t cpu_threadtype_t;
#define CPUFAMILY_ARM_BRAVA 0x17d5b93a
#define CPUFAMILY_ARM_TAHITI 0x75d4acb9
#define CPUFAMILY_ARM_TUPAI 0x204526d0
#define CPUFAMILY_ARM_THERA 0xab345f09
#define CPUFAMILY_ARM_TILOS 0x01d7a72b
/* Described in rdar://64125549 */
#define CPUSUBFAMILY_UNKNOWN 0

View File

@ -839,7 +839,7 @@ typedef kern_return_t mach_msg_return_t;
#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015
/* compatibility: no longer a returned error */
#define MACH_SEND_NO_GRANT_DEST 0x10000016
/* The destination port doesn't accept ports in body */
/* compatibility: no longer a returned error */
#define MACH_SEND_MSG_FILTERED 0x10000017
/* Message send was rejected by message filter */
#define MACH_SEND_AUX_TOO_SMALL 0x10000018
@ -885,7 +885,6 @@ typedef kern_return_t mach_msg_return_t;
/* invalid receive arguments, receive has not started */
__BEGIN_DECLS
/*

View File

@ -152,28 +152,12 @@ typedef mach_port_t *mach_port_array_t;
* and reused too quickly [to catch right/reference counting bugs].
* The dividing line between the constituent parts is exposed so
* that efficient "mach_port_name_t to data structure pointer"
* conversion implementation can be made. But it is possible
* for user-level code to assign their own names to Mach ports.
* These are not required to participate in this algorithm. So
* care should be taken before "assuming" this model.
*
* conversion implementation can be made.
*/
#ifndef NO_PORT_GEN
#define MACH_PORT_INDEX(name) ((name) >> 8)
#define MACH_PORT_GEN(name) (((name) & 0xff) << 24)
#define MACH_PORT_MAKE(index, gen) \
(((index) << 8) | (gen) >> 24)
#else /* NO_PORT_GEN */
#define MACH_PORT_INDEX(name) (name)
#define MACH_PORT_GEN(name) (0)
#define MACH_PORT_MAKE(index, gen) (index)
#endif /* NO_PORT_GEN */
#define MACH_PORT_MAKE(index, gen) (((index) << 8) | ((gen) >> 24))
/*
* These are the different rights a task may have for a port.
@ -281,7 +265,7 @@ typedef struct mach_port_limits {
#define MACH_PORT_STATUS_FLAG_REVIVE 0x10
#define MACH_PORT_STATUS_FLAG_TASKPTR 0x20
#define MACH_PORT_STATUS_FLAG_GUARD_IMMOVABLE_RECEIVE 0x40
#define MACH_PORT_STATUS_FLAG_NO_GRANT 0x80
#define MACH_PORT_STATUS_FLAG_NO_GRANT 0x80 /* Obsolete */
typedef struct mach_port_info_ext {
mach_port_status_t mpie_status;
@ -344,36 +328,95 @@ typedef struct mach_service_port_info {
typedef struct mach_service_port_info * mach_service_port_info_t;
/*
* Platform binaries are not allowed to send OOL port array to any port.
*
* MACH_MSG_OOL_PORTS_DESCRIPTOR are allowed to be sent ONLY to receive
* rights that are explicitly allow to receive that descriptor.
*
* Such ports have a dedicated port type, and are created using the
* MPO_CONNECTION_PORT_WITH_PORT_ARRAY flag.
*
* Creation of such ports requires the binary to have the following entitlement.
*/
#define MACH_PORT_CONNECTION_PORT_WITH_PORT_ARRAY "com.apple.developer.allow-connection-port-with-port-array"
/* Allows 1p process to create provisional reply port (to be rename to weak reply port) */
#define MACH_PORT_PROVISIONAL_REPLY_ENTITLEMENT "com.apple.private.allow-weak-reply-port"
/*
* Flags for mach_port_options (used for
* invocation of mach_port_construct).
* Indicates attributes to be set for the newly
* allocated port.
*/
#define MPO_CONTEXT_AS_GUARD 0x01 /* Add guard to the port */
#define MPO_QLIMIT 0x02 /* Set qlimit for the port msg queue */
#define MPO_TEMPOWNER 0x04 /* Set the tempowner bit of the port */
#define MPO_IMPORTANCE_RECEIVER 0x08 /* Mark the port as importance receiver */
#define MPO_INSERT_SEND_RIGHT 0x10 /* Insert a send right for the port */
#define MPO_STRICT 0x20 /* Apply strict guarding for port */
#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */
#define MPO_IMMOVABLE_RECEIVE 0x80 /* Mark the port as immovable; protected by the guard context */
#define MPO_FILTER_MSG 0x100 /* Allow message filtering */
#define MPO_TG_BLOCK_TRACKING 0x200 /* Track blocking relationship for thread group during sync IPC */
#define MPO_SERVICE_PORT 0x400 /* Create a service port with the given name; should be used only by launchd */
#define MPO_CONNECTION_PORT 0x800 /* Derive new peer connection port from a given service port */
#define MPO_REPLY_PORT 0x1000 /* Designate port as a reply port. */
#define MPO_ENFORCE_REPLY_PORT_SEMANTICS 0x2000 /* When talking to this port, local port of mach msg needs to follow reply port semantics.*/
#define MPO_PROVISIONAL_REPLY_PORT 0x4000 /* Designate port as a provisional reply port. */
#define MPO_EXCEPTION_PORT 0x8000 /* Used for hardened exceptions - immovable */
/* MPO options flags */
#define MPO_CONTEXT_AS_GUARD 0x01 /* Add guard to the port */
#define MPO_QLIMIT 0x02 /* Set qlimit for the port msg queue */
#define MPO_TEMPOWNER 0x04 /* Set the tempowner bit of the port */
#define MPO_IMPORTANCE_RECEIVER 0x08 /* Mark the port as importance receiver */
#define MPO_INSERT_SEND_RIGHT 0x10 /* Insert a send right for the port */
#define MPO_STRICT 0x20 /* Apply strict guarding for port */
#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */
#define MPO_IMMOVABLE_RECEIVE 0x80 /* Mark the port as immovable; protected by the guard context */
#define MPO_FILTER_MSG 0x100 /* Allow message filtering */
#define MPO_TG_BLOCK_TRACKING 0x200 /* Track blocking relationship for thread group during sync IPC */
#define MPO_ENFORCE_REPLY_PORT_SEMANTICS 0x2000 /* When talking to this port, local port of mach msg needs to follow reply port semantics.*/
/* This service port has requested security hardening */
#define MPO_STRICT_SERVICE_PORT (MPO_SERVICE_PORT | MPO_ENFORCE_REPLY_PORT_SEMANTICS)
#define MPO_OPTIONS_MASK \
(MPO_CONTEXT_AS_GUARD | \
MPO_QLIMIT | \
MPO_TEMPOWNER | \
MPO_IMPORTANCE_RECEIVER | \
MPO_INSERT_SEND_RIGHT | \
MPO_STRICT | \
MPO_DENAP_RECEIVER | \
MPO_IMMOVABLE_RECEIVE | \
MPO_FILTER_MSG | \
MPO_TG_BLOCK_TRACKING | \
MPO_ENFORCE_REPLY_PORT_SEMANTICS)
/* MPO port type flags */
#define MPO_MAKE_PORT_TYPE(a, b) (((a & 0x7) << 14) | ((b & 0x7) << 10))
#define MPO_PORT_TYPE_MASK MPO_MAKE_PORT_TYPE(0x7, 0x7) /* 0x1dc00 */
/* These need to be defined for libxpc and other clients who `#ifdef` */
#define MPO_PORT MPO_PORT
#define MPO_SERVICE_PORT MPO_SERVICE_PORT
#define MPO_CONNECTION_PORT MPO_CONNECTION_PORT
#define MPO_REPLY_PORT MPO_REPLY_PORT
#define MPO_PROVISIONAL_REPLY_PORT MPO_PROVISIONAL_REPLY_PORT
#define MPO_EXCEPTION_PORT MPO_EXCEPTION_PORT
#define MPO_CONNECTION_PORT_WITH_PORT_ARRAY MPO_CONNECTION_PORT_WITH_PORT_ARRAY
__options_decl(mpo_flags_t, uint32_t, {
/* Your classic IOT_PORT, an uninteresting message queue */
MPO_PORT = MPO_MAKE_PORT_TYPE(0, 0), /* 0x0 */
/* Create a service port with the given name; should be used only by launchd */
MPO_SERVICE_PORT = MPO_MAKE_PORT_TYPE(0, 1), /* 0x400 */
/* Derive new peer connection port from a given service port */
MPO_CONNECTION_PORT = MPO_MAKE_PORT_TYPE(0, 2), /* 0x800 */
/* Designate port as a reply port */
MPO_REPLY_PORT = MPO_MAKE_PORT_TYPE(0, 4), /* 0x1000 */
/* Designate port as a provisional (fake) reply port */
MPO_PROVISIONAL_REPLY_PORT = MPO_MAKE_PORT_TYPE(1, 0), /* 0x4000 */
/* Used for hardened exceptions - immovable */
MPO_EXCEPTION_PORT = MPO_MAKE_PORT_TYPE(2, 0), /* 0x8000 */
/* Can receive OOL port array descriptors */
MPO_CONNECTION_PORT_WITH_PORT_ARRAY = MPO_MAKE_PORT_TYPE(4, 0), /* 0x10000 */
});
#define MPO_UNUSED_BITS ~(MPO_OPTIONS_MASK | MPO_PORT_TYPE_MASK)
/* Denotes an anonymous service */
#define MPO_ANONYMOUS_SERVICE (MACH_PORT_DEAD - 1)
/*
* Structure to define optional attributes for a newly
* constructed port.
*/
typedef struct mach_port_options {
uint32_t flags; /* Flags defining attributes for port */
uint32_t flags;
mach_port_limits_t mpl; /* Message queue limit for port */
union {
uint64_t reserved[2]; /* Reserved */
@ -405,6 +448,7 @@ typedef mach_port_options_t *mach_port_options_ptr_t;
* but are truly an enum, please add new values in the "holes".
*/
enum mach_port_guard_exception_codes {
kGUARD_EXC_NONE = 0, /* never sent */
kGUARD_EXC_DESTROY = 1,
kGUARD_EXC_MOD_REFS = 2,
kGUARD_EXC_INVALID_OPTIONS = 3,
@ -413,9 +457,14 @@ enum mach_port_guard_exception_codes {
kGUARD_EXC_EXCEPTION_BEHAVIOR_ENFORCE = 6,
kGUARD_EXC_SERVICE_PORT_VIOLATION_FATAL = 7, /* unused, for future sp defense enablement */
kGUARD_EXC_UNGUARDED = 8,
kGUARD_EXC_KOBJECT_REPLY_PORT_SEMANTICS = 9,
kGUARD_EXC_REQUIRE_REPLY_PORT_SEMANTICS = 10,
kGUARD_EXC_INCORRECT_GUARD = 16,
kGUARD_EXC_IMMOVABLE = 32,
kGUARD_EXC_STRICT_REPLY = 64,
kGUARD_EXC_INVALID_NOTIFICATION_REQ = 65,
kGUARD_EXC_INVALID_MPO_ENTITLEMENT = 66,
kGUARD_EXC_DESCRIPTOR_VIOLATION = 67,
kGUARD_EXC_MSG_FILTERED = 128,
/* start of [optionally] non-fatal guards */
kGUARD_EXC_INVALID_RIGHT = 256,
@ -434,40 +483,75 @@ enum mach_port_guard_exception_codes {
kGUARD_EXC_RCV_GUARDED_DESC = 0x00100000, /* for development only */
kGUARD_EXC_SERVICE_PORT_VIOLATION_NON_FATAL = 0x00100001, /* unused, for future sp defense enablement */
kGUARD_EXC_PROVISIONAL_REPLY_PORT = 0x00100002,
kGUARD_EXC_OOL_PORT_ARRAY_CREATION = 0x00100003, /* unused */
kGUARD_EXC_MOVE_PROVISIONAL_REPLY_PORT = 0x00100004,
kGUARD_EXC_REPLY_PORT_SINGLE_SO_RIGHT = 0x00100005,
kGUARD_EXC_MOD_REFS_NON_FATAL = 1u << 21,
kGUARD_EXC_IMMOVABLE_NON_FATAL = 1u << 22,
kGUARD_EXC_REQUIRE_REPLY_PORT_SEMANTICS = 1u << 23,
};
#define MAX_FATAL_kGUARD_EXC_CODE kGUARD_EXC_MSG_FILTERED
#define MAX_OPTIONAL_kGUARD_EXC_CODE kGUARD_EXC_RCV_INVALID_NAME
/*
* Mach port guard flags.
*/
#define MPG_FLAGS_NONE (0x00ull)
#define MPG_FLAGS_NONE 0x00
/*
* These flags are used as bits in the subcode of kGUARD_EXC_STRICT_REPLY exceptions.
*/
#define MPG_FLAGS_STRICT_REPLY_INVALID_REPLY_DISP (0x01ull << 56)
#define MPG_FLAGS_STRICT_REPLY_INVALID_REPLY_PORT (0x02ull << 56)
#define MPG_FLAGS_STRICT_REPLY_INVALID_VOUCHER (0x04ull << 56)
#define MPG_FLAGS_STRICT_REPLY_NO_BANK_ATTR (0x08ull << 56)
#define MPG_FLAGS_STRICT_REPLY_MISMATCHED_PERSONA (0x10ull << 56)
#define MPG_FLAGS_STRICT_REPLY_MASK (0xffull << 56)
#define MPG_FLAGS_STRICT_REPLY_INVALID_VOUCHER 0x04
#define MPG_FLAGS_STRICT_REPLY_MISMATCHED_PERSONA 0x10
/*
* These flags are used as bits in the subcode of kGUARD_EXC_MOD_REFS exceptions.
*/
#define MPG_FLAGS_MOD_REFS_PINNED_DEALLOC (0x01ull << 56)
#define MPG_FLAGS_MOD_REFS_PINNED_DESTROY (0x02ull << 56)
#define MPG_FLAGS_MOD_REFS_PINNED_COPYIN (0x04ull << 56)
#define MPG_FLAGS_MOD_REFS_PINNED_DEALLOC 0x01
#define MPG_FLAGS_MOD_REFS_PINNED_DESTROY 0x02
#define MPG_FLAGS_MOD_REFS_PINNED_COPYIN 0x03
/*
* These flags are used as bits in the subcode of kGUARD_EXC_IMMOVABLE exceptions.
* These flags are used as bits in the subcode of kGUARD_EXC_INVALID_RIGHT exceptions.
*/
#define MPG_FLAGS_IMMOVABLE_PINNED (0x01ull << 56)
#define MPG_FLAGS_INVALID_RIGHT_RECV 0x01 /* does not have receive right */
#define MPG_FLAGS_INVALID_RIGHT_DELTA 0x02 /* ipc_right_delta() */
#define MPG_FLAGS_INVALID_RIGHT_DESTRUCT 0x03 /* ipc_right_destruct() */
#define MPG_FLAGS_INVALID_RIGHT_COPYIN 0x04 /* ipc_right_copyin() */
#define MPG_FLAGS_INVALID_RIGHT_DEALLOC 0x05 /* ipc_right_dealloc() */
#define MPG_FLAGS_INVALID_RIGHT_DEALLOC_KERNEL 0x06 /* mach_port_deallocate_kernel() */
#define MPG_FLAGS_INVALID_RIGHT_TRANSLATE_PORT 0x07 /* port in ipc_object_translate_port_pset() */
#define MPG_FLAGS_INVALID_RIGHT_TRANSLATE_PSET 0x08 /* pset in ipc_object_translate_port_pset() */
/*
* These flags are used as bits in the subcode of kGUARD_EXC_INVALID_VALUE exceptions.
*/
#define MPG_FLAGS_INVALID_VALUE_PEEK 0x01 /* mach_port_peek() */
#define MPG_FLAGS_INVALID_VALUE_DELTA 0x02 /* ipc_right_delta() */
#define MPG_FLAGS_INVALID_VALUE_DESTRUCT 0x03 /* ipc_right_destruct() */
/*
* These flags are used as bits in the subcode of kGUARD_EXC_KERN_FAILURE exceptions.
*/
#define MPG_FLAGS_KERN_FAILURE_TASK 0x01 /* task other than launchd arm pd on service ports */
#define MPG_FLAGS_KERN_FAILURE_NOTIFY_TYPE 0x02 /* not using IOT_NOTIFICATION_PORT for pd notification */
#define MPG_FLAGS_KERN_FAILURE_NOTIFY_RECV 0x03 /* notification port not owned by launchd */
#define MPG_FLAGS_KERN_FAILURE_MULTI_NOTI 0x04 /* register multiple pd notification */
/*
* These flags are used as bits in the subcode of kGUARD_EXC_SEND_INVALID_RIGHT exceptions.
*/
#define MPG_FLAGS_SEND_INVALID_RIGHT_PORT 0x01 /* ipc_kmsg_copyin_port_descriptor() */
#define MPG_FLAGS_SEND_INVALID_RIGHT_OOL_PORT 0x02 /* ipc_kmsg_copyin_ool_ports_descriptor() */
#define MPG_FLAGS_SEND_INVALID_RIGHT_GUARDED 0x03 /* ipc_kmsg_copyin_guarded_port_descriptor */
/*
* These flags are used as bits in the subcode of kGUARD_EXC_INVALID_OPTIONS exceptions.
*/
#define MPG_FLAGS_INVALID_OPTIONS_OOL_DISP 0x01 /* ipc_kmsg_copyin_ool_ports_descriptor() */
#define MPG_FLAGS_INVALID_OPTIONS_OOL_ARRAYS 0x02 /* ipc_validate_kmsg_header_from_user() */
#define MPG_FLAGS_INVALID_OPTIONS_OOL_RIGHT 0x03 /* ipc_validate_kmsg_header_from_user() */
/*
* Flags for mach_port_guard_with_flags. These flags extend

View File

@ -511,6 +511,16 @@ typedef struct task_security_config_info * task_security_config_info_t;
#define TASK_SECURITY_CONFIG_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(struct task_security_config_info) / sizeof(natural_t)))
#define TASK_IPC_SPACE_POLICY_INFO 33 /* Runtime security mitigations configuration for the task */
struct task_ipc_space_policy_info {
uint32_t space_policy; /* Configuration bitmask */
};
typedef struct task_ipc_space_policy_info * task_ipc_space_policy_info_t;
#define TASK_IPC_SPACE_POLICY_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(struct task_ipc_space_policy_info) / sizeof(natural_t)))
/*
* Type to control EXC_GUARD delivery options for a task
* via task_get/set_exc_guard_behavior interface(s).

View File

@ -121,6 +121,7 @@ typedef enum task_role {
TASK_NONUI_APPLICATION = 6,
TASK_DEFAULT_APPLICATION = 7,
TASK_DARWINBG_APPLICATION = 8,
TASK_USER_INIT_APPLICATION = 9,
} task_role_t;
struct task_category_policy {

View File

@ -74,7 +74,6 @@
#include <mach/time_value.h>
#include <mach/message.h>
#include <mach/machine/vm_types.h>
/*
* Generic information structure to allow for expansion.
*/

View File

@ -228,6 +228,7 @@ typedef struct vm_region_submap_info vm_region_submap_info_data_t;
(sizeof(vm_region_submap_info_data_t) / sizeof(natural_t)))
struct vm_region_submap_info_64 {
/* v0 fields */
vm_prot_t protection; /* present access protection */
vm_prot_t max_protection; /* max avail through vm_prot */
vm_inherit_t inheritance;/* behavior of map/obj on fork */
@ -245,18 +246,30 @@ struct vm_region_submap_info_64 {
vm_behavior_t behavior; /* access behavior hint */
vm32_object_id_t object_id; /* obj/map name, not a handle */
unsigned short user_wired_count;
unsigned short flags;
/* v1 fields */
unsigned int pages_reusable;
/* v2 fields */
vm_object_id_t object_id_full;
};
typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
/*
* Note that this size is hard-coded at the MIG boundary in mach_types.defs
* so if we ever increase this you'll need to also bump the definition of
* vm_region_recurse_info_t.
*/
#define VM_REGION_SUBMAP_INFO_V2_SIZE \
(sizeof (vm_region_submap_info_data_64_t))
/* v1 size is v2 size minus v2's new fields */
#define VM_REGION_SUBMAP_INFO_V1_SIZE \
(VM_REGION_SUBMAP_INFO_V2_SIZE - \
sizeof (vm_object_id_t) /* object_id_full */ )
/* v0 size is v1 size minus v1's new fields */
#define VM_REGION_SUBMAP_INFO_V0_SIZE \
(VM_REGION_SUBMAP_INFO_V1_SIZE - \
sizeof (unsigned int) /* pages_reusable */ )
@ -274,6 +287,10 @@ typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t
/* set this to the latest version */
#define VM_REGION_SUBMAP_INFO_COUNT_64 VM_REGION_SUBMAP_INFO_V2_COUNT_64
#define VM_REGION_FLAG_JIT_ENABLED 0x1
#define VM_REGION_FLAG_TPRO_ENABLED 0x2
struct vm_region_submap_short_info_64 {
vm_prot_t protection; /* present access protection */
vm_prot_t max_protection; /* max avail through vm_prot */
@ -288,6 +305,7 @@ struct vm_region_submap_short_info_64 {
vm_behavior_t behavior; /* access behavior hint */
vm32_object_id_t object_id; /* obj/map name, not a handle */
unsigned short user_wired_count;
unsigned short flags;
};
typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t;

View File

@ -66,6 +66,9 @@
#ifndef _MACH_VM_STATISTICS_H_
#define _MACH_VM_STATISTICS_H_
#include <Availability.h>
#include <os/base.h>
#include <stdbool.h>
#include <sys/cdefs.h>
@ -74,6 +77,8 @@
__BEGIN_DECLS
#pragma mark VM Statistics
/*
* vm_statistics
*
@ -141,7 +146,7 @@ struct vm_statistics64 {
natural_t wire_count; /* # of pages wired down */
uint64_t zero_fill_count; /* # of zero fill pages */
uint64_t reactivations; /* # of pages reactivated */
uint64_t pageins; /* # of pageins */
uint64_t pageins; /* # of pageins (lifetime) */
uint64_t pageouts; /* # of pageouts */
uint64_t faults; /* # of faults */
uint64_t cow_faults; /* # of copy-on-writes */
@ -158,15 +163,17 @@ struct vm_statistics64 {
natural_t speculative_count; /* # of pages speculative */
/* added for rev1 */
uint64_t decompressions; /* # of pages decompressed */
uint64_t compressions; /* # of pages compressed */
uint64_t swapins; /* # of pages swapped in (via compression segments) */
uint64_t swapouts; /* # of pages swapped out (via compression segments) */
uint64_t decompressions; /* # of pages decompressed (lifetime) */
uint64_t compressions; /* # of pages compressed (lifetime) */
uint64_t swapins; /* # of pages swapped in via compressor segments (lifetime) */
uint64_t swapouts; /* # of pages swapped out via compressor segments (lifetime) */
natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */
natural_t throttled_count; /* # of pages throttled */
natural_t external_page_count; /* # of pages that are file-backed (non-swap) */
natural_t internal_page_count; /* # of pages that are anonymous */
uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */
/* added for rev2 */
uint64_t swapped_count; /* # of compressor-stored pages currently stored in swap */
} __attribute__((aligned(8)));
typedef struct vm_statistics64 *vm_statistics64_t;
@ -232,6 +239,8 @@ typedef struct vm_purgeable_info *vm_purgeable_info_t;
#define VM_PAGE_QUERY_PAGE_CS_NX 0x400
#define VM_PAGE_QUERY_PAGE_REUSABLE 0x800
#pragma mark User Flags
/*
* VM allocation flags:
*
@ -334,17 +343,27 @@ typedef struct vm_purgeable_info *vm_purgeable_info_t;
__enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
kGUARD_EXC_DEALLOC_GAP = 1,
kGUARD_EXC_RECLAIM_COPYIO_FAILURE = 2,
kGUARD_EXC_SEC_LOOKUP_DENIED = 3,
kGUARD_EXC_RECLAIM_INDEX_FAILURE = 4,
kGUARD_EXC_SEC_RANGE_DENIED = 6,
kGUARD_EXC_SEC_ACCESS_FAULT = 7,
kGUARD_EXC_RECLAIM_DEALLOCATE_FAILURE = 8,
kGUARD_EXC_SEC_COPY_DENIED = 16,
kGUARD_EXC_SEC_SHARING_DENIED = 32,
kGUARD_EXC_SEC_ASYNC_ACCESS_FAULT = 64,
kGUARD_EXC_RECLAIM_ACCOUNTING_FAILURE = 9,
kGUARD_EXC_SEC_IOPL_ON_EXEC_PAGE = 10,
kGUARD_EXC_SEC_EXEC_ON_IOPL_PAGE = 11,
kGUARD_EXC_SEC_UPL_WRITE_ON_EXEC_REGION = 12,
/*
* rdar://151450801 (Remove spurious kGUARD_EXC_SEC_ACCESS_FAULT and kGUARD_EXC_SEC_ASYNC_ACCESS_FAULT once CrashReporter is aligned)
*/
kGUARD_EXC_SEC_ACCESS_FAULT = 98,
kGUARD_EXC_SEC_ASYNC_ACCESS_FAULT = 99,
/* VM policy decisions */
kGUARD_EXC_SEC_COPY_DENIED = 100,
kGUARD_EXC_SEC_SHARING_DENIED = 101,
});
#pragma mark Ledger Tags
/* current accounting postmark */
#define __VM_LEDGER_ACCOUNTING_POSTMARK 2019032600
@ -372,6 +391,14 @@ __enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
#define VM_LEDGER_FLAGS_USER (VM_LEDGER_FLAG_NO_FOOTPRINT | VM_LEDGER_FLAG_NO_FOOTPRINT_FOR_DEBUG)
#define VM_LEDGER_FLAGS_ALL (VM_LEDGER_FLAGS_USER | VM_LEDGER_FLAG_FROM_KERNEL)
#pragma mark User Memory Tags
/*
* These tags may be used to identify memory regions created with
* `mach_vm_map()` or `mach_vm_allocate()` via the top 8 bits of the `flags`
* parameter. Users should pass `VM_MAKE_TAG(tag) | flags` (see section
* "User Flags").
*/
#define VM_MEMORY_MALLOC 1
#define VM_MEMORY_MALLOC_SMALL 2
#define VM_MEMORY_MALLOC_LARGE 3
@ -400,6 +427,8 @@ __enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
/* Was a nested pmap (VM_MEMORY_SHARED_PMAP) which has now been unnested */
#define VM_MEMORY_UNSHARED_PMAP 35
/* for libchannel memory, mostly used on visionOS for communication with realtime threads */
#define VM_MEMORY_LIBCHANNEL 36
// Placeholders for now -- as we analyze the libraries and find how they
// use memory, we can make these labels more specific.
@ -411,6 +440,7 @@ __enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
#define VM_MEMORY_JAVA 44
#define VM_MEMORY_COREDATA 45
#define VM_MEMORY_COREDATA_OBJECTIDS 46
#define VM_MEMORY_ATS 50
#define VM_MEMORY_LAYERKIT 51
#define VM_MEMORY_CGIMAGE 52
@ -506,6 +536,8 @@ __enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
/* DHMM data */
#define VM_MEMORY_DHMM 84
/* memory needed for DFR related actions */
#define VM_MEMORY_DFR 85
/* memory allocated by SceneKit.framework */
#define VM_MEMORY_SCENEKIT 86
@ -562,6 +594,9 @@ __enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
/* memory allocated by CoreMedia */
#define VM_MEMORY_CM_HLS 106
/* memory allocated for CompositorServices */
#define VM_MEMORY_COMPOSITOR_SERVICES 107
/* Reserve 230-239 for Rosetta */
#define VM_MEMORY_ROSETTA 230
#define VM_MEMORY_ROSETTA_THREAD_CONTEXT 231
@ -573,7 +608,21 @@ __enum_decl(virtual_memory_guard_exception_code_t, uint32_t, {
#define VM_MEMORY_ROSETTA_10 239
/* Reserve 240-255 for application */
#define VM_MEMORY_APPLICATION_SPECIFIC_1 240
#define VM_MEMORY_APPLICATION_SPECIFIC_1 240
#define VM_MEMORY_APPLICATION_SPECIFIC_2 241
#define VM_MEMORY_APPLICATION_SPECIFIC_3 242
#define VM_MEMORY_APPLICATION_SPECIFIC_4 243
#define VM_MEMORY_APPLICATION_SPECIFIC_5 244
#define VM_MEMORY_APPLICATION_SPECIFIC_6 245
#define VM_MEMORY_APPLICATION_SPECIFIC_7 246
#define VM_MEMORY_APPLICATION_SPECIFIC_8 247
#define VM_MEMORY_APPLICATION_SPECIFIC_9 248
#define VM_MEMORY_APPLICATION_SPECIFIC_10 249
#define VM_MEMORY_APPLICATION_SPECIFIC_11 250
#define VM_MEMORY_APPLICATION_SPECIFIC_12 251
#define VM_MEMORY_APPLICATION_SPECIFIC_13 252
#define VM_MEMORY_APPLICATION_SPECIFIC_14 253
#define VM_MEMORY_APPLICATION_SPECIFIC_15 254
#define VM_MEMORY_APPLICATION_SPECIFIC_16 255
#define VM_MEMORY_COUNT 256

View File

@ -70,6 +70,81 @@
#include <mach/port.h>
#include <mach/machine/vm_types.h>
/*!
* @brief
* Type for mach_port_kobject_description() only.
*
* @discussion
* This type preserved the `IOT_*` values that @c ipc_kobject_type_t used
* to carry, whose ABI of this type was known to debugging tools of userspace,
* by copying XNU's source.
*
* This provides a guaranteed stable interface now (however no guarantee
* is made that values are still in use).
*
* Values should never be removed to that list, merely abandonned with
* a comment.
*/
__enum_decl(ipc_info_object_type_t, natural_t, {
IPC_OTYPE_NONE = 0,
IPC_OTYPE_THREAD_CONTROL = 1,
IPC_OTYPE_TASK_CONTROL = 2,
IPC_OTYPE_HOST = 3,
IPC_OTYPE_HOST_PRIV = 4,
IPC_OTYPE_PROCESSOR = 5,
IPC_OTYPE_PROCESSOR_SET = 6,
IPC_OTYPE_PROCESSOR_SET_NAME = 7,
IPC_OTYPE_TIMER = 8,
IPC_OTYPE_PORT_SUBST_ONCE = 9, /* obsolete: no instances */
IPC_OTYPE_MIG = 10, /* obsolete: no instances */
IPC_OTYPE_MEMORY_OBJECT = 11, /* no port instances */
IPC_OTYPE_XMM_PAGER = 12, /* obsolete: no instances */
IPC_OTYPE_XMM_KERNEL = 13, /* obsolete: no instances */
IPC_OTYPE_XMM_REPLY = 14, /* obsolete: no instances */
IPC_OTYPE_UND_REPLY = 15,
IPC_OTYPE_HOST_NOTIFY = 16, /* obsolete: no instances */
IPC_OTYPE_HOST_SECURITY = 17, /* obsolete: no instances */
IPC_OTYPE_LEDGER = 18, /* obsolete: no instances */
IPC_OTYPE_MAIN_DEVICE = 19,
IPC_OTYPE_TASK_NAME = 20,
IPC_OTYPE_SUBSYSTEM = 21, /* obsolete: no instances */
IPC_OTYPE_IO_DONE_QUEUE = 22, /* obsolete: no instances */
IPC_OTYPE_SEMAPHORE = 23,
IPC_OTYPE_LOCK_SET = 24, /* obsolete: no instances */
IPC_OTYPE_CLOCK = 25,
IPC_OTYPE_CLOCK_CTRL = 26, /* obsolete: no instances */
IPC_OTYPE_IOKIT_IDENT = 27,
IPC_OTYPE_NAMED_ENTRY = 28,
IPC_OTYPE_IOKIT_CONNECT = 29,
IPC_OTYPE_IOKIT_OBJECT = 30,
IPC_OTYPE_UPL = 31, /* obsolete: no instances */
IPC_OTYPE_MEM_OBJ_CONTROL = 32, /* obsolete: no instances */
IPC_OTYPE_AU_SESSIONPORT = 33,
IPC_OTYPE_FILEPORT = 34,
IPC_OTYPE_LABELH = 35, /* obsolete: no instances */
IPC_OTYPE_TASK_RESUME = 36,
IPC_OTYPE_VOUCHER = 37,
IPC_OTYPE_VOUCHER_ATTR_CONTROL = 38, /* obsolete: no instances */
IPC_OTYPE_WORK_INTERVAL = 39,
IPC_OTYPE_UX_HANDLER = 40,
IPC_OTYPE_UEXT_OBJECT = 41,
IPC_OTYPE_ARCADE_REG = 42,
IPC_OTYPE_EVENTLINK = 43,
IPC_OTYPE_TASK_INSPECT = 44,
IPC_OTYPE_TASK_READ = 45,
IPC_OTYPE_THREAD_INSPECT = 46,
IPC_OTYPE_THREAD_READ = 47,
IPC_OTYPE_SUID_CRED = 48, /* obsolete: no instances */
IPC_OTYPE_HYPERVISOR = 49,
IPC_OTYPE_TASK_ID_TOKEN = 50,
IPC_OTYPE_TASK_FATAL = 51,
IPC_OTYPE_KCDATA = 52,
IPC_OTYPE_EXCLAVES_RESOURCE = 53,
/* catchall */
IPC_OTYPE_UNKNOWN = ~0u,
});
/*
* Remember to update the mig type definitions
* in mach_debug_types.defs when adding/removing fields.

View File

@ -55,8 +55,8 @@ void * __sized_by_or_null(__size) malloc(size_t __size) __result_use_check __all
void * __sized_by_or_null(__count * __size) calloc(size_t __count, size_t __size) __result_use_check __alloc_size(1,2) _MALLOC_TYPED(malloc_type_calloc, 2);
void free(void * __unsafe_indexable);
void * __sized_by_or_null(__size) realloc(void * __unsafe_indexable __ptr, size_t __size) __result_use_check __alloc_size(2) _MALLOC_TYPED(malloc_type_realloc, 2);
void * __sized_by_or_null(__size) reallocf(void * __unsafe_indexable __ptr, size_t __size) __result_use_check __alloc_size(2);
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
void * __sized_by_or_null(__size) reallocf(void * __unsafe_indexable __ptr, size_t __size) __result_use_check __alloc_size(2);
void * __sized_by_or_null(__size) valloc(size_t __size) __result_use_check __alloc_size(1) _MALLOC_TYPED(malloc_type_valloc, 1);
#endif /* !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */
#if (defined(__DARWIN_C_LEVEL) && defined(__DARWIN_C_FULL) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \
@ -67,6 +67,75 @@ void * __sized_by_or_null(__size) aligned_alloc(size_t __alignment, size_t __siz
/* rdar://120689514 */
int posix_memalign(void * __unsafe_indexable *__memptr, size_t __alignment, size_t __size) _MALLOC_TYPED(malloc_type_posix_memalign, 3) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
#if defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_malloc_backdeploy(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1) {
__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_malloc(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
__auto_type func = malloc;
if (malloc_type_malloc) {
return malloc_type_malloc(size, type_id);
}
return func(size);
}
static void * __sized_by_or_null(count * size) __attribute__((always_inline)) malloc_type_calloc_backdeploy(size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1,2) {
__attribute__((weak_import)) void * __sized_by_or_null(count * size) malloc_type_calloc(size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1,2);
__auto_type func = calloc;
if (malloc_type_calloc) {
return malloc_type_calloc(count, size, type_id);
}
return func(count, size);
}
static void __attribute__((always_inline)) malloc_type_free_backdeploy(void * __unsafe_indexable ptr, malloc_type_id_t type_id) {
__attribute__((weak_import)) void malloc_type_free(void * __unsafe_indexable ptr, malloc_type_id_t type_id);
__auto_type func = free;
if (malloc_type_free) {
malloc_type_free(ptr, type_id);
} else {
func(ptr);
}
}
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_realloc_backdeploy(void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2) {
__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_realloc(void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
__auto_type func = realloc;
if (malloc_type_realloc) {
return malloc_type_realloc(ptr, size, type_id);
}
return func(ptr, size);
}
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_valloc_backdeploy(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1) {
__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_valloc(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
__auto_type func = valloc;
if (malloc_type_valloc) {
return malloc_type_valloc(size, type_id);
}
return func(size);
}
#if (defined(__DARWIN_C_LEVEL) && defined(__DARWIN_C_FULL) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L)
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_aligned_alloc_backdeploy(size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(1) __alloc_size(2) {
__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_aligned_alloc(size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(1) __alloc_size(2);
__auto_type func = aligned_alloc;
if (malloc_type_aligned_alloc) {
return malloc_type_aligned_alloc(alignment, size, type_id);
}
return func(alignment, size);
}
#endif
static int __attribute__((always_inline)) malloc_type_posix_memalign_backdeploy(void * __unsafe_indexable *memptr, size_t alignment, size_t size, malloc_type_id_t type_id) {
__attribute__((weak_import)) int malloc_type_posix_memalign(void * __unsafe_indexable *memptr, size_t alignment, size_t size, malloc_type_id_t type_id);
__auto_type func = posix_memalign;
if (malloc_type_posix_memalign) {
return malloc_type_posix_memalign(memptr, alignment, size, type_id);
}
return func(memptr, alignment, size);
}
#endif
__END_DECLS
#endif /* _MALLOC_UNDERSCORE_MALLOC_H_ */

View File

@ -39,44 +39,107 @@ typedef unsigned long long malloc_type_id_t;
#define __need_size_t
#include <stddef.h>
#undef __need_size_t
#endif
#endif /* size_t */
#include <sys/cdefs.h> /* __BEGIN_DECLS */
#define _MALLOC_TYPE_AVAILABILITY __API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
__BEGIN_DECLS
/* <malloc/_malloc.h> */
#define _MALLOC_TYPE_MALLOC_BACKDEPLOY_PUBLIC 1
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(size) malloc_type_malloc(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(count * size) malloc_type_calloc(size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1,2);
_MALLOC_TYPE_AVAILABILITY void malloc_type_free(void * __unsafe_indexable ptr, malloc_type_id_t type_id);
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(size) malloc_type_realloc(void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(size) malloc_type_valloc(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(size) malloc_type_aligned_alloc(size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
/* rdar://120689514 */
_MALLOC_TYPE_AVAILABILITY int malloc_type_posix_memalign(void * __unsafe_indexable *memptr, size_t alignment, size_t size, malloc_type_id_t type_id) /*__alloc_size(3)*/;
#if _MALLOC_TYPE_MALLOC_BACKDEPLOY_PUBLIC && defined(__has_feature) && __has_feature(typed_memory_operations) && __has_builtin(__is_target_os) && defined(__LP64__) && !defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING)
#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)
#define _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING 1
#endif
#endif
/** If we are in a TMO backdeployment configuration we do not globally declare the
* real TMO entry points, so that we error out if someone is trying to use them
* when their presence is not guaranteed
*/
#if defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_malloc_backdeploy(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
static void * __sized_by_or_null(count * size) __attribute__((always_inline)) malloc_type_calloc_backdeploy(size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1,2);
static void __attribute__((always_inline)) malloc_type_free_backdeploy(void * __unsafe_indexable ptr, malloc_type_id_t type_id);
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_realloc_backdeploy(void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_valloc_backdeploy(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
#if (defined(__DARWIN_C_LEVEL) && defined(__DARWIN_C_FULL) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L)
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_aligned_alloc_backdeploy(size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(1) __alloc_size(2);
#endif
static int __attribute__((always_inline)) malloc_type_posix_memalign_backdeploy(void * __unsafe_indexable *memptr, size_t alignment, size_t size, malloc_type_id_t type_id) /*__alloc_align(2) __alloc_size(3)*/;
/* <malloc/malloc.h> */
typedef struct _malloc_zone_t malloc_zone_t;
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(size) malloc_type_zone_malloc(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(count * size) malloc_type_zone_calloc(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3);
_MALLOC_TYPE_AVAILABILITY void malloc_type_zone_free(malloc_zone_t *zone, void * __unsafe_indexable ptr, malloc_type_id_t type_id);
_MALLOC_TYPE_AVAILABILITY void * __sized_by_or_null(size) malloc_type_zone_realloc(malloc_zone_t *zone, void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(3);
_MALLOC_TYPE_AVAILABILITY void *__sized_by_or_null(size) malloc_type_zone_valloc(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
_MALLOC_TYPE_AVAILABILITY void *__sized_by_or_null(size) malloc_type_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(3);
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_malloc_backdeploy(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
static void * __sized_by_or_null(count * size) __attribute__((always_inline)) malloc_type_zone_calloc_backdeploy(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3);
static void __attribute__((always_inline)) malloc_type_zone_free_backdeploy(malloc_zone_t *zone, void * __unsafe_indexable ptr, malloc_type_id_t type_id);
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_realloc_backdeploy(malloc_zone_t *zone, void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(3);
static void *__sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_valloc_backdeploy(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
static void *__sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_memalign_backdeploy(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(2) __alloc_size(3);
#else
/* <malloc/_malloc.h> */
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(size) malloc_type_malloc(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(count * size) malloc_type_calloc(size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1,2);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void malloc_type_free(void * __unsafe_indexable ptr, malloc_type_id_t type_id);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(size) malloc_type_realloc(void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(size) malloc_type_valloc(size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(1);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(size) malloc_type_aligned_alloc(size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(1) __alloc_size(2);
/* rdar://120689514 */
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
int malloc_type_posix_memalign(void * __unsafe_indexable *memptr, size_t alignment, size_t size, malloc_type_id_t type_id) /*__alloc_align(2) __alloc_size(3)*/;
/* <malloc/malloc.h> */
typedef struct _malloc_zone_t malloc_zone_t;
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(size) malloc_type_zone_malloc(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(count * size) malloc_type_zone_calloc(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void malloc_type_zone_free(malloc_zone_t *zone, void * __unsafe_indexable ptr, malloc_type_id_t type_id);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void * __sized_by_or_null(size) malloc_type_zone_realloc(malloc_zone_t *zone, void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(3);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void *__sized_by_or_null(size) malloc_type_zone_valloc(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
__API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0), watchos(10.0), visionos(1.0), driverkit(23.0))
void *__sized_by_or_null(size) malloc_type_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(2) __alloc_size(3);
#endif
__END_DECLS
/* Rewrite enablement */
#if defined(__has_feature) && __has_feature(typed_memory_operations)
#if __has_builtin(__is_target_os) && (__is_target_os(ios) || __is_target_os(driverkit) || __is_target_os(macos) || __is_target_os(xros) || __is_target_os(watchos) || __is_target_os(tvos) || (__has_builtin(__is_target_environment) && (__is_target_environment(exclavekit) || __is_target_environment(exclavecore))))
#if (__has_builtin(__is_target_os) && __is_target_os(darwin) && !__is_target_os(bridgeos)) ||\
(__has_builtin(__is_target_environment) && (__is_target_environment(exclavekit) || __is_target_environment(exclavecore)))
#if defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING
#define _MALLOC_TYPE_ENABLED 1
#define _MALLOC_TYPED(override, type_param_pos) __attribute__((typed_memory_operation(override##_backdeploy, type_param_pos)))
#else
#define _MALLOC_TYPED(override, type_param_pos) __attribute__((typed_memory_operation(override, type_param_pos)))
#define _MALLOC_TYPE_ENABLED 1
#endif
#endif
#endif
#endif /* defined(__has_feature) && __has_feature(typed_memory_operations) */
#endif /* MALLOC_TARGET_64BIT */

View File

@ -2,14 +2,14 @@
* Copyright (c) 1999-2023 Apple Computer, 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,
@ -17,7 +17,7 @@
* 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@
*/
@ -62,6 +62,57 @@ __ptrcheck_abi_assume_single()
#endif // MALLOC_ZONE_FN_PTR
__BEGIN_DECLS
/********* Typed zone functions ************/
#if defined(__has_attribute) && __has_attribute(swift_name)
#define MALLOC_SWIFT_NAME(x) __attribute__((swift_name(#x)))
#else
#define MALLOC_SWIFT_NAME(x)
#endif // defined(__has_attribute) && __has_attribute(swift_name)
/*!
* @constant MALLOC_ZONE_MALLOC_DEFAULT_ALIGN
* Default alignment for malloc_type_zone_malloc_with_options
*/
#define MALLOC_ZONE_MALLOC_DEFAULT_ALIGN __SIZEOF_POINTER__
/*!
* @enum malloc_zone_malloc_options_t
*
* @constant MALLOC_ZONE_MALLOC_OPTION_NONE
* Empty placeholder option.
*
* @constant MALLOC_ZONE_MALLOC_OPTION_CLEAR
* Zero out the allocated memory, similar to calloc().
*
*/
/*!
* @constant MALLOC_ZONE_MALLOC_OPTION_CANONICAL_TAG
* Under MTE, use a tag of zero (canonical) instead of a random value.
*/
typedef enum __enum_options : uint64_t {
MALLOC_ZONE_MALLOC_OPTION_NONE = 0u,
MALLOC_ZONE_MALLOC_OPTION_CLEAR MALLOC_SWIFT_NAME(clear) = 1u << 0,
MALLOC_ZONE_MALLOC_OPTION_CANONICAL_TAG MALLOC_SWIFT_NAME(canonicalTag) = 1u << 1,
} malloc_zone_malloc_options_t;
/*!
* @function malloc_type_zone_malloc_with_options
*
* Like the other functions declared in malloc/_malloc_type.h, this function
* is not intended to be called directly, but is rather the rewrite target for
* calls to malloc_zone_malloc_with_options when typed memory operations are
* enabled.
*/
#if defined(__LP64__)
__API_AVAILABLE(macos(26.0), ios(26.0), tvos(26.0), watchos(26.0), visionos(26.0), driverkit(25.0))
void * __sized_by_or_null(size) malloc_type_zone_malloc_with_options(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id, malloc_zone_malloc_options_t opts) __result_use_check __alloc_align(2) __alloc_size(3);
#endif /* __LP64__ */
// The remainder of these functions are declared in malloc/_malloc_type.h, and
// the backdeployment variant definitions are at the bottom of this file.
/********* Type definitions ************/
/*
@ -160,8 +211,7 @@ typedef struct _malloc_zone_t {
void * __unsafe_indexable ptr);
/*
* Memory allocation with an extensible binary flags option. Currently for
* libmalloc-internal zone implementations only - should be NULL otherwise.
* Memory allocation with an extensible binary flags option.
* Added in version >= 15.
*/
void * __sized_by_or_null(size) (* MALLOC_ZONE_FN_PTR(malloc_with_options))(
@ -188,10 +238,9 @@ typedef struct _malloc_zone_t {
struct _malloc_zone_t *zone, size_t alignment, size_t size,
malloc_type_id_t type_id);
/* Must be NULL for non-libmalloc zone implementations */
void * __sized_by_or_null(size) (* MALLOC_ZONE_FN_PTR(malloc_type_malloc_with_options))(
struct _malloc_zone_t *zone, size_t align, size_t size, uint64_t options,
malloc_type_id_t type_id);
struct _malloc_zone_t *zone, size_t align, size_t size,
uint64_t options, malloc_type_id_t type_id);
} malloc_zone_t;
/*!
@ -352,6 +401,38 @@ extern void malloc_destroy_zone(malloc_zone_t *zone);
extern void * __sized_by_or_null(size) malloc_zone_malloc(malloc_zone_t *zone, size_t size) __alloc_size(2) _MALLOC_TYPED(malloc_type_zone_malloc, 2);
/* Allocates a new pointer of size size; zone must be non-NULL */
/*!
* @function malloc_zone_malloc_with_options
*
* @param zone
* The malloc zone that should be used to used to serve the allocation. This
* parameter may be NULL, in which case the default zone will be used.
*
* @param align
* The minimum alignment of the requested allocation. This parameter must be
* MALLOC_ZONE_MALLOC_DEFAULT_ALIGN to request default alignment, or a power
* of 2 >= sizeof(void *).
*
* @param size
* The size, in bytes, of the requested allocation. Must be an integral
* multiple of align if align is non-zero.
*
* @param options
* A bitmask of options defining how the memory should be allocated. See the
* available bit values in the malloc_zone_malloc_options_t enum definition.
*
* @result
* A pointer to the newly allocated block of memory, or NULL if the allocation
* failed.
*
* @discussion
* This API does not use errno to signal information about the reason for its
* success or failure, and makes no guarantees about preserving or settings its
* value in any case.
*/
__API_AVAILABLE(macos(26.0), ios(26.0), tvos(26.0), watchos(26.0), visionos(26.0), driverkit(25.0))
extern void * __sized_by_or_null(size) malloc_zone_malloc_with_options(malloc_zone_t *zone, size_t align, size_t size, malloc_zone_malloc_options_t opts) __alloc_align(2) __alloc_size(3) _MALLOC_TYPED(malloc_type_zone_malloc_with_options, 3);
extern void * __sized_by_or_null(num_items * size) malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size) __alloc_size(2,3) _MALLOC_TYPED(malloc_type_zone_calloc, 3);
/* Allocates a new pointer of size num_items * size; block is cleared; zone must be non-NULL */
@ -590,22 +671,80 @@ extern void malloc_zone_enumerate_discharged_pointers(malloc_zone_t *zone, void
// Version 13:
// - malloc_zone_t::malloc and malloc_zone_t::calloc assume responsibility for
// setting errno to ENOMEM on failure
// - malloc_zone_t::try_free_default
// - malloc_zone_t::try_free_default (libmalloc only, NULL otherwise)
// Version 14:
// malloc_introspection_t::zone_type
// malloc_introspection_t::zone_type (mandatory, should be 0)
// Version 15:
// malloc_zone_t::malloc_with_options
// malloc_zone_t::malloc_with_options (optional)
// Version 16:
// malloc_zone_t::malloc_type_malloc
// malloc_zone_t::malloc_type_calloc
// malloc_zone_t::malloc_type_realloc
// malloc_zone_t::malloc_type_memalign
// malloc_zone_t::malloc_type_malloc_with_options
// malloc_zone_t::malloc_type_malloc (mandatory)
// malloc_zone_t::malloc_type_calloc (mandatory)
// malloc_zone_t::malloc_type_realloc (mandatory)
// malloc_zone_t::malloc_type_memalign (mandatory)
// malloc_zone_t::malloc_type_malloc_with_options (optional)
// These functions are optional and calling them requires two checks:
// Zone functions are optional unless specified otherwise above. Calling a zone
// function requires two checks:
// * Check zone version to ensure zone struct is large enough to include the member.
// * Check that the function pointer is not null.
#if defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_malloc_backdeploy(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2) {
__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_zone_malloc(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
__auto_type func = malloc_zone_malloc;
if (malloc_type_zone_malloc) {
return malloc_type_zone_malloc(zone, size, type_id);
}
return func(zone, size);
}
static void * __sized_by_or_null(count * size) __attribute__((always_inline)) malloc_type_zone_calloc_backdeploy(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3) {
__attribute__((weak_import)) void * __sized_by_or_null(count * size) malloc_type_zone_calloc(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3);
__auto_type func = malloc_zone_calloc;
if (malloc_type_zone_calloc) {
return malloc_type_zone_calloc(zone, count, size, type_id);
}
return func(zone, count, size);
}
static void __attribute__((always_inline)) malloc_type_zone_free_backdeploy(malloc_zone_t *zone, void * __unsafe_indexable ptr, malloc_type_id_t type_id) {
__attribute__((weak_import)) void malloc_type_zone_free(malloc_zone_t *zone, void * __unsafe_indexable ptr, malloc_type_id_t type_id);
__auto_type func = malloc_zone_free;
if (malloc_type_zone_free) {
malloc_type_zone_free(zone, ptr, type_id);
} else {
func(zone, ptr);
}
}
static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_realloc_backdeploy(malloc_zone_t *zone, void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(3) {
__auto_type func = malloc_zone_realloc;
__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_zone_realloc(malloc_zone_t *zone, void * __unsafe_indexable ptr, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(3);
if (malloc_type_zone_realloc) {
return malloc_type_zone_realloc(zone, ptr, size, type_id);
}
return func(zone, ptr, size);
}
static void *__sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_valloc_backdeploy(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2) {
__attribute__((weak_import)) void *__sized_by_or_null(size) malloc_type_zone_valloc(malloc_zone_t *zone, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2);
__auto_type func = malloc_zone_valloc;
if (malloc_type_zone_valloc) {
return malloc_type_zone_valloc(zone, size, type_id);
}
return func(zone, size);
}
static void *__sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_memalign_backdeploy(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(2) __alloc_size(3) {
__attribute__((weak_import)) void *__sized_by_or_null(size) malloc_type_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_align(2) __alloc_size(3);
__auto_type func = malloc_zone_memalign;
if (malloc_type_zone_memalign) {
return malloc_type_zone_memalign(zone, alignment, size, type_id);
}
return func(zone, alignment, size);
}
#endif // defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING
__END_DECLS
#endif /* _MALLOC_MALLOC_H_ */

View File

@ -129,10 +129,18 @@ extern int __math_errhandling(void);
* *
******************************************************************************/
#if !defined(__cplusplus) || !defined(__has_feature) || !__has_feature(modules)
/* libc++'s math.h comes before this header in the search order. It
* will include this header first and then undef several of these
* macros. That doesn't work when the two headers are in different
* clang modules. The only way to make that work is to not declare
* the macros here, and let libc++ handle the declarations.
*/
#define fpclassify(x) \
( sizeof(x) == sizeof(float) ? __fpclassifyf((float)(x)) \
: sizeof(x) == sizeof(double) ? __fpclassifyd((double)(x)) \
: __fpclassifyl((long double)(x)))
#endif /* !defined(__cplusplus) && !__has_feature(modules) */
extern int __fpclassifyf(float);
extern int __fpclassifyd(double);
@ -152,6 +160,7 @@ extern int __fpclassifyl(long double);
Thus, if you compile with -ffast-math, actual function calls are
generated for these utilities. */
#if !defined(__cplusplus) || !defined(__has_feature) || !__has_feature(modules)
#define isnormal(x) \
( sizeof(x) == sizeof(float) ? __inline_isnormalf((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_isnormald((double)(x)) \
@ -176,6 +185,7 @@ extern int __fpclassifyl(long double);
( sizeof(x) == sizeof(float) ? __inline_signbitf((float)(x)) \
: sizeof(x) == sizeof(double) ? __inline_signbitd((double)(x)) \
: __inline_signbitl((long double)(x)))
#endif /* !defined(__cplusplus) && !__has_feature(modules) */
__header_always_inline int __inline_isfinitef(float);
__header_always_inline int __inline_isfinited(double);
@ -262,6 +272,13 @@ __header_always_inline int __inline_isnormall(long double __x) {
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. */
#if !defined(__cplusplus) || !defined(__has_feature) || !__has_feature(modules)
/* libc++'s math.h comes before this header in the search order. It
* will include this header first and then undef several of these
* macros. That doesn't work when the two headers are in different
* clang modules. The only way to make that work is to not declare
* the macros here, and let libc++ handle the declarations.
*/
#define isnormal(x) \
( sizeof(x) == sizeof(float) ? __isnormalf((float)(x)) \
: sizeof(x) == sizeof(double) ? __isnormald((double)(x)) \
@ -286,7 +303,8 @@ __header_always_inline int __inline_isnormall(long double __x) {
( sizeof(x) == sizeof(float) ? __signbitf((float)(x)) \
: sizeof(x) == sizeof(double) ? __signbitd((double)(x)) \
: __signbitl((long double)(x)))
#endif /* !defined(__cplusplus) && !__has_feature(modules) */
extern int __isnormalf(float);
extern int __isnormald(double);
extern int __isnormall(long double);
@ -546,12 +564,20 @@ extern float fmaf(float, float, float);
extern double fma(double, double, double);
extern long double fmal(long double, long double, long double);
#if !defined(__cplusplus) || !defined(__has_feature) || !__has_feature(modules)
/* libc++'s math.h comes before this header in the search order. It
* will include this header first and then undef several of these
* macros. That doesn't work when the two headers are in different
* clang modules. The only way to make that work is to not declare
* the macros here, and let libc++ handle the declarations.
*/
#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))
#endif /* !defined(__cplusplus) && !__has_feature(modules) */
#if defined __i386__ || defined __x86_64__
/* Deprecated functions; use the INFINITY and NAN macros instead. */

View File

@ -154,16 +154,6 @@ struct if_clonereq {
#define IFQ_MAXLEN 128
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
#define IFQ_DEF_C_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */
#define IFQ_DEF_C_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
#define IFQ_DEF_L4S_TARGET_DELAY (2ULL * 1000 * 1000) /* 2 ms */
#define IFQ_DEF_L4S_WIRELESS_TARGET_DELAY (15ULL * 1000 * 1000) /* 15 ms */
#define IFQ_DEF_L4S_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
#define IFQ_LL_C_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */
#define IFQ_LL_C_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
#define IFQ_LL_L4S_TARGET_DELAY (2ULL * 1000 * 1000) /* 2 ms */
#define IFQ_LL_L4S_WIRELESS_TARGET_DELAY (15ULL * 1000 * 1000) /* 15 ms */
#define IFQ_LL_L4S_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */
/*
* Message format for use in obtaining information about interfaces
* from sysctl and the routing socket
@ -332,6 +322,7 @@ struct ifreq {
#define IFRTYPE_FUNCTIONAL_LAST 8
u_int8_t ifru_is_directlink;
u_int8_t ifru_is_vpn;
u_int8_t ifru_is_companionlink;
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */

View File

@ -118,14 +118,17 @@ struct tcphdr {
};
#define TCPOPT_EOL 0
#define TCPOLEN_EOL 1
#define TCPOPT_NOP 1
#define TCPOLEN_NOP 1
#define TCPOPT_MAXSEG 2
#define TCPOLEN_MAXSEG 4
#define TCPOPT_WINDOW 3
#define TCPOLEN_WINDOW 3
#define TCPOPT_SACK_PERMITTED 4 /* Experimental */
#define TCPOPT_SACK_PERMITTED 4 /* SACK capability in SYN */
#define TCPOLEN_SACK_PERMITTED 2
#define TCPOPT_SACK 5 /* Experimental */
#define TCPOPT_SACK 5
#define TCPOLEN_SACKHDR 2
#define TCPOLEN_SACK 8 /* len of sack block */
#define TCPOPT_TIMESTAMP 8
#define TCPOLEN_TIMESTAMP 10

View File

@ -101,6 +101,7 @@
#include <sys/_types.h>
#include <sys/_types/_sa_family_t.h>
#include <sys/_types/_in_port_t.h>
/*
* Identification of the network protocol stack

View File

@ -115,6 +115,9 @@
* ios, iOSApplicationExtension, tvos, tvOSApplicationExtension, watchos,
* watchOSApplicationExtension, driverkit, visionos, visionOSApplicationExtension
*
* Within each platform a tuple of versions will represent the version the API was
* introduced in, followed by the version it was deperecated in.
*
* Examples:
*
* API_DEPRECATED("Deprecated", macos(10.4, 10.8))
@ -143,6 +146,10 @@
* ios, iOSApplicationExtension, tvos, tvOSApplicationExtension, watchos,
* watchOSApplicationExtension, driverkit, visionos, visionOSApplicationExtension
*
* Within each platform a tuple of versions will represent the version the API was
* introduced in, followed by the version it was deperecated in, and finally the version it
* was removed in.
*
* Examples:
*
* API_OBSOLETED("No longer supported", macos(10.4, 10.8, 11.0))
@ -151,6 +158,7 @@
* API_OBSOLETED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4, 12.0), ios(9.0, 10.0, 11.0))
* API_OBSOLETED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6, 11.0), watchos(2.0, 3.0, 4.0))
*/
#define API_OBSOLETED(...) __API_OBSOLETED_MSG_GET_MACRO_93585900(__VA_ARGS__,__API_OBSOLETED_MSG15,__API_OBSOLETED_MSG14,__API_OBSOLETED_MSG13,__API_OBSOLETED_MSG12,__API_OBSOLETED_MSG11,__API_OBSOLETED_MSG10,__API_OBSOLETED_MSG9,__API_OBSOLETED_MSG8,__API_OBSOLETED_MSG7,__API_OBSOLETED_MSG6,__API_OBSOLETED_MSG5,__API_OBSOLETED_MSG4,__API_OBSOLETED_MSG3,__API_OBSOLETED_MSG2,__API_OBSOLETED_MSG1,__API_OBSOLETED_MSG0,0,0)(__VA_ARGS__)
#define API_OBSOLETED_WITH_REPLACEMENT(...) __API_OBSOLETED_REP_GET_MACRO_93585900(__VA_ARGS__,__API_OBSOLETED_REP15,__API_OBSOLETED_REP14,__API_OBSOLETED_REP13,__API_OBSOLETED_REP12,__API_OBSOLETED_REP11,__API_OBSOLETED_REP10,__API_OBSOLETED_REP9,__API_OBSOLETED_REP8,__API_OBSOLETED_REP7,__API_OBSOLETED_REP6,__API_OBSOLETED_REP5,__API_OBSOLETED_REP4,__API_OBSOLETED_REP3,__API_OBSOLETED_REP2,__API_OBSOLETED_REP1,__API_OBSOLETED_REP0,0,0)(__VA_ARGS__)
@ -189,7 +197,7 @@
#endif
#ifndef API_AVAILABLE_END
#define API_AVAILABLE_END(...)
#define API_AVAILABLE_END
#endif
#ifndef API_DEPRECATED
@ -201,7 +209,7 @@
#endif
#ifndef API_DEPRECATED_END
#define API_DEPRECATED_END(...)
#define API_DEPRECATED_END
#endif
#ifndef API_DEPRECATED_WITH_REPLACEMENT
@ -213,7 +221,7 @@
#endif
#ifndef API_DEPRECATED_WITH_REPLACEMENT_END
#define API_DEPRECATED_WITH_REPLACEMENT_END(...)
#define API_DEPRECATED_WITH_REPLACEMENT_END
#endif
#ifndef API_OBSOLETED
@ -225,7 +233,7 @@
#endif
#ifndef API_OBSOLETED_END
#define API_OBSOLETED_END(...)
#define API_OBSOLETED_END
#endif
#ifndef API_OBSOLETED_WITH_REPLACEMENT
@ -237,7 +245,7 @@
#endif
#ifndef API_OBSOLETED_WITH_REPLACEMENT_END
#define API_OBSOLETED_WITH_REPLACEMENT_END(...)
#define API_OBSOLETED_WITH_REPLACEMENT_END
#endif
#ifndef API_UNAVAILABLE
@ -249,7 +257,7 @@
#endif
#ifndef API_UNAVAILABLE_END
#define API_UNAVAILABLE_END(...)
#define API_UNAVAILABLE_END
#endif
#if __has_include(<AvailabilityProhibitedInternal.h>)
@ -269,7 +277,7 @@
#endif
#ifndef SPI_AVAILABLE_END
#define SPI_AVAILABLE_END(...)
#define SPI_AVAILABLE_END
#endif
#ifndef SPI_DEPRECATED

View File

@ -71,7 +71,11 @@
#define OS_WEAK __attribute__((__weak__))
#define OS_WEAK_IMPORT __attribute__((__weak_import__))
#define OS_NOINLINE __attribute__((__noinline__))
#ifndef __BUILDING_XNU_LIBRARY__
#define OS_ALWAYS_INLINE __attribute__((__always_inline__))
#else /* __BUILDING_XNU_LIBRARY__ */
#define OS_ALWAYS_INLINE
#endif /* __BUILDING_XNU_LIBRARY__ */
#define OS_TRANSPARENT_UNION __attribute__((__transparent_union__))
#define OS_ALIGNED(n) __attribute__((__aligned__((n))))
#define OS_FORMAT_PRINTF(x, y) __attribute__((__format__(printf,x,y)))
@ -343,4 +347,5 @@ typedef void (^os_block_t)(void);
#define OS_COUNTED_BY(N) __counted_by(N)
#define OS_SIZED_BY(N) __sized_by(N)
#endif // __OS_BASE__

View File

@ -26,6 +26,12 @@
#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN
#define OS_WORKGROUP_ASSUME_NONNULL_END
#endif
#if __has_feature(enumerator_attributes)
#define OS_WORKGROUP_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...) \
API_DEPRECATED_WITH_REPLACEMENT(__VA_ARGS__)
#else
#define OS_WORKGROUP_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...)
#endif
#define OS_WORKGROUP_WARN_RESULT __attribute__((__warn_unused_result__))
#define OS_WORKGROUP_EXPORT OS_EXPORT
#define OS_WORKGROUP_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED

View File

@ -39,5 +39,7 @@
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
#define __darwin_pass_obsz0 __attribute__((__pass_object_size__(0)))
#define __darwin_pass_obsz __attribute__((__pass_object_size__(_USE_FORTIFY_LEVEL > 1 ? 1 : 0)))
#endif

View File

@ -35,54 +35,95 @@ _LIBC_SINGLE_BY_DEFAULT()
#if _USE_FORTIFY_LEVEL > 0
extern int __snprintf_chk (char * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen, int, size_t,
const char * __restrict, ...);
extern int __vsnprintf_chk (char * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen, int, size_t,
const char * __restrict, va_list);
extern int __sprintf_chk (char * __restrict _LIBC_UNSAFE_INDEXABLE, int, size_t,
const char * __restrict, ...);
extern int __vsprintf_chk (char * __restrict _LIBC_UNSAFE_INDEXABLE, int, size_t,
const char * __restrict, va_list);
#ifdef __LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES
/* verify that there are at least __n characters at __str */
static inline char *_LIBC_COUNT(__n)
__libc_ptrchk_strbuf_chk(char *_LIBC_COUNT(__n) __str, size_t __n) { return __str; }
#undef __sprintf_chk_func /* sprintf is unavailable */
#undef __vsprintf_chk_func /* vsprintf is unavailable */
#define __vsnprintf_chk_func(str, len, flag, format, ap) ({ \
size_t __len = (len); \
__builtin___vsnprintf_chk (__libc_ptrchk_strbuf_chk(str, __len), __len, flag, __darwin_obsz(str), format, ap); \
})
#define __snprintf_chk_func(str, len, flag, ...) ({ \
size_t __len = (len); \
__builtin___snprintf_chk (__libc_ptrchk_strbuf_chk(str, __len), __len, flag, __darwin_obsz(str), __VA_ARGS__); \
})
#else
#ifndef __has_builtin
#define _undef__has_builtin
#define __has_builtin(x) 0
#define __undef__has_builtin
#define __has_builtin(x) defined(__GNUC__)
#endif
#if __has_builtin(__builtin___snprintf_chk)
#define __snprintf_chk_func(str, len, flag, ...) \
__builtin___snprintf_chk (str, len, flag, __darwin_obsz(str), __VA_ARGS__)
#endif
#if __has_builtin(__builtin___vsnprintf_chk)
#define __vsnprintf_chk_func(str, len, flag, format, ap) \
__builtin___vsnprintf_chk (str, len, flag, __darwin_obsz(str), format, ap)
#endif
#if __has_builtin(__builtin___sprintf_chk)
#define __sprintf_chk_func(str, flag, ...) \
__builtin___sprintf_chk (str, flag, __darwin_obsz(str), __VA_ARGS__)
#endif
#if __has_builtin(__builtin___vsprintf_chk)
#define __vsprintf_chk_func(str, flag, format, ap) \
__builtin___vsprintf_chk (str, flag, __darwin_obsz(str), format, ap)
#endif
#ifdef __undef__has_builtin
#undef __undef__has_builtin
#undef __has_builtin
#endif
#endif
/* sprintf, vsprintf, snprintf, vsnprintf */
#if __has_builtin(__builtin___sprintf_chk) || defined(__GNUC__)
extern int __sprintf_chk (char * __restrict _LIBC_UNSAFE_INDEXABLE, int, size_t,
const char * __restrict, ...);
#ifdef __sprintf_chk_func
#undef sprintf
#define sprintf(str, ...) \
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
#define sprintf(str, ...) __sprintf_chk_func (str, 0, __VA_ARGS__)
#endif
#if __DARWIN_C_LEVEL >= 200112L
#if __has_builtin(__builtin___snprintf_chk) || defined(__GNUC__)
extern int __snprintf_chk (char * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen, int, size_t,
const char * __restrict, ...);
#undef snprintf
#define snprintf(str, len, ...) \
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
#endif
#if __has_builtin(__builtin___vsprintf_chk) || defined(__GNUC__)
extern int __vsprintf_chk (char * __restrict _LIBC_UNSAFE_INDEXABLE, int, size_t,
const char * __restrict, va_list);
#ifdef __vsprintf_chk_func
#undef vsprintf
#define vsprintf(str, format, ap) \
__builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap)
#define vsprintf(str, ...) __vsprintf_chk_func (str, 0, __VA_ARGS__)
#endif
#if __has_builtin(__builtin___vsnprintf_chk) || defined(__GNUC__)
extern int __vsnprintf_chk (char * __restrict _LIBC_COUNT(__maxlen), size_t __maxlen, int, size_t,
const char * __restrict, va_list);
#ifdef __snprintf_chk_func
#undef snprintf
#define snprintf(str, len, ...) __snprintf_chk_func (str, len, 0, __VA_ARGS__)
#endif
#ifdef __vsnprintf_chk_func
#undef vsnprintf
#define vsnprintf(str, len, format, ap) \
__builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
#define vsnprintf(str, len, ...) __vsnprintf_chk_func (str, len, 0, __VA_ARGS__)
#endif
#endif /* __DARWIN_C_LEVEL >= 200112L */
#ifdef _undef__has_builtin
#undef _undef__has_builtin
#undef __has_builtin
#endif
#endif /* _USE_FORTIFY_LEVEL > 0 */

View File

@ -34,117 +34,262 @@
#if _USE_FORTIFY_LEVEL > 0
/* <rdar://problem/12622659> */
#if defined(__clang__) && \
((defined(__apple_build_version__) && __apple_build_version__ >= 4260006) || \
(!defined(__apple_build_version__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 3))))
#define __HAS_FIXED_CHK_PROTOTYPES 1
#ifdef __LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES
#if __has_builtin(__builtin___memcpy_chk)
static inline void *_LIBC_SIZE(__n)
__memcpy_ptrchk(void *const _LIBC_SIZE(__n) __darwin_pass_obsz0 __dst, const void *_LIBC_SIZE(__n) __src, size_t __n) {
return _LIBC_FORGE_PTR(__builtin___memcpy_chk(__dst, __src, __n, __darwin_obsz0(__dst)), __n);
}
#define __memcpy_chk_func __memcpy_ptrchk
#endif
#if __has_builtin(__builtin___memmove_chk)
static inline void *_LIBC_SIZE(__n)
__memmove_ptrchk(void *const _LIBC_SIZE(__n) __darwin_pass_obsz0 __dst, const void *_LIBC_SIZE(__n) __src, size_t __n) {
return _LIBC_FORGE_PTR(__builtin___memmove_chk(__dst, __src, __n, __darwin_obsz0(__dst)), __n);
}
#define __memmove_chk_func __memmove_ptrchk
#endif
#if __has_builtin(__builtin___memset_chk)
static inline void *_LIBC_SIZE(__n)
__memset_ptrchk(void *const _LIBC_SIZE(__n) __darwin_pass_obsz0 __dst, int __c, size_t __n) {
return _LIBC_FORGE_PTR(__builtin___memset_chk(__dst, __c, __n, __darwin_obsz0(__dst)), __n);
}
#define __memset_chk_func __memset_ptrchk
#endif
#undef __stpncpy_chk_func /* stpncpy unavailable */
#undef __strncpy_chk_func /* strncpy unavailable */
#if __has_builtin(__builtin___strlcpy_chk)
static inline size_t
__strlcpy_ptrchk(char *const _LIBC_SIZE(__n) __darwin_pass_obsz __dst, const char *__src, size_t __n) {
return __builtin___strlcpy_chk(__dst, __src, __n, __darwin_obsz(__dst));
}
#define __strlcpy_chk_func __strlcpy_ptrchk
#endif
#if __has_builtin(__builtin___strlcat_chk)
static inline size_t
__strlcat_ptrchk(char *const _LIBC_SIZE(__n) __darwin_pass_obsz __dst, const char *__src, size_t __n) {
return __builtin___strlcat_chk(__dst, __src, __n, __darwin_obsz(__dst));
}
#define __strlcat_chk_func __strlcat_ptrchk
#endif
#if __has_builtin(__builtin___memccpy_chk)
static inline void *_LIBC_SIZE(__n)
__memccpy_ptrchk(void *const _LIBC_SIZE(__n) __darwin_pass_obsz0 __dst, const void *_LIBC_SIZE(__n) __src, int __c, size_t __n) {
return _LIBC_FORGE_PTR(__builtin___memccpy_chk(__dst, __src, __c, __n, __darwin_obsz0(__dst)), __n);
}
#define __memccpy_chk_func __memccpy_ptrchk
#endif
#undef __strcpy_chk_func /* strcpy unavailable */
#undef __stpcpy_chk_func /* stpcpy unavailable */
#undef __strcat_chk_func /* strcat unavailable */
#undef __strncat_chk_func /* strncat unavailable */
#else /* __LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES */
#define __is_modern_darwin(ios, macos) \
(__IPHONE_OS_VERSION_MIN_REQUIRED >= (ios) || \
__MAC_OS_X_VERSION_MIN_REQUIRED >= (macos) || \
defined(__DRIVERKIT_VERSION_MIN_REQUIRED))
/* __is_gcc(gcc_major, gcc_minor)
* Special values:
* 10.0 means "test should always fail when __has_builtin isn't supported"
(because gcc got __has_builtin in version 10.0); this is used for builtins
that gcc did not support yet at the time __has_builtin was introduced, so
there is no point checking the compiler version.
* 0.0 means that we did not research when gcc started supporting this builtin,
but it's believed to have been the case at least since gcc 4.0, which came
out in 2005. (Hello from 2025! What year is it now? Can't believe we're still
using C!)
*/
#define __is_gcc(major, minor) \
(__GNUC__ > (gcc_major) || \
(__GNUC__ == (gcc_major) && __GNUC_MINOR__ >= (gcc_minor)))
#ifdef __has_builtin
#define __supports_builtin(builtin, gcc_major, gcc_minor) \
__has_builtin(builtin)
#else
#define __HAS_FIXED_CHK_PROTOTYPES 0
#define __supports_builtin(builtin, gcc_major, gcc_minor) __is_gcc(gcc_major, gcc_minor)
#endif
/* memccpy, memcpy, mempcpy, memmove, memset, strcpy, strlcpy, stpcpy,
strncpy, stpncpy, strcat, strlcat, and strncat */
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 || \
defined(__DRIVERKIT_VERSION_MIN_REQUIRED)
#if __has_builtin(__builtin___memccpy_chk) && __HAS_FIXED_CHK_PROTOTYPES
#undef memccpy
/* void *memccpy(void *dst, const void *src, int c, size_t n) */
#define memccpy(dest, ...) \
__builtin___memccpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
#endif
#endif
#if __has_builtin(__builtin___memcpy_chk) || defined(__GNUC__)
#undef memcpy
/* void *memcpy(void *dst, const void *src, size_t n) */
#define memcpy(dest, ...) \
#if __supports_builtin(__builtin___memcpy_chk, 0, 0)
#define __memcpy_chk_func(dest, ...) \
__builtin___memcpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
#endif
#if __has_builtin(__builtin___memmove_chk) || defined(__GNUC__)
#undef memmove
/* void *memmove(void *dst, const void *src, size_t len) */
#define memmove(dest, ...) \
#if __supports_builtin(__builtin___memmove_chk, 0, 0)
#define __memmove_chk_func(dest, ...) \
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
#endif
#if __has_builtin(__builtin___memset_chk) || defined(__GNUC__)
#undef memset
/* void *memset(void *b, int c, size_t len) */
#define memset(dest, ...) \
#if __supports_builtin(__builtin___memset_chk, 0, 0)
#define __memset_chk_func(dest, ...) \
__builtin___memset_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
#endif
#if __has_builtin(__builtin___strcpy_chk) || defined(__GNUC__)
#undef strcpy
/* char *strcpy(char *dst, const char *src) */
#define strcpy(dest, ...) \
__builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __DARWIN_C_LEVEL >= 200809L
#if __has_builtin(__builtin___stpcpy_chk) || defined(__GNUC__)
#undef stpcpy
/* char *stpcpy(char *dst, const char *src) */
#define stpcpy(dest, ...) \
__builtin___stpcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#endif /* __DARWIN_C_LEVEL >= 200809L */
#if __DARWIN_C_LEVEL >= 200809L
#if __has_builtin(__builtin___stpncpy_chk) || __APPLE_CC__ >= 5666 || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#undef stpncpy
/* char *stpncpy(char *dst, const char *src, size_t n) */
#define stpncpy(dest, ...) \
#if __supports_builtin(__builtin___stpncpy_chk, 4, 7)
#define __stpncpy_chk_func(dest, ...) \
__builtin___stpncpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#endif /* _DARWIN_C_LEVEL >= 200809L */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 || \
defined(__DRIVERKIT_VERSION_MIN_REQUIRED)
#if __has_builtin(__builtin___strlcpy_chk) && __HAS_FIXED_CHK_PROTOTYPES
#undef strlcpy
/* size_t strlcpy(char *dst, const char *source, size_t size) */
#define strlcpy(dest, ...) \
__builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __has_builtin(__builtin___strlcat_chk) && __HAS_FIXED_CHK_PROTOTYPES
#undef strlcat
/* size_t strlcat(char *dst, const char *source, size_t size) */
#define strlcat(dest, ...) \
__builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 */
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
#if __has_builtin(__builtin___strncpy_chk) || defined(__GNUC__)
#undef strncpy
/* char *strncpy(char *dst, const char *src, size_t n) */
#define strncpy(dest, ...) \
#if __supports_builtin(__builtin___strncpy_chk, 0, 0)
#define __strncpy_chk_func(dest, ...) \
__builtin___strncpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __has_builtin(__builtin___strcat_chk) || defined(__GNUC__)
#undef strcat
/* char *strcat(char *s1, const char *s2) */
#define strcat(dest, ...) \
#if __is_modern_darwin(70000, 1090)
#if __supports_builtin(__builtin___strlcpy_chk, 0, 0)
#define __strlcpy_chk_func(dest, ...) \
__builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __supports_builtin(__builtin___strlcat_chk, 0, 0)
#define __strlcat_chk_func(dest, ...) \
__builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __supports_builtin(__builtin___memccpy_chk, 10, 0)
#define __memccpy_chk_func(dest, ...) \
__builtin___memccpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
#endif
#endif /* __is_modern_darwin(70000, 1090) */
#if __supports_builtin(__builtin___strcpy_chk, 0, 0)
#define __strcpy_chk_func(dest, ...) \
__builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __supports_builtin(__builtin___stpcpy_chk, 0, 0)
#define __stpcpy_chk_func(dest, ...) \
__builtin___stpcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if __supports_builtin(__builtin___strcat_chk, 0, 0)
#define __strcat_chk_func(dest, ...) \
__builtin___strcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#if ! (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 32000)
#if __has_builtin(__builtin___strncat_chk) || defined(__GNUC__)
#undef strncat
/* char *strncat(char *s1, const char *s2, size_t n) */
#define strncat(dest, ...) \
#if __supports_builtin(__builtin___strncat_chk, 0, 0)
#define __strncat_chk_func(dest, ...) \
__builtin___strncat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif
#endif
#undef __HAS_FIXED_CHK_PROTOTYPES
#undef __supports_builtin
#undef __is_gcc
#endif /* defined(__has_ptrcheck) && __has_ptrcheck */
#undef __is_modern_darwin
/* memccpy, memcpy, mempcpy, memmove, memset, strcpy, strlcpy, stpcpy,
strncpy, stpncpy, strcat, strlcat, and strncat */
/* The use of .../__VA_ARGS__ is load-bearing. If the macros take fixed
* arguments, they are unable to themselves accept macros that expand to
* multiple arguments, like this:
* #define memcpy(a, b, c) ...
* #define FOO(data) get_bytes(data), get_length(data)
* memcpy(bar, FOO(d));
* This will fail because the preprocessor only sees two arguments on the first
* expansion of memcpy, when 3 are required.
* This is also required to support syntaxes that embed commas. The preprocessor
* recognizes parentheses for the isolation of arguments but not brackets. This
* expands to 3 arguments:
* strcpy(destination, [NSString stringWithFormat:@"%i", 4].UTF8String);
* ^ ^ ^
* |destination | |
* |[NSString stringWithFormat:@"%i" |
* |4].UTF8String
* This expands to 4 arguments:
* memcpy(destination, (uint8_t[]) { 1, 2 }, 2);
* ^ ^ ^ ^
* To work correctly under these hostile circumstances, chk_func macros
* need to expand to a bare identifier (like #define memcpy_chk_func __memcpy)
* or to a macro that also takes variadic arguments.
*/
#ifdef __memccpy_chk_func
#undef memccpy
#define memccpy(...) __memccpy_chk_func (__VA_ARGS__)
#endif
#ifdef __memcpy_chk_func
#undef memcpy
#define memcpy(...) __memcpy_chk_func (__VA_ARGS__)
#endif
#ifdef __memmove_chk_func
#undef memmove
#define memmove(...) __memmove_chk_func (__VA_ARGS__)
#endif
#ifdef __memset_chk_func
#undef memset
#define memset(...) __memset_chk_func (__VA_ARGS__)
#endif
#if defined(__strcpy_chk_func)
#undef strcpy
#define strcpy(...) __strcpy_chk_func (__VA_ARGS__)
#endif
#if defined(__strcat_chk_func)
#undef strcat
#define strcat(...) __strcat_chk_func (__VA_ARGS__)
#endif
#if defined(__strncpy_chk_func)
#undef strncpy
#define strncpy(...) __strncpy_chk_func (__VA_ARGS__)
#endif
#if defined(__strncat_chk_func)
#undef strncat
#define strncat(...) __strncat_chk_func (__VA_ARGS__)
#endif
#if __DARWIN_C_LEVEL >= 200809L
#if defined(__stpcpy_chk_func)
#undef stpcpy
#define stpcpy(...) __stpcpy_chk_func (__VA_ARGS__)
#endif
#if defined(__stpncpy_chk_func)
#undef stpncpy
#define stpncpy(...) __stpncpy_chk_func (__VA_ARGS__)
#endif
#endif /* __DARWIN_C_LEVEL >= 200809L */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#if defined(__strlcpy_chk_func)
#undef strlcpy
#define strlcpy(...) __strlcpy_chk_func (__VA_ARGS__)
#endif
#if defined(__strlcat_chk_func)
#undef strlcat
#define strlcat(...) __strlcat_chk_func (__VA_ARGS__)
#endif
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
#endif /* _USE_FORTIFY_LEVEL > 0 */
#endif /* _SECURE__STRING_H_ */

View File

@ -39,18 +39,55 @@
/* Removed in Issue 7 */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L
#if __has_builtin(__builtin___memmove_chk) || defined(__GNUC__)
#undef bcopy
/* void bcopy(const void *src, void *dst, size_t len) */
#define bcopy(src, dest, ...) \
__builtin___memmove_chk (dest, src, __VA_ARGS__, __darwin_obsz0 (dest))
#ifdef __LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES
static inline void
__bcopy_ptrcheck(const void *_LIBC_SIZE(__n) __src, void *const _LIBC_SIZE(__n) __darwin_pass_obsz0 __dst, size_t __n) {
memmove(__dst, __src, __n);
}
static inline void
__bzero_ptrcheck(void *const _LIBC_SIZE(__n) __darwin_pass_obsz0 __dst, size_t __n) {
memset(__dst, 0, __n);
}
#define __bcopy_chk_func __bcopy_ptrcheck
#define __bzero_chk_func __bzero_ptrcheck
#else
#ifndef __has_builtin
#define __undef__has_builtin
#define __has_builtin(x) defined(__GNUC__)
#endif
#if __has_builtin(__builtin___memset_chk) || defined(__GNUC__)
#if __has_builtin(__builtin___memmove_chk)
#define __bcopy_chk_func(src, dst, ...) \
__builtin___memmove_chk(dst, src, __VA_ARGS__, __darwin_obsz0 (dst))
#endif
#if __has_builtin(__builtin___memset_chk)
#define __bzero_chk_func(dst, ...) \
__builtin___memset_chk(dst, 0, __VA_ARGS__, __darwin_obsz0 (dst))
#endif
#ifdef __undef__has_builtin
#undef __undef__has_builtin
#undef __has_builtin
#endif
#endif
#ifdef __bcopy_chk_func
#undef bcopy
/* void bcopy(const void *src, void *dst, size_t len) */
#define bcopy(...) __bcopy_chk_func (__VA_ARGS__)
#endif
#ifdef __bzero_chk_func
#undef bzero
/* void bzero(void *s, size_t n) */
#define bzero(dest, ...) \
__builtin___memset_chk (dest, 0, __VA_ARGS__, __darwin_obsz0 (dest))
#define bzero(...) __bzero_chk_func (__VA_ARGS__)
#endif
#endif

View File

@ -51,9 +51,6 @@ typedef int jmp_buf[_JBLEN];
typedef int sigjmp_buf[_JBLEN + 1];
#elif defined(__arm__) && !defined(__ARM_ARCH_7K__)
#include <machine/signal.h>
/*
* _JBLEN is number of ints required to save the following:
* r4-r8, r10, fp, sp, lr, sig == 10 register_t sized

View File

@ -69,6 +69,12 @@ int posix_spawnp(pid_t * __restrict, const char * __restrict,
char *const __argv[__restrict],
char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0));
int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t *,
const char * __restrict) __API_AVAILABLE(macos(26.0)) __API_UNAVAILABLE(ios, tvos, watchos, visionos);
int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t *,
int) __API_AVAILABLE(macos(26.0)) __API_UNAVAILABLE(ios, tvos, watchos, visionos);
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int,
@ -174,10 +180,10 @@ int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *,
int) __API_AVAILABLE(macos(10.7), ios(4.3)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *,
const char * __restrict) __API_AVAILABLE(macos(10.15)) __API_UNAVAILABLE(ios, tvos, watchos);
const char * __restrict) __API_DEPRECATED("posix_spawn_file_actions_addchdir(3) has replaced posix_spawn_file_actions_addchdir_np(3)", macos(10.15, 26.0)) __API_UNAVAILABLE(ios, tvos, watchos, visionos);
int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *,
int) __API_AVAILABLE(macos(10.15)) __API_UNAVAILABLE(ios, tvos, watchos);
int) __API_DEPRECATED("posix_spawn_file_actions_addfchdir(3) has replaced posix_spawn_file_actions_addfchdir_np(3)", macos(10.15, 26.0)) __API_UNAVAILABLE(ios, tvos, watchos, visionos);
__END_DECLS

View File

@ -341,18 +341,6 @@
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_5(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140400
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_4(x) x
#else
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_4(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140500
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_5(x) x
#else
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_5(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140600
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_6(x) x
#else
@ -557,6 +545,24 @@
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_18_5(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 180600
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_18_6(x) x
#else
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_18_6(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 190000
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_19_0(x) x
#else
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_19_0(x)
#endif
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 260000
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_26_0(x) x
#else
#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_26_0(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1000
#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) x
#else
@ -857,12 +863,6 @@
#define __DARWIN_ALIAS_STARTING_MAC___MAC_13_1(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 130100
#define __DARWIN_ALIAS_STARTING_MAC___MAC_13_1(x) x
#else
#define __DARWIN_ALIAS_STARTING_MAC___MAC_13_1(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 130200
#define __DARWIN_ALIAS_STARTING_MAC___MAC_13_2(x) x
#else
@ -983,3 +983,21 @@
#define __DARWIN_ALIAS_STARTING_MAC___MAC_15_5(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 150600
#define __DARWIN_ALIAS_STARTING_MAC___MAC_15_6(x) x
#else
#define __DARWIN_ALIAS_STARTING_MAC___MAC_15_6(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 160000
#define __DARWIN_ALIAS_STARTING_MAC___MAC_16_0(x) x
#else
#define __DARWIN_ALIAS_STARTING_MAC___MAC_16_0(x)
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 260000
#define __DARWIN_ALIAS_STARTING_MAC___MAC_26_0(x) x
#else
#define __DARWIN_ALIAS_STARTING_MAC___MAC_26_0(x)
#endif

View File

@ -43,6 +43,9 @@
#define SBC_STRICT_AUTH 0x0010 /* Strict authentication mode */
#define SBC_PRESERVE_GRAFT 0x0020 /* Preserve graft itself until unmount */
/* Flag values for ungraftdmg */
#define UNGRAFTDMG_NOFORCE 0x0000000000000002ULL /* Disallow ungraft if a non-dir vnode inside the graft is in use */
typedef struct secure_boot_cryptex_args {
u_int32_t sbc_version;
u_int32_t sbc_4cc;

View File

@ -50,9 +50,10 @@
#define FSOPT_PACK_INVAL_ATTRS 0x00000008
#define FSOPT_ATTR_CMN_EXTENDED 0x00000020
#define FSOPT_ATTR_CMN_EXTENDED 0x00000020
#define FSOPT_RETURN_REALDEV 0x00000200
#define FSOPT_NOFOLLOW_ANY 0x00000800
#define FSOPT_RESOLVE_BENEATH 0x00001000
/* we currently aren't anywhere near this amount for a valid
* fssearchblock.sizeofsearchparams1 or fssearchblock.sizeofsearchparams2
@ -369,6 +370,9 @@ typedef struct vol_capabilities_attr {
*
* VOL_CAP_INT_PUNCHHOLE: When set, the volume supports the F_PUNCHHOLE
* fcntl.
*
* VOL_CAP_INT_BARRIERFSYNC: When set, the volume supports the F_BARRIERFSYNC
* fcntl.
*/
#define VOL_CAP_INT_SEARCHFS 0x00000001
#define VOL_CAP_INT_ATTRLIST 0x00000002
@ -393,6 +397,7 @@ typedef struct vol_capabilities_attr {
#define VOL_CAP_INT_RENAME_SECLUDE 0x00200000
#define VOL_CAP_INT_ATTRIBUTION_TAG 0x00400000
#define VOL_CAP_INT_PUNCHHOLE 0x00800000
#define VOL_CAP_INT_BARRIERFSYNC 0x01000000
typedef struct vol_attributes_attr {
attribute_set_t validattr;

View File

@ -199,7 +199,16 @@
*/
#define __exported __attribute__((__visibility__("default")))
#define __exported_push _Pragma("GCC visibility push(default)")
#ifndef __BUILDING_XNU_LIBRARY__
#define __exported_push_hidden _Pragma("GCC visibility push(hidden)")
#define __exported_pop _Pragma("GCC visibility pop")
#define __exported_hidden __private_extern__
#else /* __BUILDING_XNU_LIBRARY__ */
/* Don't hide symbols that the might be need to be used from outside */
#define __exported_push_hidden
#define __exported_pop
#define __exported_hidden
#endif /* __BUILDING_XNU_LIBRARY__ */
/* __deprecated causes the compiler to produce a warning when encountering
* code using the deprecated functionality.
@ -509,12 +518,14 @@
* for plain C (see also <ptrcheck.h>).
*
* Attribute __unsafe_buffer_usage can be used to label functions that should be
* avoided as they may perform or otherwise introduce unsafe buffer
* manipulation operations.
* avoided as they may perform or otherwise introduce unsafe buffer manipulation
* operations. The attribute can also be attached to class/struct fields that
* are used in unsafe buffer manipulations.
*
* Calls to such functions are flagged by -Wunsafe-buffer-usage, similarly to
* Calls to attribute annotated functions are flagged by -Wunsafe-buffer-usage, similar to
* how unchecked buffer manipulation operations are flagged when observed
* by the compiler directly:
* by the compiler directly. Similarly, use of and assignment to the struct/class fields
* that have the attribute also get flagged by the compiler.
*
* // An unsafe function that needs to be avoided.
* __unsafe_buffer_usage
@ -527,14 +538,30 @@
* int array[5];
*
* // Direct unsafe buffer manipulation through subscript operator:
* array[idx] = 3; // warning [-Wunsafe-buffer-usage]
* array[idx] = 3; // warning: function introduces unsafe buffer manipulation [-Wunsafe-buffer-usage]
* // Unsafe buffer manipulation through function foo():
* foo(array, 5); // warning [-Wunsafe-buffer-usage]
* foo(array, 5); // warning: function introduces unsafe buffer manipulation [-Wunsafe-buffer-usage]
* // Checked buffer manipulation, with bounds information automatically
* // preserved for the purposes of runtime checks in standard library:
* foo(array); // no warning
* }
*
* struct Reader {
* // Field involved in unsafe buffer manipulation
* __unsafe_buffer_usage
* void *ptr;
*
* __unsafe_buffer_usage
* size_t sz, count;
* };
*
* void add_element(Reader rdr, int value) {
* if(rdr.count < rdr.sz) { // warning: unsafe buffer access [-Wunsafe-buffer-usage]
* rdr.ptr[rdr.count] = value; // warning: unsafe buffer access [-Wunsafe-buffer-usage]
* rdr.count++; // warning: unsafe buffer access [-Wunsafe-buffer-usage]
* }
* }
*
* While annotating a function as __unsafe_buffer_usage has an effect similar
* to annotating it as __deprecated, the __unsafe_buffer_usage attribute
* should be used whenever the resulting warning needs to be controlled
@ -542,11 +569,12 @@
* don't attempt to achieve bounds safety this way) as opposed to -Wdeprecated
* (enabled in most codebases).
*
* The attribute does NOT suppress -Wunsafe-buffer-usage warnings inside
* the function's body; it simply introduces new warnings at each call site
* to help the developers avoid the function entirely. Most of the time
* it does not make sense to annotate a function as __unsafe_buffer_usage
* without providing the users with a safe alternative.
* The attribute suppresses all -Wunsafe-buffer-usage warnings inside the
* function's body as it is explictly marked as unsafe by the user and
* introduces new warnings at each call site to help the developers avoid the
* function entirely. Most of the time it does not make sense to annotate a
* function as __unsafe_buffer_usage without providing the users with a safe
* alternative.
*
* Pragmas __unsafe_buffer_usage_begin and __unsafe_buffer_usage_end
* annotate a range of code as intentionally containing unsafe buffer
@ -560,9 +588,7 @@
*
* These pragmas are NOT a way to mass-annotate functions with the attribute
* __unsafe_buffer_usage. Functions declared within the pragma range
* do NOT get annotated automatically. In some rare situations it makes sense
* to do all three: put the attribute on the function, put pragmas inside
* the body of the function, and put pragmas around some call sites.
* do NOT get annotated automatically.
*/
#if __has_cpp_attribute(clang::unsafe_buffer_usage)
#define __has_safe_buffers 1

View File

@ -30,10 +30,11 @@
#define _SYS_CLONEFILE_H_
/* Options for clonefile calls */
#define CLONE_NOFOLLOW 0x0001 /* Don't follow symbolic links */
#define CLONE_NOOWNERCOPY 0x0002 /* Don't copy ownership information from source */
#define CLONE_ACL 0x0004 /* Copy access control lists from source */
#define CLONE_NOFOLLOW_ANY 0x0008 /* Don't follow any symbolic links in the path */
#define CLONE_NOFOLLOW 0x0001 /* Don't follow symbolic links */
#define CLONE_NOOWNERCOPY 0x0002 /* Don't copy ownership information from source */
#define CLONE_ACL 0x0004 /* Copy access control lists from source */
#define CLONE_NOFOLLOW_ANY 0x0008 /* Don't follow any symbolic links in the path */
#define CLONE_RESOLVE_BENEATH 0x0010 /* path must reside in the hierarchy beneath the starting directory */
#include <sys/cdefs.h>

View File

@ -260,7 +260,12 @@ __END_DECLS
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#define EQFULL 106 /* Interface output queue is full */
#define ELAST 106 /* Must be equal largest errno */
#endif
#define ENOTCAPABLE 107 /* Capabilities insufficient */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#define ELAST 107 /* Must be equal largest errno */
#endif
#endif /* _SYS_ERRNO_H_ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2022 Apple Inc. All rights reserved.
* Copyright (c) 2000-2025 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@ -126,6 +126,7 @@
#define O_TRUNC 0x00000400 /* truncate to zero length */
#define O_EXCL 0x00000800 /* error if already exists */
#define O_RESOLVE_BENEATH 0x00001000 /* only for open(2), same value as FMARK */
#define O_UNIQUE 0x00002000 /* only for open(2), same value as FDEFER */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
@ -181,6 +182,8 @@
#define AT_REALDEV 0x0200 /* Return real device inodes resides on for fstatat(2) */
#define AT_FDONLY 0x0400 /* Use only the fd and Ignore the path for fstatat(2) */
#define AT_SYMLINK_NOFOLLOW_ANY 0x0800 /* Path should not contain any symlinks */
#define AT_RESOLVE_BENEATH 0x2000 /* Path must reside in the hierarchy beneath the starting directory */
#define AT_NODELETEBUSY 0x4000 /* Don't delete busy files */
#endif
#endif
@ -258,10 +261,8 @@
#define F_THAW_FS 54 /* "thaw" all fs operations */
#define F_GLOBAL_NOCACHE 55 /* turn data caching off/on (globally) for this file */
#define F_ADDSIGS 59 /* add detached signatures */
#define F_ADDFILESIGS 61 /* add signature from same file (used by dyld for shared libs) */
#define F_NODIRECT 62 /* used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes */
@ -282,7 +283,6 @@
/* See F_DUPFD_CLOEXEC below for 67 */
#define F_SETBACKINGSTORE 70 /* Mark the file as being the backing store for another filesystem */
#define F_GETPATH_MTMINFO 71 /* return the full path of the FD, but error in specific mtmd circumstances */
@ -300,10 +300,8 @@
#define F_FINDSIGS 78 /* Add detached code signatures (used by dyld for shared libs) */
#define F_ADDFILESIGS_FOR_DYLD_SIM 83 /* Add signature from same file, only if it is signed by Apple (used by dyld for simulator) */
#define F_BARRIERFSYNC 85 /* fsync + issue barrier to drive */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
@ -314,7 +312,6 @@
#define F_OFD_SETLKWTIMEOUT 93 /* (as F_OFD_SETLKW but return if timeout) */
#endif
#define F_ADDFILESIGS_RETURN 97 /* Add signature from same file, return end offset in structure on success */
#define F_CHECK_LV 98 /* Check if Library Validation allows this Mach-O file to be mapped into the calling process */
@ -335,10 +332,10 @@
#define F_SETLEASE_ARG(t, oc) ((t) | ((oc) << 2))
#define F_TRANSFEREXTENTS 110 /* Transfer allocated extents beyond leof to a different file */
#define F_ATTRIBUTION_TAG 111 /* Based on flags, query/set/delete a file's attribution tag */
#define F_NOCACHE_EXT 112 /* turn data caching off/on for this fd and relax size and alignment restrictions for write */
#define F_ADDSIGS_MAIN_BINARY 113 /* add detached signatures for main binary -- development only */
@ -359,7 +356,6 @@
#define F_UNLCK 2 /* unlock */
#define F_WRLCK 3 /* exclusive or write lock */
/*
* [XSI] The values used for l_whence shall be defined as described
* in <unistd.h>
@ -409,6 +405,7 @@ struct flocktimeout {
struct flock fl; /* flock passed for file locking */
struct timespec timeout; /* timespec struct for timeout */
};
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
@ -521,7 +518,6 @@ typedef struct fspecread {
off_t fsr_length; /* IN: size of the region */
} fspecread_t;
/* fattributiontag_t used by F_ATTRIBUTION_TAG */
#define ATTRIBUTION_NAME_MAX 255
typedef struct fattributiontag {
@ -573,7 +569,6 @@ struct log2phys {
#define O_POPUP 0x80000000 /* force window to popup on open */
#define O_ALERT 0x20000000 /* small, clean popup window */
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
@ -628,4 +623,5 @@ int filesec_unset_property(filesec_t, filesec_property_t) __OSX_AVAILABLE_ST
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
__END_DECLS
#endif /* !_SYS_FCNTL_H_ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2004, 2012-2016 Apple Inc. All rights reserved.
* Copyright (c) 2000-2004, 2012-2025 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*

View File

@ -384,7 +384,8 @@ struct netfs_status {
#define VQ_DESIRED_DISK 0x4000 /* the desired disk space */
#define VQ_FREE_SPACE_CHANGE 0x8000 /* free disk space has significantly changed */
#define VQ_PURGEABLE_SPACE_CHANGE 0x10000 /* purgeable disk space has significantly changed */
#define VQ_FLAG20000 0x20000 /* placeholder */
#define VQ_IDLE_PURGE_NOTIFY 0x20000 /* Above nearlowdisk and below desired disk space */
#define VQ_FLAG40000 0x40000 /* placeholder */
@ -413,7 +414,7 @@ OS_ENUM(graftdmg_type, uint32_t,
GRAFTDMG_CRYPTEX_BOOT = 1,
GRAFTDMG_CRYPTEX_PREBOOT = 2,
GRAFTDMG_CRYPTEX_DOWNLEVEL = 3,
// Reserved: CRYPTEX1_AUTH_ENV_GENERIC = 4,
GRAFTDMG_CRYPTEX_AUTH_ENV_GENERIC = 4,
// Reserved: CRYPTEX1_AUTH_ENV_GENERIC_SUPPLEMENTAL = 5,
GRAFTDMG_CRYPTEX_PDI_NONCE = 6,
GRAFTDMG_CRYPTEX_EFFECTIVE_AP = 7,
@ -459,6 +460,7 @@ int statfs(const char *, struct statfs *) __DARWIN_INODE64(statfs);
int statfs64(const char *, struct statfs64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA);
#endif /* !__DARWIN_ONLY_64_BIT_INO_T */
int unmount(const char *, int);
int funmount(int, int) __OSX_AVAILABLE(16.0) __IOS_AVAILABLE(19.0) __TVOS_AVAILABLE(19.0) __WATCHOS_AVAILABLE(12.0);
int getvfsbyname(const char *, struct vfsconf *);
__END_DECLS

View File

@ -40,5 +40,16 @@
#define _PATH_RSRCNAME "rsrc"
#define _PATH_RSRCFORKSPEC "/..namedfork/rsrc"
/* Prefix Path Namespace */
#define RESOLVE_NOFOLLOW_ANY 0x00000001 /* no symlinks allowed in path */
#define RESOLVE_NODOTDOT 0x00000002 /* prevent '..' path traversal */
#define RESOLVE_LOCAL 0x00000004 /* prevent a path lookup into a network filesystem */
#define RESOLVE_NODEVFS 0x00000008 /* prevent a path lookup into `devfs` filesystem */
#define RESOLVE_IMMOVABLE 0x00000010 /* prevent a path lookup into a removable filesystem */
#define RESOLVE_UNIQUE 0x00000020 /* prevent a path lookup on a vnode with multiple links */
#define RESOLVE_NOXATTRS 0x00000040 /* prevent a path lookup on named streams */
#define RESOLVE_VALIDMASK 0x0000007F
#endif /* __APPLE_API_PRIVATE */
#endif /* !_SYS_PATHS_H_ */

View File

@ -86,6 +86,7 @@
struct session;
struct pgrp;
struct proc;
struct proc_ident;
/* Exported fields for kern sysctls */
struct extern_proc {

View File

@ -349,6 +349,11 @@ struct proc_threadwithpathinfo {
struct vnode_info_path pvip;
};
struct proc_archinfo {
cpu_type_t p_cputype;
cpu_subtype_t p_cpusubtype;
};
/*
* Socket
*/
@ -758,6 +763,9 @@ struct channel_fdinfo {
#define PROC_PID_RUSAGE 16
#define PROC_PID_RUSAGE_SIZE 0
#define PROC_PIDARCHINFO 19
#define PROC_PIDARCHINFO_SIZE (sizeof(struct proc_archinfo))
/* Flavors for proc_pidfdinfo */
#define PROC_PIDFDVNODEINFO 1

View File

@ -514,6 +514,7 @@ struct proc_rlimit_control_wakeupmon {
#define IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE 8
#define IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES 9
#define IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY 10
#define IOPOL_TYPE_VFS_ENTITLED_RESERVE_ACCESS 14
/* scope */
#define IOPOL_SCOPE_PROCESS 0
@ -564,6 +565,9 @@ struct proc_rlimit_control_wakeupmon {
#define IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT 0
#define IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON 1
#define IOPOL_VFS_ENTITLED_RESERVE_ACCESS_OFF 0
#define IOPOL_VFS_ENTITLED_RESERVE_ACCESS_ON 1
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */

View File

@ -164,6 +164,7 @@ union sigval {
#define SIGEV_NONE 0 /* No async notification */
#define SIGEV_SIGNAL 1 /* aio - completion notification */
#define SIGEV_THREAD 3 /* [NOTIMP] [RTS] call notification function */
#define SIGEV_KEVENT 4 /* Generate a kevent */
struct sigevent {
int sigev_notify; /* Notification type */

View File

@ -37,6 +37,7 @@
#define RENAME_EXCL 0x00000004
#define RENAME_RESERVED1 0x00000008
#define RENAME_NOFOLLOW_ANY 0x00000010
#define RENAME_RESOLVE_BENEATH 0x00000020
#endif
#if __DARWIN_C_LEVEL >= 200809L

View File

@ -154,7 +154,8 @@ struct ctlname {
#define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */
#define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */
#define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */
#define CTLFLAG_EXPERIMENT 0x00100000 /* Allows writing w/ the trial experiment entitlement. */
#define CTLFLAG_EXPERIMENT 0x00100000 /* Allows read/write w/ the trial experiment entitlement. */
#define CTLFLAG_LEGACY_EXPERIMENT 0x00080000 /* Allows writing w/ the legacy trial experiment entitlement. */
/*
* USE THIS instead of a hardwired number from the categories below

View File

@ -72,7 +72,15 @@
#include <_types.h>
#include <sys/unistd.h>
#include <Availability.h>
#define _LIBC_COUNT__PATH_MAX _LIBC_UNSAFE_INDEXABLE
#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#if defined(__LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES) && __has_ptrcheck
/* required for bounds annotations, but pollutes namespace */
#include <sys/syslimits.h>
#undef _LIBC_COUNT__PATH_MAX
#define _LIBC_COUNT__PATH_MAX _LIBC_COUNT_OR_NULL(PATH_MAX)
#endif /* defined(__LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES) && __has_ptrcheck */
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
#include <sys/_types/_gid_t.h>
#include <sys/_types/_intptr_t.h>
#include <sys/_types/_off_t.h>
@ -517,8 +525,6 @@ extern int optind, opterr, optopt;
__END_DECLS
#endif /* __DARWIN_C_LEVEL >= 199209L */
/* Additional functionality provided by:
* POSIX.1c-1995,
* POSIX.1i-1995,
@ -526,7 +532,6 @@ __END_DECLS
*/
#if __DARWIN_C_LEVEL >= 199506L
#include <_ctermid.h>
/* These F_* are really XSI or Issue 6 */
#define F_ULOCK 0 /* unlock locked section */
#define F_LOCK 1 /* lock a section for exclusive use */
@ -536,6 +541,11 @@ __END_DECLS
__BEGIN_DECLS
/* Begin XSI */
/* Removed in Issue 7 */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L
#include <_ctermid.h>
#endif
/* Removed in Issue 6 */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
#if !defined(_POSIX_C_SOURCE)
@ -565,7 +575,7 @@ char *_LIBC_CSTR getpass(const char *) __POSIX_C_DEPRECATED(199506L);
/* Removed in Issue 7 */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L
char *_LIBC_CSTR getwd(char *_LIBC_COUNT_OR_NULL(PATH_MAX)) __POSIX_C_DEPRECATED(200112L); /* obsoleted by getcwd() */
char *_LIBC_CSTR getwd(char *_LIBC_COUNT__PATH_MAX) __POSIX_C_DEPRECATED(200112L); /* obsoleted by getcwd() */
#endif
int lchown(const char *, uid_t, gid_t) __DARWIN_ALIAS(lchown);

View File

@ -93,8 +93,10 @@ __BEGIN_DECLS
#if defined(__XPC_TEST__) && __XPC_TEST__
#define XPC_TESTSTATIC
#define XPC_TESTEXTERN extern
#define XPC_TESTNORETURN
#else // defined(__XPC_TEST__) && __XPC_TEST__
#define XPC_TESTSTATIC static
#define XPC_TESTNORETURN XPC_NORETURN
#endif // defined(__XPC_TEST__) && __XPC_TEST__
#if __has_feature(objc_arc)
@ -242,6 +244,8 @@ __BEGIN_DECLS
#define XPC_SWIFT_UNAVAILABLE(msg) __swift_unavailable(msg)
#define XPC_SWIFT_NOEXPORT XPC_SWIFT_UNAVAILABLE("Unavailable in Swift from the XPC C Module")
#define XPC_SWIFT_SENDABLE __attribute__((__swift_attr__("@Sendable")))
__END_DECLS
#endif // __XPC_BASE_H__

View File

@ -141,8 +141,8 @@ typedef void (*xpc_finalizer_t)(void * _Nullable value);
* The GCD queue to which the event handler block will be submitted. This
* parameter may be NULL, in which case the connection's target queue will be
* libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
* The target queue may be changed later with a call to
* xpc_connection_set_target_queue().
* The target queue may be changed prior to the connection being activated with
* a call to xpc_connection_set_target_queue().
*
* @result
* A new connection object. The caller is responsible for disposing of the
@ -178,8 +178,8 @@ xpc_connection_create(const char * _Nullable name,
* The GCD queue to which the event handler block will be submitted. This
* parameter may be NULL, in which case the connection's target queue will be
* libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
* The target queue may be changed later with a call to
* xpc_connection_set_target_queue().
* The target queue may be changed prior to the connection being activated with
* a call to xpc_connection_set_target_queue().
*
* @param flags
* Additional attributes with which to create the connection.
@ -240,14 +240,11 @@ xpc_connection_create_from_endpoint(xpc_endpoint_t endpoint);
* libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
*
* @discussion
* Setting the target queue is asynchronous and non-preemptive and therefore
* this method will not interrupt the execution of an already-running event
* handler block. Setting the target queue may be likened to issuing a barrier
* to the connection which does the actual work of changing the target queue.
* Once a connection is activated, this method may no longer be called and the
* target queue may no longer be updated.
*
* The XPC runtime guarantees this non-preemptiveness even for concurrent target
* queues. If the target queue is a concurrent queue, then XPC still guarantees
* that there will never be more than one invocation of the connection's event
* Even if the target queue is a concurrent queue, XPC still guarantees that
* there will never be more than one invocation of the connection's event
* handler block executing concurrently. If you wish to process events
* concurrently, you can dispatch_async(3) to a concurrent queue from within
* the event handler.
@ -330,7 +327,7 @@ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
XPC_EXPORT XPC_NONNULL_ALL
void
xpc_connection_set_event_handler(xpc_connection_t connection,
xpc_handler_t handler);
XPC_SWIFT_SENDABLE xpc_handler_t handler);
/*!
* @function xpc_connection_activate
@ -534,7 +531,7 @@ XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL4
void
xpc_connection_send_message_with_reply(xpc_connection_t connection,
xpc_object_t message, dispatch_queue_t _Nullable replyq,
xpc_handler_t handler);
XPC_SWIFT_SENDABLE xpc_handler_t handler);
/*!
* @function xpc_connection_send_message_with_reply_sync
@ -983,6 +980,33 @@ XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
int
xpc_connection_set_peer_lightweight_code_requirement(xpc_connection_t connection, xpc_object_t lwcr);
/*!
* @function xpc_connection_set_peer_requirement
* Requires that the connection peer has the specified requirement
*
* @param connection
* The connection object which is to be modified
*
* @param peer_requirement
* The requirement the peer must have
* It is safe to deallocate the peer requirement after calling `xpc_connection_set_peer_requirement`
*
* @discussion
* It is a programming error to call multiple of the `xpc_connection_set_peer_*_requirement` family of functions on the same
* connection. If more complex combinations of requirements are required, use lightweight code requirement.
*
* All messages received on this connection will be checked to ensure that they come from a peer who satisfies the
* requirement. For a listener connection, requests that do not satisfy the requirement are dropped. When a reply
* is expected on the connection and the peer does not satisfy the requirement `XPC_ERROR_PEER_CODE_SIGNING_REQUIREMENT`
* will be delivered instead of the reply.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_NONNULL_ALL
void
xpc_connection_set_peer_requirement(xpc_connection_t connection,
xpc_peer_requirement_t peer_requirement);
/*!
* @function xpc_connection_copy_invalidation_reason
* Returns a description of why the connection was invalidated.

View File

@ -24,7 +24,7 @@ __BEGIN_DECLS
* connect to the server
*
*/
OS_OBJECT_DECL_CLASS(xpc_listener);
OS_OBJECT_DECL_SENDABLE_CLASS(xpc_listener);
#pragma mark Constants
/*!
@ -202,19 +202,22 @@ xpc_listener_reject_peer(xpc_session_t peer, const char *reason);
* The listener object which is to be modified.
*
* @param requirement
* The code signing requirement to be satisfied by the peer
* It is safe to deallocate the requirement string after calling `xpc_listener_set_peer_code_signing_requirement`
* The code signing requirement to be satisfied by the peer. It is safe to
* deallocate the requirement string after calling this function.
*
* @result
* 0 on success, non-zero on error
*
* @discussion
* This function will return an error promptly if the code signing requirement string is invalid.
* This function will return an error promptly if the code signing requirement
* string is invalid.
*
* It is a programming error to call `xpc_listener_set_peer_code_signing_requirement` more than once per listener.
* It is a programming error to call `xpc_listener_set_peer_*requirement` more
* than once per listener.
*
* All messages received on this listener will be checked to ensure they come from a peer who satisfies
* the code signing requirement. Requests that do not satisfy the requirement are dropped.
* All messages received on this listener will be checked to ensure they come
* from a peer who satisfies the code signing requirement. Requests that do not
* satisfy the requirement are dropped.
*
* @see https://developer.apple.com/documentation/technotes/tn3127-inside-code-signing-requirements
*/
@ -224,6 +227,32 @@ XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
int
xpc_listener_set_peer_code_signing_requirement(xpc_listener_t listener, const char *requirement);
/*!
* @function xpc_listener_set_peer_requirement
* Requires that the listener peer satisfies a requirement.
*
* @param listener
* The listener object which is to be modified. Must be inactive.
*
* @param requirement
* The requirement to be satisfied by the peer. It will be retained by XPC.
*
* @discussion
* It is a programming error to call `xpc_listener_set_peer_*requirement` more
* than once per listener.
*
* All messages received on this listener will be checked to ensure they come
* from a peer who satisfies the code signing requirement. Requests that do not
* satisfy the requirement are dropped.
*
* Peer sessions created from the listener do not inherit the requirement.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_NONNULL_ALL
void
xpc_listener_set_peer_requirement(xpc_listener_t listener, xpc_peer_requirement_t requirement);
__END_DECLS
XPC_ASSUME_NONNULL_END

View File

@ -0,0 +1,242 @@
#ifndef __XPC_PEER_REQ_H__
#define __XPC_PEER_REQ_H__
#ifndef __XPC_INDIRECT__
#error "Please #include <xpc/xpc.h> instead of this file directly."
// For HeaderDoc.
#include <xpc/base.h>
#endif // __XPC_INDIRECT__
XPC_ASSUME_NONNULL_BEGIN
__BEGIN_DECLS
XPC_SWIFT_NOEXPORT
/*!
* @typedef xpc_peer_requirement_t
*
* @abstract
* XPC peer requirement is an abstract type that represents a validated
* requirement on peers.
*
* @discussion
* Users can specify a requirement via `xpc_peer_requirement_create_*` API.
* These constructors will return a non-null xpc_peer_requirement_t if the
* requirement is valid. Users can set a xpc_peer_requirement_t on connections,
* sessions or listeners using one of `xpc_*_set_peer_requirement` API.
*
* xpc_peer_requirement_t is reference counted and concurrency-safe. One
* xpc_peer_requirement_t can be shared among multiple connections, sessions
* or listeners.
*/
OS_OBJECT_DECL_CLASS(xpc_peer_requirement);
#pragma mark Constructors
/*!
* @function xpc_peer_requirement_create_entitlement_exists
* Create a requirement that the peer has the specified entitlement
*
* @param entitlement
* The entitlement the peer must have. It is safe to deallocate the entitlement
* string after calling this function.
*
* @param error_out
* An out-parameter that, if set and in the event of an error, will point to an
* {@link xpc_rich_error_t} describing the details of any errors that occurred.
*
* @result
* On success this returns a new peer requirement object. On failure this will
* return NULL and if set, error_out will be set to an error describing the
* failure.
*
* @discussion
* This function will return NULL promptly if the entitlement requirement is
* invalid.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_RETURNS_RETAINED
xpc_peer_requirement_t _Nullable
xpc_peer_requirement_create_entitlement_exists(const char *entitlement,
xpc_rich_error_t _Nullable XPC_GIVES_REFERENCE * _Nullable error_out);
/*!
* @function xpc_peer_requirement_create_entitlement_matches_value
* Create a requirement that the peer has the entitlement with matching value
*
* @param entitlement
* The entitlement the peer must have. It is safe to deallocate the entitlement
* string after calling this function.
*
* @param value
* The value that the entitlement must match. It is safe to deallocate the value
* object after calling this function. Valid xpc types for this object are
* `XPC_TYPE_BOOL`, `XPC_TYPE_STRING` and `XPC_TYPE_INT64`.
*
* @param error_out
* An out-parameter that, if set and in the event of an error, will point to an
* {@link xpc_rich_error_t} describing the details of any errors that occurred.
*
* @result
* On success this returns a new peer requirement object. On failure this will
* return NULL and if set, error_out will be set to an error describing the
* failure.
*
* @discussion
* This function will return NULL promptly if the entitlement requirement is
* invalid.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_RETURNS_RETAINED
xpc_peer_requirement_t _Nullable
xpc_peer_requirement_create_entitlement_matches_value(const char *entitlement,
xpc_object_t value,
xpc_rich_error_t _Nullable XPC_GIVES_REFERENCE * _Nullable error_out);
/*!
* @function xpc_peer_requirement_create_team_identity
* Create a requirement that the peer has the specified identity and is signed
* with the same team identifier as the current process
*
* @param signing_identifier
* The optional signing identifier the peer must have. It is safe to deallocate
* the signing identifier string after calling this function.
*
* @param error_out
* An out-parameter that, if set and in the event of an error, will point to an
* {@link xpc_rich_error_t} describing the details of any errors that occurred.
*
* @result
* On success this returns a new peer requirement object. On failure this will
* return NULL and if set, error_out will be set to an error describing the
* failure.
*
* @discussion
* This function will return NULL promptly if the identity requirement is
* invalid.
*
* The peer process must be signed as either a Testflight app or an App store
* app, or be signed by an apple issued development certificate, an enterprise
* distributed certificate (embedded only), or a Developer ID certificate (macOS
* only)
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_RETURNS_RETAINED
xpc_peer_requirement_t _Nullable
xpc_peer_requirement_create_team_identity(
const char * _Nullable signing_identifier,
xpc_rich_error_t _Nullable XPC_GIVES_REFERENCE * _Nullable error_out);
/*!
* @function xpc_peer_requirement_create_platform_identity
* Create a requirement that the peer has the specified identity and is from
* platform binary.
*
* @param signing_identifier
* The optional signing identifier the peer must have. If not specified, this
* function ensures that the peer process' executable is a platform binary. It
* is safe to deallocate the signing identifier string after calling this
* function.
*
* @param error_out
* An out-parameter that, if set and in the event of an error, will point to an
* {@link xpc_rich_error_t} describing the details of any errors that occurred.
*
* @result
* On success this returns a new peer requirement object. On failure this will
* return NULL and if set, error_out will be set to an error describing the
* failure.
*
* @discussion
* This function will return NULL promptly if the identity requirement is
* invalid.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_RETURNS_RETAINED
xpc_peer_requirement_t _Nullable
xpc_peer_requirement_create_platform_identity(
const char * _Nullable signing_identifier,
xpc_rich_error_t _Nullable XPC_GIVES_REFERENCE * _Nullable error_out);
/*!
* @function xpc_peer_requirement_create_lwcr
* Create a requirement that the peer has the specified lightweight code requirement
*
* @param lwcr
* The lightweight code requirement the peer must have. It is safe to deallocate
* the lightweight code requirement object after calling this function.
*
* @param error_out
* An out-parameter that, if set and in the event of an error, will point to an
* {@link xpc_rich_error_t} describing the details of any errors that occurred.
*
* @result
* On success this returns a new peer requirement object. On failure this will
* return NULL and if set, error_out will be set to an error describing the
* failure.
*
* @discussion
* This function will return NULL promptly if the lightweight code requirement
* is invalid.
*
* The lightweight code requirement must be an `xpc_dictionary_t` equivalent of
* an LWCR constraint (see
* https://developer.apple.com/documentation/security/defining_launch_environment_and_library_constraints
* for details on the contents of the dictionary)
*
* The lightweight code requirement in the example below uses the $or operator
* to require that an executables either signed with the Team ID 8XCUU22SN2, or
* is an operating system executable:
* ```c
* xpc_object_t or_val = xpc_dictionary_create_empty();
* xpc_dictionary_set_string(or_val, "team-identifier", "8XCUU22SN2");
* xpc_dictionary_set_int64(or_val, "validation-category", 1);
*
* xpc_object_t lwcr = xpc_dictionary_create_empty();
* xpc_dictionary_set_value(lwcr, "$or", or_val);
*
* xpc_peer_requirement_t req = xpc_peer_requirement_create_lwcr(lwcr, NULL);
* ```
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_RETURNS_RETAINED
xpc_peer_requirement_t _Nullable
xpc_peer_requirement_create_lwcr(xpc_object_t lwcr,
xpc_rich_error_t _Nullable XPC_GIVES_REFERENCE * _Nullable error_out);
#pragma mark Matching Peer Requirement on Received Messages
/*!
* @function xpc_peer_requirement_match_received_message
* Check the specified requirement against a received message from the peer.
*
* @param peer_requirement
* The requirement the peer must have
*
* @param message
* The received dictionary to be checked
*
* @param error_out
* An out-parameter that, if set and in the event of an error, will point to an
* {@link xpc_rich_error_t} describing the details of any errors that occurred.
*
* @result
* On match this returns true. On mismatch or failure this will return false and
* if set, error_out will be set to an error describing the failure.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT
bool
xpc_peer_requirement_match_received_message(xpc_peer_requirement_t peer_requirement,
xpc_object_t message,
xpc_rich_error_t _Nullable XPC_GIVES_REFERENCE * _Nullable error_out);
__END_DECLS
XPC_ASSUME_NONNULL_END
#endif

View File

@ -25,8 +25,11 @@ __BEGIN_DECLS
* Clients can initiate a session with a service that accepts xpc_connection_t connections but session
* semantics will be maintained.
*
* Sessions can be created in an active or inactive state. They must be
* activated and subsequently cancelled before they can be released.
*
*/
OS_OBJECT_DECL_CLASS(xpc_session);
OS_OBJECT_DECL_SENDABLE_CLASS(xpc_session);
#pragma mark Constants
/*!
@ -244,8 +247,8 @@ xpc_session_set_target_queue(xpc_session_t session,
*
* @discussion
* xpc_session_activate must not be called on a session that has been already
* activated. Releasing the last reference on an inactive session that was
* created with an xpc_session_create*() will trigger an API misuse crash.
* activated. Releasing the last reference on an inactive session or an
* active session that has not been cancelled will trigger an API misuse crash.
*
* If activation fails, the session is automatically cancelled.
*/
@ -266,8 +269,9 @@ xpc_session_activate(xpc_session_t session,
* The session object to cancel.
*
* @discussion
* Session must have been activated to be canceled. Cancellation is asynchronous
* and non-preemptive.
* Session must have been activated to be cancelled and must be cancelled
* before the last reference can be released. Cancellation is asynchronous and
* non-preemptive.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0))
XPC_EXPORT XPC_SWIFT_NOEXPORT
@ -388,20 +392,26 @@ xpc_session_send_message_with_reply_async(xpc_session_t session,
* The session object which is to be modified.
*
* @param requirement
* The code signing requirement to be satisfied by the peer
* It is safe to deallocate the requirement string after calling `xpc_session_set_peer_code_signing_requirement`
* The code signing requirement to be satisfied by the peer. It is safe to
* deallocate the requirement string after calling this function.
*
* @result
* 0 on success, non-zero on error
*
* @discussion
* This function will return an error promptly if the code signing requirement string is invalid.
* This function will return an error promptly if the code signing requirement
* string is invalid.
*
* It is a programming error to call `xpc_session_set_peer_code_signing_requirement` more than once per session.
* It is a programming error to call `xpc_session_set_peer_*requirement` more
* than once per session.
*
* All messages received on this session will be checked to ensure they come from a peer who satisfies
* the code signing requirement. When message or a reply is received on the session and the peer does
* not satisfy the requirement the session will be cancelled.
* All messages received on this session will be checked to ensure they come
* from a peer who satisfies the code signing requirement. When message or a
* reply is received on the session and the peer does not satisfy the
* requirement the session will be cancelled. A rich error describing the peer
* code signing error will be passed to the cancellation handler. For
* `xpc_session_send_message_with_reply_*` NULL will be returned instead of
* reply, with `error_out` pointing to that rich error.
*
* @see https://developer.apple.com/documentation/technotes/tn3127-inside-code-signing-requirements
*/
@ -411,6 +421,34 @@ XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
int
xpc_session_set_peer_code_signing_requirement(xpc_session_t session, const char *requirement);
/*!
* @function xpc_session_set_peer_requirement
* Requires that the session peer satisfies a requirement.
*
* @param session
* The session object which is to be modified. Must be inactive.
*
* @param requirement
* The requirement to be satisfied by the peer. It will be retained by XPC.
*
* @discussion
* It is a programming error to call `xpc_session_set_peer_*requirement` more
* than once per session.
*
* All messages received on this session will be checked to ensure they come
* from a peer who satisfies the requirement. When a reply is expected on the
* session and the peer does not satisfy the requirement, the session will be
* canceled with cancellation handler called with a rich error describing the
* peer code signing error. For `xpc_session_send_message_with_reply_sync` NULL
* will be returned instead of reply, with `error_out` (if set) pointing to the
* rich error describing the peer code signing error.
*/
API_AVAILABLE(macos(26.0), ios(26.0))
API_UNAVAILABLE(tvos, watchos)
XPC_EXPORT XPC_SWIFT_NOEXPORT XPC_NONNULL_ALL
void
xpc_session_set_peer_requirement(xpc_session_t session, xpc_peer_requirement_t requirement);
/* This is included for compatibility and should not be used in new code */
#define XPC_TYPE_SESSION (&_xpc_type_session)
XPC_EXPORT

View File

@ -344,6 +344,7 @@ XPC_ASSUME_NONNULL_END
#include <xpc/debug.h>
#if __BLOCKS__
#include <xpc/activity.h>
#include <xpc/peer_requirement.h>
#include <xpc/connection.h>
#include <xpc/rich_error.h>
#include <xpc/session.h>
@ -2771,7 +2772,7 @@ API_UNAVAILABLE(ios)
XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
void
xpc_set_event_stream_handler(const char *stream,
dispatch_queue_t _Nullable targetq, xpc_handler_t handler);
dispatch_queue_t _Nullable targetq, XPC_SWIFT_SENDABLE xpc_handler_t handler);
#endif // __BLOCKS__
__END_DECLS