Repository: fubark/zig-v8
Branch: master
Commit: 168c4a868287
Files: 301
Total size: 2.0 MB
Directory structure:
gitextract_5ufvb6_p/
├── .gitattributes
├── .github/
│ └── workflows/
│ ├── build-single.yml
│ └── build.yml
├── .gitignore
├── .gn
├── BUILD.gclient.gn
├── BUILD.gn
├── LICENSE
├── README.md
├── V8_REVISION
├── build.zig
├── cross-macos/
│ └── sysroot/
│ └── macos-12/
│ └── usr/
│ └── include/
│ ├── libkern/
│ │ ├── OSAtomic.h
│ │ ├── OSAtomicDeprecated.h
│ │ ├── OSAtomicQueue.h
│ │ ├── OSByteOrder.h
│ │ ├── OSCacheControl.h
│ │ ├── OSDebug.h
│ │ ├── OSKextLib.h
│ │ ├── OSReturn.h
│ │ ├── OSSpinLockDeprecated.h
│ │ ├── OSThermalNotification.h
│ │ ├── OSTypes.h
│ │ ├── _OSByteOrder.h
│ │ ├── arm/
│ │ │ └── OSByteOrder.h
│ │ ├── i386/
│ │ │ ├── OSByteOrder.h
│ │ │ └── _OSByteOrder.h
│ │ └── machine/
│ │ └── OSByteOrder.h
│ ├── mach-o/
│ │ ├── arch.h
│ │ ├── arm/
│ │ │ └── reloc.h
│ │ ├── arm64/
│ │ │ └── reloc.h
│ │ ├── compact_unwind_encoding.h
│ │ ├── compact_unwind_encoding.modulemap
│ │ ├── dyld.h
│ │ ├── dyld.modulemap
│ │ ├── dyld_images.h
│ │ ├── fat.h
│ │ ├── fixup-chains.h
│ │ ├── getsect.h
│ │ ├── i386/
│ │ │ └── swap.h
│ │ ├── ldsyms.h
│ │ ├── loader.h
│ │ ├── module.modulemap
│ │ ├── nlist.h
│ │ ├── ranlib.h
│ │ ├── reloc.h
│ │ ├── stab.h
│ │ ├── swap.h
│ │ └── x86_64/
│ │ └── reloc.h
│ ├── os/
│ │ ├── _workgroup.h
│ │ ├── activity.h
│ │ ├── atomic.h
│ │ ├── availability.h
│ │ ├── base.h
│ │ ├── clock.h
│ │ ├── lock.h
│ │ ├── log.h
│ │ ├── object.h
│ │ ├── overflow.h
│ │ ├── proc.h
│ │ ├── signpost.h
│ │ ├── trace.h
│ │ ├── trace_base.h
│ │ ├── workgroup.h
│ │ ├── workgroup_base.h
│ │ ├── workgroup_interval.h
│ │ ├── workgroup_object.h
│ │ └── workgroup_parallel.h
│ └── sys/
│ ├── _endian.h
│ ├── _posix_availability.h
│ ├── _pthread/
│ │ ├── _pthread_attr_t.h
│ │ ├── _pthread_cond_t.h
│ │ ├── _pthread_condattr_t.h
│ │ ├── _pthread_key_t.h
│ │ ├── _pthread_mutex_t.h
│ │ ├── _pthread_mutexattr_t.h
│ │ ├── _pthread_once_t.h
│ │ ├── _pthread_rwlock_t.h
│ │ ├── _pthread_rwlockattr_t.h
│ │ ├── _pthread_t.h
│ │ └── _pthread_types.h
│ ├── _select.h
│ ├── _structs.h
│ ├── _symbol_aliasing.h
│ ├── _types/
│ │ ├── _blkcnt_t.h
│ │ ├── _blksize_t.h
│ │ ├── _caddr_t.h
│ │ ├── _clock_t.h
│ │ ├── _ct_rune_t.h
│ │ ├── _dev_t.h
│ │ ├── _errno_t.h
│ │ ├── _fd_clr.h
│ │ ├── _fd_copy.h
│ │ ├── _fd_def.h
│ │ ├── _fd_isset.h
│ │ ├── _fd_set.h
│ │ ├── _fd_setsize.h
│ │ ├── _fd_zero.h
│ │ ├── _filesec_t.h
│ │ ├── _fsblkcnt_t.h
│ │ ├── _fsfilcnt_t.h
│ │ ├── _fsid_t.h
│ │ ├── _fsobj_id_t.h
│ │ ├── _gid_t.h
│ │ ├── _guid_t.h
│ │ ├── _id_t.h
│ │ ├── _in_addr_t.h
│ │ ├── _in_port_t.h
│ │ ├── _ino64_t.h
│ │ ├── _ino_t.h
│ │ ├── _int16_t.h
│ │ ├── _int32_t.h
│ │ ├── _int64_t.h
│ │ ├── _int8_t.h
│ │ ├── _intptr_t.h
│ │ ├── _iovec_t.h
│ │ ├── _key_t.h
│ │ ├── _mach_port_t.h
│ │ ├── _mbstate_t.h
│ │ ├── _mode_t.h
│ │ ├── _nlink_t.h
│ │ ├── _null.h
│ │ ├── _o_dsync.h
│ │ ├── _o_sync.h
│ │ ├── _off_t.h
│ │ ├── _offsetof.h
│ │ ├── _os_inline.h
│ │ ├── _pid_t.h
│ │ ├── _posix_vdisable.h
│ │ ├── _ptrdiff_t.h
│ │ ├── _rsize_t.h
│ │ ├── _rune_t.h
│ │ ├── _s_ifmt.h
│ │ ├── _sa_family_t.h
│ │ ├── _seek_set.h
│ │ ├── _sigaltstack.h
│ │ ├── _sigset_t.h
│ │ ├── _size_t.h
│ │ ├── _socklen_t.h
│ │ ├── _ssize_t.h
│ │ ├── _suseconds_t.h
│ │ ├── _time_t.h
│ │ ├── _timespec.h
│ │ ├── _timeval.h
│ │ ├── _timeval32.h
│ │ ├── _timeval64.h
│ │ ├── _u_char.h
│ │ ├── _u_int.h
│ │ ├── _u_int16_t.h
│ │ ├── _u_int32_t.h
│ │ ├── _u_int64_t.h
│ │ ├── _u_int8_t.h
│ │ ├── _u_short.h
│ │ ├── _ucontext.h
│ │ ├── _ucontext64.h
│ │ ├── _uid_t.h
│ │ ├── _uintptr_t.h
│ │ ├── _useconds_t.h
│ │ ├── _uuid_t.h
│ │ ├── _va_list.h
│ │ ├── _wchar_t.h
│ │ └── _wint_t.h
│ ├── _types.h
│ ├── acct.h
│ ├── acl.h
│ ├── aio.h
│ ├── appleapiopts.h
│ ├── attr.h
│ ├── buf.h
│ ├── cdefs.h
│ ├── clonefile.h
│ ├── commpage.h
│ ├── conf.h
│ ├── dir.h
│ ├── dirent.h
│ ├── disk.h
│ ├── dkstat.h
│ ├── domain.h
│ ├── dtrace.h
│ ├── dtrace_glue.h
│ ├── dtrace_impl.h
│ ├── errno.h
│ ├── ev.h
│ ├── event.h
│ ├── fasttrap.h
│ ├── fasttrap_isa.h
│ ├── fcntl.h
│ ├── file.h
│ ├── filedesc.h
│ ├── filio.h
│ ├── fsgetpath.h
│ ├── gmon.h
│ ├── ioccom.h
│ ├── ioctl.h
│ ├── ioctl_compat.h
│ ├── ipc.h
│ ├── kauth.h
│ ├── kdebug.h
│ ├── kdebug_signpost.h
│ ├── kern_control.h
│ ├── kern_event.h
│ ├── kernel.h
│ ├── kernel_types.h
│ ├── lctx.h
│ ├── loadable_fs.h
│ ├── lock.h
│ ├── lockf.h
│ ├── lockstat.h
│ ├── log_data.h
│ ├── malloc.h
│ ├── mbuf.h
│ ├── mman.h
│ ├── mount.h
│ ├── msg.h
│ ├── msgbuf.h
│ ├── netport.h
│ ├── param.h
│ ├── paths.h
│ ├── pipe.h
│ ├── poll.h
│ ├── posix_sem.h
│ ├── posix_shm.h
│ ├── proc.h
│ ├── proc_info.h
│ ├── protosw.h
│ ├── ptrace.h
│ ├── qos.h
│ ├── queue.h
│ ├── quota.h
│ ├── random.h
│ ├── rbtree.h
│ ├── reboot.h
│ ├── resource.h
│ ├── resourcevar.h
│ ├── sbuf.h
│ ├── sdt.h
│ ├── select.h
│ ├── sem.h
│ ├── semaphore.h
│ ├── shm.h
│ ├── signal.h
│ ├── signalvar.h
│ ├── snapshot.h
│ ├── socket.h
│ ├── socketvar.h
│ ├── sockio.h
│ ├── spawn.h
│ ├── stat.h
│ ├── statvfs.h
│ ├── stdio.h
│ ├── sys_domain.h
│ ├── syscall.h
│ ├── sysctl.h
│ ├── syslimits.h
│ ├── syslog.h
│ ├── termios.h
│ ├── time.h
│ ├── timeb.h
│ ├── times.h
│ ├── timex.h
│ ├── tprintf.h
│ ├── trace.h
│ ├── tty.h
│ ├── ttychars.h
│ ├── ttycom.h
│ ├── ttydefaults.h
│ ├── ttydev.h
│ ├── types.h
│ ├── ubc.h
│ ├── ucontext.h
│ ├── ucred.h
│ ├── uio.h
│ ├── un.h
│ ├── unistd.h
│ ├── unpcb.h
│ ├── user.h
│ ├── utfconv.h
│ ├── utsname.h
│ ├── vadvise.h
│ ├── vcmd.h
│ ├── vm.h
│ ├── vmmeter.h
│ ├── vmparam.h
│ ├── vnioctl.h
│ ├── vnode.h
│ ├── vnode_if.h
│ ├── vsock.h
│ ├── vstat.h
│ ├── wait.h
│ └── xattr.h
├── cross-windows/
│ ├── TraceLoggingProvider.h
│ ├── VersionHelpers.h
│ ├── Windows.h
│ └── src/
│ └── base/
│ └── win32-headers.h
├── parse_deps.py
├── patches/
│ ├── v8.patch
│ └── v8_build.patch
└── src/
├── binding.cpp
├── binding.h
├── shell.zig
├── test.zig
└── v8.zig
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
*.zig text eol=lf
*.md text eol=lf
*.patch text eol=lf
V8_REVISION text eol=lf
cross-macos/** linguist-vendored
================================================
FILE: .github/workflows/build-single.yml
================================================
name: Build V8 (Single)
on:
workflow_dispatch:
inputs:
host:
type: choice
description: Host
options:
- ubuntu-22.04
- macos-12
- windows-2019
target:
type: choice
description: Target
options:
- x86_64-linux-gnu
- x86_64-macos-none
- x86_64-windows-msvc
- x86_64-windows-gnu
- aarch64-macos-none
mode:
type: choice
description: Mode
options:
- release
toolchain:
type: choice
description: Toolchain
options:
- v8
- zig
jobs:
build:
name: host=${{ github.event.inputs.host }} target=${{ github.event.inputs.target }} mode=${{ github.event.inputs.mode }} tc=${{ github.event.inputs.toolchain }}
runs-on: ${{ github.event.inputs.host }}
env:
ARCH_OS: >-
${{ fromJson('{
"x86_64-windows-gnu": "x86_64-windows",
"x86_64-windows-msvc": "x86_64-windows",
"x86_64-linux-gnu": "x86_64-linux",
"x86_64-macos-none": "x86_64-macos",
"aarch64-macos-none": "aarch64-macos",
}')[github.event.inputs.target] }}
ZIG_TARGET_FLAG: >-
${{ fromJson('{
"x86_64-windows-gnu": "-Dtarget=x86_64-windows-gnu -Dcpu=baseline",
"x86_64-windows-msvc": "-Dtarget=x86_64-windows-msvc -Dcpu=baseline",
"x86_64-linux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline",
"x86_64-macos-none": "-Dtarget=x86_64-macos.12-none -Dcpu=baseline",
"aarch64-macos-none": "-Dtarget=aarch64-macos.12-none -Dcpu=baseline",
}')[github.event.inputs.target] }}
LIB_NAME: ${{ contains(github.event.inputs.target, 'windows') && 'c_v8' || 'libc_v8' }}
LIB_EXT: ${{ contains(github.event.inputs.target, 'windows') && 'lib' || 'a' }}
BUILD_HOST: ${{ matrix.config.host }}
BUILD_TARGET: ${{ github.event.inputs.target }}
BUILD_MODE: ${{ github.event.inputs.mode }}
BUILD_TOOLCHAIN: ${{ github.event.inputs.toolchain }}
steps:
- name: Clone repo.
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Get build tag.
shell: bash
# Need single quotes or path sep becomes escapes on windows host. xargs does trimming.
run: echo "BUILD_TAG=$(cat '${{ github.workspace }}/V8_REVISION' | xargs)" >> $GITHUB_ENV
- name: Create/Update tag.
uses: actions/github-script@v5
with:
script: |
const ref = 'tags/${{ env.BUILD_TAG }}';
const res = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/${{ env.BUILD_TAG }}',
});
if (res.data.length > 0) {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/${{ env.BUILD_TAG }}',
sha: context.sha,
});
} else {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
// Only create needs full path
ref: 'refs/tags/${{ env.BUILD_TAG }}',
sha: context.sha,
});
}
- name: Install zig.
if: env.BUILD_HOST == 'ubuntu-22.04'
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-0.11.0-dev.944+a193ec432.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install zig.
if: env.BUILD_HOST == 'macos-12'
run: |
wget -c https://ziglang.org/builds/zig-macos-x86_64-0.11.0-dev.944+a193ec432.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Cache.
if: env.BUILD_TOOLCHAIN == 'zig'
uses: actions/cache@v2
with:
path: |-
~/.cache/zig
key:
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-zig2
restore-keys:
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-zig2
- name: Cache.
if: env.BUILD_TOOLCHAIN == 'v8'
uses: actions/cache@v2
with:
# Restore sccache so subsequent runs can reuse the cache.
# TODO: Might be useful to restore some of v8 source deps so get-v8 does less work.
path: |-
sccache
key:
# The cache can behave unexpectedly (usually happens when we change the path), so we just increase a simple id counter to create a new cache.
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-2
restore-keys:
# Reuse a previous cache.
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-
- name: Install and start sccache.
if: env.BUILD_TOOLCHAIN == 'v8'
shell: pwsh
env:
SCCACHE_DIR: ${{ github.workspace }}/sccache
# Compiling all of v8 takes up about 100M for debug builds so this is a good starting point.
SCCACHE_CACHE_SIZE: 128M
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "v0.2.15"
$platform =
@{ "macOS" = "x86_64-apple-darwin"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
}.${{ runner.os }}
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/" +
"$version/$basename.tar.gz"
cd ~
curl -LO $url
tar -xzvf "$basename.tar.gz"
chmod a+x $basename/sccache
. $basename/sccache --start-server
echo "$(pwd)/$basename" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Get V8 Tools.
run: zig build get-tools
- name: Get V8 Source.
run: zig build get-v8
- name: Build release.
if: env.BUILD_MODE == 'release' && env.BUILD_TOOLCHAIN == 'v8'
run: zig build -Drelease-safe ${{ env.ZIG_TARGET_FLAG }}
- name: Build release.
if: env.BUILD_MODE == 'release' && env.BUILD_TOOLCHAIN == 'zig'
run: zig build -Drelease-safe ${{ env.ZIG_TARGET_FLAG }} -Dzig-toolchain
- name: Build debug.
if: env.BUILD_MODE == 'debug'
run: zig build
- name: Copy binary.
if: env.BUILD_TARGET != 'x86_64-windows-gnu'
continue-on-error: true
run: cp
v8-build/${{ env.ARCH_OS }}/${{ env.BUILD_MODE }}/ninja/obj/zig/${{ env.LIB_NAME }}.${{ env.LIB_EXT }}
v8-build/${{ env.LIB_NAME }}_${{ env.BUILD_TARGET }}_${{ env.BUILD_MODE }}_${{ env.BUILD_TAG }}.${{ env.LIB_EXT }}
- name: Copy binary.
if: env.BUILD_TARGET == 'x86_64-windows-gnu'
continue-on-error: true
run: cp
v8-build/${{ env.ARCH_OS }}/${{ env.BUILD_MODE }}/ninja/obj/zig/libc_v8.a
v8-build/${{ env.LIB_NAME }}_${{ env.BUILD_TARGET }}_${{ env.BUILD_MODE }}_${{ env.BUILD_TAG }}.${{ env.LIB_EXT }}
- name: Github Release.
uses: softprops/action-gh-release@v0.1.14
# Github requires tags for releases.
#if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: Release
name: ${{ env.BUILD_TAG }}
tag_name: ${{ env.BUILD_TAG }}
files: v8-build/${{ env.LIB_NAME }}_${{ env.BUILD_TARGET }}_${{ env.BUILD_MODE }}_${{ env.BUILD_TAG }}.${{ env.LIB_EXT }}
- name: Stop sccache.
if: env.BUILD_TOOLCHAIN == 'v8' && always()
run: |
sccache --show-stats
sccache --stop-server
================================================
FILE: .github/workflows/build.yml
================================================
name: Build V8
on: [workflow_dispatch, push]
concurrency:
group: my-group
cancel-in-progress: true
jobs:
build:
name: host=${{ matrix.config.host }} target=${{ matrix.config.target }} mode=${{ matrix.config.mode }} tc=${{ matrix.config.toolchain }}
runs-on: ${{ matrix.config.host }}
strategy:
fail-fast: true
matrix:
config:
- host: ubuntu-22.04
target: x86_64-linux-gnu
mode: release
toolchain: zig
- host: macos-12
target: x86_64-macos-none
mode: release
toolchain: v8
- host: ubuntu-22.04
target: x86_64-windows-gnu
mode: release
toolchain: zig
- host: ubuntu-22.04
target: aarch64-macos-none
mode: release
toolchain: zig
env:
ARCH_OS: >-
${{ fromJson('{
"x86_64-windows-gnu": "x86_64-windows",
"x86_64-linux-gnu": "x86_64-linux",
"x86_64-macos-none": "x86_64-macos",
"aarch64-macos-none": "aarch64-macos",
}')[matrix.config.target] }}
ZIG_TARGET_FLAG: >-
${{ fromJson('{
"x86_64-windows-gnu": "-Dtarget=x86_64-windows-gnu -Dcpu=baseline",
"x86_64-linux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline",
"x86_64-macos-gnu": "-Dtarget=x86_64-macos.12-none -Dcpu=baseline",
"aarch64-macos-gnu": "-Dtarget=aarch64-macos.12-none -Dcpu=baseline",
}')[matrix.config.target] }}
BUILD_HOST: ${{ matrix.config.host }}
BUILD_TARGET: ${{ matrix.config.target }}
BUILD_MODE: ${{ matrix.config.mode }}
BUILD_TOOLCHAIN: ${{ matrix.config.toolchain }}
LIB_NAME: ${{ contains(matrix.config.target, 'windows') && 'c_v8' || 'libc_v8' }}
LIB_EXT: ${{ contains(matrix.config.target, 'windows') && 'lib' || 'a' }}
steps:
- name: Clone repo.
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Get build tag.
shell: bash
# Need single quotes or path sep becomes escapes on windows host. xargs does trimming.
run: echo "BUILD_TAG=$(cat '${{ github.workspace }}/V8_REVISION' | xargs)" >> $GITHUB_ENV
- name: Create/Update tag.
uses: actions/github-script@v5
with:
script: |
const ref = 'tags/${{ env.BUILD_TAG }}';
const res = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/${{ env.BUILD_TAG }}',
});
if (res.data.length > 0) {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/${{ env.BUILD_TAG }}',
sha: context.sha,
});
} else {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
// Only create needs full path
ref: 'refs/tags/${{ env.BUILD_TAG }}',
sha: context.sha,
});
}
- name: Install zig.
if: env.BUILD_HOST == 'ubuntu-22.04'
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-0.11.0-dev.1797+d3c9bfada.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install zig.
if: env.BUILD_HOST == 'macos-12'
run: |
wget -c https://ziglang.org/builds/zig-macos-x86_64-0.11.0-dev.1797+d3c9bfada.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Cache.
if: env.BUILD_TOOLCHAIN == 'zig'
uses: actions/cache@v2
with:
path: |-
~/.cache/zig
key:
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-zig2
restore-keys:
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-zig2
- name: Cache.
if: env.BUILD_TOOLCHAIN == 'v8'
uses: actions/cache@v2
with:
# Restore sccache so subsequent runs can reuse the cache.
# TODO: Might be useful to restore some of v8 source deps so get-v8 does less work.
path: |-
sccache
key:
# The cache can behave unexpectedly (usually happens when we change the path), so we just increase a simple id counter to create a new cache.
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-2
restore-keys:
# Reuse a previous cache.
c_v8-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-
- name: Install and start sccache.
if: env.BUILD_TOOLCHAIN == 'v8'
shell: pwsh
env:
SCCACHE_DIR: ${{ github.workspace }}/sccache
# Compiling all of v8 takes up about 100M for debug builds so this is a good starting point.
SCCACHE_CACHE_SIZE: 128M
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "v0.2.15"
$platform =
@{ "macOS" = "x86_64-apple-darwin"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
}.${{ runner.os }}
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/" +
"$version/$basename.tar.gz"
cd ~
curl -LO $url
tar -xzvf "$basename.tar.gz"
chmod a+x $basename/sccache
. $basename/sccache --start-server
echo "$(pwd)/$basename" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Get V8 Tools.
run: zig build get-tools
- name: Get V8 Source.
run: zig build get-v8
- name: Build release.
if: env.BUILD_MODE == 'release' && env.BUILD_TOOLCHAIN == 'v8'
run: zig build -Doptimize=ReleaseSafe ${{ env.ZIG_TARGET_FLAG }}
- name: Build release.
if: env.BUILD_MODE == 'release' && env.BUILD_TOOLCHAIN == 'zig'
run: zig build -Doptimize=ReleaseSafe ${{ env.ZIG_TARGET_FLAG }} -Dzig-toolchain
- name: Build debug.
if: env.BUILD_MODE == 'debug'
run: zig build
- name: Copy binary.
if: env.BUILD_TARGET != 'x86_64-windows-gnu'
continue-on-error: true
run: cp
v8-build/${{ env.ARCH_OS }}/${{ env.BUILD_MODE }}/ninja/obj/zig/${{ env.LIB_NAME }}.${{ env.LIB_EXT }}
v8-build/${{ env.LIB_NAME }}_${{ env.BUILD_TARGET }}_${{ env.BUILD_MODE }}_${{ env.BUILD_TAG }}.${{ env.LIB_EXT }}
- name: Copy binary.
if: env.BUILD_TARGET == 'x86_64-windows-gnu'
continue-on-error: true
run: cp
v8-build/${{ env.ARCH_OS }}/${{ env.BUILD_MODE }}/ninja/obj/zig/libc_v8.a
v8-build/${{ env.LIB_NAME }}_${{ env.BUILD_TARGET }}_${{ env.BUILD_MODE }}_${{ env.BUILD_TAG }}.${{ env.LIB_EXT }}
- name: Github Release.
uses: softprops/action-gh-release@v0.1.14
# Github requires tags for releases.
#if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: Release
name: ${{ env.BUILD_TAG }}
tag_name: ${{ env.BUILD_TAG }}
files: v8-build/${{ env.LIB_NAME }}_${{ env.BUILD_TARGET }}_${{ env.BUILD_MODE }}_${{ env.BUILD_TAG }}.${{ env.LIB_EXT }}
- name: Stop sccache.
if: env.BUILD_TOOLCHAIN == 'v8' && always()
run: |
sccache --show-stats
sccache --stop-server
================================================
FILE: .gitignore
================================================
/zig-cache/
/tools/ninja_gn_binaries*
/v8-build/
/gclient/
/v8/
/zig-out/
/vendor
/libc_v8.a
/tools/
================================================
FILE: .gn
================================================
# This file is used by the GN meta build system to find the root of the source
# tree and to set startup options. For documentation on the values set in this
# file, run "gn help dotfile" at the command line.
# Use the default python3 so gn succeeds. Not sure why deno requires python2 atm.
script_executable = "python3"
# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"
# These are the targets to check headers for by default. The files in targets
# matching these patterns (see "gn help label_pattern" for format) will have
# their includes checked for proper dependencies when you run either
# "gn check" or "gn gen --check".
check_targets = []
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
#secondary_source = "//gclient/v8"
default_args = {
linux_use_bundled_binutils = false
use_sysroot = false
use_dummy_lastchange = true
treat_warnings_as_errors = true
v8_enable_shared_ro_heap = false
v8_imminent_deprecation_warnings = false
clang_use_chrome_plugins = false
v8_monolithic = false
v8_use_external_startup_data = false
v8_use_snapshot = true
is_component_build = false
win_crt_flavor_agnostic = true
}
================================================
FILE: BUILD.gclient.gn
================================================
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
# Based on https://github.com/denoland/rusty_v8/blob/main/BUILD.gn
import("//build/config/host_byteorder.gni")
static_library("c_v8") {
complete_static_lib = true
sources = [ "../../../src/binding.cpp" ]
deps = [
"//build/config:shared_library_deps",
"//:v8",
"//:v8_libbase",
"//:v8_libplatform",
]
configs -= [
"//build/config/compiler:default_init_stack_vars",
"//build/config/compiler:thin_archive",
]
configs += [ ":c_v8_config" ]
}
config("c_v8_config") {
configs = [
"//:external_config",
"//:toolchain",
"//:features",
]
cflags = []
# We need these directories in the search path to be able to include some
# internal V8 headers.
include_dirs = [
"v8",
"$target_gen_dir/v8",
]
if (is_debug) {
defines = [ "DEBUG" ]
}
if (is_clang) {
cflags += [
"-fcolor-diagnostics",
"-fansi-escape-codes",
]
}
if (is_debug && is_clang && !is_win) {
cflags += [ "-glldb" ]
}
}
================================================
FILE: BUILD.gn
================================================
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
# Based on https://github.com/denoland/rusty_v8/blob/main/BUILD.gn
import("//build/config/host_byteorder.gni")
import("//build/toolchain/gcc_toolchain.gni")
import("//build/config/c++/c++.gni")
static_library("c_v8") {
complete_static_lib = true
sources = [ "../../src/binding.cpp" ]
deps = [
"//build/config:shared_library_deps",
"//:v8",
"//:v8_libbase",
"//:v8_libplatform",
]
configs -= [
"//build/config/compiler:default_init_stack_vars",
"//build/config/compiler:thin_archive",
]
configs += [ ":c_v8_config" ]
}
config("c_v8_config") {
configs = [
"//:external_config",
"//:toolchain",
"//:features",
]
cflags = []
# We need these directories in the search path to be able to include some
# internal V8 headers.
include_dirs = [
"v8",
"$target_gen_dir/v8",
]
if (is_debug) {
defines = [ "DEBUG" ]
}
if (is_clang) {
cflags += [
"-fcolor-diagnostics",
"-fansi-escape-codes",
]
}
if (is_debug && is_clang && !is_win) {
cflags += [ "-glldb" ]
}
}
# Based on template("clang_toolchain") in build/toolchain/gcc_toolchain.gni
template("zig_toolchain") {
gcc_toolchain(target_name) {
prefix = rebase_path("$clang_base_path/bin", root_build_dir)
readelf = "${prefix}/llvm-readelf"
# Is this even used?
nm = "${prefix}/llvm-nm"
if (current_cpu == "x64" && current_os == "linux") {
# From //build/toolchain/linux:clang_x64
# Output linker map files for binary size analysis.
enable_linker_map = true
}
forward_variables_from(invoker,
[
"strip",
"default_shlib_subdir",
"dwp",
"enable_linker_map",
"loadable_module_extension",
"use_unstripped_as_runtime_outputs",
"cc",
"cxx",
"ld",
"ar",
"extra_cppflags",
])
toolchain_args = {
if (defined(invoker.toolchain_args)) {
forward_variables_from(invoker.toolchain_args, "*")
}
is_clang = true
}
}
}
# Used to compile the v8 library.
zig_toolchain("main_zig_toolchain") {
cc = zig_cc
cxx = zig_cxx
# ld commands in v8 use cxx with -fuse-ld
ld = cxx
#ar = "${prefix}/llvm-ar"
ar = "zig ar"
extra_cppflags = "-Wno-unused-but-set-variable"
toolchain_args = {
current_cpu = target_cpu
current_os = target_os
}
}
# Used to compile v8 snapshots/generators to run locally.
# v8_current_cpu indicates that we are still targeting a different arch but must compile tools to run on host machine.
# See gni/snapshot_toolchain.gni
zig_toolchain("v8_zig_toolchain") {
cc = host_zig_cc
cxx = host_zig_cxx
# ld commands in v8 use cxx with -fuse-ld
ld = cxx
#ar = "${prefix}/llvm-ar"
ar = "zig ar"
extra_cppflags = "-Wno-unused-but-set-variable"
toolchain_args = {
current_os = host_os
current_cpu = host_cpu
v8_current_cpu = target_cpu
}
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2021 fubark
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# zig-v8
Builds V8 from official source and provides C bindings and a Zig API. This would be used for embedding the V8 runtime into your Zig or C ABI compatible projects.
V8 is the JS/WASM runtime that powers Google Chrome and Microsoft Edge.
## Project Status
Static libs are built and released with [Github Actions](https://github.com/fubark/zig-v8/actions).
| Native | Cross Compile | Target | Demo Binary ([shell.zig](https://github.com/fubark/zig-v8/blob/master/src/shell.zig))* |
| ------ | ------ | -------- | -------- |
| ✅ | | Linux x64 | shell - 19 M |
| ✅ | ✅ | Windows x64 | shell.exe - 14 M |
| ✅ | | macOS x64 | shell - 24 M |
| ✅ | ✅ | macOS arm64 | shell - 21 M |
\* shell.zig is a JS repl and statically linked with v8. Compiled with -Doptimize=ReleaseSafe. The V8 dependency can be further reduced in size if you don't need all the features (eg. disable WASM runtime).
| Toolchain | Fresh Build* | Cached Build* |
| ------ | ------ | ------ |
| gclient, full feature + v8 toolchain | 1.5-2 hrs | with sccache: 10-20min |
| minimal feature + v8 toolchain | 40-50 min | with sccache: 5-10min |
| minimal feature + zig c++ toolchain | | with zig caching: |
\* Time is measured on standard Github instances.
## System Requirements
- Zig compiler (0.11.0). You can get that [here](https://ziglang.org/download/).
- Python 3 (2.7 seems to work as well)
- For native macOS builds:
- XCode (You won't need this when using zig's c++ toolchain!)
if you come across this error:
`xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance`
run `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`
## Build
By default UseGclient=false in build.zig. This will pull the minimum sources and deps needed to build v8 and reduce build times.
If you want to include everything, set UseGclient=true. Build times can be quite long using gclient but afterwards rerunning "zig build" should be incremental. You can also use sccache for better incremental build times.
```sh
# Clone the repo.
git clone https://github.com/fubark/zig-v8.git
cd zig-v8
# Pull prebuilt GN/Ninja. If UseGclient=true, it also pulls depot_tools.
zig build get-tools
# Pull v8 source
zig build get-v8
# Build, resulting static library should be at:
# v8-build/{target}/{debug/release}/ninja/obj/zig/libc_v8.a
# On windows, use msvc: zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-windows-msvc
zig build -Doptimize=ReleaseSafe
```
## Demo
```sh
# shell.zig is a simple JS repl.
# Assumes you've already built v8.
zig build run -Dpath="src/shell.zig" -Doptimize=ReleaseSafe
# If you built v8 using the zig toolchain, you'll need to add the flag here as well.
zig build run -Dpath="src/shell.zig" -Doptimize=ReleaseSafe -Dzig-toolchain
```
## Cross Compiling
With Zig's toolchain, we can build V8 from libstdc++ that's bundled with zig and cross compile to foreign targets/cpus! Simply amazing. Eventually, this will also replace the default V8 toolchain for native builds after further testing.
### Linux x64 (Host) to MacOS arm64 (Target)
```sh
# Assumes you've fetched tools and v8 sources. See above build steps.
# Resulting static lib will be at:
# v8-build/aarch64-macos/release/ninja/obj/zig/libc_v8.a
zig build -Doptimize=ReleaseSafe -Dtarget=aarch64-macos-gnu -Dzig-toolchain
```
### Cross compile to Windows with gnu (mingw64)
Zig comes with mingw64 source and headers so you'll be able to target Windows without MSVC.
```sh
zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-windows-gnu -Dzig-toolchain
```
## Usage
See src/shell.zig or test/test.zig on how to use the library with the Zig API as well as build.zig (fn linkV8) on how to link with the built V8 static library.
## Contributing
The C bindings is incomplete but it should be relatively easy to add more as we need them.
C API naming convention should closely follow the V8 C++ API.
## Troubleshooting
If you get an error saying that it can't find any of the following:
```
pkg-config
glib-2.0
gmodule-2.0
gobject-2.0
gthread-2.0
```
You'll need to run the following command before continuing:
```
sudo apt install -y pkg-config libglib2.0-dev
```
Or your distro's equivalent
================================================
FILE: V8_REVISION
================================================
11.1.134
================================================
FILE: build.zig
================================================
const std = @import("std");
const json = std.json;
const Builder = std.Build;
const Step = std.Build.Step;
const print = std.debug.print;
const builtin = @import("builtin");
const Pkg = std.build.Pkg;
const fs = std.fs;
pub fn build(b: *Builder) !void {
// Options.
//const build_v8 = b.option(bool, "build_v8", "Whether to build from v8 source") orelse false;
const path = b.option([]const u8, "path", "Path to main file, for: build, run") orelse "";
const use_zig_tc = b.option(bool, "zig-toolchain", "Experimental: Use zig cc/c++/ld to build v8.") orelse false;
const mode = b.standardOptimizeOption(.{}); //FIXED
const target = b.standardTargetOptions(.{});
_ = createGetTools(b);
_ = createGetV8(b);
const v8 = try createV8_Build(b, target, mode, use_zig_tc);
const tests = createTest(b, target, mode, use_zig_tc);
tests.step.dependOn(v8);
const test_step = b.addRunArtifact(tests);
b.step("test", "Run unit tests").dependOn(&test_step.step);
const build_exe = createBuildExeStep(b, path, target, mode, use_zig_tc);
const run_exe = b.addRunArtifact(build_exe);
b.step("run", "Run with main file at -Dpath").dependOn(&run_exe.step);
b.default_step.dependOn(v8);
}
// When this is true, we'll strip V8 features down to a minimum so the resulting library is smaller.
// eg. i18n will be excluded.
const MinimalV8 = true;
// gclient is comprehensive and will pull everything for the v8 project.
// Set this to false to pull the minimal required src by parsing v8/DEPS and whitelisting deps we care about.
const UseGclient = false;
// V8's build process is complex and porting it to zig could take quite awhile.
// It would be nice if there was a way to import .gn files into the zig build system.
// For now we just use gn/ninja like rusty_v8 does: https://github.com/denoland/rusty_v8/blob/main/build.rs
fn createV8_Build(b: *Builder, target: std.Build.ResolvedTarget, mode: std.builtin.OptimizeMode, use_zig_tc: bool) !*std.Build.Step {
const step = b.step("v8", "Build v8 c binding lib.");
if (UseGclient) {
const mkpath = MakePathStep.create(b, "./gclient/v8/zig");
step.dependOn(&mkpath.step);
const cp = CopyFileStep.create(b, b.pathFromRoot("BUILD.gclient.gn"), b.pathFromRoot("gclient/v8/zig/BUILD.gn"));
step.dependOn(&cp.step);
} else {
const mkpath = MakePathStep.create(b, "./v8/zig");
step.dependOn(&mkpath.step);
const cp = CopyFileStep.create(b, b.pathFromRoot("BUILD.gn"), b.pathFromRoot("v8/zig/BUILD.gn"));
step.dependOn(&cp.step);
}
var gn_args = std.ArrayList([]const u8).init(b.allocator);
switch (target.result.os.tag) {
.macos => try gn_args.append("target_os=\"mac\""),
.windows => {
try gn_args.append("target_os=\"win\"");
if (!UseGclient) {
// Don't use depot_tools.
try b.graph.env_map.put("DEPOT_TOOLS_WIN_TOOLCHAIN", "0");
}
},
.linux => try gn_args.append("target_os=\"linux\""),
else => {},
}
switch (target.result.cpu.arch) {
.x86_64 => try gn_args.append("target_cpu=\"x64\""),
.aarch64 => try gn_args.append("target_cpu=\"arm64\""),
else => {},
}
var zig_cc = std.ArrayList([]const u8).init(b.allocator);
var zig_cxx = std.ArrayList([]const u8).init(b.allocator);
var host_zig_cc = std.ArrayList([]const u8).init(b.allocator);
var host_zig_cxx = std.ArrayList([]const u8).init(b.allocator);
if (mode == .Debug) {
try gn_args.append("is_debug=true");
// full debug info (symbol_level=2).
// Setting symbol_level=1 will produce enough information for stack traces, but not line-by-line debugging.
// Setting symbol_level=0 will include no debug symbols at all. Either will speed up the build compared to full symbols.
// This will eventually pass down to v8_symbol_level.
try gn_args.append("symbol_level=1");
} else {
try gn_args.append("is_debug=false");
try gn_args.append("symbol_level=0");
// is_official_build is meant to ship chrome.
// It might be interesting to see how far we can get with it (previously saw illegal instruction in Zone::NewExpand during mksnapshot_default since stacktraces were removed)
// but a better approach for now is to set to false and slowly enable optimizations. eg. We probably still want to unwind stack traces.
try gn_args.append("is_official_build=false");
// is_official_build will do pgo optimization by default for chrome specific builds that require gclient to fetch profile data.
// https://groups.google.com/a/chromium.org/g/chromium-dev/c/-0t4s0RlmOI
// Disable that with this:
//try gn_args.append("chrome_pgo_phase=0");
//if (use_zig_tc) {
// is_official_build will enable cfi but zig does not come with the default cfi_ignorelist.
//try zig_cppflags.append("-fno-sanitize-ignorelist");
//}
// TODO: Might want to turn V8_ENABLE_CHECKS off to remove asserts.
}
if (MinimalV8) {
// Don't add i18n for now. It has a large dependency on third_party/icu.
try gn_args.append("v8_enable_i18n_support=false");
}
if (mode != .Debug) {
// TODO: document
try gn_args.append("v8_enable_handle_zapping=false");
}
// Fix GN's host_cpu detection when using x86_64 bins on Apple Silicon
if (builtin.os.tag == .macos and builtin.cpu.arch == .aarch64) {
try gn_args.append("host_cpu=\"arm64\"");
}
if (use_zig_tc) {
// Set target and cpu for building the lib.
// TODO: If mcpu is equavalent to -Dcpu then use that instead
try zig_cc.append(b.fmt("zig cc --target={s} -mcpu=baseline", .{try target.result.zigTriple(b.allocator)}));
try zig_cxx.append(b.fmt("zig c++ --target={s} -mcpu=baseline", .{try target.result.zigTriple(b.allocator)}));
try host_zig_cc.append("zig cc --target=native");
try host_zig_cxx.append("zig c++ --target=native");
// Ignore "a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]"
try zig_cc.append("-Wno-deprecated-non-prototype");
try zig_cxx.append("-Wno-deprecated-non-prototype");
try host_zig_cc.append("-Wno-deprecated-non-prototype");
try host_zig_cxx.append("-Wno-deprecated-non-prototype");
// For zlib.
try zig_cc.append("-mcrc32");
try zig_cxx.append("-mcrc32");
if (target.result.os.tag == .windows and target.result.abi == .gnu) {
// V8 expects __declspec(dllexport) to not expand in it's test in src/base/export-template.h but it does when compiling with mingw.
try zig_cxx.append("-DEXPORT_TEMPLATE_TEST_MSVC_HACK_DEFAULT\\(...\\)=true");
}
if (target.result.os.tag == .windows and builtin.os.tag != .windows) {
// Cross building to windows probably is case sensitive to header files, so provide them in include.
// Note: Directory is relative to ninja build folder.
try zig_cxx.append("-I../../../../cross-windows");
// Make src/base/bits.h include win32-headers.h
try zig_cxx.append("-DV8_OS_WIN32=1");
// Use wchar_t unicode functions.
try zig_cxx.append("-DUNICODE=1");
// clang doesn't seem to recognize guard(nocf) even with -fdeclspec. It might be because mingw has a macro for __declspec.
try zig_cxx.append("-Wno-error=unknown-attributes");
// include/v8config.h doesn't set mingw flags if __clang__ is defined.
try zig_cxx.append("-DV8_CC_MINGW32=1");
try zig_cxx.append("-DV8_CC_MINGW64=1");
try zig_cxx.append("-DV8_CC_MINGW=1");
// Windows version. See build/config/win/BUILD.gn
try zig_cxx.append("-DNTDDI_VERSION=NTDDI_WIN10_VB");
try zig_cxx.append("-D_WIN32_WINNT=0x0A00");
try zig_cxx.append("-DWINVER=0x0A00");
// Enable support for MSVC pragmas.
try zig_cxx.append("-fms-extensions");
// Disable instrumentation since mingw doesn't have TraceLoggingProvider.h
try gn_args.append("v8_enable_system_instrumentation=false");
try gn_args.append("v8_enable_etw_stack_walking=false");
}
// Use zig's libcxx instead.
// If there are problems we can see what types of flags are enabled when this is true.
try gn_args.append("use_custom_libcxx=false");
// custom_toolchain is how we can set zig as the cc/cxx compiler and linker.
try gn_args.append("custom_toolchain=\"//zig:main_zig_toolchain\"");
if (target.result.os.tag == .linux and target.result.cpu.arch == .x86_64) {
// Should add target flags that matches: //build/config/compiler:compiler_cpu_abi
try zig_cc.append("-m64");
try zig_cxx.append("-m64");
} else if (target.result.os.tag == .macos) {
if (!target.query.isNative()) {
// Cross compiling.
const sysroot_abs = b.pathFromRoot("./cross-macos/sysroot/macos-12/usr/include");
try zig_cc.append("-isystem");
try zig_cc.append(sysroot_abs);
try zig_cxx.append("-isystem");
try zig_cxx.append(sysroot_abs);
}
}
if (builtin.cpu.arch != target.result.cpu.arch or builtin.os.tag != target.result.os.tag) {
try gn_args.append("v8_snapshot_toolchain=\"//zig:v8_zig_toolchain\"");
}
// Just warn for now. TODO: Check to remove after next clang update.
// https://bugs.chromium.org/p/chromium/issues/detail?id=1016945
try zig_cxx.append("-Wno-error=builtin-assume-aligned-alignment");
try host_zig_cxx.append("-Wno-error=builtin-assume-aligned-alignment");
try gn_args.append("use_zig_tc=true");
try gn_args.append("cxx_use_ld=\"zig ld.lld\"");
// Build zig cc strings.
var arg = b.fmt("zig_cc=\"{s}\"", .{try std.mem.join(b.allocator, " ", zig_cc.items)});
try gn_args.append(arg);
arg = b.fmt("zig_cxx=\"{s}\"", .{try std.mem.join(b.allocator, " ", zig_cxx.items)});
try gn_args.append(arg);
arg = b.fmt("host_zig_cc=\"{s}\"", .{try std.mem.join(b.allocator, " ", host_zig_cc.items)});
try gn_args.append(arg);
arg = b.fmt("host_zig_cxx=\"{s}\"", .{try std.mem.join(b.allocator, " ", host_zig_cxx.items)});
try gn_args.append(arg);
} else {
if (builtin.os.tag != .windows) {
try gn_args.append("cxx_use_ld=\"lld\"");
}
}
// sccache, currently does not work with zig cc
if (!use_zig_tc) {
if (b.graph.env_map.get("SCCACHE")) |path| {
const cc_wrapper = try std.fmt.allocPrint(b.allocator, "cc_wrapper=\"{s}\"", .{path});
try gn_args.append(cc_wrapper);
} else {
if (builtin.os.tag == .windows) {
// findProgram look for "PATH" case sensitive.
try b.graph.env_map.put("PATH", b.graph.env_map.get("Path") orelse "");
}
if (b.findProgram(&.{"sccache"}, &.{})) |_| {
const cc_wrapper = try std.fmt.allocPrint(b.allocator, "cc_wrapper=\"{s}\"", .{"sccache"});
try gn_args.append(cc_wrapper);
} else |err| {
if (err != error.FileNotFound) {
unreachable;
}
}
if (builtin.os.tag == .windows) {
// After creating PATH for windows so findProgram can find sccache, we need to delete it
// or a gn tool (build/toolchain/win/setup_toolchain.py) will complain about not finding cl.exe.
b.graph.env_map.remove("PATH");
}
}
}
// var check_deps = CheckV8DepsStep.create(b);
// step.step.dependOn(&check_deps.step);
const mode_str: []const u8 = if (mode == .Debug) "debug" else "release";
// GN will generate ninja build files in ninja_out_path which will also contain the artifacts after running ninja.
const ninja_out_path = try std.fmt.allocPrint(b.allocator, "v8-build/{s}/{s}/ninja", .{
getTargetId(b.allocator, target),
mode_str,
});
const gn = getGnPath(b);
const arg_items = try std.mem.join(b.allocator, " ", gn_args.items);
const args = try std.mem.join(b.allocator, "", &.{ "--args=", arg_items });
// Currently we have to use gclient/v8 as the source root since all those nested gn files expects it, (otherwise, we'll run into duplicate argument declaration errors.)
// --dotfile lets us use a different .gn outside of the source root.
// --root-target is a directory that must be inside the source root where we can have a custom BUILD.gn.
// Since gclient/v8 is not part of our repo, we copy over BUILD.gn to gclient/v8/zig/BUILD.gn before we run gn.
// To see v8 dependency tree:
// cd gclient/v8 && gn desc ../../v8-build/x86_64-linux/release/ninja/ :v8 --tree
// We can't see our own config because gn desc doesn't accept a --root-target.
// One idea is to append our BUILD.gn to the v8 BUILD.gn instead of putting it in a subdirectory.
if (UseGclient) {
var run_gn = b.addSystemCommand(&.{ gn, "--root=gclient/v8", "--root-target=//zig", "--dotfile=.gn", "gen", ninja_out_path, args });
step.dependOn(&run_gn.step);
} else {
// To see available args for gn: cd v8 && gn args --list ../v8-build/{target}/release/ninja/
var run_gn = b.addSystemCommand(&.{ gn, "--root=v8", "--root-target=//zig", "--dotfile=.gn", "gen", ninja_out_path, args });
step.dependOn(&run_gn.step);
}
const ninja = getNinjaPath(b);
// Only build our target. If no target is specified, ninja will build all the targets which includes developer tools, tests, etc.
var run_ninja = b.addSystemCommand(&.{ ninja, "-C", ninja_out_path, "c_v8" });
step.dependOn(&run_ninja.step);
return step;
}
fn getArchOs(alloc: std.mem.Allocator, arch: std.Target.Cpu.Arch, os: std.Target.Os.Tag) []const u8 {
return std.fmt.allocPrint(alloc, "{s}-{s}-gnu", .{ @tagName(arch), @tagName(os) }) catch unreachable;
}
fn getTargetId(alloc: std.mem.Allocator, target: std.Build.ResolvedTarget) []const u8 {
return std.fmt.allocPrint(alloc, "{s}-{s}", .{ @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) }) catch unreachable;
}
const CheckV8DepsStep = struct {
const Self = @This();
step: Step,
b: *Builder,
fn create(b: *Builder) *Self {
const step = b.allocator.create(Self) catch unreachable;
step.* = .{
.step = Step.init(.custom, "check_v8_deps", b.allocator, make),
.b = b,
};
return step;
}
fn make(step: *Step) !void {
const self: *Self = @fieldParentPtr("step", step);
const output = try self.b.execFromStep(&.{ "clang", "--version" }, step);
print("clang: {s}", .{output});
// TODO: Find out the actual minimum and check against other clang flavors.
if (std.mem.startsWith(u8, output, "Homebrew clang version ")) {
const i = std.mem.indexOfScalar(u8, output, '.').?;
const major_v = try std.fmt.parseInt(u8, output["Homebrew clang version ".len..i], 10);
if (major_v < 13) {
return error.BadClangVersion;
}
}
}
};
fn createGetV8(b: *Builder) *std.Build.Step {
const step = b.step("get-v8", "Gets v8 source using gclient.");
if (UseGclient) {
const mkpath = MakePathStep.create(b, "./gclient");
step.dependOn(&mkpath.step);
// About depot_tools: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
const cmd = b.addSystemCommand(&.{ b.pathFromRoot("./tools/depot_tools/fetch"), "v8" });
cmd.cwd = "./gclient";
cmd.addPathDir(b.pathFromRoot("./tools/depot_tools"));
step.dependOn(&cmd.step);
} else {
const get = GetV8SourceStep.create(b);
step.dependOn(&get.step);
}
return step;
}
fn createGetTools(b: *Builder) *std.Build.Step {
const step = b.step("get-tools", "Gets the build tools.");
//var sub_step = b.addSystemCommand(&.{ "python", "./tools/get_ninja_gn_binaries.py", "--dir", "./tools" });
var sub_step = b.addSystemCommand(&.{ "git", "clone", "https://github.com/denoland/ninja_gn_binaries.git", "./tools" });
step.dependOn(&sub_step.step);
if (UseGclient) {
// Pull depot_tools for fetch tool.
sub_step = b.addSystemCommand(&.{ "git", "clone", "--depth=1", "https://chromium.googlesource.com/chromium/tools/depot_tools.git", "tools/depot_tools" });
step.dependOn(&sub_step.step);
}
return step;
}
fn getNinjaPath(b: *Builder) []const u8 {
const platform = switch (builtin.os.tag) {
.windows => "win",
.linux => "linux",
.macos => "mac",
else => unreachable,
};
const arch = switch (builtin.cpu.arch) {
.x86_64 => "amd64",
.aarch64 => "arm64",
else => unreachable,
};
const ext = if (builtin.os.tag == .windows) ".exe" else "";
const bin = std.mem.concat(b.allocator, u8, &.{ "ninja", ext }) catch unreachable;
const subFolder = std.mem.concat(b.allocator, u8, &.{ platform, "-", arch }) catch unreachable;
return std.fs.path.resolve(b.allocator, &.{ "./tools", subFolder, bin }) catch unreachable;
}
fn getGnPath(b: *Builder) []const u8 {
const platform = switch (builtin.os.tag) {
.windows => "win",
.linux => "linux",
.macos => "mac",
else => unreachable,
};
const arch = switch (builtin.cpu.arch) {
.x86_64 => "amd64",
.aarch64 => "arm64",
else => unreachable,
};
const ext = if (builtin.os.tag == .windows) ".exe" else "";
const bin = std.mem.concat(b.allocator, u8, &.{ "gn", ext }) catch unreachable;
const subFolder = std.mem.concat(b.allocator, u8, &.{ platform, "-", arch }) catch unreachable;
return std.fs.path.resolve(b.allocator, &.{ "./tools", subFolder, bin }) catch unreachable;
}
const MakePathStep = struct {
const Self = @This();
step: std.Build.Step,
b: *Builder,
path: []const u8,
fn create(b: *Builder, root_path: []const u8) *Self {
const new = b.allocator.create(Self) catch unreachable;
new.* = .{
.step = std.Build.Step.init(.{
.id = .custom,
.name = b.fmt("make-path", .{}),
.owner = b,
.makeFn = make,
}),
.b = b,
.path = root_path,
};
return new;
}
fn make(step: *std.Build.Step, prog_node: std.Progress.Node) anyerror!void {
_ = prog_node;
const self: *Self = @fieldParentPtr("step", step);
const cwd = fs.cwd();
const stat = try statPathFromRoot(self.b, self.path);
if (stat == .NotExist) {
try cwd.makeDir(self.path);
}
}
};
const CopyFileStep = struct {
const Self = @This();
step: std.Build.Step,
b: *Builder,
src_path: []const u8,
dst_path: []const u8,
fn create(b: *Builder, src_path: []const u8, dst_path: []const u8) *Self {
const new = b.allocator.create(Self) catch unreachable;
new.* = .{
.step = std.Build.Step.init(.{
.id = .custom,
.name = b.fmt("cp", .{}),
.owner = b,
.makeFn = make,
}),
.b = b,
.src_path = src_path,
.dst_path = dst_path,
};
return new;
}
fn make(step: *std.Build.Step, prog_node: std.Progress.Node) anyerror!void {
_ = prog_node;
const self: *Self = @fieldParentPtr("step", step);
try std.fs.copyFileAbsolute(self.src_path, self.dst_path, .{});
}
};
// TODO: Make this usable from external project.
fn linkV8(b: *Builder, step: *std.Build.Step.Compile, mode: std.builtin.OptimizeMode, target: std.Build.ResolvedTarget, use_zig_tc: bool) void {
const mode_str: []const u8 = if (mode == .Debug) "debug" else "release";
const lib: []const u8 = if (target.result.os.tag == .windows and target.result.abi == .msvc) "c_v8.lib" else "libc_v8.a";
const lib_path = std.fmt.allocPrint(b.allocator, "./v8-build/{s}/{s}/ninja/obj/zig/{s}", .{
getTargetId(b.allocator, target),
mode_str,
lib,
}) catch unreachable;
step.addAssemblyFile(b.path(lib_path));
if (builtin.os.tag == .linux) {
if (use_zig_tc) {
// TODO: This should be linked already when we built v8.
step.linkLibCpp();
}
step.linkSystemLibrary("unwind");
} else if (target.result.os.tag == .windows) {
if (target.result.abi == .gnu) {
step.linkLibCpp();
} else {
step.linkSystemLibrary("Dbghelp");
step.linkSystemLibrary("Winmm");
step.linkSystemLibrary("Advapi32");
// We need libcpmt to statically link with c++ stl for exception_ptr references from V8.
// Zig already adds the SDK path to the linker but doesn't sync it to the internal libs array which linkSystemLibrary checks against.
// For now we'll hardcode the MSVC path here.
step.addLibraryPath(b.path("C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/lib/x64"));
step.linkSystemLibrary("libcpmt");
}
}
}
fn createTest(b: *Builder, target: std.Build.ResolvedTarget, mode: std.builtin.OptimizeMode, use_zig_tc: bool) *std.Build.Step.Compile {
const step = b.addTest(.{
.root_source_file = b.path("src/test.zig"),
.target = target,
.optimize = mode,
}); //FIXED
step.addIncludePath(b.path("src"));
step.linkLibC();
linkV8(b, step, mode, target, use_zig_tc);
return step;
}
const DepEntry = struct {
const Self = @This();
alloc: std.mem.Allocator,
repo_url: []const u8,
repo_rev: []const u8,
pub fn deinit(self: Self) void {
self.alloc.free(self.repo_url);
self.alloc.free(self.repo_rev);
}
};
fn getV8Rev(b: *Builder) ![]const u8 {
var file: std.fs.File = undefined;
if (comptime isMinZigVersion()) {
file = try std.fs.openFileAbsolute(b.pathFromRoot("V8_REVISION"), .{ .read = true, .write = false });
} else {
file = try std.fs.openFileAbsolute(b.pathFromRoot("V8_REVISION"), .{ .mode = std.fs.File.OpenMode.read_write });
}
defer file.close();
return std.mem.trim(u8, try file.readToEndAlloc(b.allocator, 1e9), "\n\r ");
}
pub const GetV8SourceStep = struct {
const Self = @This();
step: Step,
b: *Builder,
pub fn create(b: *Builder) *Self {
const self = b.allocator.create(Self) catch unreachable;
self.* = .{
.b = b,
.step = Step.init(.{
.id = .run,
.name = "Get V8 Sources.",
.owner = b,
.makeFn = make,
}),
};
return self;
}
fn parseDep(self: Self, deps: json.Value, key: []const u8) !DepEntry {
const val = deps.object.get(key).?;
const i = std.mem.lastIndexOfScalar(u8, val.string, '@').?;
const repo_rev = try self.b.allocator.dupe(u8, val.string[i + 1 ..]);
const repo_url = try std.mem.replaceOwned(u8, self.b.allocator, val.string[0..i], "@chromium_url", "https://chromium.googlesource.com");
return DepEntry{
.alloc = self.b.allocator,
.repo_url = repo_url,
.repo_rev = repo_rev,
};
}
fn getDep(self: *Self, deps: json.Value, key: []const u8, local_path: []const u8) !void {
const dep = try self.parseDep(deps, key);
defer dep.deinit();
const stat = try statPathFromRoot(self.b, local_path);
if (stat == .NotExist) {
_ = self.b.run(&.{ "git", "clone", dep.repo_url, local_path });
}
_ = self.b.run(&.{ "git", "-C", local_path, "checkout", dep.repo_rev });
if (stat == .NotExist) {
// Apply patch for v8/build
if (std.mem.eql(u8, key, "build")) {
_ = self.b.run(&.{ "git", "apply", "--ignore-space-change", "--ignore-whitespace", "patches/v8_build.patch", "--directory=v8/build" });
}
}
}
fn runHook(self: *Self, hooks: json.Value, name: []const u8) !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const alloc = gpa.allocator();
defer _ = gpa.deinit();
for (hooks.array.items) |hook| {
if (std.mem.eql(u8, name, hook.object.get("name").?.string)) {
const cmd = hook.object.get("action").?.array;
var args = std.ArrayList([]const u8).init(self.b.allocator);
defer args.deinit();
for (cmd.items) |it| {
try args.append(it.string);
}
const cwd = self.b.pathFromRoot("v8");
const cmd_path = try std.fmt.allocPrint(alloc, "{s}/{s}", .{ cwd, args.items[1] });
defer alloc.free(cmd_path);
_ = self.b.run(&.{ args.items[0], cmd_path });
break;
}
}
}
fn make(step: *Step, prog_node: std.Progress.Node) !void {
_ = prog_node;
const self: *Self = @fieldParentPtr("step", step);
// Pull the minimum source we need by looking at DEPS.
// TODO: Check if we have the right branches, otherwise reclone.
// Get revision/tag to checkout.
const v8_rev = try getV8Rev(self.b);
// Clone V8.
const stat = try statPathFromRoot(self.b, "v8");
if (stat == .NotExist) {
_ = self.b.run(&.{ "git", "clone", "--depth=1", "--branch", v8_rev, "https://chromium.googlesource.com/v8/v8.git", "v8" });
// Apply patch for v8 root.
_ = self.b.run(&.{ "git", "apply", "--ignore-space-change", "--ignore-whitespace", "patches/v8.patch", "--directory=v8" });
}
// Get DEPS in json.
const deps_json = self.b.run(&.{ "python3", "parse_deps.py", "v8/DEPS" });
defer self.b.allocator.free(deps_json);
var tree = try json.parseFromSlice(json.Value, self.b.allocator, deps_json, .{});
defer tree.deinit();
const deps = tree.value.object.get("deps").?;
const hooks = tree.value.object.get("hooks").?;
// build
try self.getDep(deps, "build", "v8/build");
// Add an empty gclient_args.gni so gn is happy. gclient also creates an empty file.
const file = try std.fs.createFileAbsolute(self.b.pathFromRoot("v8/build/config/gclient_args.gni"), .{ .read = false, .truncate = true });
try file.writeAll("# Generated from build.zig");
file.close();
// buildtools
try self.getDep(deps, "buildtools", "v8/buildtools");
// libc++
try self.getDep(deps, "buildtools/third_party/libc++/trunk", "v8/buildtools/third_party/libc++/trunk");
// tools/clang
try self.getDep(deps, "tools/clang", "v8/tools/clang");
try self.runHook(hooks, "clang");
// third_party/zlib
try self.getDep(deps, "third_party/zlib", "v8/third_party/zlib");
// libc++abi
try self.getDep(deps, "buildtools/third_party/libc++abi/trunk", "v8/buildtools/third_party/libc++abi/trunk");
// googletest
try self.getDep(deps, "third_party/googletest/src", "v8/third_party/googletest/src");
// trace_event
try self.getDep(deps, "base/trace_event/common", "v8/base/trace_event/common");
// jinja2
try self.getDep(deps, "third_party/jinja2", "v8/third_party/jinja2");
// markupsafe
try self.getDep(deps, "third_party/markupsafe", "v8/third_party/markupsafe");
// For windows.
if (builtin.os.tag == .windows) {
// lastchange.py is flaky when it tries to do git commands from subprocess.Popen. Will sometimes get [WinError 50].
// For now we'll just do it in zig.
// try self.runHook(hooks, "lastchange");
const merge_base_sha = "HEAD";
const commit_filter = "^Change-Id:";
const grep_arg = try std.fmt.allocPrint(self.b.allocator, "--grep={s}", .{commit_filter});
const version_info = try self.b.execFromStep(&.{ "git", "-C", "v8/build", "log", "-1", "--format=%H %ct", grep_arg, merge_base_sha }, &self.step);
const idx = std.mem.indexOfScalar(u8, version_info, ' ').?;
const commit_timestamp = version_info[idx + 1 ..];
// build/timestamp.gni expects the file to be just the unix timestamp.
const write = std.fs.createFileAbsolute(self.b.pathFromRoot("v8/build/util/LASTCHANGE.committime"), .{ .truncate = true }) catch unreachable;
defer write.close();
write.writeAll(commit_timestamp) catch unreachable;
}
}
};
fn createBuildExeStep(b: *Builder, path: []const u8, target: std.Build.ResolvedTarget, mode: std.builtin.OptimizeMode, use_zig_tc: bool) *std.Build.Step.Compile {
_ = b.step("exe", "Build exe with main file at -Dpath");
const basename = std.fs.path.basename(path);
const i = std.mem.indexOf(u8, basename, ".zig") orelse basename.len;
const name = basename[0..i];
const step = b.addExecutable(.{
.target = target,
.root_source_file = b.path(path),
.name = name,
.optimize = mode,
}); //FIXED
//step.setBuildMode(mode);
//step.setTarget(target);
step.linkLibC();
step.addIncludePath(b.path("src"));
if (mode == .ReleaseSafe) {
step.root_module.strip = true;
}
linkV8(b, step, mode, target, use_zig_tc);
return step;
}
const PathStat = enum {
NotExist,
Directory,
File,
SymLink,
Unknown,
};
fn statPathFromRoot(b: *Builder, path_rel: []const u8) !PathStat {
const path_abs = b.pathFromRoot(path_rel);
var file: std.fs.File = undefined;
if (comptime isMinZigVersion()) {
file = std.fs.openFileAbsolute(path_abs, .{ .read = false, .write = false }) catch |err| {
if (err == error.FileNotFound) {
return .NotExist;
} else if (err == error.IsDir) {
return .Directory;
} else {
return err;
}
};
} else {
file = std.fs.openFileAbsolute(path_abs, .{ .mode = std.fs.File.OpenMode.read_only }) catch |err| {
if (err == error.FileNotFound) {
return .NotExist;
} else if (err == error.IsDir) {
return .Directory;
} else {
return err;
}
};
}
defer file.close();
const stat = try file.stat();
switch (stat.kind) {
.sym_link => return .SymLink,
.directory => return .Directory,
.file => return .File,
else => return .Unknown,
}
}
fn isMinZigVersion() bool {
return builtin.zig_version.major == 0 and builtin.zig_version.minor == 9;
}
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSAtomic.h
================================================
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSATOMIC_H_
#define _OSATOMIC_H_
/*! @header
* These are deprecated legacy interfaces for atomic and synchronization
* operations.
*
* Define OSATOMIC_USE_INLINED=1 to get inline implementations of the
* OSAtomic interfaces in terms of the primitives.
*
* Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the
* OSSpinLock interfaces in terms of the primitives.
*
* These are intended as a transition convenience, direct use of those
* primitives should be preferred.
*/
#include
#include "OSAtomicDeprecated.h"
#include "OSSpinLockDeprecated.h"
#include "OSAtomicQueue.h"
#endif /* _OSATOMIC_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSAtomicDeprecated.h
================================================
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSATOMIC_DEPRECATED_H_
#define _OSATOMIC_DEPRECATED_H_
/*! @header
* These are deprecated legacy interfaces for atomic operations.
* The C11 interfaces in resp. C++11 interfaces in
* should be used instead.
*
* Define OSATOMIC_USE_INLINED=1 to get inline implementations of these
* interfaces in terms of the resp. primitives.
* This is intended as a transition convenience, direct use of those primitives
* is preferred.
*/
#include
#if !(defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED)
#include
#include
#include
#include
#ifndef OSATOMIC_DEPRECATED
#define OSATOMIC_DEPRECATED 1
#ifndef __cplusplus
#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \
"Use " #_r "() from instead"
#define OSATOMIC_DEPRECATED_MSG(_r) \
"Use " #_r "_explicit(memory_order_relaxed) from instead"
#else
#define OSATOMIC_BARRIER_DEPRECATED_MSG(_r) \
"Use std::" #_r "() from instead"
#define OSATOMIC_DEPRECATED_MSG(_r) \
"Use std::" #_r "_explicit(std::memory_order_relaxed) from instead"
#endif
#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r) \
__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_BARRIER_DEPRECATED_MSG(_r))
#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r) \
__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSATOMIC_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSATOMIC_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSATOMIC_DEPRECATED_MSG(_r))
#else
#undef OSATOMIC_DEPRECATED
#define OSATOMIC_DEPRECATED 0
#define OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(_r)
#define OSATOMIC_DEPRECATED_REPLACE_WITH(_r)
#endif
/*
* WARNING: all addresses passed to these functions must be "naturally aligned",
* i.e. int32_t pointers must be 32-bit aligned (low 2 bits of
* address are zeroes), and int64_t pointers must be 64-bit
* aligned (low 3 bits of address are zeroes.).
* Note that this is not the default alignment of the int64_t type
* in the iOS ARMv7 ABI, see
* {@link //apple_ref/doc/uid/TP40009021-SW8 iPhoneOSABIReference}
*
* Note that some versions of the atomic functions incorporate memory barriers
* and some do not. Barriers strictly order memory access on weakly-ordered
* architectures such as ARM. All loads and stores that appear (in sequential
* program order) before the barrier are guaranteed to complete before any
* load or store that appears after the barrier.
*
* The barrier operation is typically a no-op on uniprocessor systems and
* fully enabled on multiprocessor systems. On some platforms, such as ARM,
* the barrier can be quite expensive.
*
* Most code should use the barrier functions to ensure that memory shared
* between threads is properly synchronized. For example, if you want to
* initialize a shared data structure and then atomically increment a variable
* to indicate that the initialization is complete, you must use
* {@link OSAtomicIncrement32Barrier} to ensure that the stores to your data
* structure complete before the atomic increment.
*
* Likewise, the consumer of that data structure must use
* {@link OSAtomicDecrement32Barrier},
* in order to ensure that their loads of the structure are not executed before
* the atomic decrement. On the other hand, if you are simply incrementing a
* global counter, then it is safe and potentially faster to use
* {@link OSAtomicIncrement32}.
*
* If you are unsure which version to use, prefer the barrier variants as they
* are safer.
*
* For the kernel-space version of this header, see
* {@link //apple_ref/doc/header/OSAtomic.h OSAtomic.h (Kernel Framework)}
*
* @apiuid //apple_ref/doc/header/user_space_OSAtomic.h
*/
__BEGIN_DECLS
/*! @typedef OSAtomic_int64_aligned64_t
* 64-bit aligned int64_t type.
* Use for variables whose addresses are passed to OSAtomic*64() functions to
* get the compiler to generate the required alignment.
*/
#if __has_attribute(aligned)
typedef int64_t __attribute__((__aligned__((sizeof(int64_t)))))
OSAtomic_int64_aligned64_t;
#else
typedef int64_t OSAtomic_int64_aligned64_t;
#endif
/*! @group Arithmetic functions
All functions in this group return the new value.
*/
/*! @abstract Atomically adds two 32-bit values.
@discussion
This function adds the value given by __theAmount to the
value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAdd32( int32_t __theAmount, volatile int32_t *__theValue );
/*! @abstract Atomically adds two 32-bit values.
@discussion
This function adds the value given by __theAmount to the
value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicAdd32}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAdd32Barrier( int32_t __theAmount, volatile int32_t *__theValue );
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1 || TARGET_OS_DRIVERKIT
/*! @abstract Atomically increments a 32-bit value.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicIncrement32( volatile int32_t *__theValue );
/*! @abstract Atomically increments a 32-bit value with a barrier.
@discussion
This function is equivalent to {@link OSAtomicIncrement32}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue );
/*! @abstract Atomically decrements a 32-bit value.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicDecrement32( volatile int32_t *__theValue );
/*! @abstract Atomically decrements a 32-bit value with a barrier.
@discussion
This function is equivalent to {@link OSAtomicDecrement32}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue );
#else
__inline static
int32_t OSAtomicIncrement32( volatile int32_t *__theValue )
{ return OSAtomicAdd32( 1, __theValue); }
__inline static
int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue )
{ return OSAtomicAdd32Barrier( 1, __theValue); }
__inline static
int32_t OSAtomicDecrement32( volatile int32_t *__theValue )
{ return OSAtomicAdd32( -1, __theValue); }
__inline static
int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue )
{ return OSAtomicAdd32Barrier( -1, __theValue); }
#endif
/*! @abstract Atomically adds two 64-bit values.
@discussion
This function adds the value given by __theAmount to the
value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int64_t OSAtomicAdd64( int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue );
/*! @abstract Atomically adds two 64-bit values with a barrier.
@discussion
This function adds the value given by __theAmount to the
value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicAdd64}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2)
int64_t OSAtomicAdd64Barrier( int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue );
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10 || __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1 || TARGET_OS_DRIVERKIT
/*! @abstract Atomically increments a 64-bit value.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue );
/*! @abstract Atomically increments a 64-bit value with a barrier.
@discussion
This function is equivalent to {@link OSAtomicIncrement64}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_add)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue );
/*! @abstract Atomically decrements a 64-bit value.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue );
/*! @abstract Atomically decrements a 64-bit value with a barrier.
@discussion
This function is equivalent to {@link OSAtomicDecrement64}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_sub)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_1)
int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue );
#else
__inline static
int64_t OSAtomicIncrement64( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64( 1, __theValue); }
__inline static
int64_t OSAtomicIncrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64Barrier( 1, __theValue); }
__inline static
int64_t OSAtomicDecrement64( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64( -1, __theValue); }
__inline static
int64_t OSAtomicDecrement64Barrier( volatile OSAtomic_int64_aligned64_t *__theValue )
{ return OSAtomicAdd64Barrier( -1, __theValue); }
#endif
/*! @group Boolean functions (AND, OR, XOR)
*
* @discussion Functions in this group come in four variants for each operation:
* with and without barriers, and functions that return the original value or
* the result value of the operation.
*
* The "Orig" versions return the original value, (before the operation); the non-Orig
* versions return the value after the operation. All are layered on top of
* {@link OSAtomicCompareAndSwap32} and similar.
*/
/*! @abstract Atomic bitwise OR of two 32-bit values.
@discussion
This function performs the bitwise OR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicOr32( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise OR of two 32-bit values with barrier.
@discussion
This function performs the bitwise OR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicOr32}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicOr32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise OR of two 32-bit values returning original.
@discussion
This function performs the bitwise OR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the original value referenced by __theValue.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicOr32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise OR of two 32-bit values returning original with barrier.
@discussion
This function performs the bitwise OR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicOr32Orig}
except that it also introduces a barrier.
@result Returns the original value referenced by __theValue.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicOr32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise AND of two 32-bit values.
@discussion
This function performs the bitwise AND of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAnd32( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise AND of two 32-bit values with barrier.
@discussion
This function performs the bitwise AND of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicAnd32}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicAnd32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise AND of two 32-bit values returning original.
@discussion
This function performs the bitwise AND of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the original value referenced by __theValue.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicAnd32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise AND of two 32-bit values returning original with barrier.
@discussion
This function performs the bitwise AND of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicAnd32Orig}
except that it also introduces a barrier.
@result Returns the original value referenced by __theValue.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicAnd32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise XOR of two 32-bit values.
@discussion
This function performs the bitwise XOR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the new value.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicXor32( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise XOR of two 32-bit values with barrier.
@discussion
This function performs the bitwise XOR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicXor32}
except that it also introduces a barrier.
@result Returns the new value.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
int32_t OSAtomicXor32Barrier( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise XOR of two 32-bit values returning original.
@discussion
This function performs the bitwise XOR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
@result Returns the original value referenced by __theValue.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicXor32Orig( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @abstract Atomic bitwise XOR of two 32-bit values returning original with barrier.
@discussion
This function performs the bitwise XOR of the value given by __theMask
with the value in the memory location referenced by __theValue,
storing the result back to that memory location atomically.
This function is equivalent to {@link OSAtomicXor32Orig}
except that it also introduces a barrier.
@result Returns the original value referenced by __theValue.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_xor)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2)
int32_t OSAtomicXor32OrigBarrier( uint32_t __theMask, volatile uint32_t *__theValue );
/*! @group Compare and swap
* Functions in this group return true if the swap occured. There are several versions,
* depending on data type and on whether or not a barrier is used.
*/
/*! @abstract Compare and swap for 32-bit values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
/*! @abstract Compare and swap for 32-bit values with barrier.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwap32}
except that it also introduces a barrier.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
/*! @abstract Compare and swap pointers.
@discussion
This function compares the pointer stored in __oldValue to the pointer
in the memory location referenced by __theValue. If the pointers
match, this function stores the pointer from __newValue into
that memory location atomically.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
/*! @abstract Compare and swap pointers with barrier.
@discussion
This function compares the pointer stored in __oldValue to the pointer
in the memory location referenced by __theValue. If the pointers
match, this function stores the pointer from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwapPtr}
except that it also introduces a barrier.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
/*! @abstract Compare and swap for int values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwap32}.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapInt( int __oldValue, int __newValue, volatile int *__theValue );
/*! @abstract Compare and swap for int values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwapInt}
except that it also introduces a barrier.
This function is equivalent to {@link OSAtomicCompareAndSwap32Barrier}.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue );
/*! @abstract Compare and swap for long values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwap32} on 32-bit architectures,
or {@link OSAtomicCompareAndSwap64} on 64-bit architectures.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapLong( long __oldValue, long __newValue, volatile long *__theValue );
/*! @abstract Compare and swap for long values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwapLong}
except that it also introduces a barrier.
This function is equivalent to {@link OSAtomicCompareAndSwap32} on 32-bit architectures,
or {@link OSAtomicCompareAndSwap64} on 64-bit architectures.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
bool OSAtomicCompareAndSwapLongBarrier( long __oldValue, long __newValue, volatile long *__theValue );
/*! @abstract Compare and swap for uint64_t values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue );
/*! @abstract Compare and swap for uint64_t values.
@discussion
This function compares the value in __oldValue to the value
in the memory location referenced by __theValue. If the values
match, this function stores the value from __newValue into
that memory location atomically.
This function is equivalent to {@link OSAtomicCompareAndSwap64}
except that it also introduces a barrier.
@result Returns TRUE on a match, FALSE otherwise.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_compare_exchange_strong)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_3_2)
bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue );
/* Test and set.
* They return the original value of the bit, and operate on bit (0x80>>(n&7))
* in byte ((char*)theAddress + (n>>3)).
*/
/*! @abstract Atomic test and set
@discussion
This function tests a bit in the value referenced by
__theAddress and if it is not set, sets it.
The bit is chosen by the value of __n such that the
operation will be performed on bit (0x80 >> (__n & 7))
of byte ((char *)__theAddress + (n >> 3)).
For example, if __theAddress points to a 64-bit value,
to compare the value of the most significant bit, you would specify
56 for __n.
@result
Returns the original value of the bit being tested.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndSet( uint32_t __n, volatile void *__theAddress );
/*! @abstract Atomic test and set with barrier
@discussion
This function tests a bit in the value referenced by __theAddress
and if it is not set, sets it.
The bit is chosen by the value of __n such that the
operation will be performed on bit (0x80 >> (__n & 7))
of byte ((char *)__theAddress + (n >> 3)).
For example, if __theAddress points to a 64-bit value,
to compare the value of the most significant bit, you would specify
56 for __n.
This function is equivalent to {@link OSAtomicTestAndSet}
except that it also introduces a barrier.
@result
Returns the original value of the bit being tested.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_or)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndSetBarrier( uint32_t __n, volatile void *__theAddress );
/*! @abstract Atomic test and clear
@discussion
This function tests a bit in the value referenced by __theAddress
and if it is not cleared, clears it.
The bit is chosen by the value of __n such that the
operation will be performed on bit (0x80 >> (__n & 7))
of byte ((char *)__theAddress + (n >> 3)).
For example, if __theAddress points to a 64-bit value,
to compare the value of the most significant bit, you would specify
56 for __n.
@result
Returns the original value of the bit being tested.
*/
OSATOMIC_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndClear( uint32_t __n, volatile void *__theAddress );
/*! @abstract Atomic test and clear
@discussion
This function tests a bit in the value referenced by __theAddress
and if it is not cleared, clears it.
The bit is chosen by the value of __n such that the
operation will be performed on bit (0x80 >> (__n & 7))
of byte ((char *)__theAddress + (n >> 3)).
For example, if __theAddress points to a 64-bit value,
to compare the value of the most significant bit, you would specify
56 for __n.
This function is equivalent to {@link OSAtomicTestAndSet}
except that it also introduces a barrier.
@result
Returns the original value of the bit being tested.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_fetch_and)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSAtomicTestAndClearBarrier( uint32_t __n, volatile void *__theAddress );
/*! @group Memory barriers */
/*! @abstract Memory barrier.
@discussion
This function serves as both a read and write barrier.
*/
OSATOMIC_BARRIER_DEPRECATED_REPLACE_WITH(atomic_thread_fence)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
void OSMemoryBarrier( void );
__END_DECLS
#else // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED
/*
* Inline implementations of the legacy OSAtomic interfaces in terms of
* C11 resp. C++11 primitives.
* Direct use of those primitives is preferred.
*/
#include
#include
#include
#include
#ifdef __cplusplus
extern "C++" {
#if !(__has_include() && __has_extension(cxx_atomic))
#error Cannot use inlined OSAtomic without and C++11 atomics
#endif
#include
typedef std::atomic _OSAtomic_uint8_t;
typedef std::atomic _OSAtomic_int32_t;
typedef std::atomic _OSAtomic_uint32_t;
typedef std::atomic _OSAtomic_int64_t;
typedef std::atomic _OSAtomic_void_ptr_t;
#define OSATOMIC_STD(_a) std::_a
__BEGIN_DECLS
#else
#if !(__has_include() && __has_extension(c_atomic))
#error Cannot use inlined OSAtomic without and C11 atomics
#endif
#include
typedef _Atomic(uint8_t) _OSAtomic_uint8_t;
typedef _Atomic(int32_t) _OSAtomic_int32_t;
typedef _Atomic(uint32_t) _OSAtomic_uint32_t;
typedef _Atomic(int64_t) _OSAtomic_int64_t;
typedef _Atomic(void*) _OSAtomic_void_ptr_t;
#define OSATOMIC_STD(_a) _a
#endif
#if __has_extension(c_alignof) && __has_attribute(aligned)
typedef int64_t __attribute__((__aligned__(_Alignof(_OSAtomic_int64_t))))
OSAtomic_int64_aligned64_t;
#elif __has_attribute(aligned)
typedef int64_t __attribute__((__aligned__((sizeof(_OSAtomic_int64_t)))))
OSAtomic_int64_aligned64_t;
#else
typedef int64_t OSAtomic_int64_aligned64_t;
#endif
#if __has_attribute(always_inline)
#define OSATOMIC_INLINE static __inline __attribute__((__always_inline__))
#else
#define OSATOMIC_INLINE static __inline
#endif
OSATOMIC_INLINE
int32_t
OSAtomicAdd32(int32_t __theAmount, volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int32_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_relaxed)) + __theAmount);
}
OSATOMIC_INLINE
int32_t
OSAtomicAdd32Barrier(int32_t __theAmount, volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int32_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_seq_cst)) + __theAmount);
}
OSATOMIC_INLINE
int32_t
OSAtomicIncrement32(volatile int32_t *__theValue)
{
return OSAtomicAdd32(1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicIncrement32Barrier(volatile int32_t *__theValue)
{
return OSAtomicAdd32Barrier(1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicDecrement32(volatile int32_t *__theValue)
{
return OSAtomicAdd32(-1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicDecrement32Barrier(volatile int32_t *__theValue)
{
return OSAtomicAdd32Barrier(-1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicAdd64(int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int64_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_relaxed)) + __theAmount);
}
OSATOMIC_INLINE
int64_t
OSAtomicAdd64Barrier(int64_t __theAmount,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_fetch_add_explicit)(
(volatile _OSAtomic_int64_t*) __theValue, __theAmount,
OSATOMIC_STD(memory_order_seq_cst)) + __theAmount);
}
OSATOMIC_INLINE
int64_t
OSAtomicIncrement64(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64(1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicIncrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64Barrier(1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicDecrement64(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64(-1, __theValue);
}
OSATOMIC_INLINE
int64_t
OSAtomicDecrement64Barrier(volatile OSAtomic_int64_aligned64_t *__theValue)
{
return OSAtomicAdd64Barrier(-1, __theValue);
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)) | __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)) | __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
int32_t
OSAtomicOr32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_or_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)));
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)) & __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)) & __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
int32_t
OSAtomicAnd32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_and_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)));
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)) ^ __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32Barrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)) ^ __theMask);
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32Orig(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
int32_t
OSAtomicXor32OrigBarrier(uint32_t __theMask, volatile uint32_t *__theValue)
{
return (int32_t)(OSATOMIC_STD(atomic_fetch_xor_explicit)(
(volatile _OSAtomic_uint32_t*)__theValue, __theMask,
OSATOMIC_STD(memory_order_seq_cst)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap32(int32_t __oldValue, int32_t __newValue,
volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap32Barrier(int32_t __oldValue, int32_t __newValue,
volatile int32_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int32_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapPtr(void *__oldValue, void *__newValue,
void * volatile *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapPtrBarrier(void *__oldValue, void *__newValue,
void * volatile *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_void_ptr_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapInt(int __oldValue, int __newValue,
volatile int *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapIntBarrier(int __oldValue, int __newValue,
volatile int *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_int)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapLong(long __oldValue, long __newValue,
volatile long *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwapLongBarrier(long __oldValue, long __newValue,
volatile long *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile OSATOMIC_STD(atomic_long)*)__theValue, &__oldValue,
__newValue, OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap64(int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_relaxed),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicCompareAndSwap64Barrier(int64_t __oldValue, int64_t __newValue,
volatile OSAtomic_int64_aligned64_t *__theValue)
{
return (OSATOMIC_STD(atomic_compare_exchange_strong_explicit)(
(volatile _OSAtomic_int64_t*)__theValue, &__oldValue, __newValue,
OSATOMIC_STD(memory_order_seq_cst),
OSATOMIC_STD(memory_order_relaxed)));
}
OSATOMIC_INLINE
bool
OSAtomicTestAndSet(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v,
OSATOMIC_STD(memory_order_relaxed)) & v);
}
OSATOMIC_INLINE
bool
OSAtomicTestAndSetBarrier(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_or_explicit)((_OSAtomic_uint8_t*)a, v,
OSATOMIC_STD(memory_order_seq_cst)) & v);
}
OSATOMIC_INLINE
bool
OSAtomicTestAndClear(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a,
(uint8_t)~v, OSATOMIC_STD(memory_order_relaxed)) & v);
}
OSATOMIC_INLINE
bool
OSAtomicTestAndClearBarrier(uint32_t __n, volatile void *__theAddress)
{
uintptr_t a = (uintptr_t)__theAddress + (__n >> 3);
uint8_t v = (0x80u >> (__n & 7));
return (OSATOMIC_STD(atomic_fetch_and_explicit)((_OSAtomic_uint8_t*)a,
(uint8_t)~v, OSATOMIC_STD(memory_order_seq_cst)) & v);
}
OSATOMIC_INLINE
void
OSMemoryBarrier(void)
{
OSATOMIC_STD(atomic_thread_fence)(OSATOMIC_STD(memory_order_seq_cst));
}
#undef OSATOMIC_INLINE
#undef OSATOMIC_STD
#ifdef __cplusplus
__END_DECLS
} // extern "C++"
#endif
#endif // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED
#if TARGET_OS_OSX || TARGET_OS_DRIVERKIT
__BEGIN_DECLS
/*! @group Lockless atomic fifo enqueue and dequeue
* These routines manipulate singly-linked FIFO lists.
*
* This API is deprecated and no longer recommended
*/
/*! @abstract The data structure for a fifo queue head.
@discussion
You should always initialize a fifo queue head structure with the
initialization vector {@link OS_ATOMIC_FIFO_QUEUE_INIT} before use.
*/
#if defined(__LP64__)
typedef volatile struct {
void *opaque1;
void *opaque2;
int opaque3;
} __attribute__ ((aligned (16))) OSFifoQueueHead;
#else
typedef volatile struct {
void *opaque1;
void *opaque2;
int opaque3;
} OSFifoQueueHead;
#endif
/*! @abstract The initialization vector for a fifo queue head. */
#define OS_ATOMIC_FIFO_QUEUE_INIT { NULL, NULL, 0 }
/*! @abstract Enqueue an element onto a list.
@discussion
Memory barriers are incorporated as needed to permit thread-safe access
to the queue element.
@param __list
The list on which you want to enqueue the element.
@param __new
The element to add.
@param __offset
The "offset" parameter is the offset (in bytes) of the link field
from the beginning of the data structure being queued (__new).
The link field should be a pointer type.
The __offset value needs to be same for all enqueuing and
dequeuing operations on the same list, even if different structure types
are enqueued on that list. The use of offsetset(), defined in
stddef.h is the common way to specify the __offset
value.
@note
This API is deprecated and no longer recommended
*/
__API_DEPRECATED("No longer supported", macos(10.7, 11.0))
void OSAtomicFifoEnqueue( OSFifoQueueHead *__list, void *__new, size_t __offset);
/*! @abstract Dequeue an element from a list.
@discussion
Memory barriers are incorporated as needed to permit thread-safe access
to the queue element.
@param __list
The list from which you want to dequeue an element.
@param __offset
The "offset" parameter is the offset (in bytes) of the link field
from the beginning of the data structure being dequeued (__new).
The link field should be a pointer type.
The __offset value needs to be same for all enqueuing and
dequeuing operations on the same list, even if different structure types
are enqueued on that list. The use of offsetset(), defined in
stddef.h is the common way to specify the __offset
value.
@result
Returns the oldest enqueued element, or NULL if the
list is empty.
@note
This API is deprecated and no longer recommended
*/
__API_DEPRECATED("No longer supported", macos(10.7, 11.0))
void* OSAtomicFifoDequeue( OSFifoQueueHead *__list, size_t __offset);
__END_DECLS
#endif /* TARGET_OS_OSX || TARGET_OS_DRIVERKIT */
#endif /* _OSATOMIC_DEPRECATED_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSAtomicQueue.h
================================================
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSATOMICQUEUE_H_
#define _OSATOMICQUEUE_H_
#include
#include
#include
#include
#include "OSAtomicDeprecated.h"
#include
/*! @header Lockless atomic enqueue and dequeue
* These routines manipulate singly-linked LIFO lists.
*/
__BEGIN_DECLS
/*! @abstract The data structure for a queue head.
@discussion
You should always initialize a queue head structure with the
initialization vector {@link OS_ATOMIC_QUEUE_INIT} before use.
*/
#if defined(__LP64__)
typedef volatile struct {
void *opaque1;
long opaque2;
} __attribute__ ((aligned (16))) OSQueueHead;
#else
typedef volatile struct {
void *opaque1;
long opaque2;
} OSQueueHead;
#endif
/*! @abstract The initialization vector for a queue head. */
#define OS_ATOMIC_QUEUE_INIT { NULL, 0 }
/*! @abstract Enqueue an element onto a list.
@discussion
Memory barriers are incorporated as needed to permit thread-safe access
to the queue element.
@param __list
The list on which you want to enqueue the element.
@param __new
The element to add.
@param __offset
The "offset" parameter is the offset (in bytes) of the link field
from the beginning of the data structure being queued (__new).
The link field should be a pointer type.
The __offset value needs to be same for all enqueuing and
dequeuing operations on the same list, even if different structure types
are enqueued on that list. The use of offsetset(), defined in
stddef.h is the common way to specify the __offset
value.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0)
void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset);
/*! @abstract Dequeue an element from a list.
@discussion
Memory barriers are incorporated as needed to permit thread-safe access
to the queue element.
@param __list
The list from which you want to dequeue an element.
@param __offset
The "offset" parameter is the offset (in bytes) of the link field
from the beginning of the data structure being dequeued (__new).
The link field should be a pointer type.
The __offset value needs to be same for all enqueuing and
dequeuing operations on the same list, even if different structure types
are enqueued on that list. The use of offsetset(), defined in
stddef.h is the common way to specify the __offset
value.
IMPORTANT: the memory backing the link field of a queue element must not be
unmapped after OSAtomicDequeue() returns until all concurrent calls to
OSAtomicDequeue() for the same list on other threads have also returned,
as they may still be accessing that memory location.
@result
Returns the most recently enqueued element, or NULL if the
list is empty.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0)
void* OSAtomicDequeue( OSQueueHead *__list, size_t __offset);
__END_DECLS
#endif /* _OSATOMICQUEUE_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSByteOrder.h
================================================
/*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _OS_OSBYTEORDER_H
#define _OS_OSBYTEORDER_H
#include
#include
/* Macros for swapping constant values in the preprocessing stage. */
#define OSSwapConstInt16(x) __DARWIN_OSSwapConstInt16(x)
#define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x)
#define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x)
#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define __DARWIN_OS_INLINE static inline
# else
# define __DARWIN_OS_INLINE static __inline__
# endif
#endif
#if defined(__GNUC__)
#if (defined(__i386__) || defined(__x86_64__))
#include
#elif defined (__arm__) || defined(__arm64__)
#include
#else
#include
#endif
#else /* ! __GNUC__ */
#include
#endif /* __GNUC__ */
#define OSSwapInt16(x) __DARWIN_OSSwapInt16(x)
#define OSSwapInt32(x) __DARWIN_OSSwapInt32(x)
#define OSSwapInt64(x) __DARWIN_OSSwapInt64(x)
enum {
OSUnknownByteOrder,
OSLittleEndian,
OSBigEndian
};
__DARWIN_OS_INLINE
int32_t
OSHostByteOrder(void)
{
#if defined(__LITTLE_ENDIAN__)
return OSLittleEndian;
#elif defined(__BIG_ENDIAN__)
return OSBigEndian;
#else
return OSUnknownByteOrder;
#endif
}
#define OSReadBigInt(x, y) OSReadBigInt32(x, y)
#define OSWriteBigInt(x, y, z) OSWriteBigInt32(x, y, z)
#define OSSwapBigToHostInt(x) OSSwapBigToHostInt32(x)
#define OSSwapHostToBigInt(x) OSSwapHostToBigInt32(x)
#define OSReadLittleInt(x, y) OSReadLittleInt32(x, y)
#define OSWriteLittleInt(x, y, z) OSWriteLittleInt32(x, y, z)
#define OSSwapHostToLittleInt(x) OSSwapHostToLittleInt32(x)
#define OSSwapLittleToHostInt(x) OSSwapLittleToHostInt32(x)
/* Functions for loading native endian values. */
__DARWIN_OS_INLINE
uint16_t
_OSReadInt16(
const volatile void * base,
uintptr_t byteOffset
)
{
return *(volatile uint16_t *)((uintptr_t)base + byteOffset);
}
__DARWIN_OS_INLINE
uint32_t
_OSReadInt32(
const volatile void * base,
uintptr_t byteOffset
)
{
return *(volatile uint32_t *)((uintptr_t)base + byteOffset);
}
__DARWIN_OS_INLINE
uint64_t
_OSReadInt64(
const volatile void * base,
uintptr_t byteOffset
)
{
return *(volatile uint64_t *)((uintptr_t)base + byteOffset);
}
/* Functions for storing native endian values. */
__DARWIN_OS_INLINE
void
_OSWriteInt16(
volatile void * base,
uintptr_t byteOffset,
uint16_t data
)
{
*(volatile uint16_t *)((uintptr_t)base + byteOffset) = data;
}
__DARWIN_OS_INLINE
void
_OSWriteInt32(
volatile void * base,
uintptr_t byteOffset,
uint32_t data
)
{
*(volatile uint32_t *)((uintptr_t)base + byteOffset) = data;
}
__DARWIN_OS_INLINE
void
_OSWriteInt64(
volatile void * base,
uintptr_t byteOffset,
uint64_t data
)
{
*(volatile uint64_t *)((uintptr_t)base + byteOffset) = data;
}
#if defined(__BIG_ENDIAN__)
/* Functions for loading big endian to host endianess. */
#define OSReadBigInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
#define OSReadBigInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
#define OSReadBigInt64(base, byteOffset) _OSReadInt64(base, byteOffset)
/* Functions for storing host endianess to big endian. */
#define OSWriteBigInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
#define OSWriteBigInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
#define OSWriteBigInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)
/* Functions for loading little endian to host endianess. */
#define OSReadLittleInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
#define OSReadLittleInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
#define OSReadLittleInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)
/* Functions for storing host endianess to little endian. */
#define OSWriteLittleInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
#define OSWriteLittleInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
#define OSWriteLittleInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)
/* Host endianess to big endian byte swapping macros for constants. */
#define OSSwapHostToBigConstInt16(x) ((uint16_t)(x))
#define OSSwapHostToBigConstInt32(x) ((uint32_t)(x))
#define OSSwapHostToBigConstInt64(x) ((uint64_t)(x))
/* Generic host endianess to big endian byte swapping functions. */
#define OSSwapHostToBigInt16(x) ((uint16_t)(x))
#define OSSwapHostToBigInt32(x) ((uint32_t)(x))
#define OSSwapHostToBigInt64(x) ((uint64_t)(x))
/* Host endianess to little endian byte swapping macros for constants. */
#define OSSwapHostToLittleConstInt16(x) OSSwapConstInt16(x)
#define OSSwapHostToLittleConstInt32(x) OSSwapConstInt32(x)
#define OSSwapHostToLittleConstInt64(x) OSSwapConstInt64(x)
/* Generic host endianess to little endian byte swapping functions. */
#define OSSwapHostToLittleInt16(x) OSSwapInt16(x)
#define OSSwapHostToLittleInt32(x) OSSwapInt32(x)
#define OSSwapHostToLittleInt64(x) OSSwapInt64(x)
/* Big endian to host endianess byte swapping macros for constants. */
#define OSSwapBigToHostConstInt16(x) ((uint16_t)(x))
#define OSSwapBigToHostConstInt32(x) ((uint32_t)(x))
#define OSSwapBigToHostConstInt64(x) ((uint64_t)(x))
/* Generic big endian to host endianess byte swapping functions. */
#define OSSwapBigToHostInt16(x) ((uint16_t)(x))
#define OSSwapBigToHostInt32(x) ((uint32_t)(x))
#define OSSwapBigToHostInt64(x) ((uint64_t)(x))
/* Little endian to host endianess byte swapping macros for constants. */
#define OSSwapLittleToHostConstInt16(x) OSSwapConstInt16(x)
#define OSSwapLittleToHostConstInt32(x) OSSwapConstInt32(x)
#define OSSwapLittleToHostConstInt64(x) OSSwapConstInt64(x)
/* Generic little endian to host endianess byte swapping functions. */
#define OSSwapLittleToHostInt16(x) OSSwapInt16(x)
#define OSSwapLittleToHostInt32(x) OSSwapInt32(x)
#define OSSwapLittleToHostInt64(x) OSSwapInt64(x)
#elif defined(__LITTLE_ENDIAN__)
/* Functions for loading big endian to host endianess. */
#define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
#define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
#define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)
/* Functions for storing host endianess to big endian. */
#define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
#define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
#define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)
/* Functions for loading little endian to host endianess. */
#define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
#define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
#define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset)
/* Functions for storing host endianess to little endian. */
#define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
#define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
#define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)
/* Host endianess to big endian byte swapping macros for constants. */
#define OSSwapHostToBigConstInt16(x) OSSwapConstInt16(x)
#define OSSwapHostToBigConstInt32(x) OSSwapConstInt32(x)
#define OSSwapHostToBigConstInt64(x) OSSwapConstInt64(x)
/* Generic host endianess to big endian byte swapping functions. */
#define OSSwapHostToBigInt16(x) OSSwapInt16(x)
#define OSSwapHostToBigInt32(x) OSSwapInt32(x)
#define OSSwapHostToBigInt64(x) OSSwapInt64(x)
/* Host endianess to little endian byte swapping macros for constants. */
#define OSSwapHostToLittleConstInt16(x) ((uint16_t)(x))
#define OSSwapHostToLittleConstInt32(x) ((uint32_t)(x))
#define OSSwapHostToLittleConstInt64(x) ((uint64_t)(x))
/* Generic host endianess to little endian byte swapping functions. */
#define OSSwapHostToLittleInt16(x) ((uint16_t)(x))
#define OSSwapHostToLittleInt32(x) ((uint32_t)(x))
#define OSSwapHostToLittleInt64(x) ((uint64_t)(x))
/* Big endian to host endianess byte swapping macros for constants. */
#define OSSwapBigToHostConstInt16(x) OSSwapConstInt16(x)
#define OSSwapBigToHostConstInt32(x) OSSwapConstInt32(x)
#define OSSwapBigToHostConstInt64(x) OSSwapConstInt64(x)
/* Generic big endian to host endianess byte swapping functions. */
#define OSSwapBigToHostInt16(x) OSSwapInt16(x)
#define OSSwapBigToHostInt32(x) OSSwapInt32(x)
#define OSSwapBigToHostInt64(x) OSSwapInt64(x)
/* Little endian to host endianess byte swapping macros for constants. */
#define OSSwapLittleToHostConstInt16(x) ((uint16_t)(x))
#define OSSwapLittleToHostConstInt32(x) ((uint32_t)(x))
#define OSSwapLittleToHostConstInt64(x) ((uint64_t)(x))
/* Generic little endian to host endianess byte swapping functions. */
#define OSSwapLittleToHostInt16(x) ((uint16_t)(x))
#define OSSwapLittleToHostInt32(x) ((uint32_t)(x))
#define OSSwapLittleToHostInt64(x) ((uint64_t)(x))
#else
#error Unknown endianess.
#endif
#endif /* ! _OS_OSBYTEORDER_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSCacheControl.h
================================================
/*
* Copyright (c) 2006 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 _OS_CACHE_CONTROL_H_
#define _OS_CACHE_CONTROL_H_
#include
#include
#include
#include
__BEGIN_DECLS
/* Functions performed by sys_cache_control(): */
/* Prepare memory for execution. This should be called
* after writing machine instructions to memory, before
* executing them. It syncs the dcache and icache.
* On IA32 processors this function is a NOP, because
* no synchronization is required.
*/
#define kCacheFunctionPrepareForExecution 1
/* Flush data cache(s). This ensures that cached data
* makes it all the way out to DRAM, and then removes
* copies of the data from all processor caches.
* It can be useful when dealing with cache incoherent
* devices or DMA.
*/
#define kCacheFunctionFlushDcache 2
/* perform one of the above cache functions: */
int sys_cache_control( int function, void *start, size_t len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
/* equivalent to sys_cache_control(kCacheFunctionPrepareForExecution): */
void sys_icache_invalidate( void *start, size_t len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
/* equivalent to sys_cache_control(kCacheFunctionFlushDcache): */
void sys_dcache_flush( void *start, size_t len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
__END_DECLS
#endif /* _OS_CACHE_CONTROL_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSDebug.h
================================================
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* HISTORY
*
*/
#ifndef _OS_OSDEBBUG_H
#define _OS_OSDEBBUG_H
#include
#include
__BEGIN_DECLS
extern int log_leaks;
/* Use kernel_debug() to log a backtrace */
extern void trace_backtrace(unsigned int debugid, unsigned int debugid2, unsigned long size, unsigned long data);
/* Report a message with a 4 entry backtrace - very slow */
extern void OSReportWithBacktrace(const char *str, ...);
extern unsigned OSBacktrace(void **bt, unsigned maxAddrs);
/* Simple dump of 20 backtrace entries */
extern void OSPrintBacktrace(void);
/*! @function OSKernelStackRemaining
* @abstract Returns bytes available below the current stack frame.
* @discussion Returns bytes available below the current stack frame. Safe for interrupt or thread context.
* @result Approximate byte count available. */
vm_offset_t OSKernelStackRemaining( void );
__END_DECLS
#define TRACE_MACHLEAKS(a, b, c, d) \
do { \
if (__builtin_expect(!!log_leaks, 0)) \
trace_backtrace(a,b,c,d); \
} while(0)
#endif /* !_OS_OSDEBBUG_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSKextLib.h
================================================
/*
* Copyright (c) 2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _LIBKERN_OSKEXTLIB_H
#define _LIBKERN_OSKEXTLIB_H
#include
__BEGIN_DECLS
#include
#include
#include
#include
#include
/*!
* @header
*
* Declares functions, basic return values, and other constants
* related to kernel extensions (kexts).
*/
#if PRAGMA_MARK
#pragma mark -
/********************************************************************/
#pragma mark OSReturn Values for Kernel Extensions
/********************************************************************/
#endif
/*!
* @group OSReturn Values for Kernel Extensions
* Many kext-related functions return these values,
* as well as those defined under
* @link //apple_ref/c/tdef/OSReturn OSReturn@/link
* and other variants of kern_return_t.
*/
#define sub_libkern_kext err_sub(2)
#define libkern_kext_err(code) (sys_libkern|sub_libkern_kext|(code))
/*!
* @define kOSKextReturnInternalError
* @abstract An internal error in the kext library.
* Contrast with @link //apple_ref/c/econst/OSReturnError
* OSReturnError@/link.
*/
#define kOSKextReturnInternalError libkern_kext_err(0x1)
/*!
* @define kOSKextReturnNoMemory
* @abstract Memory allocation failed.
*/
#define kOSKextReturnNoMemory libkern_kext_err(0x2)
/*!
* @define kOSKextReturnNoResources
* @abstract Some resource other than memory (such as available load tags)
* is exhausted.
*/
#define kOSKextReturnNoResources libkern_kext_err(0x3)
/*!
* @define kOSKextReturnNotPrivileged
* @abstract The caller lacks privileges to perform the requested operation.
*/
#define kOSKextReturnNotPrivileged libkern_kext_err(0x4)
/*!
* @define kOSKextReturnInvalidArgument
* @abstract Invalid argument.
*/
#define kOSKextReturnInvalidArgument libkern_kext_err(0x5)
/*!
* @define kOSKextReturnNotFound
* @abstract Search item not found.
*/
#define kOSKextReturnNotFound libkern_kext_err(0x6)
/*!
* @define kOSKextReturnBadData
* @abstract Malformed data (not used for XML).
*/
#define kOSKextReturnBadData libkern_kext_err(0x7)
/*!
* @define kOSKextReturnSerialization
* @abstract Error converting or (un)serializing URL, string, or XML.
*/
#define kOSKextReturnSerialization libkern_kext_err(0x8)
/*!
* @define kOSKextReturnUnsupported
* @abstract Operation is no longer or not yet supported.
*/
#define kOSKextReturnUnsupported libkern_kext_err(0x9)
/*!
* @define kOSKextReturnDisabled
* @abstract Operation is currently disabled.
*/
#define kOSKextReturnDisabled libkern_kext_err(0xa)
/*!
* @define kOSKextReturnNotAKext
* @abstract Bundle is not a kernel extension.
*/
#define kOSKextReturnNotAKext libkern_kext_err(0xb)
/*!
* @define kOSKextReturnValidation
* @abstract Validation failures encountered; check diagnostics for details.
*/
#define kOSKextReturnValidation libkern_kext_err(0xc)
/*!
* @define kOSKextReturnAuthentication
* @abstract Authetication failures encountered; check diagnostics for details.
*/
#define kOSKextReturnAuthentication libkern_kext_err(0xd)
/*!
* @define kOSKextReturnDependencies
* @abstract Dependency resolution failures encountered; check diagnostics for details.
*/
#define kOSKextReturnDependencies libkern_kext_err(0xe)
/*!
* @define kOSKextReturnArchNotFound
* @abstract Kext does not contain code for the requested architecture.
*/
#define kOSKextReturnArchNotFound libkern_kext_err(0xf)
/*!
* @define kOSKextReturnCache
* @abstract An error occurred processing a system kext cache.
*/
#define kOSKextReturnCache libkern_kext_err(0x10)
/*!
* @define kOSKextReturnDeferred
* @abstract Operation has been posted asynchronously to user space (kernel only).
*/
#define kOSKextReturnDeferred libkern_kext_err(0x11)
/*!
* @define kOSKextReturnBootLevel
* @abstract Kext not loadable or operation not allowed at current boot level.
*/
#define kOSKextReturnBootLevel libkern_kext_err(0x12)
/*!
* @define kOSKextReturnNotLoadable
* @abstract Kext cannot be loaded; check diagnostics for details.
*/
#define kOSKextReturnNotLoadable libkern_kext_err(0x13)
/*!
* @define kOSKextReturnLoadedVersionDiffers
* @abstract A different version (or executable UUID, or executable by checksum)
* of the requested kext is already loaded.
*/
#define kOSKextReturnLoadedVersionDiffers libkern_kext_err(0x14)
/*!
* @define kOSKextReturnDependencyLoadError
* @abstract A load error occurred on a dependency of the kext being loaded.
*/
#define kOSKextReturnDependencyLoadError libkern_kext_err(0x15)
/*!
* @define kOSKextReturnLinkError
* @abstract A link failure occured with this kext or a dependency.
*/
#define kOSKextReturnLinkError libkern_kext_err(0x16)
/*!
* @define kOSKextReturnStartStopError
* @abstract The kext start or stop routine returned an error.
*/
#define kOSKextReturnStartStopError libkern_kext_err(0x17)
/*!
* @define kOSKextReturnInUse
* @abstract The kext is currently in use or has outstanding references,
* and cannot be unloaded.
*/
#define kOSKextReturnInUse libkern_kext_err(0x18)
/*!
* @define kOSKextReturnTimeout
* @abstract A kext request has timed out.
*/
#define kOSKextReturnTimeout libkern_kext_err(0x19)
/*!
* @define kOSKextReturnStopping
* @abstract The kext is in the process of stopping; requests cannot be made.
*/
#define kOSKextReturnStopping libkern_kext_err(0x1a)
/*!
* @define kOSKextReturnSystemPolicy
* @abstract The kext was prevented from loading due to system policy.
*/
#define kOSKextReturnSystemPolicy libkern_kext_err(0x1b)
/*!
* @define kOSKextReturnKCLoadFailure
* @abstract Loading of the System KC failed
*/
#define kOSKextReturnKCLoadFailure libkern_kext_err(0x1c)
/*!
* @define kOSKextReturnKCLoadFailureSystemKC
* @abstract Loading of the System KC failed
*
* This a sub-code of kOSKextReturnKCLoadFailure. It can be OR'd together
* with: kOSKextReturnKCLoadFailureAuxKC
*
* If both the System and Aux KCs fail to load, then the error code will be:
* libkern_kext_err(0x1f)
*/
#define kOSKextReturnKCLoadFailureSystemKC libkern_kext_err(0x1d)
/*!
* @define kOSKextReturnKCLoadFailureAuxKC
* @abstract Loading of the Aux KC failed
*
* This a sub-code of kOSKextReturnKCLoadFailure. It can be OR'd together
* with: kOSKextReturnKCLoadFailureSystemKC
*
* If both the System and Aux KCs fail to load, then the error code will be:
* libkern_kext_err(0x1f)
*/
#define kOSKextReturnKCLoadFailureAuxKC libkern_kext_err(0x1e)
/* next available error is: libkern_kext_err(0x20) */
#if PRAGMA_MARK
#pragma mark -
/********************************************************************/
#pragma mark Kext/OSBundle Property List Keys
/********************************************************************/
#endif
/*!
* @group Kext Property List Keys
* These constants cover CFBundle properties defined for kernel extensions.
* Because they are used in the kernel, if you want to use one with
* CFBundle APIs you'll need to wrap it in a CFSTR() macro.
*/
/*!
* @define kOSBundleCompatibleVersionKey
* @abstract A string giving the backwards-compatible version of a library kext
* in extended Mac OS 'vers' format (####.##.##s{1-255} where 's'
* is a build stage 'd', 'a', 'b', 'f' or 'fc').
*/
#define kOSBundleCompatibleVersionKey "OSBundleCompatibleVersion"
/*!
* @define kOSBundleEnableKextLoggingKey
* @abstract Set to true to have the kernel kext logging spec applied
* to the kext.
* See @link //apple_ref/c/econst/OSKextLogSpec
* OSKextLogSpec@/link.
*/
#define kOSBundleEnableKextLoggingKey "OSBundleEnableKextLogging"
/*!
* @define kOSBundleIsInterfaceKey
* @abstract A boolean value indicating whether the kext executable
* contains only symbol references.
*/
#define kOSBundleIsInterfaceKey "OSBundleIsInterface"
/*!
* @define kOSBundleLibrariesKey
* @abstract A dictionary listing link dependencies for this kext.
* Keys are bundle identifiers, values are version strings.
*/
#define kOSBundleLibrariesKey "OSBundleLibraries"
/*!
* @define kOSBundleRequiredKey
* @abstract A string indicating in which kinds of startup this kext
* may need to load during early startup (before
* @link //apple_ref/doc/man/8/kextd kextcache(8)@/link).
* @discussion
* The value is one of:
*
* - @link kOSBundleRequiredRoot "OSBundleRequiredRoot"@/link
* - @link kOSBundleRequiredLocalRoot "OSBundleRequiredLocalRoot"@/link
* - @link kOSBundleRequiredNetworkRoot "OSBundleRequiredNetworkRoot"@/link
* - @link kOSBundleRequiredSafeBoot "OSBundleRequiredSafeBoot"@/link
* - @link kOSBundleRequiredConsole "OSBundleRequiredConsole"@/link
*
*
* Use this property judiciously.
* Every kext that declares a value other than "OSBundleRequiredSafeBoot"
* increases startup time, as the booter must read it into memory,
* or startup kext caches must include it.
*/
#define kOSBundleRequiredKey "OSBundleRequired"
/*!
* @define kOSBundleRequireExplicitLoadKey
* @abstract A boolean value indicating whether the kext requires an
* explicit kextload in order to start/match.
*/
#define kOSBundleRequireExplicitLoadKey "OSBundleRequireExplicitLoad"
/*!
* @define kOSBundleAllowUserLoadKey
* @abstract A boolean value indicating whether
* @link //apple_ref/doc/man/8/kextd kextcache(8)@/link
* will honor a non-root process's request to load a kext.
* @discussion
* See @link //apple_ref/doc/compositePage/c/func/KextManagerLoadKextWithURL
* KextManagerLoadKextWithURL@/link
* and @link //apple_ref/doc/compositePage/c/func/KextManagerLoadKextWithIdentifier
* KextManagerLoadKextWithIdentifier@/link.
*/
#define kOSBundleAllowUserLoadKey "OSBundleAllowUserLoad"
/*!
* @define kOSBundleAllowUserTerminateKey
* @abstract A boolean value indicating whether the kextunload tool
* is allowed to issue IOService terminate to classes defined in this kext.
* @discussion A boolean value indicating whether the kextunload tool
* is allowed to issue IOService terminate to classes defined in this kext.
*/
#define kOSBundleAllowUserTerminateKey "OSBundleAllowUserTerminate"
/*!
* @define kOSKernelResourceKey
* @abstract A boolean value indicating whether the kext represents a built-in
* component of the kernel.
*/
#define kOSKernelResourceKey "OSKernelResource"
/*!
* @define kOSKextVariantOverrideKey
* @abstract A dictionary with target names as key and a target-specific variant
* name as value.
*/
#define kOSKextVariantOverrideKey "OSKextVariantOverride"
/*!
* @define kIOKitPersonalitiesKey
* @abstract A dictionary of dictionaries used in matching for I/O Kit drivers.
*/
#define kIOKitPersonalitiesKey "IOKitPersonalities"
/*
* @define kIOPersonalityPublisherKey
* @abstract Used in personalities sent to the I/O Kit,
* contains the CFBundleIdentifier of the kext
* that the personality originated in.
*/
#define kIOPersonalityPublisherKey "IOPersonalityPublisher"
#if CONFIG_KEC_FIPS
/*
* @define kAppleTextHashesKey
* @abstract A dictionary conataining hashes for corecrypto kext.
*/
#define kAppleTextHashesKey "AppleTextHashes"
#endif
/*!
* @define kOSMutableSegmentCopy
* @abstract A boolean value indicating whether the kext requires a copy of
* its mutable segments to be kept in memory, and then reset when the kext
* unloads. This should be used with caution as it will increase the
* amount of memory used by the kext.
*/
#define kOSMutableSegmentCopy "OSMutableSegmentCopy"
#if PRAGMA_MARK
/********************************************************************/
#pragma mark Kext/OSBundle Property Deprecated Keys
/********************************************************************/
#endif
/*
* @define kOSBundleDebugLevelKey
* @abstract
* Deprecated (used on some releases of Mac OS X prior to 10.6 Snow Leopard).
* Value is an integer from 1-6, corresponding to the verbose levels
* of kext tools on those releases.
* On 10.6 Snow Leopard, use @link OSKextEnableKextLogging
* OSKextEnableKextLogging@/link.
*/
#define kOSBundleDebugLevelKey "OSBundleDebugLevel"
/*!
* @define kOSBundleSharedExecutableIdentifierKey
* @abstract Deprecated (used on some releases of Mac OS X
* prior to 10.6 Snow Leopard).
* Value is the bundle identifier of the pseudokext
* that contains an executable shared by this kext.
*/
#define kOSBundleSharedExecutableIdentifierKey "OSBundleSharedExecutableIdentifier"
#if PRAGMA_MARK
/********************************************************************/
#pragma mark Kext/OSBundle Property List Values
/********************************************************************/
#endif
/*!
* @group Kext Property List Values
* These constants encompass established values
* for kernel extension bundle properties.
*/
/*!
* @define kOSKextKernelIdentifier
* @abstract
* This is the CFBundleIdentifier user for the kernel itself.
*/
#define kOSKextKernelIdentifier "__kernel__"
/*!
* @define kOSKextBundlePackageTypeKext
* @abstract
* The bundle type value for Kernel Extensions.
*/
#define kOSKextBundlePackageTypeKext "KEXT"
/*!
* @define kOSKextBundlePackageTypeDriverKit
* @abstract
* The bundle type value for Driver Extensions.
*/
#define kOSKextBundlePackageTypeDriverKit "DEXT"
/*!
* @define kOSBundleRequiredRoot
* @abstract
* This @link kOSBundleRequiredKey OSBundleRequired@/link
* value indicates that the kext may be needed to mount the root filesystem
* whether starting from a local or a network volume.
*/
#define kOSBundleRequiredRoot "Root"
/*!
* @define kOSBundleRequiredLocalRoot
* @abstract
* This @link kOSBundleRequiredKey OSBundleRequired@/link
* value indicates that the kext may be needed to mount the root filesystem
* when starting from a local disk.
*/
#define kOSBundleRequiredLocalRoot "Local-Root"
/*!
* @define kOSBundleRequiredNetworkRoot
* @abstract
* This @link kOSBundleRequiredKey OSBundleRequired@/link
* value indicates that the kext may be needed to mount the root filesystem
* when starting over a network connection.
*/
#define kOSBundleRequiredNetworkRoot "Network-Root"
/*!
* @define kOSBundleRequiredSafeBoot
* @abstract
* This @link kOSBundleRequiredKey OSBundleRequired@/link
* value indicates that the kext can be loaded during a safe startup.
* This value does not normally cause the kext to be read by the booter
* or included in startup kext caches.
*/
#define kOSBundleRequiredSafeBoot "Safe Boot"
/*!
* @define kOSBundleRequiredConsole
* @abstract
* This @link kOSBundleRequiredKey OSBundleRequired@/link
* value indicates that the kext may be needed for console access
* (specifically in a single-user startup when
* @link //apple_ref/doc/man/8/kextd kextd(8)@/link.
* does not run)
* and should be loaded during early startup.
*/
#define kOSBundleRequiredConsole "Console"
/*!
* @define kOSBundleRequiredDriverKit
* @abstract
* This @link kOSBundleRequiredKey OSBundleRequired@/link
* value indicates that the driver extension's (DriverKit driver's)
* personalities must be present in the kernel at early boot (specifically
* before @link //apple_ref/doc/man/8/kextd kextd(8)@/link starts)
* in order to compete with kexts built into the prelinkedkernel. Note that
* kextd is still required to launch the user space driver binary. The IOKit
* matching will happen during early boot, and the actual driver launch
* will happen after kextd starts.
*/
#define kOSBundleRequiredDriverKit "DriverKit"
#if PRAGMA_MARK
#pragma mark -
/********************************************************************/
#pragma mark Kext Information
/********************************************************************/
#endif
/*!
* @group Kext Information
* Types, constants, and macros providing a kext with information
* about itself.
*/
/*!
* @typedef OSKextLoadTag
*
* @abstract
* A unique identifier assigned to a loaded instanace of a kext.
*
* @discussion
* If a kext is unloaded and later reloaded, the new instance
* has a different load tag.
*
* A kext can get its own load tag in the kmod_info_t
* structure passed into its module start routine, as the
* id field (cast to this type).
*/
typedef uint32_t OSKextLoadTag;
/*!
* @define kOSKextInvalidLoadTag
*
* @abstract
* A load tag value that will never be used for a loaded kext;
* indicates kext not found.
*/
#define kOSKextInvalidLoadTag ((OSKextLoadTag)(-1))
__END_DECLS
#endif /* _LIBKERN_OSKEXTLIB_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSReturn.h
================================================
/*
* Copyright (c) 2000 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1998 Apple Inc. All rights reserved.
*
* HISTORY
*
*/
/*
* Core OSReturn values.
*/
#ifndef __LIBKERN_OSRETURN_H
#define __LIBKERN_OSRETURN_H
#include
__BEGIN_DECLS
#include
/*!
* @header
*
* Declares functions, basic return values, and other constants
* related to kernel extensions (kexts).
*/
#if PRAGMA_MARK
#pragma mark Core OSReturn Values for Libkern
#endif
/*********************************************************************
* Core OSReturn Values for Libkern
*********************************************************************/
/*!
* @group Core OSReturn Values for Libkern
* Some kext and I/O Kit functions can return these values,
* as well as other values of
* kern_return_t.
*
* Many of these return values represent internal errors
* in the Libkern C++ run-time typing information system
* based on @link //apple_ref/doc/class/OSMetaClass OSMetaClass@/link;
* you are unlikely to ever see them.
*
*/
/*!
* @typedef OSReturn
* @abstract The return type for many Libkern functions.
*/
typedef kern_return_t OSReturn;
#ifndef sys_libkern
#define sys_libkern err_system(0x37)
#endif /* sys_libkern */
#define sub_libkern_common err_sub(0)
#define sub_libkern_metaclass err_sub(1)
#define sub_libkern_reserved err_sub(-1)
#define libkern_common_err(return ) (sys_libkern|sub_libkern_common|(return))
#define libkern_metaclass_err(return ) (sys_libkern|sub_libkern_metaclass|(return))
/* See OSKextLib.h for these
* #define sub_libkern_kext err_sub(2)
* #define libkern_kext_err(code) (sys_libkern|sub_libkern_kext|(code))
*/
/*!
* @define kOSReturnSuccess
* @abstract Operation successful.
* Equal to @link //apple_ref/c/econst/KERN_SUCCESS
* KERN_SUCCESS@/link.
*/
#define kOSReturnSuccess KERN_SUCCESS
/*!
* @define kOSReturnError
* @abstract Unspecified Libkern error.
* Not equal to
* @link //apple_ref/c/econst/KERN_FAILURE
* KERN_FAILURE@/link.
*/
#define kOSReturnError libkern_common_err(1)
/*!
* @define kOSMetaClassInternal
* @abstract Internal OSMetaClass run-time error.
*/
#define kOSMetaClassInternal libkern_metaclass_err(1)
/*!
* @define kOSMetaClassHasInstances
* @abstract A kext cannot be unloaded because there are instances
* derived from Libkern C++ classes that it defines.
*/
#define kOSMetaClassHasInstances libkern_metaclass_err(2)
/*!
* @define kOSMetaClassNoInit
* @abstract Internal error: The Libkern C++ class registration system
* was not properly initialized during kext loading.
*/
#define kOSMetaClassNoInit libkern_metaclass_err(3)
// OSMetaClass::preModLoad wasn't called, runtime internal error
/*!
* @define kOSMetaClassNoTempData
* @abstract Internal error: An allocation failure occurred
* registering Libkern C++ classes during kext loading.
*/
#define kOSMetaClassNoTempData libkern_metaclass_err(4)
// Allocation failure internal data
/*!
* @define kOSMetaClassNoDicts
* @abstract Internal error: An allocation failure occurred
* registering Libkern C++ classes during kext loading.
*/
#define kOSMetaClassNoDicts libkern_metaclass_err(5)
// Allocation failure for Metaclass internal dictionaries
/*!
* @define kOSMetaClassNoKModSet
* @abstract Internal error: An allocation failure occurred
* registering Libkern C++ classes during kext loading.
*/
#define kOSMetaClassNoKModSet libkern_metaclass_err(6)
// Allocation failure for internal kmodule set
/*!
* @define kOSMetaClassNoInsKModSet
* @abstract Internal error: An error occurred registering
* a specific Libkern C++ class during kext loading.
*/
#define kOSMetaClassNoInsKModSet libkern_metaclass_err(7)
// Can't insert the KMod set into the module dictionary
/*!
* @define kOSMetaClassNoSuper
* @abstract Internal error: No superclass can be found
* for a specific Libkern C++ class during kext loading.
*/
#define kOSMetaClassNoSuper libkern_metaclass_err(8)
/*!
* @define kOSMetaClassInstNoSuper
* @abstract Internal error: No superclass can be found when constructing
* an instance of a Libkern C++ class.
*/
#define kOSMetaClassInstNoSuper libkern_metaclass_err(9)
/*!
* @define kOSMetaClassDuplicateClass
* @abstract A duplicate Libkern C++ classname was encountered
* during kext loading.
*/
#define kOSMetaClassDuplicateClass libkern_metaclass_err(10)
/*!
* @define kOSMetaClassNoKext
* @abstract Internal error: The kext for a Libkern C++ class
* can't be found during kext loading.
*/
#define kOSMetaClassNoKext libkern_metaclass_err(11)
__END_DECLS
#endif /* ! __LIBKERN_OSRETURN_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSSpinLockDeprecated.h
================================================
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSSPINLOCK_DEPRECATED_H_
#define _OSSPINLOCK_DEPRECATED_H_
/*! @header
* These are deprecated legacy interfaces for userspace spinlocks.
*
* These interfaces should no longer be used, particularily in situations where
* threads of differing priorities may contend on the same spinlock.
*
* The interfaces in should be used instead in cases where a very
* low-level lock primitive is required. In general however, using higher level
* synchronization primitives such as those provided by the pthread or dispatch
* subsystems should be preferred.
*
* Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these
* interfaces in terms of the primitives. This is intended as a
* transition convenience, direct use of those primitives is preferred.
*/
#ifndef OSSPINLOCK_DEPRECATED
#define OSSPINLOCK_DEPRECATED 1
#define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from instead"
#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \
__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r))
#else
#undef OSSPINLOCK_DEPRECATED
#define OSSPINLOCK_DEPRECATED 0
#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r)
#endif
#if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED)
#include
#include
#include
#include
#include
__BEGIN_DECLS
/*! @abstract The default value for an OSSpinLock.
@discussion
The convention is that unlocked is zero, locked is nonzero.
*/
#define OS_SPINLOCK_INIT 0
/*! @abstract Data type for a spinlock.
@discussion
You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before
using it.
*/
typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
/*! @abstract Locks a spinlock if it would not block
@result
Returns false if the lock was already held by another thread,
true if it took the lock successfully.
*/
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSSpinLockTry( volatile OSSpinLock *__lock );
/*! @abstract Locks a spinlock
@discussion
Although the lock operation spins, it employs various strategies to back
off if the lock is held.
*/
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
void OSSpinLockLock( volatile OSSpinLock *__lock );
/*! @abstract Unlocks a spinlock */
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
void OSSpinLockUnlock( volatile OSSpinLock *__lock );
__END_DECLS
#else /* OSSPINLOCK_USE_INLINED */
/*
* Inline implementations of the legacy OSSpinLock interfaces in terms of the
* of the primitives. Direct use of those primitives is preferred.
*
* NOTE: the locked value of os_unfair_lock is implementation defined and
* subject to change, code that relies on the specific locked value used by the
* legacy OSSpinLock interface WILL break when using these inline
* implementations in terms of os_unfair_lock.
*/
#if !OSSPINLOCK_USE_INLINED_TRANSPARENT
#include
__BEGIN_DECLS
#if __has_attribute(always_inline)
#define OSSPINLOCK_INLINE static __inline
#else
#define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__))
#endif
#define OS_SPINLOCK_INIT 0
typedef int32_t OSSpinLock;
#if __has_extension(c_static_assert)
_Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock),
"Incompatible os_unfair_lock type");
#endif
OSSPINLOCK_INLINE
void
OSSpinLockLock(volatile OSSpinLock *__lock)
{
os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
return os_unfair_lock_lock(lock);
}
OSSPINLOCK_INLINE
bool
OSSpinLockTry(volatile OSSpinLock *__lock)
{
os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
return os_unfair_lock_trylock(lock);
}
OSSPINLOCK_INLINE
void
OSSpinLockUnlock(volatile OSSpinLock *__lock)
{
os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
return os_unfair_lock_unlock(lock);
}
#undef OSSPINLOCK_INLINE
__END_DECLS
#else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */
#include
#include
#include
#include
#include
#define OS_NOSPIN_LOCK_AVAILABILITY \
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \
__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
__BEGIN_DECLS
#define OS_SPINLOCK_INIT 0
typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
typedef volatile OSSpinLock *_os_nospin_lock_t
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t);
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
OS_NOSPIN_LOCK_AVAILABILITY
void _os_nospin_lock_lock(_os_nospin_lock_t lock);
#undef OSSpinLockLock
#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock)
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
OS_NOSPIN_LOCK_AVAILABILITY
bool _os_nospin_lock_trylock(_os_nospin_lock_t lock);
#undef OSSpinLockTry
#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock)
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
OS_NOSPIN_LOCK_AVAILABILITY
void _os_nospin_lock_unlock(_os_nospin_lock_t lock);
#undef OSSpinLockUnlock
#define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock)
__END_DECLS
#endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */
#endif /* OSSPINLOCK_USE_INLINED */
#endif /* _OSSPINLOCK_DEPRECATED_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSThermalNotification.h
================================================
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSTHERMALNOTIFICATION_H_
#define _OSTHERMALNOTIFICATION_H_
#include
#include
/*
** OSThermalNotification.h
**
** Notification mechanism to alert registered tasks when device thermal conditions
** reach certain thresholds. Notifications are triggered in both directions
** so clients can manage their memory usage more and less aggressively.
**
*/
__BEGIN_DECLS
/* Define pressure levels usable by OSThermalPressureLevel */
typedef enum {
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
kOSThermalPressureLevelNominal = 0,
kOSThermalPressureLevelModerate,
kOSThermalPressureLevelHeavy,
kOSThermalPressureLevelTrapping,
kOSThermalPressureLevelSleeping
#else
kOSThermalPressureLevelNominal = 0,
kOSThermalPressureLevelLight = 10,
kOSThermalPressureLevelModerate = 20,
kOSThermalPressureLevelHeavy = 30,
kOSThermalPressureLevelTrapping = 40,
kOSThermalPressureLevelSleeping = 50
#endif
} OSThermalPressureLevel;
/*
** External notify(3) string for thermal pressure level notification
*/
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0)
extern const char * const kOSThermalNotificationPressureLevelName;
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0
typedef enum {
OSThermalNotificationLevelAny = -1,
OSThermalNotificationLevelNormal = 0,
} OSThermalNotificationLevel;
extern OSThermalNotificationLevel _OSThermalNotificationLevelForBehavior(int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2);
extern void _OSThermalNotificationSetLevelForBehavior(int, int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2);
enum {
kOSThermalMitigationNone,
kOSThermalMitigation70PercentTorch,
kOSThermalMitigation70PercentBacklight,
kOSThermalMitigation50PercentTorch,
kOSThermalMitigation50PercentBacklight,
kOSThermalMitigationDisableTorch,
kOSThermalMitigation25PercentBacklight,
kOSThermalMitigationDisableMapsHalo,
kOSThermalMitigationAppTerminate,
kOSThermalMitigationDeviceRestart,
kOSThermalMitigationThermalTableReady,
kOSThermalMitigationCount
};
#define OSThermalNotificationLevel70PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentTorch)
#define OSThermalNotificationLevel70PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentBacklight)
#define OSThermalNotificationLevel50PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentTorch)
#define OSThermalNotificationLevel50PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentBacklight)
#define OSThermalNotificationLevelDisableTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableTorch)
#define OSThermalNotificationLevel25PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation25PercentBacklight)
#define OSThermalNotificationLevelDisableMapsHalo _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableMapsHalo)
#define OSThermalNotificationLevelAppTerminate _OSThermalNotificationLevelForBehavior(kOSThermalMitigationAppTerminate)
#define OSThermalNotificationLevelDeviceRestart _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDeviceRestart)
/* Backwards compatibility */
#define OSThermalNotificationLevelWarning OSThermalNotificationLevel70PercentBacklight
#define OSThermalNotificationLevelUrgent OSThermalNotificationLevelAppTerminate
#define OSThermalNotificationLevelCritical OSThermalNotificationLevelDeviceRestart
/*
** Simple polling interface to detect current thermal level
*/
__OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0)
extern OSThermalNotificationLevel OSThermalNotificationCurrentLevel(void);
/*
** External notify(3) string for manual notification setup
*/
__OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0)
extern const char * const kOSThermalNotificationName;
/*
** External notify(3) string for alerting user of a thermal condition
*/
__OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0)
extern const char * const kOSThermalNotificationAlert;
/*
** External notify(3) string for notifying system the options taken to resolve thermal condition
*/
__OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0)
extern const char * const kOSThermalNotificationDecision;
#endif // __IPHONE_OS_VERSION_MIN_REQUIRED
__END_DECLS
#endif /* _OSTHERMALNOTIFICATION_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/OSTypes.h
================================================
/*
* Copyright (c) 1999-2012 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#include
#ifndef _OS_OSTYPES_H
#define _OS_OSTYPES_H
#define OSTYPES_K64_REV 2
typedef unsigned int UInt;
typedef signed int SInt;
#include
#endif /* _OS_OSTYPES_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/_OSByteOrder.h
================================================
/*
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _OS__OSBYTEORDER_H
#define _OS__OSBYTEORDER_H
/*
* This header is normally included from . However,
* also includes this in the case of little-endian
* architectures, so that we can map OSByteOrder routines to the hton* and ntoh*
* macros. This results in the asymmetry below; we only include
* for little-endian architectures.
*/
#include
/* Macros for swapping constant values in the preprocessing stage. */
#define __DARWIN_OSSwapConstInt16(x) \
((__uint16_t)((((__uint16_t)(x) & 0xff00U) >> 8) | \
(((__uint16_t)(x) & 0x00ffU) << 8)))
#define __DARWIN_OSSwapConstInt32(x) \
((__uint32_t)((((__uint32_t)(x) & 0xff000000U) >> 24) | \
(((__uint32_t)(x) & 0x00ff0000U) >> 8) | \
(((__uint32_t)(x) & 0x0000ff00U) << 8) | \
(((__uint32_t)(x) & 0x000000ffU) << 24)))
#define __DARWIN_OSSwapConstInt64(x) \
((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
(((__uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
(((__uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
(((__uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
(((__uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
(((__uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
(((__uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
(((__uint64_t)(x) & 0x00000000000000ffULL) << 56)))
#if defined(__GNUC__)
#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define __DARWIN_OS_INLINE static inline
# else
# define __DARWIN_OS_INLINE static __inline__
# endif
#endif
#if defined(__i386__) || defined(__x86_64__)
#include
#endif
#if defined (__arm__) || defined(__arm64__)
#include
#endif
#define __DARWIN_OSSwapInt16(x) \
((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
#define __DARWIN_OSSwapInt32(x) \
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt32(x) : _OSSwapInt32(x))
#define __DARWIN_OSSwapInt64(x) \
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
#else /* ! __GNUC__ */
#if defined(__i386__) || defined(__x86_64__)
__DARWIN_OS_INLINE
uint16_t
_OSSwapInt16(
uint16_t data
)
{
return __DARWIN_OSSwapConstInt16(data);
}
__DARWIN_OS_INLINE
uint32_t
_OSSwapInt32(
uint32_t data
)
{
return __DARWIN_OSSwapConstInt32(data);
}
__DARWIN_OS_INLINE
uint64_t
_OSSwapInt64(
uint64_t data
)
{
return __DARWIN_OSSwapConstInt64(data);
}
#endif
#define __DARWIN_OSSwapInt16(x) _OSSwapInt16(x)
#define __DARWIN_OSSwapInt32(x) _OSSwapInt32(x)
#define __DARWIN_OSSwapInt64(x) _OSSwapInt64(x)
#endif /* __GNUC__ */
#endif /* ! _OS__OSBYTEORDER_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/arm/OSByteOrder.h
================================================
/*
* Copyright (c) 1999-2007 Apple Inc. All rights reserved.
*/
#ifndef _OS_OSBYTEORDERARM_H
#define _OS_OSBYTEORDERARM_H
#include
#include /* for _ARM_ARCH_6 */
/* Generic byte swapping functions. */
__DARWIN_OS_INLINE
uint16_t
_OSSwapInt16(
uint16_t _data
)
{
/* Reduces to 'rev16' with clang */
return (uint16_t)(_data << 8 | _data >> 8);
}
__DARWIN_OS_INLINE
uint32_t
_OSSwapInt32(
uint32_t _data
)
{
#if defined(__llvm__)
_data = __builtin_bswap32(_data);
#else
/* This actually generates the best code */
_data = (((_data ^ (_data >> 16 | (_data << 16))) & 0xFF00FFFF) >> 8) ^ (_data >> 8 | _data << 24);
#endif
return _data;
}
__DARWIN_OS_INLINE
uint64_t
_OSSwapInt64(
uint64_t _data
)
{
#if defined(__llvm__)
return __builtin_bswap64(_data);
#else
union {
uint64_t _ull;
uint32_t _ul[2];
} _u;
/* This actually generates the best code */
_u._ul[0] = (uint32_t)(_data >> 32);
_u._ul[1] = (uint32_t)(_data & 0xffffffff);
_u._ul[0] = _OSSwapInt32(_u._ul[0]);
_u._ul[1] = _OSSwapInt32(_u._ul[1]);
return _u._ull;
#endif
}
/* Functions for byte reversed loads. */
struct _OSUnalignedU16 {
volatile uint16_t __val;
} __attribute__((__packed__));
struct _OSUnalignedU32 {
volatile uint32_t __val;
} __attribute__((__packed__));
struct _OSUnalignedU64 {
volatile uint64_t __val;
} __attribute__((__packed__));
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
uint16_t
_OSReadSwapInt16(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val);
}
#else
__DARWIN_OS_INLINE
uint16_t
OSReadSwapInt16(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
uint32_t
_OSReadSwapInt32(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val);
}
#else
__DARWIN_OS_INLINE
uint32_t
OSReadSwapInt32(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
uint64_t
_OSReadSwapInt64(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val);
}
#else
__DARWIN_OS_INLINE
uint64_t
OSReadSwapInt64(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val);
}
#endif
/* Functions for byte reversed stores. */
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
void
_OSWriteSwapInt16(
volatile void * _base,
uintptr_t _offset,
uint16_t _data
)
{
((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt16(_data);
}
#else
__DARWIN_OS_INLINE
void
OSWriteSwapInt16(
volatile void * _base,
uintptr_t _offset,
uint16_t _data
)
{
((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt16(_data);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
void
_OSWriteSwapInt32(
volatile void * _base,
uintptr_t _offset,
uint32_t _data
)
{
((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt32(_data);
}
#else
__DARWIN_OS_INLINE
void
OSWriteSwapInt32(
volatile void * _base,
uintptr_t _offset,
uint32_t _data
)
{
((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt32(_data);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
void
_OSWriteSwapInt64(
volatile void * _base,
uintptr_t _offset,
uint64_t _data
)
{
((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt64(_data);
}
#else
__DARWIN_OS_INLINE
void
OSWriteSwapInt64(
volatile void * _base,
uintptr_t _offset,
uint64_t _data
)
{
((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt64(_data);
}
#endif
#endif /* ! _OS_OSBYTEORDERARM_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/i386/OSByteOrder.h
================================================
/*
* Copyright (c) 1999-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _OS_OSBYTEORDERI386_H
#define _OS_OSBYTEORDERI386_H
#include
#include
#include
/* Functions for byte reversed loads. */
OS_INLINE
uint16_t
OSReadSwapInt16(
const volatile void * base,
uintptr_t byteOffset
)
{
uint16_t result;
result = *(volatile uint16_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt16(result);
}
OS_INLINE
uint32_t
OSReadSwapInt32(
const volatile void * base,
uintptr_t byteOffset
)
{
uint32_t result;
result = *(volatile uint32_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt32(result);
}
OS_INLINE
uint64_t
OSReadSwapInt64(
const volatile void * base,
uintptr_t byteOffset
)
{
uint64_t result;
result = *(volatile uint64_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt64(result);
}
/* Functions for byte reversed stores. */
OS_INLINE
void
OSWriteSwapInt16(
volatile void * base,
uintptr_t byteOffset,
uint16_t data
)
{
*(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data);
}
OS_INLINE
void
OSWriteSwapInt32(
volatile void * base,
uintptr_t byteOffset,
uint32_t data
)
{
*(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data);
}
OS_INLINE
void
OSWriteSwapInt64(
volatile void * base,
uintptr_t byteOffset,
uint64_t data
)
{
*(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data);
}
#endif /* ! _OS_OSBYTEORDERI386_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/i386/_OSByteOrder.h
================================================
/*
* Copyright (c) 2006-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _OS__OSBYTEORDERI386_H
#define _OS__OSBYTEORDERI386_H
#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define __DARWIN_OS_INLINE static inline
# else
# define __DARWIN_OS_INLINE static __inline__
# endif
#endif
/* Generic byte swapping functions. */
__DARWIN_OS_INLINE
__uint16_t
_OSSwapInt16(
__uint16_t _data
)
{
return (__uint16_t)((_data << 8) | (_data >> 8));
}
__DARWIN_OS_INLINE
__uint32_t
_OSSwapInt32(
__uint32_t _data
)
{
#if defined(__llvm__)
return __builtin_bswap32(_data);
#else
__asm__ ("bswap %0" : "+r" (_data));
return _data;
#endif
}
#if defined(__llvm__)
__DARWIN_OS_INLINE
__uint64_t
_OSSwapInt64(
__uint64_t _data
)
{
return __builtin_bswap64(_data);
}
#elif defined(__i386__)
__DARWIN_OS_INLINE
__uint64_t
_OSSwapInt64(
__uint64_t _data
)
{
__asm__ ("bswap %%eax\n\t"
"bswap %%edx\n\t"
"xchgl %%eax, %%edx"
: "+A" (_data));
return _data;
}
#elif defined(__x86_64__)
__DARWIN_OS_INLINE
__uint64_t
_OSSwapInt64(
__uint64_t _data
)
{
__asm__ ("bswap %0" : "+r" (_data));
return _data;
}
#else
#error Unknown architecture
#endif
#endif /* ! _OS__OSBYTEORDERI386_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/libkern/machine/OSByteOrder.h
================================================
/*
* Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _OS_OSBYTEORDERMACHINE_H
#define _OS_OSBYTEORDERMACHINE_H
#include
#if !defined(OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define OS_INLINE static inline
# else
# define OS_INLINE static __inline__
# endif
#endif
/* Generic byte swapping functions. */
OS_INLINE
uint16_t
_OSSwapInt16(
uint16_t data
)
{
return OSSwapConstInt16(data);
}
OS_INLINE
uint32_t
_OSSwapInt32(
uint32_t data
)
{
return OSSwapConstInt32(data);
}
OS_INLINE
uint64_t
_OSSwapInt64(
uint64_t data
)
{
return OSSwapConstInt64(data);
}
/* Functions for byte reversed loads. */
OS_INLINE
uint16_t
OSReadSwapInt16(
const volatile void * base,
uintptr_t byteOffset
)
{
uint16_t data = *(volatile uint16_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt16(data);
}
OS_INLINE
uint32_t
OSReadSwapInt32(
const volatile void * base,
uintptr_t byteOffset
)
{
uint32_t data = *(volatile uint32_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt32(data);
}
OS_INLINE
uint64_t
OSReadSwapInt64(
const volatile void * base,
uintptr_t byteOffset
)
{
uint64_t data = *(volatile uint64_t *)((uintptr_t)base + byteOffset);
return _OSSwapInt64(data);
}
/* Functions for byte reversed stores. */
OS_INLINE
void
OSWriteSwapInt16(
volatile void * base,
uintptr_t byteOffset,
uint16_t data
)
{
*(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data);
}
OS_INLINE
void
OSWriteSwapInt32(
volatile void * base,
uintptr_t byteOffset,
uint32_t data
)
{
*(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data);
}
OS_INLINE
void
OSWriteSwapInt64(
volatile void * base,
uintptr_t byteOffset,
uint64_t data
)
{
*(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data);
}
#endif /* ! _OS_OSBYTEORDERMACHINE_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/arch.h
================================================
/*
* Copyright (c) 1999 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 _MACH_O_ARCH_H_
#define _MACH_O_ARCH_H_
/*
* Copyright (c) 1997 Apple Computer, Inc.
*
* Functions that deal with information about architectures.
*
*/
#include
#include
#include
/* The NXArchInfo structs contain the architectures symbolic name
* (such as "ppc"), its CPU type and CPU subtype as defined in
* mach/machine.h, the byte order for the architecture, and a
* describing string (such as "PowerPC").
* There will both be entries for specific CPUs (such as ppc604e) as
* well as generic "family" entries (such as ppc).
*/
typedef struct {
const char *name;
cpu_type_t cputype;
cpu_subtype_t cpusubtype;
enum NXByteOrder byteorder;
const char *description;
} NXArchInfo;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* NXGetAllArchInfos() returns a pointer to an array of all known
* NXArchInfo structures. The last NXArchInfo is marked by a NULL name.
*/
extern const NXArchInfo *NXGetAllArchInfos(void);
/* NXGetLocalArchInfo() returns the NXArchInfo for the local host, or NULL
* if none is known.
*/
extern const NXArchInfo *NXGetLocalArchInfo(void);
/* NXGetArchInfoFromName() and NXGetArchInfoFromCpuType() return the
* NXArchInfo from the architecture's name or cputype/cpusubtype
* combination. A cpusubtype of CPU_SUBTYPE_MULTIPLE can be used
* to request the most general NXArchInfo known for the given cputype.
* NULL is returned if no matching NXArchInfo can be found.
*/
extern const NXArchInfo *NXGetArchInfoFromName(const char *name);
extern const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype,
cpu_subtype_t cpusubtype);
/* The above interfaces that return pointers to NXArchInfo structs in normal
* cases returns a pointer from the array returned in NXGetAllArchInfos().
* In some cases when the cputype is CPU_TYPE_I386 or CPU_TYPE_POWERPC it will
* retun malloc(3)'ed NXArchInfo struct which contains a string in the
* description field also a malloc(3)'ed pointer. To allow programs not to
* leak memory they can call NXFreeArchInfo() on pointers returned from the
* above interfaces. Since this is a new API on older systems can use the
* code below. Going forward the above interfaces will only return pointers
* from the array returned in NXGetAllArchInfos().
*/
extern void NXFreeArchInfo(const NXArchInfo *x);
/* The code that can be used for NXFreeArchInfo() when it is not available is:
*
* static void NXFreeArchInfo(
* const NXArchInfo *x)
* {
* const NXArchInfo *p;
*
* p = NXGetAllArchInfos();
* while(p->name != NULL){
* if(x == p)
* return;
* p++;
* }
* free((char *)x->description);
* free((NXArchInfo *)x);
* }
*/
/* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of
* fat_arch structs and selects the best one that matches (if any) and returns
* a pointer to that fat_arch struct (or NULL). The fat_arch structs must be
* in the host byte order and correct such that the fat_archs really points to
* enough memory for nfat_arch structs. It is possible that this routine could
* fail if new cputypes or cpusubtypes are added and an old version of this
* routine is used. But if there is an exact match between the cputype and
* cpusubtype and one of the fat_arch structs this routine will always succeed.
*/
extern struct fat_arch *NXFindBestFatArch(cpu_type_t cputype,
cpu_subtype_t cpusubtype,
struct fat_arch *fat_archs,
uint32_t nfat_archs);
/* NXFindBestFatArch_64() is passed a cputype and cpusubtype and a set of
* fat_arch_64 structs and selects the best one that matches (if any) and
* returns a pointer to that fat_arch_64 struct (or NULL). The fat_arch_64
* structs must be in the host byte order and correct such that the fat_archs64
* really points to enough memory for nfat_arch structs. It is possible that
* this routine could fail if new cputypes or cpusubtypes are added and an old
* version of this routine is used. But if there is an exact match between the
* cputype and cpusubtype and one of the fat_arch_64 structs this routine will
* always succeed.
*/
extern struct fat_arch_64 *NXFindBestFatArch_64(cpu_type_t cputype,
cpu_subtype_t cpusubtype,
struct fat_arch_64 *fat_archs64,
uint32_t nfat_archs);
/* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two
* different cpusubtypes for the specified cputype. If the two cpusubtypes
* can't be combined (the specific subtypes are mutually exclusive) -1 is
* returned indicating it is an error to combine them. This can also fail and
* return -1 if new cputypes or cpusubtypes are added and an old version of
* this routine is used. But if the cpusubtypes are the same they can always
* be combined and this routine will return the cpusubtype pass in.
*/
extern cpu_subtype_t NXCombineCpuSubtypes(cpu_type_t cputype,
cpu_subtype_t cpusubtype1,
cpu_subtype_t cpusubtype2);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_ARCH_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/arm/reloc.h
================================================
/*
* Copyright (c) 1999 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@
*/
/*
* Relocation types used in the arm implementation. Relocation entries for
* things other than instructions use the same generic relocation as discribed
* in and their r_type is ARM_RELOC_VANILLA, one of the
* *_SECTDIFF or the *_PB_LA_PTR types. The rest of the relocation types are
* for instructions. Since they are for instructions the r_address field
* indicates the 32 bit instruction that the relocation is to be preformed on.
*/
enum reloc_type_arm
{
ARM_RELOC_VANILLA, /* generic relocation as discribed above */
ARM_RELOC_PAIR, /* the second relocation entry of a pair */
ARM_RELOC_SECTDIFF, /* a PAIR follows with subtract symbol value */
ARM_RELOC_LOCAL_SECTDIFF, /* like ARM_RELOC_SECTDIFF, but the symbol
referenced was local. */
ARM_RELOC_PB_LA_PTR,/* prebound lazy pointer */
ARM_RELOC_BR24, /* 24 bit branch displacement (to a word address) */
ARM_THUMB_RELOC_BR22, /* 22 bit branch displacement (to a half-word
address) */
ARM_THUMB_32BIT_BRANCH, /* obsolete - a thumb 32-bit branch instruction
possibly needing page-spanning branch workaround */
/*
* For these two r_type relocations they always have a pair following them
* and the r_length bits are used differently. The encoding of the
* r_length is as follows:
* low bit of r_length:
* 0 - :lower16: for movw instructions
* 1 - :upper16: for movt instructions
* high bit of r_length:
* 0 - arm instructions
* 1 - thumb instructions
* the other half of the relocated expression is in the following pair
* relocation entry in the the low 16 bits of r_address field.
*/
ARM_RELOC_HALF,
ARM_RELOC_HALF_SECTDIFF
};
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/arm64/reloc.h
================================================
/*
* Copyright (c) 2010 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 _MACHO_ARM64_RELOC_H_
#define _MACHO_ARM64_RELOC_H_
/*
* Relocation types used in the arm64 implementation.
*/
enum reloc_type_arm64
{
ARM64_RELOC_UNSIGNED, // for pointers
ARM64_RELOC_SUBTRACTOR, // must be followed by a ARM64_RELOC_UNSIGNED
ARM64_RELOC_BRANCH26, // a B/BL instruction with 26-bit displacement
ARM64_RELOC_PAGE21, // pc-rel distance to page of target
ARM64_RELOC_PAGEOFF12, // offset within page, scaled by r_length
ARM64_RELOC_GOT_LOAD_PAGE21, // pc-rel distance to page of GOT slot
ARM64_RELOC_GOT_LOAD_PAGEOFF12, // offset within page of GOT slot,
// scaled by r_length
ARM64_RELOC_POINTER_TO_GOT, // for pointers to GOT slots
ARM64_RELOC_TLVP_LOAD_PAGE21, // pc-rel distance to page of TLVP slot
ARM64_RELOC_TLVP_LOAD_PAGEOFF12, // offset within page of TLVP slot,
// scaled by r_length
ARM64_RELOC_ADDEND, // must be followed by PAGE21 or PAGEOFF12
// An arm64e authenticated pointer.
//
// Represents a pointer to a symbol (like ARM64_RELOC_UNSIGNED).
// Additionally, the resulting pointer is signed. The signature is
// specified in the target location: the addend is restricted to the lower
// 32 bits (instead of the full 64 bits for ARM64_RELOC_UNSIGNED):
//
// |63|62|61-51|50-49| 48 |47 - 32|31 - 0|
// | 1| 0| 0 | key | addr | discriminator | addend |
//
// The key is one of:
// IA: 00 IB: 01
// DA: 10 DB: 11
//
// The discriminator field is used as extra signature diversification.
//
// The addr field indicates whether the target address should be blended
// into the discriminator.
//
ARM64_RELOC_AUTHENTICATED_POINTER,
};
#endif /* #ifndef _MACHO_ARM64_RELOC_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/compact_unwind_encoding.h
================================================
//===------------------ mach-o/compact_unwind_encoding.h ------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// Darwin's alternative to DWARF based unwind encodings.
//
//===----------------------------------------------------------------------===//
#ifndef __COMPACT_UNWIND_ENCODING__
#define __COMPACT_UNWIND_ENCODING__
#include
//
// Compilers can emit standard DWARF FDEs in the __TEXT,__eh_frame section
// of object files. Or compilers can emit compact unwind information in
// the __LD,__compact_unwind section.
//
// When the linker creates a final linked image, it will create a
// __TEXT,__unwind_info section. This section is a small and fast way for the
// runtime to access unwind info for any given function. If the compiler
// emitted compact unwind info for the function, that compact unwind info will
// be encoded in the __TEXT,__unwind_info section. If the compiler emitted
// DWARF unwind info, the __TEXT,__unwind_info section will contain the offset
// of the FDE in the __TEXT,__eh_frame section in the final linked image.
//
// Note: Previously, the linker would transform some DWARF unwind infos into
// compact unwind info. But that is fragile and no longer done.
//
// The compact unwind endoding is a 32-bit value which encoded in an
// architecture specific way, which registers to restore from where, and how
// to unwind out of the function.
//
typedef uint32_t compact_unwind_encoding_t;
// architecture independent bits
enum {
UNWIND_IS_NOT_FUNCTION_START = 0x80000000,
UNWIND_HAS_LSDA = 0x40000000,
UNWIND_PERSONALITY_MASK = 0x30000000,
};
//
// x86
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=DWARF
// ebp based:
// 15-bits (5*3-bits per reg) register permutation
// 8-bits for stack offset
// frameless:
// 8-bits stack size
// 3-bits stack adjust
// 3-bits register count
// 10-bits register permutation
//
enum {
UNWIND_X86_MODE_MASK = 0x0F000000,
UNWIND_X86_MODE_EBP_FRAME = 0x01000000,
UNWIND_X86_MODE_STACK_IMMD = 0x02000000,
UNWIND_X86_MODE_STACK_IND = 0x03000000,
UNWIND_X86_MODE_DWARF = 0x04000000,
UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF,
UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000,
UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000,
UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000,
UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
UNWIND_X86_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
enum {
UNWIND_X86_REG_NONE = 0,
UNWIND_X86_REG_EBX = 1,
UNWIND_X86_REG_ECX = 2,
UNWIND_X86_REG_EDX = 3,
UNWIND_X86_REG_EDI = 4,
UNWIND_X86_REG_ESI = 5,
UNWIND_X86_REG_EBP = 6,
};
//
// For x86 there are four modes for the compact unwind encoding:
// UNWIND_X86_MODE_EBP_FRAME:
// EBP based frame where EBP is push on stack immediately after return address,
// then ESP is moved to EBP. Thus, to unwind ESP is restored with the current
// EPB value, then EBP is restored by popping off the stack, and the return
// is done by popping the stack once more into the pc.
// All non-volatile registers that need to be restored must have been saved
// in a small range in the stack that starts EBP-4 to EBP-1020. The offset/4
// is encoded in the UNWIND_X86_EBP_FRAME_OFFSET bits. The registers saved
// are encoded in the UNWIND_X86_EBP_FRAME_REGISTERS bits as five 3-bit entries.
// Each entry contains which register to restore.
// UNWIND_X86_MODE_STACK_IMMD:
// A "frameless" (EBP not used as frame pointer) function with a small
// constant stack size. To return, a constant (encoded in the compact
// unwind encoding) is added to the ESP. Then the return is done by
// popping the stack into the pc.
// All non-volatile registers that need to be restored must have been saved
// on the stack immediately after the return address. The stack_size/4 is
// encoded in the UNWIND_X86_FRAMELESS_STACK_SIZE (max stack size is 1024).
// The number of registers saved is encoded in UNWIND_X86_FRAMELESS_STACK_REG_COUNT.
// UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
// saved and their order.
// UNWIND_X86_MODE_STACK_IND:
// A "frameless" (EBP not used as frame pointer) function large constant
// stack size. This case is like the previous, except the stack size is too
// large to encode in the compact unwind encoding. Instead it requires that
// the function contains "subl $nnnnnnnn,ESP" in its prolog. The compact
// encoding contains the offset to the nnnnnnnn value in the function in
// UNWIND_X86_FRAMELESS_STACK_SIZE.
// UNWIND_X86_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
// The permutation encoding is a Lehmer code sequence encoded into a
// single variable-base number so we can encode the ordering of up to
// six registers in a 10-bit space.
//
// The following is the algorithm used to create the permutation encoding used
// with frameless stacks. It is passed the number of registers to be saved and
// an array of the register numbers saved.
//
//uint32_t permute_encode(uint32_t registerCount, const uint32_t registers[6])
//{
// uint32_t renumregs[6];
// for (int i=6-registerCount; i < 6; ++i) {
// int countless = 0;
// for (int j=6-registerCount; j < i; ++j) {
// if ( registers[j] < registers[i] )
// ++countless;
// }
// renumregs[i] = registers[i] - countless -1;
// }
// uint32_t permutationEncoding = 0;
// switch ( registerCount ) {
// case 6:
// permutationEncoding |= (120*renumregs[0] + 24*renumregs[1]
// + 6*renumregs[2] + 2*renumregs[3]
// + renumregs[4]);
// break;
// case 5:
// permutationEncoding |= (120*renumregs[1] + 24*renumregs[2]
// + 6*renumregs[3] + 2*renumregs[4]
// + renumregs[5]);
// break;
// case 4:
// permutationEncoding |= (60*renumregs[2] + 12*renumregs[3]
// + 3*renumregs[4] + renumregs[5]);
// break;
// case 3:
// permutationEncoding |= (20*renumregs[3] + 4*renumregs[4]
// + renumregs[5]);
// break;
// case 2:
// permutationEncoding |= (5*renumregs[4] + renumregs[5]);
// break;
// case 1:
// permutationEncoding |= (renumregs[5]);
// break;
// }
// return permutationEncoding;
//}
//
//
// x86_64
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=DWARF
// rbp based:
// 15-bits (5*3-bits per reg) register permutation
// 8-bits for stack offset
// frameless:
// 8-bits stack size
// 3-bits stack adjust
// 3-bits register count
// 10-bits register permutation
//
enum {
UNWIND_X86_64_MODE_MASK = 0x0F000000,
UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000,
UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000,
UNWIND_X86_64_MODE_STACK_IND = 0x03000000,
UNWIND_X86_64_MODE_DWARF = 0x04000000,
UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF,
UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000,
UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000,
UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000,
UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
enum {
UNWIND_X86_64_REG_NONE = 0,
UNWIND_X86_64_REG_RBX = 1,
UNWIND_X86_64_REG_R12 = 2,
UNWIND_X86_64_REG_R13 = 3,
UNWIND_X86_64_REG_R14 = 4,
UNWIND_X86_64_REG_R15 = 5,
UNWIND_X86_64_REG_RBP = 6,
};
//
// For x86_64 there are four modes for the compact unwind encoding:
// UNWIND_X86_64_MODE_RBP_FRAME:
// RBP based frame where RBP is push on stack immediately after return address,
// then RSP is moved to RBP. Thus, to unwind RSP is restored with the current
// EPB value, then RBP is restored by popping off the stack, and the return
// is done by popping the stack once more into the pc.
// All non-volatile registers that need to be restored must have been saved
// in a small range in the stack that starts RBP-8 to RBP-2040. The offset/8
// is encoded in the UNWIND_X86_64_RBP_FRAME_OFFSET bits. The registers saved
// are encoded in the UNWIND_X86_64_RBP_FRAME_REGISTERS bits as five 3-bit entries.
// Each entry contains which register to restore.
// UNWIND_X86_64_MODE_STACK_IMMD:
// A "frameless" (RBP not used as frame pointer) function with a small
// constant stack size. To return, a constant (encoded in the compact
// unwind encoding) is added to the RSP. Then the return is done by
// popping the stack into the pc.
// All non-volatile registers that need to be restored must have been saved
// on the stack immediately after the return address. The stack_size/8 is
// encoded in the UNWIND_X86_64_FRAMELESS_STACK_SIZE (max stack size is 2048).
// The number of registers saved is encoded in UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT.
// UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
// saved and their order.
// UNWIND_X86_64_MODE_STACK_IND:
// A "frameless" (RBP not used as frame pointer) function large constant
// stack size. This case is like the previous, except the stack size is too
// large to encode in the compact unwind encoding. Instead it requires that
// the function contains "subq $nnnnnnnn,RSP" in its prolog. The compact
// encoding contains the offset to the nnnnnnnn value in the function in
// UNWIND_X86_64_FRAMELESS_STACK_SIZE.
// UNWIND_X86_64_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
// ARM64
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 4=frame-based, 3=DWARF, 2=frameless
// frameless:
// 12-bits of stack size
// frame-based:
// 4-bits D reg pairs saved
// 5-bits X reg pairs saved
// DWARF:
// 24-bits offset of DWARF FDE in __eh_frame section
//
enum {
UNWIND_ARM64_MODE_MASK = 0x0F000000,
UNWIND_ARM64_MODE_FRAMELESS = 0x02000000,
UNWIND_ARM64_MODE_DWARF = 0x03000000,
UNWIND_ARM64_MODE_FRAME = 0x04000000,
UNWIND_ARM64_FRAME_X19_X20_PAIR = 0x00000001,
UNWIND_ARM64_FRAME_X21_X22_PAIR = 0x00000002,
UNWIND_ARM64_FRAME_X23_X24_PAIR = 0x00000004,
UNWIND_ARM64_FRAME_X25_X26_PAIR = 0x00000008,
UNWIND_ARM64_FRAME_X27_X28_PAIR = 0x00000010,
UNWIND_ARM64_FRAME_D8_D9_PAIR = 0x00000100,
UNWIND_ARM64_FRAME_D10_D11_PAIR = 0x00000200,
UNWIND_ARM64_FRAME_D12_D13_PAIR = 0x00000400,
UNWIND_ARM64_FRAME_D14_D15_PAIR = 0x00000800,
UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK = 0x00FFF000,
UNWIND_ARM64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
// For arm64 there are three modes for the compact unwind encoding:
// UNWIND_ARM64_MODE_FRAME:
// This is a standard arm64 prolog where FP/LR are immediately pushed on the
// stack, then SP is copied to FP. If there are any non-volatile registers
// saved, then are copied into the stack frame in pairs in a contiguous
// range right below the saved FP/LR pair. Any subset of the five X pairs
// and four D pairs can be saved, but the memory layout must be in register
// number order.
// UNWIND_ARM64_MODE_FRAMELESS:
// A "frameless" leaf function, where FP/LR are not saved. The return address
// remains in LR throughout the function. If any non-volatile registers
// are saved, they must be pushed onto the stack before any stack space is
// allocated for local variables. The stack sized (including any saved
// non-volatile registers) divided by 16 is encoded in the bits
// UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK.
// UNWIND_ARM64_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
#ifndef __OPEN_SOURCE__
//
// armv7k
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 1=frame, 2=frame+dregs, 4=dwarf
//
enum {
UNWIND_ARM_MODE_MASK = 0x0F000000,
UNWIND_ARM_MODE_FRAME = 0x01000000,
UNWIND_ARM_MODE_FRAME_D = 0x02000000,
UNWIND_ARM_MODE_DWARF = 0x04000000,
UNWIND_ARM_FRAME_STACK_ADJUST_MASK = 0x00C00000,
UNWIND_ARM_FRAME_FIRST_PUSH_R4 = 0x00000001,
UNWIND_ARM_FRAME_FIRST_PUSH_R5 = 0x00000002,
UNWIND_ARM_FRAME_FIRST_PUSH_R6 = 0x00000004,
UNWIND_ARM_FRAME_SECOND_PUSH_R8 = 0x00000008,
UNWIND_ARM_FRAME_SECOND_PUSH_R9 = 0x00000010,
UNWIND_ARM_FRAME_SECOND_PUSH_R10 = 0x00000020,
UNWIND_ARM_FRAME_SECOND_PUSH_R11 = 0x00000040,
UNWIND_ARM_FRAME_SECOND_PUSH_R12 = 0x00000080,
UNWIND_ARM_FRAME_D_REG_COUNT_MASK = 0x00000700,
UNWIND_ARM_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
// For armv7k there are three modes for the compact unwind encoding:
// UNWIND_ARM_MODE_FRAME:
// This is a standard arm prolog where lr/r7 are immediately pushed on the
// stack. As part of that first push r4, r5, or r6 can be also pushed
// and if so the FIRST_PUSH bit is set in the compact unwind. Additionally
// there can be a second push multiple which can save r8 through r12.
// If that is used, the registers saved is recorded with a SECOND_PUSH bit.
// Lastly, for var-args support, the prolog may save r1, r2, r3 to the
// stack before the frame push. If that is done the STACK_ADJUST_MASK
// records that the stack pointer must be adjust (e.g 0x00800000 means
// the stack pointer was adjusted 8 bytes down and the unwinder would
// need to add back 8 bytes to SP when unwinding through this function.
// UNWIND_ARM_MODE_FRAME_D:
// This is the same as UNWIND_ARM_MODE_FRAME, except that additionally
// some D registers were saved. The D_REG_COUNT_MASK contains which
// set if D registers were saved and where. There are currently 8 (0-7)
// possible D register save patterns supported.
// UNWIND_ARM_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the dwarf FDE in the __eh_frame section.
// The offset only exists in final linked images. It is zero in object files.
#endif
////////////////////////////////////////////////////////////////////////////////
//
// Relocatable Object Files: __LD,__compact_unwind
//
////////////////////////////////////////////////////////////////////////////////
//
// A compiler can generated compact unwind information for a function by adding
// a "row" to the __LD,__compact_unwind section. This section has the
// S_ATTR_DEBUG bit set, so the section will be ignored by older linkers.
// It is removed by the new linker, so never ends up in final executables.
// This section is a table, initially with one row per function (that needs
// unwind info). The table columns and some conceptual entries are:
//
// range-start pointer to start of function/range
// range-length
// compact-unwind-encoding 32-bit encoding
// personality-function or zero if no personality function
// lsda or zero if no LSDA data
//
// The length and encoding fields are 32-bits. The other are all pointer sized.
//
// In x86_64 assembly, these entry would look like:
//
// .section __LD,__compact_unwind,regular,debug
//
// #compact unwind for _foo
// .quad _foo
// .set L1,LfooEnd-_foo
// .long L1
// .long 0x01010001
// .quad 0
// .quad 0
//
// #compact unwind for _bar
// .quad _bar
// .set L2,LbarEnd-_bar
// .long L2
// .long 0x01020011
// .quad __gxx_personality
// .quad except_tab1
//
//
// Notes: There is no need for any labels in the the __compact_unwind section.
// The use of the .set directive is to force the evaluation of the
// range-length at assembly time, instead of generating relocations.
//
// To support future compiler optimizations where which non-volatile registers
// are saved changes within a function (e.g. delay saving non-volatiles until
// necessary), there can by multiple lines in the __compact_unwind table for one
// function, each with a different (non-overlapping) range and each with
// different compact unwind encodings that correspond to the non-volatiles
// saved at that range of the function.
//
// If a particular function is so wacky that there is no compact unwind way
// to encode it, then the compiler can emit traditional DWARF unwind info.
// The runtime will use which ever is available.
//
// Runtime support for compact unwind encodings are only available on 10.6
// and later. So, the compiler should not generate it when targeting pre-10.6.
////////////////////////////////////////////////////////////////////////////////
//
// Final Linked Images: __TEXT,__unwind_info
//
////////////////////////////////////////////////////////////////////////////////
//
// The __TEXT,__unwind_info section is laid out for an efficient two level lookup.
// The header of the section contains a coarse index that maps function address
// to the page (4096 byte block) containing the unwind info for that function.
//
#define UNWIND_SECTION_VERSION 1
struct unwind_info_section_header
{
uint32_t version; // UNWIND_SECTION_VERSION
uint32_t commonEncodingsArraySectionOffset;
uint32_t commonEncodingsArrayCount;
uint32_t personalityArraySectionOffset;
uint32_t personalityArrayCount;
uint32_t indexSectionOffset;
uint32_t indexCount;
// compact_unwind_encoding_t[]
// uint32_t personalities[]
// unwind_info_section_header_index_entry[]
// unwind_info_section_header_lsda_index_entry[]
};
struct unwind_info_section_header_index_entry
{
uint32_t functionOffset;
uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page
uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range
};
struct unwind_info_section_header_lsda_index_entry
{
uint32_t functionOffset;
uint32_t lsdaOffset;
};
//
// There are two kinds of second level index pages: regular and compressed.
// A compressed page can hold up to 1021 entries, but it cannot be used
// if too many different encoding types are used. The regular page holds
// 511 entries.
//
struct unwind_info_regular_second_level_entry
{
uint32_t functionOffset;
compact_unwind_encoding_t encoding;
};
#define UNWIND_SECOND_LEVEL_REGULAR 2
struct unwind_info_regular_second_level_page_header
{
uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR
uint16_t entryPageOffset;
uint16_t entryCount;
// entry array
};
#define UNWIND_SECOND_LEVEL_COMPRESSED 3
struct unwind_info_compressed_second_level_page_header
{
uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED
uint16_t entryPageOffset;
uint16_t entryCount;
uint16_t encodingsPageOffset;
uint16_t encodingsCount;
// 32-bit entry array
// encodings array
};
#define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF)
#define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF)
#endif
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/compact_unwind_encoding.modulemap
================================================
module MachO.compact_unwind_encoding [system] [extern_c] {
header "compact_unwind_encoding.h"
export *
}
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/dyld.h
================================================
/*
* Copyright (c) 1999-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_DYLD_H_
#define _MACH_O_DYLD_H_
#include
#include
#include
#include
#include
#if __cplusplus
extern "C" {
#endif
#ifdef __DRIVERKIT_19_0
#define DYLD_DRIVERKIT_UNAVAILABLE __API_UNAVAILABLE(driverkit)
#else
#define DYLD_DRIVERKIT_UNAVAILABLE
#endif
/*
* The following functions allow you to iterate through all loaded images.
* This is not a thread safe operation. Another thread can add or remove
* an image during the iteration.
*
* Many uses of these routines can be replace by a call to dladdr() which
* will return the mach_header and name of an image, given an address in
* the image. dladdr() is thread safe.
*/
extern uint32_t _dyld_image_count(void) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern const struct mach_header* _dyld_get_image_header(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern intptr_t _dyld_get_image_vmaddr_slide(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern const char* _dyld_get_image_name(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* The following functions allow you to install callbacks which will be called
* by dyld whenever an image is loaded or unloaded. During a call to _dyld_register_func_for_add_image()
* the callback func is called for every existing image. Later, it is called as each new image
* is loaded and bound (but initializers not yet run). The callback registered with
* _dyld_register_func_for_remove_image() is called after any terminators in an image are run
* and before the image is un-memory-mapped.
*/
extern void _dyld_register_func_for_add_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern void _dyld_register_func_for_remove_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* NSVersionOfRunTimeLibrary() returns the current_version number of the currently dylib
* specifed by the libraryName. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
* "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if no such library is loaded.
*/
extern int32_t NSVersionOfRunTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* NSVersionOfLinkTimeLibrary() returns the current_version number that the main executable was linked
* against at build time. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
* "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if the main executable did not link
* against the specified library.
*/
extern int32_t NSVersionOfLinkTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* _NSGetExecutablePath() copies the path of the main executable into the buffer. The bufsize parameter
* should initially be the size of the buffer. The function returns 0 if the path was successfully copied,
* and *bufsize is left unchanged. It returns -1 if the buffer is not large enough, and *bufsize is set
* to the size required.
*
* Note that _NSGetExecutablePath will return "a path" to the executable not a "real path" to the executable.
* That is the path may be a symbolic link and not the real file. With deep directories the total bufsize
* needed could be more than MAXPATHLEN.
*/
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize) __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
/*
* Registers a function to be called when the current thread terminates.
* Called by c++ compiler to implement destructors on thread_local object variables.
*/
extern void _tlv_atexit(void (*termFunc)(void* objAddr), void* objAddr) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
/*
* Never called. On-disk thread local variables contain a pointer to this. Once
* the thread local is prepared, the pointer changes to a real handler such as tlv_get_addr.
*/
extern void _tlv_bootstrap(void) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) DYLD_DRIVERKIT_UNAVAILABLE ;
/*
* Dylibs that are incorporated into the dyld cache are removed from disk. That means code
* cannot stat() the file to see if it "exists". This function is like a stat() call that checks if a
* path is to a dylib that was removed from disk and is incorporated into the active dyld cache.
*/
extern bool _dyld_shared_cache_contains_path(const char* path) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) DYLD_DRIVERKIT_UNAVAILABLE;
/*
* The following dyld API's are deprecated as of Mac OS X 10.5. They are either
* no longer necessary or are superceeded by dlopen and friends in .
* dlopen/dlsym/dlclose have been available since Mac OS X 10.3 and work with
* dylibs and bundles.
*
* NSAddImage -> dlopen
* NSLookupSymbolInImage -> dlsym
* NSCreateObjectFileImageFromFile -> dlopen
* NSDestroyObjectFileImage -> dlclose
* NSLinkModule -> not needed when dlopen used
* NSUnLinkModule -> not needed when dlclose used
* NSLookupSymbolInModule -> dlsym
* _dyld_image_containing_address -> dladdr
* NSLinkEditError -> dlerror
*
*/
#ifndef ENUM_DYLD_BOOL
#define ENUM_DYLD_BOOL
#undef FALSE
#undef TRUE
enum DYLD_BOOL { FALSE, TRUE };
#endif /* ENUM_DYLD_BOOL */
/* Object file image API */
typedef enum {
NSObjectFileImageFailure, /* for this a message is printed on stderr */
NSObjectFileImageSuccess,
NSObjectFileImageInappropriateFile,
NSObjectFileImageArch,
NSObjectFileImageFormat, /* for this a message is printed on stderr */
NSObjectFileImageAccess
} NSObjectFileImageReturnCode;
typedef struct __NSObjectFileImage* NSObjectFileImage;
/* NSObjectFileImage can only be used with MH_BUNDLE files */
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile(const char* pathName, NSObjectFileImage *objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromMemory(const void *address, size_t size, NSObjectFileImage *objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSDestroyObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlclose()");
extern uint32_t NSSymbolDefinitionCountInObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSSymbolDefinitionNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern uint32_t NSSymbolReferenceCountInObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSSymbolReferenceNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal, bool *tentative_definition) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSIsSymbolDefinedInObjectFileImage(NSObjectFileImage objectFileImage, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void* NSGetSectionDataInObjectFileImage(NSObjectFileImage objectFileImage, const char* segmentName, const char* sectionName, size_t *size) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "getsectiondata()");
typedef struct __NSModule* NSModule;
extern const char* NSNameOfModule(NSModule m) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSLibraryNameForModule(NSModule m) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern NSModule NSLinkModule(NSObjectFileImage objectFileImage, const char* moduleName, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
#define NSLINKMODULE_OPTION_NONE 0x0
#define NSLINKMODULE_OPTION_BINDNOW 0x1
#define NSLINKMODULE_OPTION_PRIVATE 0x2
#define NSLINKMODULE_OPTION_RETURN_ON_ERROR 0x4
#define NSLINKMODULE_OPTION_DONT_CALL_MOD_INIT_ROUTINES 0x8
#define NSLINKMODULE_OPTION_TRAILING_PHYS_NAME 0x10
extern bool NSUnLinkModule(NSModule module, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
#define NSUNLINKMODULE_OPTION_NONE 0x0
#define NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED 0x1
#define NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES 0x2
/* symbol API */
typedef struct __NSSymbol* NSSymbol;
extern bool NSIsSymbolNameDefined(const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern bool NSIsSymbolNameDefinedWithHint(const char* symbolName, const char* libraryNameHint) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern bool NSIsSymbolNameDefinedInImage(const struct mach_header* image, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupAndBindSymbol(const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupAndBindSymbolWithHint(const char* symbolName, const char* libraryNameHint) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupSymbolInModule(NSModule module, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern NSSymbol NSLookupSymbolInImage(const struct mach_header* image, const char* symbolName, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY 0x2
#define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4
extern const char* NSNameOfSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern void * NSAddressOfSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern NSModule NSModuleForSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dladdr()");
/* error handling API */
typedef enum {
NSLinkEditFileAccessError,
NSLinkEditFileFormatError,
NSLinkEditMachResourceError,
NSLinkEditUnixResourceError,
NSLinkEditOtherError,
NSLinkEditWarningError,
NSLinkEditMultiplyDefinedError,
NSLinkEditUndefinedError
} NSLinkEditErrors;
/*
* For the NSLinkEditErrors value NSLinkEditOtherError these are the values
* passed to the link edit error handler as the errorNumber (what would be an
* errno value for NSLinkEditUnixResourceError or a kern_return_t value for
* NSLinkEditMachResourceError).
*/
typedef enum {
NSOtherErrorRelocation,
NSOtherErrorLazyBind,
NSOtherErrorIndrLoop,
NSOtherErrorLazyInit,
NSOtherErrorInvalidArgs
} NSOtherErrorNumbers;
extern void NSLinkEditError(NSLinkEditErrors *c, int *errorNumber, const char** fileName, const char** errorString) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlerror()");
typedef struct {
void (*undefined)(const char* symbolName);
NSModule (*multiple)(NSSymbol s, NSModule oldModule, NSModule newModule);
void (*linkEdit)(NSLinkEditErrors errorClass, int errorNumber,
const char* fileName, const char* errorString);
} NSLinkEditErrorHandlers;
extern void NSInstallLinkEditErrorHandlers(const NSLinkEditErrorHandlers *handlers) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSAddLibrary(const char* pathName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlopen()");
extern bool NSAddLibraryWithSearching(const char* pathName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlopen()");
extern const struct mach_header* NSAddImage(const char* image_name, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
#define NSADDIMAGE_OPTION_NONE 0x0
#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1
#define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2
#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4
#define NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME 0x8
extern bool _dyld_present(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "always true");
extern bool _dyld_launched_prebound(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "moot");
extern bool _dyld_all_twolevel_modules_prebound(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "moot");
extern bool _dyld_bind_fully_image_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen(RTLD_NOW)");
extern bool _dyld_image_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "dladdr()");
extern void _dyld_lookup_and_bind(const char* symbol_name, void **address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void _dyld_lookup_and_bind_with_hint(const char* symbol_name, const char* library_name_hint, void** address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void _dyld_lookup_and_bind_fully(const char* symbol_name, void** address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern const struct mach_header* _dyld_get_image_header_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "dladdr()");
#if __cplusplus
}
#endif
#endif /* _MACH_O_DYLD_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/dyld.modulemap
================================================
module MachO.dyld [system] [extern_c] {
header "dyld.h"
export *
}
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/dyld_images.h
================================================
/*
* Copyright (c) 2006-2010 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _DYLD_IMAGES_
#define _DYLD_IMAGES_
#include
#include
#include
#include
#if defined(__cplusplus) && (BUILDING_LIBDYLD || BUILDING_DYLD)
#include
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Beginning in Mac OS X 10.4, this is how gdb discovers which mach-o images are loaded in a process.
*
* gdb looks for the symbol "_dyld_all_image_infos" in dyld. It contains the fields below.
*
* For a snashot of what images are currently loaded, the infoArray fields contain a pointer
* to an array of all images. If infoArray is NULL, it means it is being modified, come back later.
*
* To be notified of changes, gdb sets a break point on the address pointed to by the notificationn
* field. The function it points to is called by dyld with an array of information about what images
* have been added (dyld_image_adding) or are about to be removed (dyld_image_removing).
*
* The notification is called after infoArray is updated. This means that if gdb attaches to a process
* and infoArray is NULL, gdb can set a break point on notification and let the proccess continue to
* run until the break point. Then gdb can inspect the full infoArray.
*
* The dyldVersion field always points to a C string that contains the dyld version. For instance,
* in dyld-127.3, dyldVersion would contain a pointer to "127.3".
*
* The errorMessage and terminationFlags fields are normally zero. If dyld terminates a process
* (for instance because a required dylib or symbol is missing), then the errorMessage field will
* be set to point to a C string message buffer containing the reason dyld terminate the process.
* The low bit of the terminationFlags will be set if dyld terminated the process before any user
* code ran, in which case there is no need for the crash log to contain the backtrace.
*
* When dyld terminates a process because some required dylib or symbol cannot be bound, in
* addition to the errorMessage field, it now sets the errorKind field and the corresponding
* fields: errorClientOfDylibPath, errorTargetDylibPath, errorSymbol.
*
*/
enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1, dyld_image_info_change=2 };
struct dyld_image_info {
const struct mach_header* imageLoadAddress; /* base address image is mapped into */
const char* imageFilePath; /* path dyld used to load the image */
uintptr_t imageFileModDate; /* time_t of image file */
/* if stat().st_mtime of imageFilePath does not match imageFileModDate, */
/* then file has been modified since dyld loaded it */
};
struct dyld_uuid_info {
const struct mach_header* imageLoadAddress; /* base address image is mapped into */
uuid_t imageUUID; /* UUID of image */
};
#define DYLD_AOT_IMAGE_KEY_SIZE 32
struct dyld_aot_image_info {
const struct mach_header* x86LoadAddress;
const struct mach_header* aotLoadAddress;
uint64_t aotImageSize;
uint8_t aotImageKey[DYLD_AOT_IMAGE_KEY_SIZE]; // uniquely identifying SHA-256 key for this aot
};
struct dyld_aot_shared_cache_info {
const uintptr_t cacheBaseAddress;
uuid_t cacheUUID;
};
typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]);
/* for use in dyld_all_image_infos.errorKind field */
enum { dyld_error_kind_none=0,
dyld_error_kind_dylib_missing=1,
dyld_error_kind_dylib_wrong_arch=2,
dyld_error_kind_dylib_version=3,
dyld_error_kind_symbol_missing=4
};
/* internal limit */
#define DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT 8
struct dyld_all_image_infos {
uint32_t version; /* 1 in Mac OS X 10.4 and 10.5 */
uint32_t infoArrayCount;
#if defined(__cplusplus) && (BUILDING_LIBDYLD || BUILDING_DYLD)
std::atomic infoArray;
#else
const struct dyld_image_info* infoArray;
#endif
dyld_image_notifier notification;
bool processDetachedFromSharedRegion;
/* the following fields are only in version 2 (Mac OS X 10.6, iPhoneOS 2.0) and later */
bool libSystemInitialized;
const struct mach_header* dyldImageLoadAddress;
/* the following field is only in version 3 (Mac OS X 10.6, iPhoneOS 3.0) and later */
void* jitInfo;
/* the following fields are only in version 5 (Mac OS X 10.6, iPhoneOS 3.0) and later */
const char* dyldVersion;
const char* errorMessage;
uintptr_t terminationFlags;
/* the following field is only in version 6 (Mac OS X 10.6, iPhoneOS 3.1) and later */
void* coreSymbolicationShmPage;
/* the following field is only in version 7 (Mac OS X 10.6, iPhoneOS 3.1) and later */
uintptr_t systemOrderFlag;
/* the following field is only in version 8 (Mac OS X 10.7, iPhoneOS 3.1) and later */
uintptr_t uuidArrayCount;
const struct dyld_uuid_info* uuidArray; /* only images not in dyld shared cache */
/* the following field is only in version 9 (Mac OS X 10.7, iOS 4.0) and later */
struct dyld_all_image_infos* dyldAllImageInfosAddress;
/* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */
uintptr_t initialImageCount;
/* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */
uintptr_t errorKind;
const char* errorClientOfDylibPath;
const char* errorTargetDylibPath;
const char* errorSymbol;
/* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */
uintptr_t sharedCacheSlide;
/* the following field is only in version 13 (Mac OS X 10.9, iOS 7.0) and later */
uint8_t sharedCacheUUID[16];
/* the following field is only in version 15 (macOS 10.12, iOS 10.0) and later */
uintptr_t sharedCacheBaseAddress;
#if defined(__cplusplus) && (BUILDING_LIBDYLD || BUILDING_DYLD)
// We want this to be atomic in libdyld so that we can see updates when we map it shared
std::atomic infoArrayChangeTimestamp;
#else
uint64_t infoArrayChangeTimestamp;
#endif
const char* dyldPath;
mach_port_t notifyPorts[DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
#if __LP64__
uintptr_t reserved[11-(DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT/2)];
#else
uintptr_t reserved[9-DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
#endif
// The following fields were added in version 18 (previously they were reserved padding fields)
uint64_t sharedCacheFSID;
uint64_t sharedCacheFSObjID;
/* the following field is only in version 16 (macOS 10.13, iOS 11.0) and later */
uintptr_t compact_dyld_image_info_addr;
size_t compact_dyld_image_info_size;
uint32_t platform; // FIXME: really a dyld_platform_t, but those aren't exposed here.
/* the following field is only in version 17 (macOS 10.16) and later */
uint32_t aotInfoCount;
const struct dyld_aot_image_info* aotInfoArray;
uint64_t aotInfoArrayChangeTimestamp;
uintptr_t aotSharedCacheBaseAddress;
uint8_t aotSharedCacheUUID[16];
};
/*
* Beginning in Mac OS X 10.5, this is how gdb discovers where the shared cache is in a process.
* Images that are in the shared cache have their segments rearranged, so when using imageFilePath
* to load the file from disk, you have to know to adjust addresses based on how their segment
* was rearranged.
*
* gdb looks for the symbol "_dyld_shared_region_ranges" in dyld.
*
* It contains information the count of shared regions used by the process. The count is
* the number of start/length pairs.
*/
struct dyld_shared_cache_ranges {
uintptr_t sharedRegionsCount; /* how many ranges follow */
struct {
uintptr_t start;
uintptr_t length;
} ranges[4]; /* max regions */
};
extern struct dyld_shared_cache_ranges dyld_shared_cache_ranges __attribute__((visibility("hidden")));
#ifdef __cplusplus
}
#endif
#endif /* _DYLD_IMAGES_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/fat.h
================================================
/*
* Copyright (c) 2016 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_FAT_H_
#define _MACH_O_FAT_H_
/*
* This header file describes the structures of the file format for "fat"
* architecture specific file (wrapper design). At the begining of the file
* there is one fat_header structure followed by a number of fat_arch
* structures. For each architecture in the file, specified by a pair of
* cputype and cpusubtype, the fat_header describes the file offset, file
* size and alignment in the file of the architecture specific member.
* The padded bytes in the file to place each member on it's specific alignment
* are defined to be read as zeros and can be left as "holes" if the file system
* can support them as long as they read as zeros.
*
* All structures defined here are always written and read to/from disk
* in big-endian order.
*/
/*
* is needed here for the cpu_type_t and cpu_subtype_t types
* and contains the constants for the possible values of these types.
*/
#include
#include
#include
#define FAT_MAGIC 0xcafebabe
#define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */
struct fat_header {
uint32_t magic; /* FAT_MAGIC or FAT_MAGIC_64 */
uint32_t nfat_arch; /* number of structs that follow */
};
struct fat_arch {
cpu_type_t cputype; /* cpu specifier (int) */
cpu_subtype_t cpusubtype; /* machine specifier (int) */
uint32_t offset; /* file offset to this object file */
uint32_t size; /* size of this object file */
uint32_t align; /* alignment as a power of 2 */
};
/*
* The support for the 64-bit fat file format described here is a work in
* progress and not yet fully supported in all the Apple Developer Tools.
*
* When a slice is greater than 4mb or an offset to a slice is greater than 4mb
* then the 64-bit fat file format is used.
*/
#define FAT_MAGIC_64 0xcafebabf
#define FAT_CIGAM_64 0xbfbafeca /* NXSwapLong(FAT_MAGIC_64) */
struct fat_arch_64 {
cpu_type_t cputype; /* cpu specifier (int) */
cpu_subtype_t cpusubtype; /* machine specifier (int) */
uint64_t offset; /* file offset to this object file */
uint64_t size; /* size of this object file */
uint32_t align; /* alignment as a power of 2 */
uint32_t reserved; /* reserved */
};
#endif /* _MACH_O_FAT_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/fixup-chains.h
================================================
/* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __MACH_O_FIXUP_CHAINS__
#define __MACH_O_FIXUP_CHAINS__ 6
#include
//#define LC_DYLD_EXPORTS_TRIE 0x80000033 // used with linkedit_data_command
//#define LC_DYLD_CHAINED_FIXUPS 0x80000034 // used with linkedit_data_command, payload is dyld_chained_fixups_header
// header of the LC_DYLD_CHAINED_FIXUPS payload
struct dyld_chained_fixups_header
{
uint32_t fixups_version; // 0
uint32_t starts_offset; // offset of dyld_chained_starts_in_image in chain_data
uint32_t imports_offset; // offset of imports table in chain_data
uint32_t symbols_offset; // offset of symbol strings in chain_data
uint32_t imports_count; // number of imported symbol names
uint32_t imports_format; // DYLD_CHAINED_IMPORT*
uint32_t symbols_format; // 0 => uncompressed, 1 => zlib compressed
};
// This struct is embedded in LC_DYLD_CHAINED_FIXUPS payload
struct dyld_chained_starts_in_image
{
uint32_t seg_count;
uint32_t seg_info_offset[1]; // each entry is offset into this struct for that segment
// followed by pool of dyld_chain_starts_in_segment data
};
// This struct is embedded in dyld_chain_starts_in_image
// and passed down to the kernel for page-in linking
struct dyld_chained_starts_in_segment
{
uint32_t size; // size of this (amount kernel needs to copy)
uint16_t page_size; // 0x1000 or 0x4000
uint16_t pointer_format; // DYLD_CHAINED_PTR_*
uint64_t segment_offset; // offset in memory to start of segment
uint32_t max_valid_pointer; // for 32-bit OS, any value beyond this is not a pointer
uint16_t page_count; // how many pages are in array
uint16_t page_start[1]; // each entry is offset in each page of first element in chain
// or DYLD_CHAINED_PTR_START_NONE if no fixups on page
// uint16_t chain_starts[1]; // some 32-bit formats may require multiple starts per page.
// for those, if high bit is set in page_starts[], then it
// is index into chain_starts[] which is a list of starts
// the last of which has the high bit set
};
enum {
DYLD_CHAINED_PTR_START_NONE = 0xFFFF, // used in page_start[] to denote a page with no fixups
DYLD_CHAINED_PTR_START_MULTI = 0x8000, // used in page_start[] to denote a page which has multiple starts
DYLD_CHAINED_PTR_START_LAST = 0x8000, // used in chain_starts[] to denote last start in list for page
};
// This struct is embedded in __TEXT,__chain_starts section in firmware
struct dyld_chained_starts_offsets
{
uint32_t pointer_format; // DYLD_CHAINED_PTR_32_FIRMWARE
uint32_t starts_count; // number of starts in array
uint32_t chain_starts[1]; // array chain start offsets
};
// values for dyld_chained_starts_in_segment.pointer_format
enum {
DYLD_CHAINED_PTR_ARM64E = 1, // stride 8, unauth target is vmaddr
DYLD_CHAINED_PTR_64 = 2, // target is vmaddr
DYLD_CHAINED_PTR_32 = 3,
DYLD_CHAINED_PTR_32_CACHE = 4,
DYLD_CHAINED_PTR_32_FIRMWARE = 5,
DYLD_CHAINED_PTR_64_OFFSET = 6, // target is vm offset
DYLD_CHAINED_PTR_ARM64E_OFFSET = 7, // old name
DYLD_CHAINED_PTR_ARM64E_KERNEL = 7, // stride 4, unauth target is vm offset
DYLD_CHAINED_PTR_64_KERNEL_CACHE = 8,
DYLD_CHAINED_PTR_ARM64E_USERLAND = 9, // stride 8, unauth target is vm offset
DYLD_CHAINED_PTR_ARM64E_FIRMWARE = 10, // stride 4, unauth target is vmaddr
DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE = 11, // stride 1, x86_64 kernel caches
DYLD_CHAINED_PTR_ARM64E_USERLAND24 = 12, // stride 8, unauth target is vm offset, 24-bit bind
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_rebase
{
uint64_t target : 43,
high8 : 8,
next : 11, // 4 or 8-byte stide
bind : 1, // == 0
auth : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_bind
{
uint64_t ordinal : 16,
zero : 16,
addend : 19, // +/-256K
next : 11, // 4 or 8-byte stide
bind : 1, // == 1
auth : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_auth_rebase
{
uint64_t target : 32, // runtimeOffset
diversity : 16,
addrDiv : 1,
key : 2,
next : 11, // 4 or 8-byte stide
bind : 1, // == 0
auth : 1; // == 1
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_auth_bind
{
uint64_t ordinal : 16,
zero : 16,
diversity : 16,
addrDiv : 1,
key : 2,
next : 11, // 4 or 8-byte stide
bind : 1, // == 1
auth : 1; // == 1
};
// DYLD_CHAINED_PTR_64/DYLD_CHAINED_PTR_64_OFFSET
struct dyld_chained_ptr_64_rebase
{
uint64_t target : 36, // 64GB max image size (DYLD_CHAINED_PTR_64 => vmAddr, DYLD_CHAINED_PTR_64_OFFSET => runtimeOffset)
high8 : 8, // top 8 bits set to this (DYLD_CHAINED_PTR_64 => after slide added, DYLD_CHAINED_PTR_64_OFFSET => before slide added)
reserved : 7, // all zeros
next : 12, // 4-byte stride
bind : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E_USERLAND24
struct dyld_chained_ptr_arm64e_bind24
{
uint64_t ordinal : 24,
zero : 8,
addend : 19, // +/-256K
next : 11, // 8-byte stide
bind : 1, // == 1
auth : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E_USERLAND24
struct dyld_chained_ptr_arm64e_auth_bind24
{
uint64_t ordinal : 24,
zero : 8,
diversity : 16,
addrDiv : 1,
key : 2,
next : 11, // 8-byte stide
bind : 1, // == 1
auth : 1; // == 1
};
// DYLD_CHAINED_PTR_64
struct dyld_chained_ptr_64_bind
{
uint64_t ordinal : 24,
addend : 8, // 0 thru 255
reserved : 19, // all zeros
next : 12, // 4-byte stride
bind : 1; // == 1
};
// DYLD_CHAINED_PTR_64_KERNEL_CACHE, DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE
struct dyld_chained_ptr_64_kernel_cache_rebase
{
uint64_t target : 30, // basePointers[cacheLevel] + target
cacheLevel : 2, // what level of cache to bind to (indexes a mach_header array)
diversity : 16,
addrDiv : 1,
key : 2,
next : 12, // 1 or 4-byte stide
isAuth : 1; // 0 -> not authenticated. 1 -> authenticated
};
// DYLD_CHAINED_PTR_32
// Note: for DYLD_CHAINED_PTR_32 some non-pointer values are co-opted into the chain
// as out of range rebases. If an entry in the chain is > max_valid_pointer, then it
// is not a pointer. To restore the value, subtract off the bias, which is
// (64MB+max_valid_pointer)/2.
struct dyld_chained_ptr_32_rebase
{
uint32_t target : 26, // vmaddr, 64MB max image size
next : 5, // 4-byte stride
bind : 1; // == 0
};
// DYLD_CHAINED_PTR_32
struct dyld_chained_ptr_32_bind
{
uint32_t ordinal : 20,
addend : 6, // 0 thru 63
next : 5, // 4-byte stride
bind : 1; // == 1
};
// DYLD_CHAINED_PTR_32_CACHE
struct dyld_chained_ptr_32_cache_rebase
{
uint32_t target : 30, // 1GB max dyld cache TEXT and DATA
next : 2; // 4-byte stride
};
// DYLD_CHAINED_PTR_32_FIRMWARE
struct dyld_chained_ptr_32_firmware_rebase
{
uint32_t target : 26, // 64MB max firmware TEXT and DATA
next : 6; // 4-byte stride
};
// values for dyld_chained_fixups_header.imports_format
enum {
DYLD_CHAINED_IMPORT = 1,
DYLD_CHAINED_IMPORT_ADDEND = 2,
DYLD_CHAINED_IMPORT_ADDEND64 = 3,
};
// DYLD_CHAINED_IMPORT
struct dyld_chained_import
{
uint32_t lib_ordinal : 8,
weak_import : 1,
name_offset : 23;
};
// DYLD_CHAINED_IMPORT_ADDEND
struct dyld_chained_import_addend
{
uint32_t lib_ordinal : 8,
weak_import : 1,
name_offset : 23;
int32_t addend;
};
// DYLD_CHAINED_IMPORT_ADDEND64
struct dyld_chained_import_addend64
{
uint64_t lib_ordinal : 16,
weak_import : 1,
reserved : 15,
name_offset : 32;
uint64_t addend;
};
#endif // __MACH_O_FIXUP_CHAINS__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/getsect.h
================================================
/*
* Copyright (c) 2004 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 _MACH_O_GETSECT_H_
#define _MACH_O_GETSECT_H_
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Runtime interfaces for Mach-O programs. For both 32-bit and 64-bit programs,
* where the sizes returned will be 32-bit or 64-bit based on the size of
* 'unsigned long'.
*/
extern char *getsectdata(
const char *segname,
const char *sectname,
unsigned long *size);
extern char *getsectdatafromFramework(
const char *FrameworkName,
const char *segname,
const char *sectname,
unsigned long *size);
extern unsigned long get_end(void);
extern unsigned long get_etext(void);
extern unsigned long get_edata(void);
#ifndef __LP64__
/*
* Runtime interfaces for 32-bit Mach-O programs.
*/
extern const struct section *getsectbyname(
const char *segname,
const char *sectname);
extern uint8_t *getsectiondata(
const struct mach_header *mhp,
const char *segname,
const char *sectname,
unsigned long *size);
extern const struct segment_command *getsegbyname(
const char *segname);
extern uint8_t *getsegmentdata(
const struct mach_header *mhp,
const char *segname,
unsigned long *size);
#else /* defined(__LP64__) */
/*
* Runtime interfaces for 64-bit Mach-O programs.
*/
extern const struct section_64 *getsectbyname(
const char *segname,
const char *sectname);
extern uint8_t *getsectiondata(
const struct mach_header_64 *mhp,
const char *segname,
const char *sectname,
unsigned long *size);
extern const struct segment_command_64 *getsegbyname(
const char *segname);
extern uint8_t *getsegmentdata(
const struct mach_header_64 *mhp,
const char *segname,
unsigned long *size);
#endif /* defined(__LP64__) */
/*
* Interfaces for tools working with 32-bit Mach-O files.
*/
extern char *getsectdatafromheader(
const struct mach_header *mhp,
const char *segname,
const char *sectname,
uint32_t *size);
extern const struct section *getsectbynamefromheader(
const struct mach_header *mhp,
const char *segname,
const char *sectname);
extern const struct section *getsectbynamefromheaderwithswap(
struct mach_header *mhp,
const char *segname,
const char *sectname,
int fSwap);
/*
* Interfaces for tools working with 64-bit Mach-O files.
*/
extern char *getsectdatafromheader_64(
const struct mach_header_64 *mhp,
const char *segname,
const char *sectname,
uint64_t *size);
extern const struct section_64 *getsectbynamefromheader_64(
const struct mach_header_64 *mhp,
const char *segname,
const char *sectname);
extern const struct section *getsectbynamefromheaderwithswap_64(
struct mach_header_64 *mhp,
const char *segname,
const char *sectname,
int fSwap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_GETSECT_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/i386/swap.h
================================================
/*
* Copyright (c) 1999 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@
*/
#include
#include
struct i386_float_state;
extern void swap_i386_thread_state(
i386_thread_state_t *cpu,
enum NXByteOrder target_byte_order);
/* current i386 thread states */
#if i386_THREAD_STATE == 1
extern void swap_i386_float_state(
struct i386_float_state *fpu,
enum NXByteOrder target_byte_order);
extern void swap_i386_exception_state(
i386_exception_state_t *exc,
enum NXByteOrder target_byte_order);
#endif /* i386_THREAD_STATE == 1 */
/* i386 thread states on older releases */
#if i386_THREAD_STATE == -1
extern void swap_i386_thread_fpstate(
i386_thread_fpstate_t *fpu,
enum NXByteOrder target_byte_order);
extern void swap_i386_thread_exceptstate(
i386_thread_exceptstate_t *exc,
enum NXByteOrder target_byte_order);
extern void swap_i386_thread_cthreadstate(
i386_thread_cthreadstate_t *user,
enum NXByteOrder target_byte_order);
#endif /* i386_THREAD_STATE == -1 */
#ifdef x86_THREAD_STATE64
extern void swap_x86_thread_state64(
x86_thread_state64_t *cpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_state_hdr(
x86_state_hdr_t *hdr,
enum NXByteOrder target_byte_order);
extern void swap_x86_float_state64(
x86_float_state64_t *fpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_exception_state64(
x86_exception_state64_t *exc,
enum NXByteOrder target_byte_order);
extern void swap_x86_thread_state(
x86_thread_state_t *cpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_float_state(
x86_float_state_t *fpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_exception_state(
x86_exception_state_t *exc,
enum NXByteOrder target_byte_order);
extern void swap_x86_debug_state32(
x86_debug_state32_t *debug,
enum NXByteOrder target_byte_order);
extern void swap_x86_debug_state64(
x86_debug_state64_t *debug,
enum NXByteOrder target_byte_order);
extern void swap_x86_debug_state(
x86_debug_state_t *debug,
enum NXByteOrder target_byte_order);
#endif /* x86_THREAD_STATE64 */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/ldsyms.h
================================================
/*
* Copyright (c) 1999 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 _MACHO_LDSYMS_H_
#define _MACHO_LDSYMS_H_
#include
/*
* This file describes the link editor defined symbols. The semantics of a
* link editor symbol is that it is defined by the link editor only if it is
* referenced and it is an error for the user to define them (see the man page
* ld(1)). The standard UNIX link editor symbols: __end, __etext and __edata
* are not not supported by the Apple Mach-O link editor. These symbols are
* really not meaningful in a Mach-O object file and the link editor symbols
* that are supported (described here) replace them. In the case of the
* standard UNIX link editor symbols the program can use the symbol
* __mh_execute_header and walk the load commands of it's program to determine
* the ending (or beginning) of any section or segment in the program. Note
* that the compiler prepends an underbar to all external symbol names coded
* in a high level language. Thus in 'C' names are coded without an underbar
* and symbol names in the symbol table have an underbar. There are two cpp
* macros for each link editor defined name in this file. The macro with a
* leading underbar is the symbol name and the one without is the name as
* coded in 'C'.
*/
/*
* The value of the link editor defined symbol _MH_EXECUTE_SYM is the address
* of the mach header in a Mach-O executable file type. It does not appear in
* any file type other than a MH_EXECUTE file type. The type of the symbol is
* absolute as the header is not part of any section.
*/
#define _MH_EXECUTE_SYM "__mh_execute_header"
#define MH_EXECUTE_SYM "_mh_execute_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_execute_header;
/*
* The value of the link editor defined symbol _MH_BUNDLE_SYM is the address
* of the mach header in a Mach-O bundle file type. It does not appear in
* any file type other than a MH_BUNDLE file type. The type of the symbol is
* an N_SECT symbol even thought the header is not part of any section. This
* symbol is private to the code in the bundle it is a part of.
*/
#define _MH_BUNDLE_SYM "__mh_bundle_header"
#define MH_BUNDLE_SYM "_mh_bundle_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_bundle_header;
/*
* The value of the link editor defined symbol _MH_DYLIB_SYM is the address
* of the mach header in a Mach-O dylib file type. It does not appear in
* any file type other than a MH_DYLIB file type. The type of the symbol is
* an N_SECT symbol even thought the header is not part of any section. This
* symbol is private to the code in the library it is a part of.
*/
#define _MH_DYLIB_SYM "__mh_dylib_header"
#define MH_DYLIB_SYM "_mh_dylib_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_dylib_header;
/*
* The value of the link editor defined symbol _MH_DYLINKER_SYM is the address
* of the mach header in a Mach-O dylinker file type. It does not appear in
* any file type other than a MH_DYLINKER file type. The type of the symbol is
* an N_SECT symbol even thought the header is not part of any section. This
* symbol is private to the code in the dynamic linker it is a part of.
*/
#define _MH_DYLINKER_SYM "__mh_dylinker_header"
#define MH_DYLINKER_SYM "_mh_dylinker_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_dylinker_header;
/*
* For the MH_PRELOAD file type the headers are not loaded as part of any
* segment so the link editor defines symbols defined for the beginning
* and ending of each segment and each section in each segment. The names for
* the symbols for a segment's beginning and end will have the form:
* __SEGNAME__begin and __SEGNAME__end where __SEGNAME is the name of the
* segment. The names for the symbols for a section's beginning and end will
* have the form: __SEGNAME__sectname__begin and __SEGNAME__sectname__end
* where __sectname is the name of the section and __SEGNAME is the segment it
* is in.
*
* The above symbols' types are those of the section they are referring to.
* This is true even for symbols who's values are end's of a section and
* that value is next address after that section and not really in that
* section. This results in these symbols having types referring to sections
* who's values are not in that section.
*/
#endif /* _MACHO_LDSYMS_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/loader.h
================================================
/*
* Copyright (c) 1999-2010 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_LOADER_H_
#define _MACHO_LOADER_H_
/*
* This file describes the format of mach object files.
*/
#include
/*
* is needed here for the cpu_type_t and cpu_subtype_t types
* and contains the constants for the possible values of these types.
*/
#include
/*
* is needed here for the vm_prot_t type and contains the
* constants that are or'ed together for the possible values of this type.
*/
#include
/*
* is expected to define the flavors of the thread
* states and the structures of those flavors for each machine.
*/
#include
#include
/*
* The 32-bit mach header appears at the very beginning of the object file for
* 32-bit architectures.
*/
struct mach_header {
uint32_t magic; /* mach magic number identifier */
cpu_type_t cputype; /* cpu specifier */
cpu_subtype_t cpusubtype; /* machine specifier */
uint32_t filetype; /* type of file */
uint32_t ncmds; /* number of load commands */
uint32_t sizeofcmds; /* the size of all the load commands */
uint32_t flags; /* flags */
};
/* Constant for the magic field of the mach_header (32-bit architectures) */
#define MH_MAGIC 0xfeedface /* the mach magic number */
#define MH_CIGAM 0xcefaedfe /* NXSwapInt(MH_MAGIC) */
/*
* The 64-bit mach header appears at the very beginning of object files for
* 64-bit architectures.
*/
struct mach_header_64 {
uint32_t magic; /* mach magic number identifier */
cpu_type_t cputype; /* cpu specifier */
cpu_subtype_t cpusubtype; /* machine specifier */
uint32_t filetype; /* type of file */
uint32_t ncmds; /* number of load commands */
uint32_t sizeofcmds; /* the size of all the load commands */
uint32_t flags; /* flags */
uint32_t reserved; /* reserved */
};
/* Constant for the magic field of the mach_header_64 (64-bit architectures) */
#define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */
#define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */
/*
* The layout of the file depends on the filetype. For all but the MH_OBJECT
* file type the segments are padded out and aligned on a segment alignment
* boundary for efficient demand pageing. The MH_EXECUTE, MH_FVMLIB, MH_DYLIB,
* MH_DYLINKER and MH_BUNDLE file types also have the headers included as part
* of their first segment.
*
* The file type MH_OBJECT is a compact format intended as output of the
* assembler and input (and possibly output) of the link editor (the .o
* format). All sections are in one unnamed segment with no segment padding.
* This format is used as an executable format when the file is so small the
* segment padding greatly increases its size.
*
* The file type MH_PRELOAD is an executable format intended for things that
* are not executed under the kernel (proms, stand alones, kernels, etc). The
* format can be executed under the kernel but may demand paged it and not
* preload it before execution.
*
* A core file is in MH_CORE format and can be any in an arbritray legal
* Mach-O file.
*
* Constants for the filetype field of the mach_header
*/
#define MH_OBJECT 0x1 /* relocatable object file */
#define MH_EXECUTE 0x2 /* demand paged executable file */
#define MH_FVMLIB 0x3 /* fixed VM shared library file */
#define MH_CORE 0x4 /* core file */
#define MH_PRELOAD 0x5 /* preloaded executable file */
#define MH_DYLIB 0x6 /* dynamically bound shared library */
#define MH_DYLINKER 0x7 /* dynamic link editor */
#define MH_BUNDLE 0x8 /* dynamically bound bundle file */
#define MH_DYLIB_STUB 0x9 /* shared library stub for static
linking only, no section contents */
#define MH_DSYM 0xa /* companion file with only debug
sections */
#define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */
#define MH_FILESET 0xc /* a file composed of other Mach-Os to
be run in the same userspace sharing
a single linkedit. */
/* Constants for the flags field of the mach_header */
#define MH_NOUNDEFS 0x1 /* the object file has no undefined
references */
#define MH_INCRLINK 0x2 /* the object file is the output of an
incremental link against a base file
and can't be link edited again */
#define MH_DYLDLINK 0x4 /* the object file is input for the
dynamic linker and can't be staticly
link edited again */
#define MH_BINDATLOAD 0x8 /* the object file's undefined
references are bound by the dynamic
linker when loaded. */
#define MH_PREBOUND 0x10 /* the file has its dynamic undefined
references prebound. */
#define MH_SPLIT_SEGS 0x20 /* the file has its read-only and
read-write segments split */
#define MH_LAZY_INIT 0x40 /* the shared library init routine is
to be run lazily via catching memory
faults to its writeable segments
(obsolete) */
#define MH_TWOLEVEL 0x80 /* the image is using two-level name
space bindings */
#define MH_FORCE_FLAT 0x100 /* the executable is forcing all images
to use flat name space bindings */
#define MH_NOMULTIDEFS 0x200 /* this umbrella guarantees no multiple
defintions of symbols in its
sub-images so the two-level namespace
hints can always be used. */
#define MH_NOFIXPREBINDING 0x400 /* do not have dyld notify the
prebinding agent about this
executable */
#define MH_PREBINDABLE 0x800 /* the binary is not prebound but can
have its prebinding redone. only used
when MH_PREBOUND is not set. */
#define MH_ALLMODSBOUND 0x1000 /* indicates that this binary binds to
all two-level namespace modules of
its dependent libraries. only used
when MH_PREBINDABLE and MH_TWOLEVEL
are both set. */
#define MH_SUBSECTIONS_VIA_SYMBOLS 0x2000/* safe to divide up the sections into
sub-sections via symbols for dead
code stripping */
#define MH_CANONICAL 0x4000 /* the binary has been canonicalized
via the unprebind operation */
#define MH_WEAK_DEFINES 0x8000 /* the final linked image contains
external weak symbols */
#define MH_BINDS_TO_WEAK 0x10000 /* the final linked image uses
weak symbols */
#define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks
in the task will be given stack
execution privilege. Only used in
MH_EXECUTE filetypes. */
#define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary
declares it is safe for use in
processes with uid zero */
#define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary
declares it is safe for use in
processes when issetugid() is true */
#define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib,
the static linker does not need to
examine dependent dylibs to see
if any are re-exported */
#define MH_PIE 0x200000 /* When this bit is set, the OS will
load the main executable at a
random address. Only used in
MH_EXECUTE filetypes. */
#define MH_DEAD_STRIPPABLE_DYLIB 0x400000 /* Only for use on dylibs. When
linking against a dylib that
has this bit set, the static linker
will automatically not create a
LC_LOAD_DYLIB load command to the
dylib if no symbols are being
referenced from the dylib. */
#define MH_HAS_TLV_DESCRIPTORS 0x800000 /* Contains a section of type
S_THREAD_LOCAL_VARIABLES */
#define MH_NO_HEAP_EXECUTION 0x1000000 /* When this bit is set, the OS will
run the main executable with
a non-executable heap even on
platforms (e.g. i386) that don't
require it. Only used in MH_EXECUTE
filetypes. */
#define MH_APP_EXTENSION_SAFE 0x02000000 /* The code was linked for use in an
application extension. */
#define MH_NLIST_OUTOFSYNC_WITH_DYLDINFO 0x04000000 /* The external symbols
listed in the nlist symbol table do
not include all the symbols listed in
the dyld info. */
#define MH_SIM_SUPPORT 0x08000000 /* Allow LC_MIN_VERSION_MACOS and
LC_BUILD_VERSION load commands with
the platforms macOS, macCatalyst,
iOSSimulator, tvOSSimulator and
watchOSSimulator. */
#define MH_DYLIB_IN_CACHE 0x80000000 /* Only for use on dylibs. When this bit
is set, the dylib is part of the dyld
shared cache, rather than loose in
the filesystem. */
/*
* The load commands directly follow the mach_header. The total size of all
* of the commands is given by the sizeofcmds field in the mach_header. All
* load commands must have as their first two fields cmd and cmdsize. The cmd
* field is filled in with a constant for that command type. Each command type
* has a structure specifically for it. The cmdsize field is the size in bytes
* of the particular load command structure plus anything that follows it that
* is a part of the load command (i.e. section structures, strings, etc.). To
* advance to the next load command the cmdsize can be added to the offset or
* pointer of the current load command. The cmdsize for 32-bit architectures
* MUST be a multiple of 4 bytes and for 64-bit architectures MUST be a multiple
* of 8 bytes (these are forever the maximum alignment of any load commands).
* The padded bytes must be zero. All tables in the object file must also
* follow these rules so the file can be memory mapped. Otherwise the pointers
* to these tables will not work well or at all on some machines. With all
* padding zeroed like objects will compare byte for byte.
*/
struct load_command {
uint32_t cmd; /* type of load command */
uint32_t cmdsize; /* total size of command in bytes */
};
/*
* After MacOS X 10.1 when a new load command is added that is required to be
* understood by the dynamic linker for the image to execute properly the
* LC_REQ_DYLD bit will be or'ed into the load command constant. If the dynamic
* linker sees such a load command it it does not understand will issue a
* "unknown load command required for execution" error and refuse to use the
* image. Other load commands without this bit that are not understood will
* simply be ignored.
*/
#define LC_REQ_DYLD 0x80000000
/* Constants for the cmd field of all load commands, the type */
#define LC_SEGMENT 0x1 /* segment of this file to be mapped */
#define LC_SYMTAB 0x2 /* link-edit stab symbol table info */
#define LC_SYMSEG 0x3 /* link-edit gdb symbol table info (obsolete) */
#define LC_THREAD 0x4 /* thread */
#define LC_UNIXTHREAD 0x5 /* unix thread (includes a stack) */
#define LC_LOADFVMLIB 0x6 /* load a specified fixed VM shared library */
#define LC_IDFVMLIB 0x7 /* fixed VM shared library identification */
#define LC_IDENT 0x8 /* object identification info (obsolete) */
#define LC_FVMFILE 0x9 /* fixed VM file inclusion (internal use) */
#define LC_PREPAGE 0xa /* prepage command (internal use) */
#define LC_DYSYMTAB 0xb /* dynamic link-edit symbol table info */
#define LC_LOAD_DYLIB 0xc /* load a dynamically linked shared library */
#define LC_ID_DYLIB 0xd /* dynamically linked shared lib ident */
#define LC_LOAD_DYLINKER 0xe /* load a dynamic linker */
#define LC_ID_DYLINKER 0xf /* dynamic linker identification */
#define LC_PREBOUND_DYLIB 0x10 /* modules prebound for a dynamically */
/* linked shared library */
#define LC_ROUTINES 0x11 /* image routines */
#define LC_SUB_FRAMEWORK 0x12 /* sub framework */
#define LC_SUB_UMBRELLA 0x13 /* sub umbrella */
#define LC_SUB_CLIENT 0x14 /* sub client */
#define LC_SUB_LIBRARY 0x15 /* sub library */
#define LC_TWOLEVEL_HINTS 0x16 /* two-level namespace lookup hints */
#define LC_PREBIND_CKSUM 0x17 /* prebind checksum */
/*
* load a dynamically linked shared library that is allowed to be missing
* (all symbols are weak imported).
*/
#define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD)
#define LC_SEGMENT_64 0x19 /* 64-bit segment of this file to be
mapped */
#define LC_ROUTINES_64 0x1a /* 64-bit image routines */
#define LC_UUID 0x1b /* the uuid */
#define LC_RPATH (0x1c | LC_REQ_DYLD) /* runpath additions */
#define LC_CODE_SIGNATURE 0x1d /* local of code signature */
#define LC_SEGMENT_SPLIT_INFO 0x1e /* local of info to split segments */
#define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */
#define LC_LAZY_LOAD_DYLIB 0x20 /* delay load of dylib until first use */
#define LC_ENCRYPTION_INFO 0x21 /* encrypted segment information */
#define LC_DYLD_INFO 0x22 /* compressed dyld information */
#define LC_DYLD_INFO_ONLY (0x22|LC_REQ_DYLD) /* compressed dyld information only */
#define LC_LOAD_UPWARD_DYLIB (0x23 | LC_REQ_DYLD) /* load upward dylib */
#define LC_VERSION_MIN_MACOSX 0x24 /* build for MacOSX min OS version */
#define LC_VERSION_MIN_IPHONEOS 0x25 /* build for iPhoneOS min OS version */
#define LC_FUNCTION_STARTS 0x26 /* compressed table of function start addresses */
#define LC_DYLD_ENVIRONMENT 0x27 /* string for dyld to treat
like environment variable */
#define LC_MAIN (0x28|LC_REQ_DYLD) /* replacement for LC_UNIXTHREAD */
#define LC_DATA_IN_CODE 0x29 /* table of non-instructions in __text */
#define LC_SOURCE_VERSION 0x2A /* source version used to build binary */
#define LC_DYLIB_CODE_SIGN_DRS 0x2B /* Code signing DRs copied from linked dylibs */
#define LC_ENCRYPTION_INFO_64 0x2C /* 64-bit encrypted segment information */
#define LC_LINKER_OPTION 0x2D /* linker options in MH_OBJECT files */
#define LC_LINKER_OPTIMIZATION_HINT 0x2E /* optimization hints in MH_OBJECT files */
#define LC_VERSION_MIN_TVOS 0x2F /* build for AppleTV min OS version */
#define LC_VERSION_MIN_WATCHOS 0x30 /* build for Watch min OS version */
#define LC_NOTE 0x31 /* arbitrary data included within a Mach-O file */
#define LC_BUILD_VERSION 0x32 /* build for platform min OS version */
#define LC_DYLD_EXPORTS_TRIE (0x33 | LC_REQ_DYLD) /* used with linkedit_data_command, payload is trie */
#define LC_DYLD_CHAINED_FIXUPS (0x34 | LC_REQ_DYLD) /* used with linkedit_data_command */
#define LC_FILESET_ENTRY (0x35 | LC_REQ_DYLD) /* used with fileset_entry_command */
/*
* A variable length string in a load command is represented by an lc_str
* union. The strings are stored just after the load command structure and
* the offset is from the start of the load command structure. The size
* of the string is reflected in the cmdsize field of the load command.
* Once again any padded bytes to bring the cmdsize field to a multiple
* of 4 bytes must be zero.
*/
union lc_str {
uint32_t offset; /* offset to the string */
#ifndef __LP64__
char *ptr; /* pointer to the string */
#endif
};
/*
* The segment load command indicates that a part of this file is to be
* mapped into the task's address space. The size of this segment in memory,
* vmsize, maybe equal to or larger than the amount to map from this file,
* filesize. The file is mapped starting at fileoff to the beginning of
* the segment in memory, vmaddr. The rest of the memory of the segment,
* if any, is allocated zero fill on demand. The segment's maximum virtual
* memory protection and initial virtual memory protection are specified
* by the maxprot and initprot fields. If the segment has sections then the
* section structures directly follow the segment command and their size is
* reflected in cmdsize.
*/
struct segment_command { /* for 32-bit architectures */
uint32_t cmd; /* LC_SEGMENT */
uint32_t cmdsize; /* includes sizeof section structs */
char segname[16]; /* segment name */
uint32_t vmaddr; /* memory address of this segment */
uint32_t vmsize; /* memory size of this segment */
uint32_t fileoff; /* file offset of this segment */
uint32_t filesize; /* amount to map from the file */
vm_prot_t maxprot; /* maximum VM protection */
vm_prot_t initprot; /* initial VM protection */
uint32_t nsects; /* number of sections in segment */
uint32_t flags; /* flags */
};
/*
* The 64-bit segment load command indicates that a part of this file is to be
* mapped into a 64-bit task's address space. If the 64-bit segment has
* sections then section_64 structures directly follow the 64-bit segment
* command and their size is reflected in cmdsize.
*/
struct segment_command_64 { /* for 64-bit architectures */
uint32_t cmd; /* LC_SEGMENT_64 */
uint32_t cmdsize; /* includes sizeof section_64 structs */
char segname[16]; /* segment name */
uint64_t vmaddr; /* memory address of this segment */
uint64_t vmsize; /* memory size of this segment */
uint64_t fileoff; /* file offset of this segment */
uint64_t filesize; /* amount to map from the file */
vm_prot_t maxprot; /* maximum VM protection */
vm_prot_t initprot; /* initial VM protection */
uint32_t nsects; /* number of sections in segment */
uint32_t flags; /* flags */
};
/* Constants for the flags field of the segment_command */
#define SG_HIGHVM 0x1 /* the file contents for this segment is for
the high part of the VM space, the low part
is zero filled (for stacks in core files) */
#define SG_FVMLIB 0x2 /* this segment is the VM that is allocated by
a fixed VM library, for overlap checking in
the link editor */
#define SG_NORELOC 0x4 /* this segment has nothing that was relocated
in it and nothing relocated to it, that is
it maybe safely replaced without relocation*/
#define SG_PROTECTED_VERSION_1 0x8 /* This segment is protected. If the
segment starts at file offset 0, the
first page of the segment is not
protected. All other pages of the
segment are protected. */
#define SG_READ_ONLY 0x10 /* This segment is made read-only after fixups */
/*
* A segment is made up of zero or more sections. Non-MH_OBJECT files have
* all of their segments with the proper sections in each, and padded to the
* specified segment alignment when produced by the link editor. The first
* segment of a MH_EXECUTE and MH_FVMLIB format file contains the mach_header
* and load commands of the object file before its first section. The zero
* fill sections are always last in their segment (in all formats). This
* allows the zeroed segment padding to be mapped into memory where zero fill
* sections might be. The gigabyte zero fill sections, those with the section
* type S_GB_ZEROFILL, can only be in a segment with sections of this type.
* These segments are then placed after all other segments.
*
* The MH_OBJECT format has all of its sections in one segment for
* compactness. There is no padding to a specified segment boundary and the
* mach_header and load commands are not part of the segment.
*
* Sections with the same section name, sectname, going into the same segment,
* segname, are combined by the link editor. The resulting section is aligned
* to the maximum alignment of the combined sections and is the new section's
* alignment. The combined sections are aligned to their original alignment in
* the combined section. Any padded bytes to get the specified alignment are
* zeroed.
*
* The format of the relocation entries referenced by the reloff and nreloc
* fields of the section structure for mach object files is described in the
* header file .
*/
struct section { /* for 32-bit architectures */
char sectname[16]; /* name of this section */
char segname[16]; /* segment this section goes in */
uint32_t addr; /* memory address of this section */
uint32_t size; /* size in bytes of this section */
uint32_t offset; /* file offset of this section */
uint32_t align; /* section alignment (power of 2) */
uint32_t reloff; /* file offset of relocation entries */
uint32_t nreloc; /* number of relocation entries */
uint32_t flags; /* flags (section type and attributes)*/
uint32_t reserved1; /* reserved (for offset or index) */
uint32_t reserved2; /* reserved (for count or sizeof) */
};
struct section_64 { /* for 64-bit architectures */
char sectname[16]; /* name of this section */
char segname[16]; /* segment this section goes in */
uint64_t addr; /* memory address of this section */
uint64_t size; /* size in bytes of this section */
uint32_t offset; /* file offset of this section */
uint32_t align; /* section alignment (power of 2) */
uint32_t reloff; /* file offset of relocation entries */
uint32_t nreloc; /* number of relocation entries */
uint32_t flags; /* flags (section type and attributes)*/
uint32_t reserved1; /* reserved (for offset or index) */
uint32_t reserved2; /* reserved (for count or sizeof) */
uint32_t reserved3; /* reserved */
};
/*
* The flags field of a section structure is separated into two parts a section
* type and section attributes. The section types are mutually exclusive (it
* can only have one type) but the section attributes are not (it may have more
* than one attribute).
*/
#define SECTION_TYPE 0x000000ff /* 256 section types */
#define SECTION_ATTRIBUTES 0xffffff00 /* 24 section attributes */
/* Constants for the type of a section */
#define S_REGULAR 0x0 /* regular section */
#define S_ZEROFILL 0x1 /* zero fill on demand section */
#define S_CSTRING_LITERALS 0x2 /* section with only literal C strings*/
#define S_4BYTE_LITERALS 0x3 /* section with only 4 byte literals */
#define S_8BYTE_LITERALS 0x4 /* section with only 8 byte literals */
#define S_LITERAL_POINTERS 0x5 /* section with only pointers to */
/* literals */
/*
* For the two types of symbol pointers sections and the symbol stubs section
* they have indirect symbol table entries. For each of the entries in the
* section the indirect symbol table entries, in corresponding order in the
* indirect symbol table, start at the index stored in the reserved1 field
* of the section structure. Since the indirect symbol table entries
* correspond to the entries in the section the number of indirect symbol table
* entries is inferred from the size of the section divided by the size of the
* entries in the section. For symbol pointers sections the size of the entries
* in the section is 4 bytes and for symbol stubs sections the byte size of the
* stubs is stored in the reserved2 field of the section structure.
*/
#define S_NON_LAZY_SYMBOL_POINTERS 0x6 /* section with only non-lazy
symbol pointers */
#define S_LAZY_SYMBOL_POINTERS 0x7 /* section with only lazy symbol
pointers */
#define S_SYMBOL_STUBS 0x8 /* section with only symbol
stubs, byte size of stub in
the reserved2 field */
#define S_MOD_INIT_FUNC_POINTERS 0x9 /* section with only function
pointers for initialization*/
#define S_MOD_TERM_FUNC_POINTERS 0xa /* section with only function
pointers for termination */
#define S_COALESCED 0xb /* section contains symbols that
are to be coalesced */
#define S_GB_ZEROFILL 0xc /* zero fill on demand section
(that can be larger than 4
gigabytes) */
#define S_INTERPOSING 0xd /* section with only pairs of
function pointers for
interposing */
#define S_16BYTE_LITERALS 0xe /* section with only 16 byte
literals */
#define S_DTRACE_DOF 0xf /* section contains
DTrace Object Format */
#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 /* section with only lazy
symbol pointers to lazy
loaded dylibs */
/*
* Section types to support thread local variables
*/
#define S_THREAD_LOCAL_REGULAR 0x11 /* template of initial
values for TLVs */
#define S_THREAD_LOCAL_ZEROFILL 0x12 /* template of initial
values for TLVs */
#define S_THREAD_LOCAL_VARIABLES 0x13 /* TLV descriptors */
#define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 /* pointers to TLV
descriptors */
#define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 /* functions to call
to initialize TLV
values */
#define S_INIT_FUNC_OFFSETS 0x16 /* 32-bit offsets to
initializers */
/*
* Constants for the section attributes part of the flags field of a section
* structure.
*/
#define SECTION_ATTRIBUTES_USR 0xff000000 /* User setable attributes */
#define S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* section contains only true
machine instructions */
#define S_ATTR_NO_TOC 0x40000000 /* section contains coalesced
symbols that are not to be
in a ranlib table of
contents */
#define S_ATTR_STRIP_STATIC_SYMS 0x20000000 /* ok to strip static symbols
in this section in files
with the MH_DYLDLINK flag */
#define S_ATTR_NO_DEAD_STRIP 0x10000000 /* no dead stripping */
#define S_ATTR_LIVE_SUPPORT 0x08000000 /* blocks are live if they
reference live blocks */
#define S_ATTR_SELF_MODIFYING_CODE 0x04000000 /* Used with i386 code stubs
written on by dyld */
/*
* If a segment contains any sections marked with S_ATTR_DEBUG then all
* sections in that segment must have this attribute. No section other than
* a section marked with this attribute may reference the contents of this
* section. A section with this attribute may contain no symbols and must have
* a section type S_REGULAR. The static linker will not copy section contents
* from sections with this attribute into its output file. These sections
* generally contain DWARF debugging info.
*/
#define S_ATTR_DEBUG 0x02000000 /* a debug section */
#define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */
#define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some
machine instructions */
#define S_ATTR_EXT_RELOC 0x00000200 /* section has external
relocation entries */
#define S_ATTR_LOC_RELOC 0x00000100 /* section has local
relocation entries */
/*
* The names of segments and sections in them are mostly meaningless to the
* link-editor. But there are few things to support traditional UNIX
* executables that require the link-editor and assembler to use some names
* agreed upon by convention.
*
* The initial protection of the "__TEXT" segment has write protection turned
* off (not writeable).
*
* The link-editor will allocate common symbols at the end of the "__common"
* section in the "__DATA" segment. It will create the section and segment
* if needed.
*/
/* The currently known segment names and the section names in those segments */
#define SEG_PAGEZERO "__PAGEZERO" /* the pagezero segment which has no */
/* protections and catches NULL */
/* references for MH_EXECUTE files */
#define SEG_TEXT "__TEXT" /* the tradition UNIX text segment */
#define SECT_TEXT "__text" /* the real text part of the text */
/* section no headers, and no padding */
#define SECT_FVMLIB_INIT0 "__fvmlib_init0" /* the fvmlib initialization */
/* section */
#define SECT_FVMLIB_INIT1 "__fvmlib_init1" /* the section following the */
/* fvmlib initialization */
/* section */
#define SEG_DATA "__DATA" /* the tradition UNIX data segment */
#define SECT_DATA "__data" /* the real initialized data section */
/* no padding, no bss overlap */
#define SECT_BSS "__bss" /* the real uninitialized data section*/
/* no padding */
#define SECT_COMMON "__common" /* the section common symbols are */
/* allocated in by the link editor */
#define SEG_OBJC "__OBJC" /* objective-C runtime segment */
#define SECT_OBJC_SYMBOLS "__symbol_table" /* symbol table */
#define SECT_OBJC_MODULES "__module_info" /* module information */
#define SECT_OBJC_STRINGS "__selector_strs" /* string table */
#define SECT_OBJC_REFS "__selector_refs" /* string table */
#define SEG_ICON "__ICON" /* the icon segment */
#define SECT_ICON_HEADER "__header" /* the icon headers */
#define SECT_ICON_TIFF "__tiff" /* the icons in tiff format */
#define SEG_LINKEDIT "__LINKEDIT" /* the segment containing all structs */
/* created and maintained by the link */
/* editor. Created with -seglinkedit */
/* option to ld(1) for MH_EXECUTE and */
/* FVMLIB file types only */
#define SEG_UNIXSTACK "__UNIXSTACK" /* the unix stack segment */
#define SEG_IMPORT "__IMPORT" /* the segment for the self (dyld) */
/* modifing code stubs that has read, */
/* write and execute permissions */
/*
* Fixed virtual memory shared libraries are identified by two things. The
* target pathname (the name of the library as found for execution), and the
* minor version number. The address of where the headers are loaded is in
* header_addr. (THIS IS OBSOLETE and no longer supported).
*/
struct fvmlib {
union lc_str name; /* library's target pathname */
uint32_t minor_version; /* library's minor version number */
uint32_t header_addr; /* library's header address */
};
/*
* A fixed virtual shared library (filetype == MH_FVMLIB in the mach header)
* contains a fvmlib_command (cmd == LC_IDFVMLIB) to identify the library.
* An object that uses a fixed virtual shared library also contains a
* fvmlib_command (cmd == LC_LOADFVMLIB) for each library it uses.
* (THIS IS OBSOLETE and no longer supported).
*/
struct fvmlib_command {
uint32_t cmd; /* LC_IDFVMLIB or LC_LOADFVMLIB */
uint32_t cmdsize; /* includes pathname string */
struct fvmlib fvmlib; /* the library identification */
};
/*
* Dynamicly linked shared libraries are identified by two things. The
* pathname (the name of the library as found for execution), and the
* compatibility version number. The pathname must match and the compatibility
* number in the user of the library must be greater than or equal to the
* library being used. The time stamp is used to record the time a library was
* built and copied into user so it can be use to determined if the library used
* at runtime is exactly the same as used to built the program.
*/
struct dylib {
union lc_str name; /* library's path name */
uint32_t timestamp; /* library's build time stamp */
uint32_t current_version; /* library's current version number */
uint32_t compatibility_version; /* library's compatibility vers number*/
};
/*
* A dynamically linked shared library (filetype == MH_DYLIB in the mach header)
* contains a dylib_command (cmd == LC_ID_DYLIB) to identify the library.
* An object that uses a dynamically linked shared library also contains a
* dylib_command (cmd == LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, or
* LC_REEXPORT_DYLIB) for each library it uses.
*/
struct dylib_command {
uint32_t cmd; /* LC_ID_DYLIB, LC_LOAD_{,WEAK_}DYLIB,
LC_REEXPORT_DYLIB */
uint32_t cmdsize; /* includes pathname string */
struct dylib dylib; /* the library identification */
};
/*
* A dynamically linked shared library may be a subframework of an umbrella
* framework. If so it will be linked with "-umbrella umbrella_name" where
* Where "umbrella_name" is the name of the umbrella framework. A subframework
* can only be linked against by its umbrella framework or other subframeworks
* that are part of the same umbrella framework. Otherwise the static link
* editor produces an error and states to link against the umbrella framework.
* The name of the umbrella framework for subframeworks is recorded in the
* following structure.
*/
struct sub_framework_command {
uint32_t cmd; /* LC_SUB_FRAMEWORK */
uint32_t cmdsize; /* includes umbrella string */
union lc_str umbrella; /* the umbrella framework name */
};
/*
* For dynamically linked shared libraries that are subframework of an umbrella
* framework they can allow clients other than the umbrella framework or other
* subframeworks in the same umbrella framework. To do this the subframework
* is built with "-allowable_client client_name" and an LC_SUB_CLIENT load
* command is created for each -allowable_client flag. The client_name is
* usually a framework name. It can also be a name used for bundles clients
* where the bundle is built with "-client_name client_name".
*/
struct sub_client_command {
uint32_t cmd; /* LC_SUB_CLIENT */
uint32_t cmdsize; /* includes client string */
union lc_str client; /* the client name */
};
/*
* A dynamically linked shared library may be a sub_umbrella of an umbrella
* framework. If so it will be linked with "-sub_umbrella umbrella_name" where
* Where "umbrella_name" is the name of the sub_umbrella framework. When
* staticly linking when -twolevel_namespace is in effect a twolevel namespace
* umbrella framework will only cause its subframeworks and those frameworks
* listed as sub_umbrella frameworks to be implicited linked in. Any other
* dependent dynamic libraries will not be linked it when -twolevel_namespace
* is in effect. The primary library recorded by the static linker when
* resolving a symbol in these libraries will be the umbrella framework.
* Zero or more sub_umbrella frameworks may be use by an umbrella framework.
* The name of a sub_umbrella framework is recorded in the following structure.
*/
struct sub_umbrella_command {
uint32_t cmd; /* LC_SUB_UMBRELLA */
uint32_t cmdsize; /* includes sub_umbrella string */
union lc_str sub_umbrella; /* the sub_umbrella framework name */
};
/*
* A dynamically linked shared library may be a sub_library of another shared
* library. If so it will be linked with "-sub_library library_name" where
* Where "library_name" is the name of the sub_library shared library. When
* staticly linking when -twolevel_namespace is in effect a twolevel namespace
* shared library will only cause its subframeworks and those frameworks
* listed as sub_umbrella frameworks and libraries listed as sub_libraries to
* be implicited linked in. Any other dependent dynamic libraries will not be
* linked it when -twolevel_namespace is in effect. The primary library
* recorded by the static linker when resolving a symbol in these libraries
* will be the umbrella framework (or dynamic library). Zero or more sub_library
* shared libraries may be use by an umbrella framework or (or dynamic library).
* The name of a sub_library framework is recorded in the following structure.
* For example /usr/lib/libobjc_profile.A.dylib would be recorded as "libobjc".
*/
struct sub_library_command {
uint32_t cmd; /* LC_SUB_LIBRARY */
uint32_t cmdsize; /* includes sub_library string */
union lc_str sub_library; /* the sub_library name */
};
/*
* A program (filetype == MH_EXECUTE) that is
* prebound to its dynamic libraries has one of these for each library that
* the static linker used in prebinding. It contains a bit vector for the
* modules in the library. The bits indicate which modules are bound (1) and
* which are not (0) from the library. The bit for module 0 is the low bit
* of the first byte. So the bit for the Nth module is:
* (linked_modules[N/8] >> N%8) & 1
*/
struct prebound_dylib_command {
uint32_t cmd; /* LC_PREBOUND_DYLIB */
uint32_t cmdsize; /* includes strings */
union lc_str name; /* library's path name */
uint32_t nmodules; /* number of modules in library */
union lc_str linked_modules; /* bit vector of linked modules */
};
/*
* A program that uses a dynamic linker contains a dylinker_command to identify
* the name of the dynamic linker (LC_LOAD_DYLINKER). And a dynamic linker
* contains a dylinker_command to identify the dynamic linker (LC_ID_DYLINKER).
* A file can have at most one of these.
* This struct is also used for the LC_DYLD_ENVIRONMENT load command and
* contains string for dyld to treat like environment variable.
*/
struct dylinker_command {
uint32_t cmd; /* LC_ID_DYLINKER, LC_LOAD_DYLINKER or
LC_DYLD_ENVIRONMENT */
uint32_t cmdsize; /* includes pathname string */
union lc_str name; /* dynamic linker's path name */
};
/*
* Thread commands contain machine-specific data structures suitable for
* use in the thread state primitives. The machine specific data structures
* follow the struct thread_command as follows.
* Each flavor of machine specific data structure is preceded by an uint32_t
* constant for the flavor of that data structure, an uint32_t that is the
* count of uint32_t's of the size of the state data structure and then
* the state data structure follows. This triple may be repeated for many
* flavors. The constants for the flavors, counts and state data structure
* definitions are expected to be in the header file .
* These machine specific data structures sizes must be multiples of
* 4 bytes. The cmdsize reflects the total size of the thread_command
* and all of the sizes of the constants for the flavors, counts and state
* data structures.
*
* For executable objects that are unix processes there will be one
* thread_command (cmd == LC_UNIXTHREAD) created for it by the link-editor.
* This is the same as a LC_THREAD, except that a stack is automatically
* created (based on the shell's limit for the stack size). Command arguments
* and environment variables are copied onto that stack.
*/
struct thread_command {
uint32_t cmd; /* LC_THREAD or LC_UNIXTHREAD */
uint32_t cmdsize; /* total size of this command */
/* uint32_t flavor flavor of thread state */
/* uint32_t count count of uint32_t's in thread state */
/* struct XXX_thread_state state thread state for this flavor */
/* ... */
};
/*
* The routines command contains the address of the dynamic shared library
* initialization routine and an index into the module table for the module
* that defines the routine. Before any modules are used from the library the
* dynamic linker fully binds the module that defines the initialization routine
* and then calls it. This gets called before any module initialization
* routines (used for C++ static constructors) in the library.
*/
struct routines_command { /* for 32-bit architectures */
uint32_t cmd; /* LC_ROUTINES */
uint32_t cmdsize; /* total size of this command */
uint32_t init_address; /* address of initialization routine */
uint32_t init_module; /* index into the module table that */
/* the init routine is defined in */
uint32_t reserved1;
uint32_t reserved2;
uint32_t reserved3;
uint32_t reserved4;
uint32_t reserved5;
uint32_t reserved6;
};
/*
* The 64-bit routines command. Same use as above.
*/
struct routines_command_64 { /* for 64-bit architectures */
uint32_t cmd; /* LC_ROUTINES_64 */
uint32_t cmdsize; /* total size of this command */
uint64_t init_address; /* address of initialization routine */
uint64_t init_module; /* index into the module table that */
/* the init routine is defined in */
uint64_t reserved1;
uint64_t reserved2;
uint64_t reserved3;
uint64_t reserved4;
uint64_t reserved5;
uint64_t reserved6;
};
/*
* The symtab_command contains the offsets and sizes of the link-edit 4.3BSD
* "stab" style symbol table information as described in the header files
* and .
*/
struct symtab_command {
uint32_t cmd; /* LC_SYMTAB */
uint32_t cmdsize; /* sizeof(struct symtab_command) */
uint32_t symoff; /* symbol table offset */
uint32_t nsyms; /* number of symbol table entries */
uint32_t stroff; /* string table offset */
uint32_t strsize; /* string table size in bytes */
};
/*
* This is the second set of the symbolic information which is used to support
* the data structures for the dynamically link editor.
*
* The original set of symbolic information in the symtab_command which contains
* the symbol and string tables must also be present when this load command is
* present. When this load command is present the symbol table is organized
* into three groups of symbols:
* local symbols (static and debugging symbols) - grouped by module
* defined external symbols - grouped by module (sorted by name if not lib)
* undefined external symbols (sorted by name if MH_BINDATLOAD is not set,
* and in order the were seen by the static
* linker if MH_BINDATLOAD is set)
* In this load command there are offsets and counts to each of the three groups
* of symbols.
*
* This load command contains a the offsets and sizes of the following new
* symbolic information tables:
* table of contents
* module table
* reference symbol table
* indirect symbol table
* The first three tables above (the table of contents, module table and
* reference symbol table) are only present if the file is a dynamically linked
* shared library. For executable and object modules, which are files
* containing only one module, the information that would be in these three
* tables is determined as follows:
* table of contents - the defined external symbols are sorted by name
* module table - the file contains only one module so everything in the
* file is part of the module.
* reference symbol table - is the defined and undefined external symbols
*
* For dynamically linked shared library files this load command also contains
* offsets and sizes to the pool of relocation entries for all sections
* separated into two groups:
* external relocation entries
* local relocation entries
* For executable and object modules the relocation entries continue to hang
* off the section structures.
*/
struct dysymtab_command {
uint32_t cmd; /* LC_DYSYMTAB */
uint32_t cmdsize; /* sizeof(struct dysymtab_command) */
/*
* The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
* are grouped into the following three groups:
* local symbols (further grouped by the module they are from)
* defined external symbols (further grouped by the module they are from)
* undefined symbols
*
* The local symbols are used only for debugging. The dynamic binding
* process may have to use them to indicate to the debugger the local
* symbols for a module that is being bound.
*
* The last two groups are used by the dynamic binding process to do the
* binding (indirectly through the module table and the reference symbol
* table when this is a dynamically linked shared library file).
*/
uint32_t ilocalsym; /* index to local symbols */
uint32_t nlocalsym; /* number of local symbols */
uint32_t iextdefsym;/* index to externally defined symbols */
uint32_t nextdefsym;/* number of externally defined symbols */
uint32_t iundefsym; /* index to undefined symbols */
uint32_t nundefsym; /* number of undefined symbols */
/*
* For the for the dynamic binding process to find which module a symbol
* is defined in the table of contents is used (analogous to the ranlib
* structure in an archive) which maps defined external symbols to modules
* they are defined in. This exists only in a dynamically linked shared
* library file. For executable and object modules the defined external
* symbols are sorted by name and is use as the table of contents.
*/
uint32_t tocoff; /* file offset to table of contents */
uint32_t ntoc; /* number of entries in table of contents */
/*
* To support dynamic binding of "modules" (whole object files) the symbol
* table must reflect the modules that the file was created from. This is
* done by having a module table that has indexes and counts into the merged
* tables for each module. The module structure that these two entries
* refer to is described below. This exists only in a dynamically linked
* shared library file. For executable and object modules the file only
* contains one module so everything in the file belongs to the module.
*/
uint32_t modtaboff; /* file offset to module table */
uint32_t nmodtab; /* number of module table entries */
/*
* To support dynamic module binding the module structure for each module
* indicates the external references (defined and undefined) each module
* makes. For each module there is an offset and a count into the
* reference symbol table for the symbols that the module references.
* This exists only in a dynamically linked shared library file. For
* executable and object modules the defined external symbols and the
* undefined external symbols indicates the external references.
*/
uint32_t extrefsymoff; /* offset to referenced symbol table */
uint32_t nextrefsyms; /* number of referenced symbol table entries */
/*
* The sections that contain "symbol pointers" and "routine stubs" have
* indexes and (implied counts based on the size of the section and fixed
* size of the entry) into the "indirect symbol" table for each pointer
* and stub. For every section of these two types the index into the
* indirect symbol table is stored in the section header in the field
* reserved1. An indirect symbol table entry is simply a 32bit index into
* the symbol table to the symbol that the pointer or stub is referring to.
* The indirect symbol table is ordered to match the entries in the section.
*/
uint32_t indirectsymoff; /* file offset to the indirect symbol table */
uint32_t nindirectsyms; /* number of indirect symbol table entries */
/*
* To support relocating an individual module in a library file quickly the
* external relocation entries for each module in the library need to be
* accessed efficiently. Since the relocation entries can't be accessed
* through the section headers for a library file they are separated into
* groups of local and external entries further grouped by module. In this
* case the presents of this load command who's extreloff, nextrel,
* locreloff and nlocrel fields are non-zero indicates that the relocation
* entries of non-merged sections are not referenced through the section
* structures (and the reloff and nreloc fields in the section headers are
* set to zero).
*
* Since the relocation entries are not accessed through the section headers
* this requires the r_address field to be something other than a section
* offset to identify the item to be relocated. In this case r_address is
* set to the offset from the vmaddr of the first LC_SEGMENT command.
* For MH_SPLIT_SEGS images r_address is set to the the offset from the
* vmaddr of the first read-write LC_SEGMENT command.
*
* The relocation entries are grouped by module and the module table
* entries have indexes and counts into them for the group of external
* relocation entries for that the module.
*
* For sections that are merged across modules there must not be any
* remaining external relocation entries for them (for merged sections
* remaining relocation entries must be local).
*/
uint32_t extreloff; /* offset to external relocation entries */
uint32_t nextrel; /* number of external relocation entries */
/*
* All the local relocation entries are grouped together (they are not
* grouped by their module since they are only used if the object is moved
* from it staticly link edited address).
*/
uint32_t locreloff; /* offset to local relocation entries */
uint32_t nlocrel; /* number of local relocation entries */
};
/*
* An indirect symbol table entry is simply a 32bit index into the symbol table
* to the symbol that the pointer or stub is refering to. Unless it is for a
* non-lazy symbol pointer section for a defined symbol which strip(1) as
* removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the
* symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that.
*/
#define INDIRECT_SYMBOL_LOCAL 0x80000000
#define INDIRECT_SYMBOL_ABS 0x40000000
/* a table of contents entry */
struct dylib_table_of_contents {
uint32_t symbol_index; /* the defined external symbol
(index into the symbol table) */
uint32_t module_index; /* index into the module table this symbol
is defined in */
};
/* a module table entry */
struct dylib_module {
uint32_t module_name; /* the module name (index into string table) */
uint32_t iextdefsym; /* index into externally defined symbols */
uint32_t nextdefsym; /* number of externally defined symbols */
uint32_t irefsym; /* index into reference symbol table */
uint32_t nrefsym; /* number of reference symbol table entries */
uint32_t ilocalsym; /* index into symbols for local symbols */
uint32_t nlocalsym; /* number of local symbols */
uint32_t iextrel; /* index into external relocation entries */
uint32_t nextrel; /* number of external relocation entries */
uint32_t iinit_iterm; /* low 16 bits are the index into the init
section, high 16 bits are the index into
the term section */
uint32_t ninit_nterm; /* low 16 bits are the number of init section
entries, high 16 bits are the number of
term section entries */
uint32_t /* for this module address of the start of */
objc_module_info_addr; /* the (__OBJC,__module_info) section */
uint32_t /* for this module size of */
objc_module_info_size; /* the (__OBJC,__module_info) section */
};
/* a 64-bit module table entry */
struct dylib_module_64 {
uint32_t module_name; /* the module name (index into string table) */
uint32_t iextdefsym; /* index into externally defined symbols */
uint32_t nextdefsym; /* number of externally defined symbols */
uint32_t irefsym; /* index into reference symbol table */
uint32_t nrefsym; /* number of reference symbol table entries */
uint32_t ilocalsym; /* index into symbols for local symbols */
uint32_t nlocalsym; /* number of local symbols */
uint32_t iextrel; /* index into external relocation entries */
uint32_t nextrel; /* number of external relocation entries */
uint32_t iinit_iterm; /* low 16 bits are the index into the init
section, high 16 bits are the index into
the term section */
uint32_t ninit_nterm; /* low 16 bits are the number of init section
entries, high 16 bits are the number of
term section entries */
uint32_t /* for this module size of */
objc_module_info_size; /* the (__OBJC,__module_info) section */
uint64_t /* for this module address of the start of */
objc_module_info_addr; /* the (__OBJC,__module_info) section */
};
/*
* The entries in the reference symbol table are used when loading the module
* (both by the static and dynamic link editors) and if the module is unloaded
* or replaced. Therefore all external symbols (defined and undefined) are
* listed in the module's reference table. The flags describe the type of
* reference that is being made. The constants for the flags are defined in
* as they are also used for symbol table entries.
*/
struct dylib_reference {
uint32_t isym:24, /* index into the symbol table */
flags:8; /* flags to indicate the type of reference */
};
/*
* The twolevel_hints_command contains the offset and number of hints in the
* two-level namespace lookup hints table.
*/
struct twolevel_hints_command {
uint32_t cmd; /* LC_TWOLEVEL_HINTS */
uint32_t cmdsize; /* sizeof(struct twolevel_hints_command) */
uint32_t offset; /* offset to the hint table */
uint32_t nhints; /* number of hints in the hint table */
};
/*
* The entries in the two-level namespace lookup hints table are twolevel_hint
* structs. These provide hints to the dynamic link editor where to start
* looking for an undefined symbol in a two-level namespace image. The
* isub_image field is an index into the sub-images (sub-frameworks and
* sub-umbrellas list) that made up the two-level image that the undefined
* symbol was found in when it was built by the static link editor. If
* isub-image is 0 the the symbol is expected to be defined in library and not
* in the sub-images. If isub-image is non-zero it is an index into the array
* of sub-images for the umbrella with the first index in the sub-images being
* 1. The array of sub-images is the ordered list of sub-images of the umbrella
* that would be searched for a symbol that has the umbrella recorded as its
* primary library. The table of contents index is an index into the
* library's table of contents. This is used as the starting point of the
* binary search or a directed linear search.
*/
struct twolevel_hint {
uint32_t
isub_image:8, /* index into the sub images */
itoc:24; /* index into the table of contents */
};
/*
* The prebind_cksum_command contains the value of the original check sum for
* prebound files or zero. When a prebound file is first created or modified
* for other than updating its prebinding information the value of the check sum
* is set to zero. When the file has it prebinding re-done and if the value of
* the check sum is zero the original check sum is calculated and stored in
* cksum field of this load command in the output file. If when the prebinding
* is re-done and the cksum field is non-zero it is left unchanged from the
* input file.
*/
struct prebind_cksum_command {
uint32_t cmd; /* LC_PREBIND_CKSUM */
uint32_t cmdsize; /* sizeof(struct prebind_cksum_command) */
uint32_t cksum; /* the check sum or zero */
};
/*
* The uuid load command contains a single 128-bit unique random number that
* identifies an object produced by the static link editor.
*/
struct uuid_command {
uint32_t cmd; /* LC_UUID */
uint32_t cmdsize; /* sizeof(struct uuid_command) */
uint8_t uuid[16]; /* the 128-bit uuid */
};
/*
* The rpath_command contains a path which at runtime should be added to
* the current run path used to find @rpath prefixed dylibs.
*/
struct rpath_command {
uint32_t cmd; /* LC_RPATH */
uint32_t cmdsize; /* includes string */
union lc_str path; /* path to add to run path */
};
/*
* The linkedit_data_command contains the offsets and sizes of a blob
* of data in the __LINKEDIT segment.
*/
struct linkedit_data_command {
uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO,
LC_FUNCTION_STARTS, LC_DATA_IN_CODE,
LC_DYLIB_CODE_SIGN_DRS,
LC_LINKER_OPTIMIZATION_HINT,
LC_DYLD_EXPORTS_TRIE, or
LC_DYLD_CHAINED_FIXUPS. */
uint32_t cmdsize; /* sizeof(struct linkedit_data_command) */
uint32_t dataoff; /* file offset of data in __LINKEDIT segment */
uint32_t datasize; /* file size of data in __LINKEDIT segment */
};
/*
* The encryption_info_command contains the file offset and size of an
* of an encrypted segment.
*/
struct encryption_info_command {
uint32_t cmd; /* LC_ENCRYPTION_INFO */
uint32_t cmdsize; /* sizeof(struct encryption_info_command) */
uint32_t cryptoff; /* file offset of encrypted range */
uint32_t cryptsize; /* file size of encrypted range */
uint32_t cryptid; /* which enryption system,
0 means not-encrypted yet */
};
/*
* The encryption_info_command_64 contains the file offset and size of an
* of an encrypted segment (for use in x86_64 targets).
*/
struct encryption_info_command_64 {
uint32_t cmd; /* LC_ENCRYPTION_INFO_64 */
uint32_t cmdsize; /* sizeof(struct encryption_info_command_64) */
uint32_t cryptoff; /* file offset of encrypted range */
uint32_t cryptsize; /* file size of encrypted range */
uint32_t cryptid; /* which enryption system,
0 means not-encrypted yet */
uint32_t pad; /* padding to make this struct's size a multiple
of 8 bytes */
};
/*
* The version_min_command contains the min OS version on which this
* binary was built to run.
*/
struct version_min_command {
uint32_t cmd; /* LC_VERSION_MIN_MACOSX or
LC_VERSION_MIN_IPHONEOS or
LC_VERSION_MIN_WATCHOS or
LC_VERSION_MIN_TVOS */
uint32_t cmdsize; /* sizeof(struct min_version_command) */
uint32_t version; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
};
/*
* The build_version_command contains the min OS version on which this
* binary was built to run for its platform. The list of known platforms and
* tool values following it.
*/
struct build_version_command {
uint32_t cmd; /* LC_BUILD_VERSION */
uint32_t cmdsize; /* sizeof(struct build_version_command) plus */
/* ntools * sizeof(struct build_tool_version) */
uint32_t platform; /* platform */
uint32_t minos; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
uint32_t ntools; /* number of tool entries following this */
};
struct build_tool_version {
uint32_t tool; /* enum for the tool */
uint32_t version; /* version number of the tool */
};
/* Known values for the platform field above. */
#define PLATFORM_MACOS 1
#define PLATFORM_IOS 2
#define PLATFORM_TVOS 3
#define PLATFORM_WATCHOS 4
#define PLATFORM_BRIDGEOS 5
#define PLATFORM_MACCATALYST 6
#define PLATFORM_IOSSIMULATOR 7
#define PLATFORM_TVOSSIMULATOR 8
#define PLATFORM_WATCHOSSIMULATOR 9
#define PLATFORM_DRIVERKIT 10
/* Known values for the tool field above. */
#define TOOL_CLANG 1
#define TOOL_SWIFT 2
#define TOOL_LD 3
/*
* The dyld_info_command contains the file offsets and sizes of
* the new compressed form of the information dyld needs to
* load the image. This information is used by dyld on Mac OS X
* 10.6 and later. All information pointed to by this command
* is encoded using byte streams, so no endian swapping is needed
* to interpret it.
*/
struct dyld_info_command {
uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */
uint32_t cmdsize; /* sizeof(struct dyld_info_command) */
/*
* Dyld rebases an image whenever dyld loads it at an address different
* from its preferred address. The rebase information is a stream
* of byte sized opcodes whose symbolic names start with REBASE_OPCODE_.
* Conceptually the rebase information is a table of tuples:
*
* The opcodes are a compressed way to encode the table by only
* encoding when a column changes. In addition simple patterns
* like "every n'th offset for m times" can be encoded in a few
* bytes.
*/
uint32_t rebase_off; /* file offset to rebase info */
uint32_t rebase_size; /* size of rebase info */
/*
* Dyld binds an image during the loading process, if the image
* requires any pointers to be initialized to symbols in other images.
* The bind information is a stream of byte sized
* opcodes whose symbolic names start with BIND_OPCODE_.
* Conceptually the bind information is a table of tuples:
*
* The opcodes are a compressed way to encode the table by only
* encoding when a column changes. In addition simple patterns
* like for runs of pointers initialzed to the same value can be
* encoded in a few bytes.
*/
uint32_t bind_off; /* file offset to binding info */
uint32_t bind_size; /* size of binding info */
/*
* Some C++ programs require dyld to unique symbols so that all
* images in the process use the same copy of some code/data.
* This step is done after binding. The content of the weak_bind
* info is an opcode stream like the bind_info. But it is sorted
* alphabetically by symbol name. This enable dyld to walk
* all images with weak binding information in order and look
* for collisions. If there are no collisions, dyld does
* no updating. That means that some fixups are also encoded
* in the bind_info. For instance, all calls to "operator new"
* are first bound to libstdc++.dylib using the information
* in bind_info. Then if some image overrides operator new
* that is detected when the weak_bind information is processed
* and the call to operator new is then rebound.
*/
uint32_t weak_bind_off; /* file offset to weak binding info */
uint32_t weak_bind_size; /* size of weak binding info */
/*
* Some uses of external symbols do not need to be bound immediately.
* Instead they can be lazily bound on first use. The lazy_bind
* are contains a stream of BIND opcodes to bind all lazy symbols.
* Normal use is that dyld ignores the lazy_bind section when
* loading an image. Instead the static linker arranged for the
* lazy pointer to initially point to a helper function which
* pushes the offset into the lazy_bind area for the symbol
* needing to be bound, then jumps to dyld which simply adds
* the offset to lazy_bind_off to get the information on what
* to bind.
*/
uint32_t lazy_bind_off; /* file offset to lazy binding info */
uint32_t lazy_bind_size; /* size of lazy binding infs */
/*
* The symbols exported by a dylib are encoded in a trie. This
* is a compact representation that factors out common prefixes.
* It also reduces LINKEDIT pages in RAM because it encodes all
* information (name, address, flags) in one small, contiguous range.
* The export area is a stream of nodes. The first node sequentially
* is the start node for the trie.
*
* Nodes for a symbol start with a uleb128 that is the length of
* the exported symbol information for the string so far.
* If there is no exported symbol, the node starts with a zero byte.
* If there is exported info, it follows the length.
*
* First is a uleb128 containing flags. Normally, it is followed by
* a uleb128 encoded offset which is location of the content named
* by the symbol from the mach_header for the image. If the flags
* is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags is
* a uleb128 encoded library ordinal, then a zero terminated
* UTF8 string. If the string is zero length, then the symbol
* is re-export from the specified dylib with the same name.
* If the flags is EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, then following
* the flags is two uleb128s: the stub offset and the resolver offset.
* The stub is used by non-lazy pointers. The resolver is used
* by lazy pointers and must be called to get the actual address to use.
*
* After the optional exported symbol information is a byte of
* how many edges (0-255) that this node has leaving it,
* followed by each edge.
* Each edge is a zero terminated UTF8 of the addition chars
* in the symbol, followed by a uleb128 offset for the node that
* edge points to.
*
*/
uint32_t export_off; /* file offset to lazy binding info */
uint32_t export_size; /* size of lazy binding infs */
};
/*
* The following are used to encode rebasing information
*/
#define REBASE_TYPE_POINTER 1
#define REBASE_TYPE_TEXT_ABSOLUTE32 2
#define REBASE_TYPE_TEXT_PCREL32 3
#define REBASE_OPCODE_MASK 0xF0
#define REBASE_IMMEDIATE_MASK 0x0F
#define REBASE_OPCODE_DONE 0x00
#define REBASE_OPCODE_SET_TYPE_IMM 0x10
#define REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20
#define REBASE_OPCODE_ADD_ADDR_ULEB 0x30
#define REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40
#define REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50
#define REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60
#define REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70
#define REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80
/*
* The following are used to encode binding information
*/
#define BIND_TYPE_POINTER 1
#define BIND_TYPE_TEXT_ABSOLUTE32 2
#define BIND_TYPE_TEXT_PCREL32 3
#define BIND_SPECIAL_DYLIB_SELF 0
#define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1
#define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2
#define BIND_SPECIAL_DYLIB_WEAK_LOOKUP -3
#define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1
#define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8
#define BIND_OPCODE_MASK 0xF0
#define BIND_IMMEDIATE_MASK 0x0F
#define BIND_OPCODE_DONE 0x00
#define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10
#define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20
#define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30
#define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40
#define BIND_OPCODE_SET_TYPE_IMM 0x50
#define BIND_OPCODE_SET_ADDEND_SLEB 0x60
#define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70
#define BIND_OPCODE_ADD_ADDR_ULEB 0x80
#define BIND_OPCODE_DO_BIND 0x90
#define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0
#define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0
#define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0
#define BIND_OPCODE_THREADED 0xD0
#define BIND_SUBOPCODE_THREADED_SET_BIND_ORDINAL_TABLE_SIZE_ULEB 0x00
#define BIND_SUBOPCODE_THREADED_APPLY 0x01
/*
* The following are used on the flags byte of a terminal node
* in the export information.
*/
#define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03
#define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00
#define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01
#define EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE 0x02
#define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04
#define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08
#define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10
#define EXPORT_SYMBOL_FLAGS_STATIC_RESOLVER 0x20
/*
* The linker_option_command contains linker options embedded in object files.
*/
struct linker_option_command {
uint32_t cmd; /* LC_LINKER_OPTION only used in MH_OBJECT filetypes */
uint32_t cmdsize;
uint32_t count; /* number of strings */
/* concatenation of zero terminated UTF8 strings.
Zero filled at end to align */
};
/*
* The symseg_command contains the offset and size of the GNU style
* symbol table information as described in the header file .
* The symbol roots of the symbol segments must also be aligned properly
* in the file. So the requirement of keeping the offsets aligned to a
* multiple of a 4 bytes translates to the length field of the symbol
* roots also being a multiple of a long. Also the padding must again be
* zeroed. (THIS IS OBSOLETE and no longer supported).
*/
struct symseg_command {
uint32_t cmd; /* LC_SYMSEG */
uint32_t cmdsize; /* sizeof(struct symseg_command) */
uint32_t offset; /* symbol segment offset */
uint32_t size; /* symbol segment size in bytes */
};
/*
* The ident_command contains a free format string table following the
* ident_command structure. The strings are null terminated and the size of
* the command is padded out with zero bytes to a multiple of 4 bytes/
* (THIS IS OBSOLETE and no longer supported).
*/
struct ident_command {
uint32_t cmd; /* LC_IDENT */
uint32_t cmdsize; /* strings that follow this command */
};
/*
* The fvmfile_command contains a reference to a file to be loaded at the
* specified virtual address. (Presently, this command is reserved for
* internal use. The kernel ignores this command when loading a program into
* memory).
*/
struct fvmfile_command {
uint32_t cmd; /* LC_FVMFILE */
uint32_t cmdsize; /* includes pathname string */
union lc_str name; /* files pathname */
uint32_t header_addr; /* files virtual address */
};
/*
* The entry_point_command is a replacement for thread_command.
* It is used for main executables to specify the location (file offset)
* of main(). If -stack_size was used at link time, the stacksize
* field will contain the stack size need for the main thread.
*/
struct entry_point_command {
uint32_t cmd; /* LC_MAIN only used in MH_EXECUTE filetypes */
uint32_t cmdsize; /* 24 */
uint64_t entryoff; /* file (__TEXT) offset of main() */
uint64_t stacksize;/* if not zero, initial stack size */
};
/*
* The source_version_command is an optional load command containing
* the version of the sources used to build the binary.
*/
struct source_version_command {
uint32_t cmd; /* LC_SOURCE_VERSION */
uint32_t cmdsize; /* 16 */
uint64_t version; /* A.B.C.D.E packed as a24.b10.c10.d10.e10 */
};
/*
* The LC_DATA_IN_CODE load commands uses a linkedit_data_command
* to point to an array of data_in_code_entry entries. Each entry
* describes a range of data in a code section.
*/
struct data_in_code_entry {
uint32_t offset; /* from mach_header to start of data range*/
uint16_t length; /* number of bytes in data range */
uint16_t kind; /* a DICE_KIND_* value */
};
#define DICE_KIND_DATA 0x0001
#define DICE_KIND_JUMP_TABLE8 0x0002
#define DICE_KIND_JUMP_TABLE16 0x0003
#define DICE_KIND_JUMP_TABLE32 0x0004
#define DICE_KIND_ABS_JUMP_TABLE32 0x0005
/*
* Sections of type S_THREAD_LOCAL_VARIABLES contain an array
* of tlv_descriptor structures.
*/
struct tlv_descriptor
{
void* (*thunk)(struct tlv_descriptor*);
unsigned long key;
unsigned long offset;
};
/*
* LC_NOTE commands describe a region of arbitrary data included in a Mach-O
* file. Its initial use is to record extra data in MH_CORE files.
*/
struct note_command {
uint32_t cmd; /* LC_NOTE */
uint32_t cmdsize; /* sizeof(struct note_command) */
char data_owner[16]; /* owner name for this LC_NOTE */
uint64_t offset; /* file offset of this data */
uint64_t size; /* length of data region */
};
/*
* LC_FILESET_ENTRY commands describe constituent Mach-O files that are part
* of a fileset. In one implementation, entries are dylibs with individual
* mach headers and repositionable text and data segments. Each entry is
* further described by its own mach header.
*/
struct fileset_entry_command {
uint32_t cmd; /* LC_FILESET_ENTRY */
uint32_t cmdsize; /* includes entry_id string */
uint64_t vmaddr; /* memory address of the entry */
uint64_t fileoff; /* file offset of the entry */
union lc_str entry_id; /* contained entry id */
uint32_t reserved; /* reserved */
};
/*
* These deprecated values may still be used within Apple but are mechanically
* removed from public API. The mechanical process may produce unusual results.
*/
#if (!defined(PLATFORM_MACCATALYST))
#define PLATFORM_MACCATALYST PLATFORM_MACCATALYST
#endif
#endif /* _MACHO_LOADER_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/module.modulemap
================================================
module MachO [system] [extern_c] {
extern module dyld "dyld.modulemap"
extern module compact_unwind_encoding "compact_unwind_encoding.modulemap"
export *
module arch {
header "arch.h"
export *
}
module fat {
header "fat.h"
export *
}
module getsect {
header "getsect.h"
export *
}
module ldsyms {
header "ldsyms.h"
export *
}
module loader {
header "loader.h"
export *
}
module nlist {
header "nlist.h"
export *
}
module ranlib {
header "ranlib.h"
export *
}
module reloc {
header "reloc.h"
export *
}
module stab {
header "stab.h"
export *
}
module swap {
header "swap.h"
export *
}
}
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/nlist.h
================================================
/*
* Copyright (c) 1999-2003 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 _MACHO_NLIST_H_
#define _MACHO_NLIST_H_
/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nlist.h 8.2 (Berkeley) 1/21/94
*/
#include
/*
* Format of a symbol table entry of a Mach-O file for 32-bit architectures.
* Modified from the BSD format. The modifications from the original format
* were changing n_other (an unused field) to n_sect and the addition of the
* N_SECT type. These modifications are required to support symbols in a larger
* number of sections not just the three sections (text, data and bss) in a BSD
* file.
*/
struct nlist {
union {
#ifndef __LP64__
char *n_name; /* for use when in-core */
#endif
uint32_t n_strx; /* index into the string table */
} n_un;
uint8_t n_type; /* type flag, see below */
uint8_t n_sect; /* section number or NO_SECT */
int16_t n_desc; /* see */
uint32_t n_value; /* value of this symbol (or stab offset) */
};
/*
* This is the symbol table entry structure for 64-bit architectures.
*/
struct nlist_64 {
union {
uint32_t n_strx; /* index into the string table */
} n_un;
uint8_t n_type; /* type flag, see below */
uint8_t n_sect; /* section number or NO_SECT */
uint16_t n_desc; /* see */
uint64_t n_value; /* value of this symbol (or stab offset) */
};
/*
* Symbols with a index into the string table of zero (n_un.n_strx == 0) are
* defined to have a null, "", name. Therefore all string indexes to non null
* names must not have a zero string index. This is bit historical information
* that has never been well documented.
*/
/*
* The n_type field really contains four fields:
* unsigned char N_STAB:3,
* N_PEXT:1,
* N_TYPE:3,
* N_EXT:1;
* which are used via the following masks.
*/
#define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */
#define N_PEXT 0x10 /* private external symbol bit */
#define N_TYPE 0x0e /* mask for the type bits */
#define N_EXT 0x01 /* external symbol bit, set for external symbols */
/*
* Only symbolic debugging entries have some of the N_STAB bits set and if any
* of these bits are set then it is a symbolic debugging entry (a stab). In
* which case then the values of the n_type field (the entire field) are given
* in
*/
/*
* Values for N_TYPE bits of the n_type field.
*/
#define N_UNDF 0x0 /* undefined, n_sect == NO_SECT */
#define N_ABS 0x2 /* absolute, n_sect == NO_SECT */
#define N_SECT 0xe /* defined in section number n_sect */
#define N_PBUD 0xc /* prebound undefined (defined in a dylib) */
#define N_INDR 0xa /* indirect */
/*
* If the type is N_INDR then the symbol is defined to be the same as another
* symbol. In this case the n_value field is an index into the string table
* of the other symbol's name. When the other symbol is defined then they both
* take on the defined type and value.
*/
/*
* If the type is N_SECT then the n_sect field contains an ordinal of the
* section the symbol is defined in. The sections are numbered from 1 and
* refer to sections in order they appear in the load commands for the file
* they are in. This means the same ordinal may very well refer to different
* sections in different files.
*
* The n_value field for all symbol table entries (including N_STAB's) gets
* updated by the link editor based on the value of it's n_sect field and where
* the section n_sect references gets relocated. If the value of the n_sect
* field is NO_SECT then it's n_value field is not changed by the link editor.
*/
#define NO_SECT 0 /* symbol is not in any section */
#define MAX_SECT 255 /* 1 thru 255 inclusive */
/*
* Common symbols are represented by undefined (N_UNDF) external (N_EXT) types
* who's values (n_value) are non-zero. In which case the value of the n_value
* field is the size (in bytes) of the common symbol. The n_sect field is set
* to NO_SECT. The alignment of a common symbol may be set as a power of 2
* between 2^1 and 2^15 as part of the n_desc field using the macros below. If
* the alignment is not set (a value of zero) then natural alignment based on
* the size is used.
*/
#define GET_COMM_ALIGN(n_desc) (((n_desc) >> 8) & 0x0f)
#define SET_COMM_ALIGN(n_desc,align) \
(n_desc) = (((n_desc) & 0xf0ff) | (((align) & 0x0f) << 8))
/*
* To support the lazy binding of undefined symbols in the dynamic link-editor,
* the undefined symbols in the symbol table (the nlist structures) are marked
* with the indication if the undefined reference is a lazy reference or
* non-lazy reference. If both a non-lazy reference and a lazy reference is
* made to the same symbol the non-lazy reference takes precedence. A reference
* is lazy only when all references to that symbol are made through a symbol
* pointer in a lazy symbol pointer section.
*
* The implementation of marking nlist structures in the symbol table for
* undefined symbols will be to use some of the bits of the n_desc field as a
* reference type. The mask REFERENCE_TYPE will be applied to the n_desc field
* of an nlist structure for an undefined symbol to determine the type of
* undefined reference (lazy or non-lazy).
*
* The constants for the REFERENCE FLAGS are propagated to the reference table
* in a shared library file. In that case the constant for a defined symbol,
* REFERENCE_FLAG_DEFINED, is also used.
*/
/* Reference type bits of the n_desc field of undefined symbols */
#define REFERENCE_TYPE 0x7
/* types of references */
#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0
#define REFERENCE_FLAG_UNDEFINED_LAZY 1
#define REFERENCE_FLAG_DEFINED 2
#define REFERENCE_FLAG_PRIVATE_DEFINED 3
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5
/*
* To simplify stripping of objects that use are used with the dynamic link
* editor, the static link editor marks the symbols defined an object that are
* referenced by a dynamicly bound object (dynamic shared libraries, bundles).
* With this marking strip knows not to strip these symbols.
*/
#define REFERENCED_DYNAMICALLY 0x0010
/*
* For images created by the static link editor with the -twolevel_namespace
* option in effect the flags field of the mach header is marked with
* MH_TWOLEVEL. And the binding of the undefined references of the image are
* determined by the static link editor. Which library an undefined symbol is
* bound to is recorded by the static linker in the high 8 bits of the n_desc
* field using the SET_LIBRARY_ORDINAL macro below. The ordinal recorded
* references the libraries listed in the Mach-O's LC_LOAD_DYLIB,
* LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and
* LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the
* headers. The library ordinals start from 1.
* For a dynamic library that is built as a two-level namespace image the
* undefined references from module defined in another use the same nlist struct
* an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal. For
* defined symbols in all images they also must have the library ordinal set to
* SELF_LIBRARY_ORDINAL. The EXECUTABLE_ORDINAL refers to the executable
* image for references from plugins that refer to the executable that loads
* them.
*
* The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace
* image that are looked up by the dynamic linker with flat namespace semantics.
* This ordinal was added as a feature in Mac OS X 10.3 by reducing the
* value of MAX_LIBRARY_ORDINAL by one. So it is legal for existing binaries
* or binaries built with older tools to have 0xfe (254) dynamic libraries. In
* this case the ordinal value 0xfe (254) must be treated as a library ordinal
* for compatibility.
*/
#define GET_LIBRARY_ORDINAL(n_desc) (((n_desc) >> 8) & 0xff)
#define SET_LIBRARY_ORDINAL(n_desc,ordinal) \
(n_desc) = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8))
#define SELF_LIBRARY_ORDINAL 0x0
#define MAX_LIBRARY_ORDINAL 0xfd
#define DYNAMIC_LOOKUP_ORDINAL 0xfe
#define EXECUTABLE_ORDINAL 0xff
/*
* The bit 0x0020 of the n_desc field is used for two non-overlapping purposes
* and has two different symbolic names, N_NO_DEAD_STRIP and N_DESC_DISCARDED.
*/
/*
* The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a
* relocatable .o file (MH_OBJECT filetype). And is used to indicate to the
* static link editor it is never to dead strip the symbol.
*/
#define N_NO_DEAD_STRIP 0x0020 /* symbol is not to be dead stripped */
/*
* The N_DESC_DISCARDED bit of the n_desc field never appears in linked image.
* But is used in very rare cases by the dynamic link editor to mark an in
* memory symbol as discared and longer used for linking.
*/
#define N_DESC_DISCARDED 0x0020 /* symbol is discarded */
/*
* The N_WEAK_REF bit of the n_desc field indicates to the dynamic linker that
* the undefined symbol is allowed to be missing and is to have the address of
* zero when missing.
*/
#define N_WEAK_REF 0x0040 /* symbol is weak referenced */
/*
* The N_WEAK_DEF bit of the n_desc field indicates to the static and dynamic
* linkers that the symbol definition is weak, allowing a non-weak symbol to
* also be used which causes the weak definition to be discared. Currently this
* is only supported for symbols in coalesed sections.
*/
#define N_WEAK_DEF 0x0080 /* coalesed symbol is a weak definition */
/*
* The N_REF_TO_WEAK bit of the n_desc field indicates to the dynamic linker
* that the undefined symbol should be resolved using flat namespace searching.
*/
#define N_REF_TO_WEAK 0x0080 /* reference to a weak symbol */
/*
* The N_ARM_THUMB_DEF bit of the n_desc field indicates that the symbol is
* a defintion of a Thumb function.
*/
#define N_ARM_THUMB_DEF 0x0008 /* symbol is a Thumb function (ARM) */
/*
* The N_SYMBOL_RESOLVER bit of the n_desc field indicates that the
* that the function is actually a resolver function and should
* be called to get the address of the real function to use.
* This bit is only available in .o files (MH_OBJECT filetype)
*/
#define N_SYMBOL_RESOLVER 0x0100
/*
* The N_ALT_ENTRY bit of the n_desc field indicates that the
* symbol is pinned to the previous content.
*/
#define N_ALT_ENTRY 0x0200
/*
* The N_COLD_FUNC bit of the n_desc field indicates that the symbol is used
* infrequently and the linker should order it towards the end of the section.
*/
#define N_COLD_FUNC 0x0400
#ifndef __STRICT_BSD__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* The function nlist(3) from the C library.
*/
extern int nlist (const char *filename, struct nlist *list);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __STRICT_BSD__ */
#endif /* _MACHO_LIST_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/ranlib.h
================================================
/*
* Copyright (c) 2016 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* ranlib.h 4.1 83/05/03 */
#ifndef _MACH_O_RANLIB_H_
#define _MACH_O_RANLIB_H_
#include
#include /* off_t */
/*
* There are two known orders of table of contents for archives. The first is
* the order ranlib(1) originally produced and still produces without any
* options. This table of contents has the archive member name "__.SYMDEF"
* This order has the ranlib structures in the order the objects appear in the
* archive and the symbol names of those objects in the order of symbol table.
* The second know order is sorted by symbol name and is produced with the -s
* option to ranlib(1). This table of contents has the archive member name
* "__.SYMDEF SORTED" and many programs (notably the 1.0 version of ld(1) can't
* tell the difference between names because of the imbedded blank in the name
* and works with either table of contents). This second order is used by the
* post 1.0 link editor to produce faster linking. The original 1.0 version of
* ranlib(1) gets confused when it is run on a archive with the second type of
* table of contents because it and ar(1) which it uses use different ways to
* determined the member name (ar(1) treats all blanks in the name as
* significant and ranlib(1) only checks for the first one).
*/
#define SYMDEF "__.SYMDEF"
#define SYMDEF_SORTED "__.SYMDEF SORTED"
/*
* Structure of the __.SYMDEF table of contents for an archive.
* __.SYMDEF begins with a uint32_t giving the size in bytes of the ranlib
* structures which immediately follow, and then continues with a string
* table consisting of a uint32_t giving the number of bytes of strings which
* follow and then the strings themselves. The ran_strx fields index the
* string table whose first byte is numbered 0.
*/
struct ranlib {
union {
uint32_t ran_strx; /* string table index of */
#ifndef __LP64__
char *ran_name; /* symbol defined by */
#endif
} ran_un;
uint32_t ran_off; /* library member at this offset */
};
#define SYMDEF_64 "__.SYMDEF_64"
#define SYMDEF_64_SORTED "__.SYMDEF_64 SORTED"
/*
* The support for the 64-bit table of contents described here is a work in
* progress and not yet fully supported in all the Apple Developer Tools.
*
* When an archive offset to a library member is more than 32-bits then this is
* the structure of the __.SYMDEF_64 table of contents for an archive.
* __.SYMDEF_64 begins with a uint64_t giving the size in bytes of the ranlib
* structures which immediately follow, and then continues with a string
* table consisting of a uint64_t giving the number of bytes of strings which
* follow and then the strings themselves. The ran_strx fields index the
* string table whose first byte is numbered 0.
*/
struct ranlib_64 {
union {
uint64_t ran_strx; /* string table index of */
} ran_un;
uint64_t ran_off; /* library member at this offset */
};
#endif /* _MACH_O_RANLIB_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/reloc.h
================================================
/*
* Copyright (c) 1999 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@
*/
/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MACHO_RELOC_H_
#define _MACHO_RELOC_H_
#include
/*
* Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD
* format. The modifications from the original format were changing the value
* of the r_symbolnum field for "local" (r_extern == 0) relocation entries.
* This modification is required to support symbols in an arbitrary number of
* sections not just the three sections (text, data and bss) in a 4.3BSD file.
* Also the last 4 bits have had the r_type tag added to them.
*/
struct relocation_info {
int32_t r_address; /* offset in the section to what is being
relocated */
uint32_t r_symbolnum:24, /* symbol index if r_extern == 1 or section
ordinal if r_extern == 0 */
r_pcrel:1, /* was relocated pc relative already */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_extern:1, /* does not include value of sym referenced */
r_type:4; /* if not 0, machine specific relocation type */
};
#define R_ABS 0 /* absolute relocation type for Mach-O files */
/*
* The r_address is not really the address as it's name indicates but an offset.
* In 4.3BSD a.out objects this offset is from the start of the "segment" for
* which relocation entry is for (text or data). For Mach-O object files it is
* also an offset but from the start of the "section" for which the relocation
* entry is for. See comments in about the r_address feild
* in images for used with the dynamic linker.
*
* In 4.3BSD a.out objects if r_extern is zero then r_symbolnum is an ordinal
* for the segment the symbol being relocated is in. These ordinals are the
* symbol types N_TEXT, N_DATA, N_BSS or N_ABS. In Mach-O object files these
* ordinals refer to the sections in the object file in the order their section
* structures appear in the headers of the object file they are in. The first
* section has the ordinal 1, the second 2, and so on. This means that the
* same ordinal in two different object files could refer to two different
* sections. And further could have still different ordinals when combined
* by the link-editor. The value R_ABS is used for relocation entries for
* absolute symbols which need no further relocation.
*/
/*
* For RISC machines some of the references are split across two instructions
* and the instruction does not contain the complete value of the reference.
* In these cases a second, or paired relocation entry, follows each of these
* relocation entries, using a PAIR r_type, which contains the other part of the
* reference not contained in the instruction. This other part is stored in the
* pair's r_address field. The exact number of bits of the other part of the
* reference store in the r_address field is dependent on the particular
* relocation type for the particular architecture.
*/
/*
* To make scattered loading by the link editor work correctly "local"
* relocation entries can't be used when the item to be relocated is the value
* of a symbol plus an offset (where the resulting expresion is outside the
* block the link editor is moving, a blocks are divided at symbol addresses).
* In this case. where the item is a symbol value plus offset, the link editor
* needs to know more than just the section the symbol was defined. What is
* needed is the actual value of the symbol without the offset so it can do the
* relocation correctly based on where the value of the symbol got relocated to
* not the value of the expression (with the offset added to the symbol value).
* So for the NeXT 2.0 release no "local" relocation entries are ever used when
* there is a non-zero offset added to a symbol. The "external" and "local"
* relocation entries remain unchanged.
*
* The implemention is quite messy given the compatibility with the existing
* relocation entry format. The ASSUMPTION is that a section will never be
* bigger than 2**24 - 1 (0x00ffffff or 16,777,215) bytes. This assumption
* allows the r_address (which is really an offset) to fit in 24 bits and high
* bit of the r_address field in the relocation_info structure to indicate
* it is really a scattered_relocation_info structure. Since these are only
* used in places where "local" relocation entries are used and not where
* "external" relocation entries are used the r_extern field has been removed.
*
* For scattered loading to work on a RISC machine where some of the references
* are split across two instructions the link editor needs to be assured that
* each reference has a unique 32 bit reference (that more than one reference is
* NOT sharing the same high 16 bits for example) so it move each referenced
* item independent of each other. Some compilers guarantees this but the
* compilers don't so scattered loading can be done on those that do guarantee
* this.
*/
#if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)
/*
* The reason for the ifdef's of __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are that
* when stattered relocation entries were added the mistake of using a mask
* against a structure that is made up of bit fields was used. To make this
* design work this structure must be laid out in memory the same way so the
* mask can be applied can check the same bit each time (r_scattered).
*/
#endif /* defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) */
#define R_SCATTERED 0x80000000 /* mask to be applied to the r_address field
of a relocation_info structure to tell that
is is really a scattered_relocation_info
stucture */
struct scattered_relocation_info {
#ifdef __BIG_ENDIAN__
uint32_t r_scattered:1, /* 1=scattered, 0=non-scattered (see above) */
r_pcrel:1, /* was relocated pc relative already */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_type:4, /* if not 0, machine specific relocation type */
r_address:24; /* offset in the section to what is being
relocated */
int32_t r_value; /* the value the item to be relocated is
refering to (without any offset added) */
#endif /* __BIG_ENDIAN__ */
#ifdef __LITTLE_ENDIAN__
uint32_t
r_address:24, /* offset in the section to what is being
relocated */
r_type:4, /* if not 0, machine specific relocation type */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_pcrel:1, /* was relocated pc relative already */
r_scattered:1; /* 1=scattered, 0=non-scattered (see above) */
int32_t r_value; /* the value the item to be relocated is
refering to (without any offset added) */
#endif /* __LITTLE_ENDIAN__ */
};
/*
* Relocation types used in a generic implementation. Relocation entries for
* normal things use the generic relocation as discribed above and their r_type
* is GENERIC_RELOC_VANILLA (a value of zero).
*
* Another type of generic relocation, GENERIC_RELOC_SECTDIFF, is to support
* the difference of two symbols defined in different sections. That is the
* expression "symbol1 - symbol2 + constant" is a relocatable expression when
* both symbols are defined in some section. For this type of relocation the
* both relocations entries are scattered relocation entries. The value of
* symbol1 is stored in the first relocation entry's r_value field and the
* value of symbol2 is stored in the pair's r_value field.
*
* A special case for a prebound lazy pointer is needed to beable to set the
* value of the lazy pointer back to its non-prebound state. This is done
* using the GENERIC_RELOC_PB_LA_PTR r_type. This is a scattered relocation
* entry where the r_value feild is the value of the lazy pointer not prebound.
*/
enum reloc_type_generic
{
GENERIC_RELOC_VANILLA, /* generic relocation as discribed above */
GENERIC_RELOC_PAIR, /* Only follows a GENERIC_RELOC_SECTDIFF */
GENERIC_RELOC_SECTDIFF,
GENERIC_RELOC_PB_LA_PTR, /* prebound lazy pointer */
GENERIC_RELOC_LOCAL_SECTDIFF,
GENERIC_RELOC_TLV /* thread local variables */
};
#endif /* _MACHO_RELOC_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/stab.h
================================================
/*
* Copyright (c) 1999 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 _MACHO_STAB_H_
#define _MACHO_STAB_H_
/* $NetBSD: stab.h,v 1.4 1994/10/26 00:56:25 cgd Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)stab.h 5.2 (Berkeley) 4/4/91
*/
/*
* This file gives definitions supplementing for permanent symbol
* table entries of Mach-O files. Modified from the BSD definitions. The
* modifications from the original definitions were changing what the values of
* what was the n_other field (an unused field) which is now the n_sect field.
* These modifications are required to support symbols in an arbitrary number of
* sections not just the three sections (text, data and bss) in a BSD file.
* The values of the defined constants have NOT been changed.
*
* These must have one of the N_STAB bits on. The n_value fields are subject
* to relocation according to the value of their n_sect field. So for types
* that refer to things in sections the n_sect field must be filled in with the
* proper section ordinal. For types that are not to have their n_value field
* relocatated the n_sect field must be NO_SECT.
*/
/*
* Symbolic debugger symbols. The comments give the conventional use for
*
* .stabs "n_name", n_type, n_sect, n_desc, n_value
*
* where n_type is the defined constant and not listed in the comment. Other
* fields not listed are zero. n_sect is the section ordinal the entry is
* refering to.
*/
#define N_GSYM 0x20 /* global symbol: name,,NO_SECT,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,NO_SECT,0,0 */
#define N_FUN 0x24 /* procedure: name,,n_sect,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,n_sect,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,n_sect,type,address */
#define N_BNSYM 0x2e /* begin nsect sym: 0,,n_sect,0,address */
#define N_AST 0x32 /* AST file path: name,,NO_SECT,0,0 */
#define N_OPT 0x3c /* emitted with gcc2_compiled and in gcc source */
#define N_RSYM 0x40 /* register sym: name,,NO_SECT,type,register */
#define N_SLINE 0x44 /* src line: 0,,n_sect,linenumber,address */
#define N_ENSYM 0x4e /* end nsect sym: 0,,n_sect,0,address */
#define N_SSYM 0x60 /* structure elt: name,,NO_SECT,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,n_sect,0,address */
#define N_OSO 0x66 /* object file name: name,,(see below),0,st_mtime */
/* historically N_OSO set n_sect to 0. The N_OSO
* n_sect may instead hold the low byte of the
* cpusubtype value from the Mach-O header. */
#define N_LSYM 0x80 /* local sym: name,,NO_SECT,type,offset */
#define N_BINCL 0x82 /* include file beginning: name,,NO_SECT,0,sum */
#define N_SOL 0x84 /* #included file name: name,,n_sect,0,address */
#define N_PARAMS 0x86 /* compiler parameters: name,,NO_SECT,0,0 */
#define N_VERSION 0x88 /* compiler version: name,,NO_SECT,0,0 */
#define N_OLEVEL 0x8A /* compiler -O level: name,,NO_SECT,0,0 */
#define N_PSYM 0xa0 /* parameter: name,,NO_SECT,type,offset */
#define N_EINCL 0xa2 /* include file end: name,,NO_SECT,0,0 */
#define N_ENTRY 0xa4 /* alternate entry: name,,n_sect,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,NO_SECT,nesting level,address */
#define N_EXCL 0xc2 /* deleted include file: name,,NO_SECT,0,sum */
#define N_RBRAC 0xe0 /* right bracket: 0,,NO_SECT,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,,NO_SECT,0,0 */
#define N_ECOMM 0xe4 /* end common: name,,n_sect,0,0 */
#define N_ECOML 0xe8 /* end common (local name): 0,,n_sect,0,address */
#define N_LENG 0xfe /* second stab entry with length information */
/*
* for the berkeley pascal compiler, pc(1):
*/
#define N_PC 0x30 /* global pascal symbol: name,,NO_SECT,subtype,line */
#endif /* _MACHO_STAB_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/swap.h
================================================
/*
* Copyright (c) 1999 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 _MACH_O_SWAP_H_
#define _MACH_O_SWAP_H_
#include
#include
#include
#include
#include
#include
#include
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern void swap_fat_header(
struct fat_header *fat_header,
enum NXByteOrder target_byte_order);
extern void swap_fat_arch(
struct fat_arch *fat_archs,
uint32_t nfat_arch,
enum NXByteOrder target_byte_order);
extern void swap_fat_arch_64(
struct fat_arch_64 *fat_archs64,
uint32_t nfat_arch,
enum NXByteOrder target_byte_order);
extern void swap_mach_header(
struct mach_header *mh,
enum NXByteOrder target_byte_order);
extern void swap_mach_header_64(
struct mach_header_64 *mh,
enum NXByteOrder target_byte_order);
extern void swap_load_command(
struct load_command *lc,
enum NXByteOrder target_byte_order);
extern void swap_segment_command(
struct segment_command *sg,
enum NXByteOrder target_byte_order);
extern void swap_segment_command_64(
struct segment_command_64 *sg,
enum NXByteOrder target_byte_order);
extern void swap_section(
struct section *s,
uint32_t nsects,
enum NXByteOrder target_byte_order);
extern void swap_section_64(
struct section_64 *s,
uint32_t nsects,
enum NXByteOrder target_byte_order);
extern void swap_symtab_command(
struct symtab_command *st,
enum NXByteOrder target_byte_order);
extern void swap_dysymtab_command(
struct dysymtab_command *dyst,
enum NXByteOrder target_byte_sex);
extern void swap_symseg_command(
struct symseg_command *ss,
enum NXByteOrder target_byte_order);
extern void swap_fvmlib_command(
struct fvmlib_command *fl,
enum NXByteOrder target_byte_order);
extern void swap_dylib_command(
struct dylib_command *dl,
enum NXByteOrder target_byte_sex);
extern void swap_sub_framework_command(
struct sub_framework_command *sub,
enum NXByteOrder target_byte_sex);
extern void swap_sub_umbrella_command(
struct sub_umbrella_command *usub,
enum NXByteOrder target_byte_sex);
extern void swap_sub_library_command(
struct sub_library_command *lsub,
enum NXByteOrder target_byte_sex);
extern void swap_sub_client_command(
struct sub_client_command *csub,
enum NXByteOrder target_byte_sex);
extern void swap_prebound_dylib_command(
struct prebound_dylib_command *pbdylib,
enum NXByteOrder target_byte_sex);
extern void swap_dylinker_command(
struct dylinker_command *dyld,
enum NXByteOrder target_byte_sex);
extern void swap_fvmfile_command(
struct fvmfile_command *ff,
enum NXByteOrder target_byte_order);
extern void swap_thread_command(
struct thread_command *ut,
enum NXByteOrder target_byte_order);
extern void swap_ident_command(
struct ident_command *ident,
enum NXByteOrder target_byte_order);
extern void swap_routines_command(
struct routines_command *r_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_routines_command_64(
struct routines_command_64 *r_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_twolevel_hints_command(
struct twolevel_hints_command *hints_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_prebind_cksum_command(
struct prebind_cksum_command *cksum_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_uuid_command(
struct uuid_command *uuid_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_linkedit_data_command(
struct linkedit_data_command *ld,
enum NXByteOrder target_byte_sex);
extern void swap_version_min_command(
struct version_min_command *ver_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_rpath_command(
struct rpath_command *rpath_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_encryption_command(
struct encryption_info_command *ec,
enum NXByteOrder target_byte_sex);
extern void swap_encryption_command_64(
struct encryption_info_command_64 *ec,
enum NXByteOrder target_byte_sex);
extern void swap_linker_option_command(
struct linker_option_command *lo,
enum NXByteOrder target_byte_sex);
extern void swap_dyld_info_command(
struct dyld_info_command *ed,
enum NXByteOrder target_byte_sex);
extern void swap_entry_point_command(
struct entry_point_command *ep,
enum NXByteOrder target_byte_sex);
extern void swap_source_version_command(
struct source_version_command *sv,
enum NXByteOrder target_byte_sex);
extern void swap_note_command(
struct note_command *nc,
enum NXByteOrder target_byte_sex);
extern void swap_build_version_command(
struct build_version_command *bv,
enum NXByteOrder target_byte_sex);
extern void swap_build_tool_version(
struct build_tool_version *bt,
uint32_t ntools,
enum NXByteOrder target_byte_sex);
extern void swap_prebind_cksum_command(
struct prebind_cksum_command *cksum_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_uuid_command(
struct uuid_command *uuid_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_twolevel_hint(
struct twolevel_hint *hints,
uint32_t nhints,
enum NXByteOrder target_byte_sex);
extern void swap_fileset_entry_command(
struct fileset_entry_command *lc,
enum NXByteOrder target_byte_sex);
extern void swap_nlist(
struct nlist *symbols,
uint32_t nsymbols,
enum NXByteOrder target_byte_order);
extern void swap_nlist_64(
struct nlist_64 *symbols,
uint32_t nsymbols,
enum NXByteOrder target_byte_order);
extern void swap_ranlib(
struct ranlib *ranlibs,
uint32_t nranlibs,
enum NXByteOrder target_byte_order);
extern void swap_ranlib_64(
struct ranlib_64 *ranlibs,
uint64_t nranlibs,
enum NXByteOrder target_byte_order);
extern void swap_relocation_info(
struct relocation_info *relocs,
uint32_t nrelocs,
enum NXByteOrder target_byte_order);
extern void swap_indirect_symbols(
uint32_t *indirect_symbols,
uint32_t nindirect_symbols,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_reference(
struct dylib_reference *refs,
uint32_t nrefs,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_module(
struct dylib_module *mods,
uint32_t nmods,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_module_64(
struct dylib_module_64 *mods,
uint32_t nmods,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_table_of_contents(
struct dylib_table_of_contents *tocs,
uint32_t ntocs,
enum NXByteOrder target_byte_sex);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_SWAP_H_ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/mach-o/x86_64/reloc.h
================================================
/*
* Copyright (c) 2006 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@
*/
/*
* Relocations for x86_64 are a bit different than for other architectures in
* Mach-O: Scattered relocations are not used. Almost all relocations produced
* by the compiler are external relocations. An external relocation has the
* r_extern bit set to 1 and the r_symbolnum field contains the symbol table
* index of the target label.
*
* When the assembler is generating relocations, if the target label is a local
* label (begins with 'L'), then the previous non-local label in the same
* section is used as the target of the external relocation. An addend is used
* with the distance from that non-local label to the target label. Only when
* there is no previous non-local label in the section is an internal
* relocation used.
*
* The addend (i.e. the 4 in _foo+4) is encoded in the instruction (Mach-O does
* not have RELA relocations). For PC-relative relocations, the addend is
* stored directly in the instruction. This is different from other Mach-O
* architectures, which encode the addend minus the current section offset.
*
* The relocation types are:
*
* X86_64_RELOC_UNSIGNED // for absolute addresses
* X86_64_RELOC_SIGNED // for signed 32-bit displacement
* X86_64_RELOC_BRANCH // a CALL/JMP instruction with 32-bit displacement
* X86_64_RELOC_GOT_LOAD // a MOVQ load of a GOT entry
* X86_64_RELOC_GOT // other GOT references
* X86_64_RELOC_SUBTRACTOR // must be followed by a X86_64_RELOC_UNSIGNED
*
* The following are sample assembly instructions, followed by the relocation
* and section content they generate in an object file:
*
* call _foo
* r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* E8 00 00 00 00
*
* call _foo+4
* r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* E8 04 00 00 00
*
* movq _foo@GOTPCREL(%rip), %rax
* r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 48 8B 05 00 00 00 00
*
* pushq _foo@GOTPCREL(%rip)
* r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* FF 35 00 00 00 00
*
* movl _foo(%rip), %eax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 8B 05 00 00 00 00
*
* movl _foo+4(%rip), %eax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 8B 05 04 00 00 00
*
* movb $0x12, _foo(%rip)
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* C6 05 FF FF FF FF 12
*
* movl $0x12345678, _foo(%rip)
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* C7 05 FC FF FF FF 78 56 34 12
*
* .quad _foo
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00 00 00 00 00
*
* .quad _foo+4
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 04 00 00 00 00 00 00 00
*
* .quad _foo - _bar
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00 00 00 00 00
*
* .quad _foo - _bar + 4
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 04 00 00 00 00 00 00 00
*
* .long _foo - _bar
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00
*
* lea L1(%rip), %rax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_prev
* 48 8d 05 12 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* lea L0(%rip), %rax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3
* 48 8d 05 56 00 00 00
* // assumes L0 is in third section and there is no previous non-local label.
* // The rip-relative-offset of 0x00000056 is L0-address_of_next_instruction.
* // address_of_next_instruction is the address of the relocation + 4.
*
* add $6,L0(%rip)
* r_type=X86_64_RELOC_SIGNED_1, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3
* 83 05 18 00 00 00 06
* // assumes L0 is in third section and there is no previous non-local label.
* // The rip-relative-offset of 0x00000018 is L0-address_of_next_instruction.
* // address_of_next_instruction is the address of the relocation + 4 + 1.
* // The +1 comes from SIGNED_1. This is used because the relocation is not
* // at the end of the instruction.
*
* .quad L1
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* 12 00 00 00 00 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* .quad L0
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=0, r_pcrel=0, r_symbolnum=3
* 56 00 00 00 00 00 00 00
* // assumes L0 is in third section, has an address of 0x00000056 in .o
* // file, and there is no previous non-local label
*
* .quad _foo - .
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* EE FF FF FF FF FF FF FF
* // assumes _prev is the first non-local label 0x12 bytes before this
* // .quad
*
* .quad _foo - L1
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* EE FF FF FF FF FF FF FF
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* .quad L1 - _prev
* // No relocations. This is an assembly time constant.
* 12 00 00 00 00 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
*
*
* In final linked images, there are only two valid relocation kinds:
*
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=1, r_symbolnum=sym_index
* This tells dyld to add the address of a symbol to a pointer sized (8-byte)
* piece of data (i.e on disk the 8-byte piece of data contains the addend). The
* r_symbolnum contains the index into the symbol table of the target symbol.
*
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=0, r_symbolnum=0
* This tells dyld to adjust the pointer sized (8-byte) piece of data by the amount
* the containing image was loaded from its base address (e.g. slide).
*
*/
enum reloc_type_x86_64
{
X86_64_RELOC_UNSIGNED, // for absolute addresses
X86_64_RELOC_SIGNED, // for signed 32-bit displacement
X86_64_RELOC_BRANCH, // a CALL/JMP instruction with 32-bit displacement
X86_64_RELOC_GOT_LOAD, // a MOVQ load of a GOT entry
X86_64_RELOC_GOT, // other GOT references
X86_64_RELOC_SUBTRACTOR, // must be followed by a X86_64_RELOC_UNSIGNED
X86_64_RELOC_SIGNED_1, // for signed 32-bit displacement with a -1 addend
X86_64_RELOC_SIGNED_2, // for signed 32-bit displacement with a -2 addend
X86_64_RELOC_SIGNED_4, // for signed 32-bit displacement with a -4 addend
X86_64_RELOC_TLV, // for thread local variables
};
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/_workgroup.h
================================================
/*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef ___WORKGROUP_H__
#define ___WORKGROUP_H__
#if !defined(__has_feature)
# define __has_feature(x) 0
#endif
#if (!__has_feature(modules))
#error "Do not include this header directly, please include instead"
#endif
#include
#endif /* ___WORKGROUP_H__ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/activity.h
================================================
/*
* Copyright (c) 2013-2016 Apple Inc. All rights reserved.
*/
#ifndef __OS_ACTIVITY_H__
#define __OS_ACTIVITY_H__
#include
__BEGIN_DECLS
OS_ASSUME_NONNULL_BEGIN
#pragma mark - types and globals
#if OS_LOG_TARGET_HAS_10_12_FEATURES
#ifndef OS_ACTIVITY_OBJECT_API
#define OS_ACTIVITY_OBJECT_API 1
#endif // OS_ACTIVITY_OBJECT_API
#else
#if OS_ACTIVITY_OBJECT_API
#error Please change your minimum OS requirements because OS_ACTIVITY_OBJECT_API is not available
#endif // OS_ACTIVITY_OBJECT_API
#define OS_ACTIVITY_OBJECT_API 0
#endif // OS_LOG_TARGET_HAS_10_12_FEATURES
/*!
* @enum os_activity_flag_t
*
* @discussion
* Support flags for os_activity_create or os_activity_start.
*
* @constant OS_ACTIVITY_FLAG_DEFAULT
* Use the default flags.
*
* @constant OS_ACTIVITY_FLAG_DETACHED
* Detach the newly created activity from the provided activity (if any). If
* passed in conjunction with an exiting activity, the activity will only note
* what activity "created" the new one, but will make the new activity a top
* level activity. This allows users to see what activity triggered work
* without actually relating the activities.
*
* @constant OS_ACTIVITY_FLAG_IF_NONE_PRESENT
* Will only create a new activity if none present. If an activity ID is
* already present, a new object will be returned with the same activity ID
* underneath.
*
* Passing both OS_ACTIVITY_FLAG_DETACHED and OS_ACTIVITY_FLAG_IF_NONE_PRESENT
* is undefined.
*/
OS_ENUM(os_activity_flag, uint32_t,
OS_ACTIVITY_FLAG_DEFAULT = 0,
OS_ACTIVITY_FLAG_DETACHED = 0x1,
OS_ACTIVITY_FLAG_IF_NONE_PRESENT = 0x2
);
#if OS_ACTIVITY_OBJECT_API
#define OS_ACTIVITY_NULL NULL
/*!
* @typedef os_activity_t
* An opaque activity object.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
#if OS_OBJECT_USE_OBJC
OS_OBJECT_DECL(os_activity);
#else
typedef struct os_activity_s *os_activity_t;
#endif /* OS_OBJECT_USE_OBJC */
/*!
* @const OS_ACTIVITY_NONE
*
* @discussion
* Create activity with no current traits, this is the equivalent of a
* detached activity.
*/
#define OS_ACTIVITY_NONE OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_none)
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT
struct os_activity_s _os_activity_none;
/*!
* @const OS_ACTIVITY_CURRENT
*
* @discussion
* Create activity and links to the current activity if one is present.
* If no activity is present it is treated as if it is detached.
*/
#define OS_ACTIVITY_CURRENT OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_current)
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT
struct os_activity_s _os_activity_current;
#else // !OS_ACTIVITY_OBJECT_API
#define OS_ACTIVITY_NULL 0
/*!
* @typedef os_activity_t
* An opaque activity identifier.
*/
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
typedef uint64_t os_activity_t;
#endif // OS_ACTIVITY_OBJECT_API
/*!
* @typedef os_activity_id_t
* An value representing the activity ID assigned to an newly created activity.
*/
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
typedef uint64_t os_activity_id_t;
/*!
* @typedef os_activity_scope_state_t
* Structure that is populated by os_activity_scope_enter and restored using
* os_activity_scope_leave.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
typedef struct os_activity_scope_state_s {
uint64_t opaque[2];
} *os_activity_scope_state_t;
#pragma mark - Internal support functions
#if OS_ACTIVITY_OBJECT_API
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT_NEEDS_RELEASE OS_NOT_TAIL_CALLED
OS_OBJECT_RETURNS_RETAINED
os_activity_t
_os_activity_create(void *dso, const char *description, os_activity_t activity,
os_activity_flag_t flags);
#endif
/*!
* @function _os_activity_label_useraction
*
* @abstract
* Internal function for use by os_activity_label_useraction.
*
* @warning
* Do not use directly.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_activity_label_useraction(void *dso, const char *name);
/*!
* @function _os_activity_initiate
*
* @abstract
* Do not use directly because your description will not be preserved.
*/
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_activity_initiate(void *dso, const char *description,
os_activity_flag_t flags, os_block_t activity_block OS_NOESCAPE);
/*!
* @function _os_activity_initiate_f
*
* @abstract
* Do not use directly because your description will not be preserved.
*/
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_activity_initiate_f(void *dso, const char *description,
os_activity_flag_t flags, void *context, os_function_t function);
#pragma mark - activity related
/*!
* @function os_activity_initiate
*
* @abstract
* Synchronously initiates an activity using provided block.
*
* @discussion
* Synchronously initiates an activity using the provided block and creates
* a tracing buffer as appropriate. All new activities are created as a
* subactivity of an existing activity on the current thread.
*
*
* os_activity_initiate("indexing database", OS_ACTIVITY_FLAG_DEFAULT, ^(void) {
* // either do work directly or issue work asynchronously
* });
*
*
* @param description
* A constant string describing the activity, e.g., "performClick" or
* "menuSelection".
*
* @param flags
* Flags to be used when initiating the activity, typically
* OS_ACTIVITY_FLAG_DEFAULT.
*
* @param activity_block
* The block to execute a given activity
*/
#define os_activity_initiate(description, flags, activity_block) __extension__({ \
OS_LOG_STRING(ACT, __description, description); \
_os_activity_initiate(&__dso_handle, __description, flags, activity_block); \
})
/*!
* @function os_activity_initiate_f
*
* @abstract
* Synchronously initiates an activity using the provided function.
*
* @discussion
* Synchronously initiates an activity using the provided function and creates
* a tracing buffer as appropriate. All new activities are created as a
* subactivity of an existing activity on the current thread.
*
*
* os_activity_initiate_f("indexing database", OS_ACTIVITY_FLAG_DEFAULT, context, function);
*
*
* @param description
* A constant string describing the activity, e.g., "performClick" or
* "menuSelection".
*
* @param flags
* Flags to be used when initiating the activity, typically
* OS_ACTIVITY_FLAG_DEFAULT.
*
* @param context
* An optional context that will be supplied to the activity function.
*
* @param activity_func
* The function to execute for the new activity.
*/
#define os_activity_initiate_f(description, flags, context, function) __extension__({ \
OS_LOG_STRING(ACT, __description, description); \
_os_activity_initiate_f(&__dso_handle, __description, flags, context, function); \
})
#if OS_ACTIVITY_OBJECT_API
/*!
* @function os_activity_create
*
* @abstract
* Creates an os_activity_t object which can be passed to os_activity_apply
* function.
*
* @param description
* Pass a description for the activity. The description must be a constant
* string within the calling executable or library.
*
* @param parent_activity
* Depending on flags will link the newly created activity to the value passed
* or note where the activity was created. Possible activities include:
* OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT or any existing os_activity_t object
* created using os_activity_create.
*
* @param flags
* A valid os_activity_flag_t which will determine behavior of the newly created
* activity.
*
* If the OS_ACTIVITY_FLAG_DETACHED flag is passed, the value passed to the
* parent_activity argument is ignored, and OS_ACTIVITY_NONE is used instead.
*
* If the OS_ACTIVITY_FLAG_IF_NONE_PRESENT flag is passed, then passing another
* value than OS_ACTIVITY_CURRENT to the parent_activity argument is undefined.
*
* @result
* Returns an os_activity_t object which can be used with os_activity_apply.
*/
#define os_activity_create(description, parent_activity, flags) __extension__({ \
OS_LOG_STRING(ACT, __description, description); \
_os_activity_create(&__dso_handle, __description, parent_activity, flags); \
})
/*!
* @function os_activity_apply
*
* @abstract
* Execute a block using a given activity object.
*
* @param activity
* The given activity object created with os_activity_create() or
* OS_ACTIVITY_NONE.
*
* @param block
* Pass the block to be executed within the context of the given activity.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW
void
os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
/*!
* @function os_activity_apply_f
*
* @abstract
* Execute a given function with a provided activity.
*
* @param activity
* The given activity object created with os_activity_create() or
* OS_ACTIVITY_NONE.
*
* @param context
* Context to pass to the function which may be NULL.
*
* @param function
* Pass the function to be executed within the context of the given activity.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW
void
os_activity_apply_f(os_activity_t activity, void *context,
os_function_t function);
/*!
* @function os_activity_scope_enter
*
* @abstract
* Will change the current execution context to use the provided activity.
*
* @discussion
* Will change the current execution context to use the provided activity.
* An activity can be created and then applied to the current scope by doing:
*
*
* struct os_activity_scope_state_s state;
* os_activity_t activity = os_activity_create("my new activity", 0);
* os_activity_scope_enter(activity, &state);
* ... do some work ...
* os_activity_scope_leave(&state);
*
*
* To auto-cleanup state call:
*
* os_activity_scope(activity);
*
* @param activity
* Pass a valid activity created with os_activity_create or any global object.
*
* @param state
* A stack-based struct os_activity_scope_state_s to store the state.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW
void
os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state);
/*!
* @function os_activity_scope_leave
*
* @abstract
* Will pop state up to the state provided.
*
* @discussion
* Will leave scope using the state provided. If state is not present an error
* will be generated.
*
* @param state
* Must be a valid value filled by os_activity_scope_enter call.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW
void
os_activity_scope_leave(os_activity_scope_state_t state);
#if defined(__GNUC__)
#define _os_activity_scope(var, activity) \
struct os_activity_scope_state_s var __attribute__((__cleanup__(os_activity_scope_leave))); \
os_activity_scope_enter(activity, &var)
#define os_activity_scope(activity) _os_activity_scope(OS_CONCAT(scope, __COUNTER__), activity)
#endif
#endif // OS_ACTIVITY_OBJECT_API
/*!
* @function os_activity_get_active
*
* @abstract
* Returns the stack of nested activities associated with the current thread.
*
* @discussion
* Activities have a sense of nesting and therefore there could be more than
* one activity involved on the current thread. This should be used by
* diagnostic tools only for making additional decisions about a situation.
*
* @param entries
* Pass a buffer of sufficient size to hold the the number of os_activity_id_t
* being requested.
*
* @param count
* Pointer to the requested number of activity identifiers.
* On output will be filled with the number of activities that are available.
*
* @result
* Number of activity identifiers written to 'entries'
*/
API_DEPRECATED("No longer supported", macos(10.10, 10.12), ios(8.0, 10.0),
watchos(2.0, 3.0), tvos(9.0, 10.0))
OS_EXPORT OS_NOTHROW
unsigned int
os_activity_get_active(os_activity_id_t *entries, unsigned int *count);
/*!
* @function os_activity_get_identifier
*
* @abstract
* Returns the current activity ID and will fill the parent_id if present.
*
* @discussion
* Returns the current activity ID and will fill the parent_id if present.
*
* @param parent_id
* If non-null will set the parent activity ID.
*
* @result
* The identifier for the provided activity.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
os_activity_id_t
os_activity_get_identifier(os_activity_t activity,
os_activity_id_t *_Nullable parent_id);
/*!
* @function os_activity_label_useraction
*
* @abstract
* Label an activity that is auto-generated by AppKit/UIKit with a name that is
* useful for debugging macro-level user actions.
*
* @discussion
* Label an activity that is auto-generated by AppKit/UIKit with a name that is
* useful for debugging macro-level user actions. The API should be called
* early within the scope of the IBAction and before any sub-activities are
* created. The name provided will be shown in tools in additon to the
* underlying AppKit/UIKit provided name. This API can only be called once and
* only on the activity created by AppKit/UIKit. These actions help determine
* workflow of the user in order to reproduce problems that occur. For example,
* a control press and/or menu item selection can be labeled:
*
*
* os_activity_label_useraction("New mail message");
* os_activity_label_useraction("Empty trash");
*
*
* Where the underlying AppKit/UIKit name will be "gesture:" or "menuSelect:".
*
* @param name
* A constant string that describes the the action.
*/
#define os_activity_label_useraction(label) __extension__({ \
OS_LOG_STRING(ACT, __label, label); \
_os_activity_label_useraction(&__dso_handle, __label); \
})
#pragma mark - deprecated function support
/*!
* @function _os_activity_start
*
* @abstract
* Internal function for activity start, do not use directly will not preserve
* description.
*/
API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope",
macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NOT_TAIL_CALLED
os_activity_t
_os_activity_start(void *dso, const char *description, os_activity_flag_t flags);
/*!
* @function os_activity_start
*
* @warning
* Deprecated please use new os_activity_create and os_activity_apply.
*/
#define os_activity_start(description, flags) __extension__({ \
OS_LOG_STRING(ACT, __description, description); \
_os_activity_start(&__dso_handle, __description, flags); \
})
/*!
* @function os_activity_end
*
* @warning
* Deprecated please use new os_activity_create and os_activity_apply.
*/
API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope",
macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
OS_EXPORT OS_NOTHROW
void
os_activity_end(os_activity_t activity);
/*!
* @typedef os_breadcrumb_t
* An opaque value for the breadcrumb ID.
*/
API_DEPRECATED("No longer supported", macos(10.10, 10.12), ios(8.0, 10.0),
watchos(2.0, 3.0), tvos(9.0, 10.0))
typedef uint32_t os_breadcrumb_t;
/*!
* @function _os_activity_set_breadcrumb
*
* @warning
* Deprecated, please use os_activity_label_useraction.
*/
API_DEPRECATED_WITH_REPLACEMENT("os_activity_label_useraction",
macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_activity_set_breadcrumb(void *dso, const char *name);
/*!
* @function os_activity_set_breadcrumb
*
* @warning
* Deprecated, please use os_activity_label_useraction.
*/
#define os_activity_set_breadcrumb(name) __extension__({ \
OS_LOG_STRING(ACT, __name, name); \
_os_activity_set_breadcrumb(&__dso_handle, __name); \
})
OS_ASSUME_NONNULL_END
__END_DECLS
#endif // __OS_ACTIVITY_H__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/atomic.h
================================================
/*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __OS_ATOMIC_H__
#define __OS_ATOMIC_H__
/*!
* @file
*
* @brief
* Small header that helps write code that works with both C11 and C++11,
* or pre-C11 type declarations.
*
* @discussion
* The macros below allow to write code like this, that can be put in a header
* and will work with both C11 and C++11:
*
*
* struct old_type {
* int atomic_field;
* } old_variable;
*
* os_atomic_std(atomic_fetch_add_explicit)(
* os_cast_to_atomic_pointer(&old_variable), 1,
* os_atomic_std(memory_order_relaxed));
*
*/
#include
#ifndef OS_ATOMIC_USES_CXX
#if defined(__cplusplus) && __cplusplus >= 201103L
#define OS_ATOMIC_USES_CXX 1
#else
#define OS_ATOMIC_USES_CXX 0
#endif
#endif
#if OS_ATOMIC_USES_CXX
#include
#define OS_ATOMIC_STD std::
#define os_atomic_std(op) std::op
#define os_atomic(type) std::atomic volatile
#define os_cast_to_atomic_pointer(p) os::cast_to_atomic_pointer(p)
#define os_atomic_basetypeof(p) decltype(os_cast_to_atomic_pointer(p)->load())
#define os_cast_to_nonatomic_pointer(p) os::cast_to_nonatomic_pointer(p)
#else /* !OS_ATOMIC_USES_CXX */
#include
#define OS_ATOMIC_STD
#define os_atomic_std(op) op
#define os_atomic(type) type volatile _Atomic
#define os_cast_to_atomic_pointer(p) (__typeof__(*(p)) volatile _Atomic *)(uintptr_t)(p)
#define os_atomic_basetypeof(p) __typeof__(atomic_load(os_cast_to_atomic_pointer(p)))
#define os_cast_to_nonatomic_pointer(p) (os_atomic_basetypeof(p) *)(uintptr_t)(p)
#endif /* !OS_ATOMIC_USES_CXX */
/*!
* @group Internal implementation details
*
* @discussion The functions below are not intended to be used directly.
*/
#if OS_ATOMIC_USES_CXX
#include
namespace os {
template using add_volatile_t = typename std::add_volatile::type;
template using remove_volatile_t = typename std::remove_volatile::type;
template
inline add_volatile_t > > *
cast_to_atomic_pointer(T *v)
{
return reinterpret_cast > > *>(v);
}
template
inline add_volatile_t > > *
cast_to_atomic_pointer(std::atomic *v)
{
return reinterpret_cast > > *>(v);
}
template
inline remove_volatile_t *
cast_to_nonatomic_pointer(T *v)
{
return const_cast *>(v);
}
template
inline remove_volatile_t *
cast_to_nonatomic_pointer(std::atomic *v)
{
return reinterpret_cast *>(v);
}
template
inline remove_volatile_t *
cast_to_nonatomic_pointer(volatile std::atomic *v)
{
auto _v = const_cast *>(v);
return reinterpret_cast *>(_v);
}
};
#endif /* OS_ATOMIC_USES_CXX */
#endif /* __OS_ATOMIC_H__ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/availability.h
================================================
/*
* Copyright (c) 2008-2017 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_AVAILABILITY__
#define __OS_AVAILABILITY__
/*
* API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated
* in an upcoming release. This soft deprecation is an intermediate step before formal
* deprecation to notify developers about the API before compiler warnings are generated.
* You can find all places in your code that use soft deprecated API by redefining the
* value of this macro to your current minimum deployment target, for example:
* (macOS)
* clang -DAPI_TO_BE_DEPRECATED=10.12
* (iOS)
* clang -DAPI_TO_BE_DEPRECATED=11.0
*/
#ifndef API_TO_BE_DEPRECATED
#define API_TO_BE_DEPRECATED 100000
#endif
#include
#if defined(__has_feature) && defined(__has_attribute)
#if __has_attribute(availability)
/*
* API Introductions
*
* Use to specify the release that a particular API became available.
*
* Platform names:
* macos, ios, tvos, watchos
*
* Examples:
* API_AVAILABLE(macos(10.10))
* API_AVAILABLE(macos(10.9), ios(10.0))
* API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
*/
#define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE7, __API_AVAILABLE6, __API_AVAILABLE5, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1, 0)(__VA_ARGS__)
#define API_AVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_AVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_AVAILABLE_BEGIN7,__API_AVAILABLE_BEGIN6, __API_AVAILABLE_BEGIN5, __API_AVAILABLE_BEGIN4, __API_AVAILABLE_BEGIN3, __API_AVAILABLE_BEGIN2, __API_AVAILABLE_BEGIN1, 0)(__VA_ARGS__)
#define API_AVAILABLE_END _Pragma("clang attribute pop")
/*
* API Deprecations
*
* Use to specify the release that a particular API became unavailable.
*
* Platform names:
* macos, ios, tvos, watchos
*
* Examples:
*
* API_DEPRECATED("No longer supported", macos(10.4, 10.8))
* API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
*
* API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
* API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
*/
#define API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG8,__API_DEPRECATED_MSG7, __API_DEPRECATED_MSG6,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1, 0)(__VA_ARGS__)
#define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP8,__API_DEPRECATED_REP7, __API_DEPRECATED_REP6,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1, 0)(__VA_ARGS__)
#define API_DEPRECATED_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN_MSG8,__API_DEPRECATED_BEGIN_MSG7, __API_DEPRECATED_BEGIN_MSG6, __API_DEPRECATED_BEGIN_MSG5, __API_DEPRECATED_BEGIN_MSG4, __API_DEPRECATED_BEGIN_MSG3, __API_DEPRECATED_BEGIN_MSG2, __API_DEPRECATED_BEGIN_MSG1, 0)(__VA_ARGS__)
#define API_DEPRECATED_END _Pragma("clang attribute pop")
#define API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN_REP8,__API_DEPRECATED_BEGIN_REP7, __API_DEPRECATED_BEGIN_REP6, __API_DEPRECATED_BEGIN_REP5, __API_DEPRECATED_BEGIN_REP4, __API_DEPRECATED_BEGIN_REP3, __API_DEPRECATED_BEGIN_REP2, __API_DEPRECATED_BEGIN_REP1, 0)(__VA_ARGS__)
#define API_DEPRECATED_WITH_REPLACEMENT_END _Pragma("clang attribute pop")
/*
* API Unavailability
* Use to specify that an API is unavailable for a particular platform.
*
* Example:
* API_UNAVAILABLE(macos)
* API_UNAVAILABLE(watchos, tvos)
*/
#define API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE7,__API_UNAVAILABLE6, __API_UNAVAILABLE5, __API_UNAVAILABLE4,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1, 0)(__VA_ARGS__)
#define API_UNAVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_UNAVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE_BEGIN7,__API_UNAVAILABLE_BEGIN6, __API_UNAVAILABLE_BEGIN5, __API_UNAVAILABLE_BEGIN4, __API_UNAVAILABLE_BEGIN3, __API_UNAVAILABLE_BEGIN2, __API_UNAVAILABLE_BEGIN1, 0)(__VA_ARGS__)
#define API_UNAVAILABLE_END _Pragma("clang attribute pop")
#else
/*
* Evaluate to nothing for compilers that don't support availability.
*/
#define API_AVAILABLE(...)
#define API_AVAILABLE_BEGIN(...)
#define API_AVAILABLE_END
#define API_DEPRECATED(...)
#define API_DEPRECATED_WITH_REPLACEMENT(...)
#define API_DEPRECATED_BEGIN(...)
#define API_DEPRECATED_END
#define API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...)
#define API_DEPRECATED_WITH_REPLACEMENT_END
#define API_UNAVAILABLE(...)
#define API_UNAVAILABLE_BEGIN(...)
#define API_UNAVAILABLE_END
#endif /* __has_attribute(availability) */
#else
/*
* Evaluate to nothing for compilers that don't support clang language extensions.
*/
#define API_AVAILABLE(...)
#define API_AVAILABLE_BEGIN(...)
#define API_AVAILABLE_END
#define API_DEPRECATED(...)
#define API_DEPRECATED_WITH_REPLACEMENT(...)
#define API_DEPRECATED_BEGIN(...)
#define API_DEPRECATED_END
#define API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...)
#define API_DEPRECATED_WITH_REPLACEMENT_END
#define API_UNAVAILABLE(...)
#define API_UNAVAILABLE_BEGIN(...)
#define API_UNAVAILABLE_END
#endif /* #if defined(__has_feature) && defined(__has_attribute) */
#if __has_include()
#include
#endif
/*
* If SPI decorations have not been defined elsewhere, disable them.
*/
#ifndef SPI_AVAILABLE
#define SPI_AVAILABLE(...)
#endif
#ifndef SPI_DEPRECATED
#define SPI_DEPRECATED(...)
#endif
#ifndef SPI_DEPRECATED_WITH_REPLACEMENT
#define SPI_DEPRECATED_WITH_REPLACEMENT(...)
#endif
#endif /* __OS_AVAILABILITY__ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/base.h
================================================
/*
* Copyright (c) 2008-2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_BASE__
#define __OS_BASE__
#include
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_include
#define __has_include(x) 0
#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#undef OS_INLINE //
#if __GNUC__
#define OS_NORETURN __attribute__((__noreturn__))
#define OS_NOTHROW __attribute__((__nothrow__))
#define OS_NONNULL1 __attribute__((__nonnull__(1)))
#define OS_NONNULL2 __attribute__((__nonnull__(2)))
#define OS_NONNULL3 __attribute__((__nonnull__(3)))
#define OS_NONNULL4 __attribute__((__nonnull__(4)))
#define OS_NONNULL5 __attribute__((__nonnull__(5)))
#define OS_NONNULL6 __attribute__((__nonnull__(6)))
#define OS_NONNULL7 __attribute__((__nonnull__(7)))
#define OS_NONNULL8 __attribute__((__nonnull__(8)))
#define OS_NONNULL9 __attribute__((__nonnull__(9)))
#define OS_NONNULL10 __attribute__((__nonnull__(10)))
#define OS_NONNULL11 __attribute__((__nonnull__(11)))
#define OS_NONNULL12 __attribute__((__nonnull__(12)))
#define OS_NONNULL13 __attribute__((__nonnull__(13)))
#define OS_NONNULL14 __attribute__((__nonnull__(14)))
#define OS_NONNULL15 __attribute__((__nonnull__(15)))
#define OS_NONNULL_ALL __attribute__((__nonnull__))
#define OS_SENTINEL __attribute__((__sentinel__))
#define OS_PURE __attribute__((__pure__))
#define OS_CONST __attribute__((__const__))
#define OS_WARN_RESULT __attribute__((__warn_unused_result__))
#define OS_MALLOC __attribute__((__malloc__))
#define OS_USED __attribute__((__used__))
#define OS_UNUSED __attribute__((__unused__))
#define OS_COLD __attribute__((__cold__))
#define OS_WEAK __attribute__((__weak__))
#define OS_WEAK_IMPORT __attribute__((__weak_import__))
#define OS_NOINLINE __attribute__((__noinline__))
#define OS_ALWAYS_INLINE __attribute__((__always_inline__))
#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)))
#define OS_EXPORT extern __attribute__((__visibility__("default")))
#define OS_INLINE static __inline__
#define OS_EXPECT(x, v) __builtin_expect((x), (v))
#else
#define OS_NORETURN
#define OS_NOTHROW
#define OS_NONNULL1
#define OS_NONNULL2
#define OS_NONNULL3
#define OS_NONNULL4
#define OS_NONNULL5
#define OS_NONNULL6
#define OS_NONNULL7
#define OS_NONNULL8
#define OS_NONNULL9
#define OS_NONNULL10
#define OS_NONNULL11
#define OS_NONNULL12
#define OS_NONNULL13
#define OS_NONNULL14
#define OS_NONNULL15
#define OS_NONNULL_ALL
#define OS_SENTINEL
#define OS_PURE
#define OS_CONST
#define OS_WARN_RESULT
#define OS_MALLOC
#define OS_USED
#define OS_UNUSED
#define OS_COLD
#define OS_WEAK
#define OS_WEAK_IMPORT
#define OS_NOINLINE
#define OS_ALWAYS_INLINE
#define OS_TRANSPARENT_UNION
#define OS_ALIGNED(n)
#define OS_FORMAT_PRINTF(x, y)
#define OS_EXPORT extern
#define OS_INLINE static inline
#define OS_EXPECT(x, v) (x)
#endif
#if __has_attribute(noescape)
#define OS_NOESCAPE __attribute__((__noescape__))
#else
#define OS_NOESCAPE
#endif
#if defined(__cplusplus) && defined(__clang__)
#define OS_FALLTHROUGH [[clang::fallthrough]]
#elif __has_attribute(fallthrough)
#define OS_FALLTHROUGH __attribute__((__fallthrough__))
#else
#define OS_FALLTHROUGH
#endif
#if __has_feature(assume_nonnull)
#define OS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define OS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#else
#define OS_ASSUME_NONNULL_BEGIN
#define OS_ASSUME_NONNULL_END
#endif
#if __has_builtin(__builtin_assume)
#define OS_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
#else
#define OS_COMPILER_CAN_ASSUME(expr) ((void)(expr))
#endif
#if __has_extension(attribute_overloadable)
#define OS_OVERLOADABLE __attribute__((__overloadable__))
#else
#define OS_OVERLOADABLE
#endif
#if __has_attribute(analyzer_suppress)
#define OS_ANALYZER_SUPPRESS(RADAR) __attribute__((analyzer_suppress))
#else
#define OS_ANALYZER_SUPPRESS(RADAR)
#endif
#if __has_attribute(enum_extensibility)
#define __OS_ENUM_ATTR __attribute__((enum_extensibility(open)))
#define __OS_ENUM_ATTR_CLOSED __attribute__((enum_extensibility(closed)))
#else
#define __OS_ENUM_ATTR
#define __OS_ENUM_ATTR_CLOSED
#endif // __has_attribute(enum_extensibility)
#if __has_attribute(flag_enum)
/*!
* Compile with -Wflag-enum and -Wassign-enum to enforce at definition and
* assignment, respectively, i.e. -Wflag-enum prevents you from creating new
* enumeration values from illegal values within the enum definition, and
* -Wassign-enum prevents you from assigning illegal values to a variable of the
* enum type.
*/
#define __OS_OPTIONS_ATTR __attribute__((flag_enum))
#else
#define __OS_OPTIONS_ATTR
#endif // __has_attribute(flag_enum)
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \
__has_extension(cxx_strong_enums)
#define OS_ENUM(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } _name##_t
#define OS_CLOSED_ENUM(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED _name##_t
#define OS_OPTIONS(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t
#define OS_CLOSED_OPTIONS(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t
#else
/*!
* There is unfortunately no good way in plain C to have both fixed-type enums
* and enforcement for clang's enum_extensibility extensions. The primary goal
* of these macros is to allow you to define an enum and specify its width in a
* single statement, and for plain C that is accomplished by defining an
* anonymous enum and then separately typedef'ing the requested type name to the
* requested underlying integer type. So the type emitted actually has no
* relationship at all to the enum, and therefore while the compiler could
* enforce enum extensibility if you used the enum type, it cannot do so if you
* use the "_t" type resulting from this expression.
*
* But we still define a named enum type and decorate it appropriately for you,
* so if you really want the enum extensibility enforcement, you can use the
* enum type yourself, i.e. when compiling with a C compiler:
*
* OS_CLOSED_ENUM(my_type, uint64_t,
* FOO,
* BAR,
* BAZ,
* );
*
* my_type_t mt = 98; // legal
* enum my_type emt = 98; // illegal
*
* But be aware that the underlying enum type's width is subject only to the C
* language's guarantees -- namely that it will be compatible with int, char,
* and unsigned char. It is not safe to rely on the size of this type.
*
* When compiling in ObjC or C++, both of the above assignments are illegal.
*/
#define __OS_ENUM_C_FALLBACK(_name, _type, ...) \
typedef _type _name##_t; enum _name { __VA_ARGS__ }
#define OS_ENUM(_name, _type, ...) \
typedef _type _name##_t; enum { __VA_ARGS__ }
#define OS_CLOSED_ENUM(_name, _type, ...) \
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR_CLOSED
#define OS_OPTIONS(_name, _type, ...) \
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR __OS_OPTIONS_ATTR
#define OS_CLOSED_OPTIONS(_name, _type, ...) \
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR
#endif // __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
#if __has_feature(attribute_availability_swift)
// equivalent to __SWIFT_UNAVAILABLE from Availability.h
#define OS_SWIFT_UNAVAILABLE(_msg) \
__attribute__((__availability__(swift, unavailable, message=_msg)))
#else
#define OS_SWIFT_UNAVAILABLE(_msg)
#endif
#if __has_attribute(swift_private)
# define OS_REFINED_FOR_SWIFT __attribute__((__swift_private__))
#else
# define OS_REFINED_FOR_SWIFT
#endif
#if __has_attribute(swift_name)
# define OS_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
#else
# define OS_SWIFT_NAME(_name)
#endif
#define __OS_STRINGIFY(s) #s
#define OS_STRINGIFY(s) __OS_STRINGIFY(s)
#define __OS_CONCAT(x, y) x ## y
#define OS_CONCAT(x, y) __OS_CONCAT(x, y)
#ifdef __GNUC__
#define os_prevent_tail_call_optimization() __asm__("")
#define os_is_compile_time_constant(expr) __builtin_constant_p(expr)
#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory")
#else
#define os_prevent_tail_call_optimization() do { } while (0)
#define os_is_compile_time_constant(expr) 0
#define os_compiler_barrier() do { } while (0)
#endif
#if __has_attribute(not_tail_called)
#define OS_NOT_TAIL_CALLED __attribute__((__not_tail_called__))
#else
#define OS_NOT_TAIL_CALLED
#endif
typedef void (*os_function_t)(void *_Nullable);
#ifdef __BLOCKS__
/*!
* @typedef os_block_t
*
* @abstract
* Generic type for a block taking no arguments and returning no value.
*
* @discussion
* When not building with Objective-C ARC, a block object allocated on or
* copied to the heap must be released with a -[release] message or the
* Block_release() function.
*
* The declaration of a block literal allocates storage on the stack.
* Therefore, this is an invalid construct:
*
* os_block_t block;
* if (x) {
* block = ^{ printf("true\n"); };
* } else {
* block = ^{ printf("false\n"); };
* }
* block(); // unsafe!!!
*
*
* What is happening behind the scenes:
*
* if (x) {
* struct Block __tmp_1 = ...; // setup details
* block = &__tmp_1;
* } else {
* struct Block __tmp_2 = ...; // setup details
* block = &__tmp_2;
* }
*
*
* As the example demonstrates, the address of a stack variable is escaping the
* scope in which it is allocated. That is a classic C bug.
*
* Instead, the block literal must be copied to the heap with the Block_copy()
* function or by sending it a -[copy] message.
*/
typedef void (^os_block_t)(void);
#endif
#endif // __OS_BASE__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/clock.h
================================================
#ifndef __OS_CLOCK__
#define __OS_CLOCK__
#include
#include
/*
* @typedef os_clockid_t
*
* @abstract
* Describes the kind of clock that the workgroup timestamp parameters are
* specified in
*/
OS_ENUM(os_clockid, uint32_t,
OS_CLOCK_MACH_ABSOLUTE_TIME = 32,
);
#endif /* __OS_CLOCK__ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/lock.h
================================================
/*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_LOCK__
#define __OS_LOCK__
#include
#include
#include
#include
#include
#include
OS_ASSUME_NONNULL_BEGIN
/*! @header
* Low-level lock API.
*/
#define OS_LOCK_API_VERSION 20160309
__BEGIN_DECLS
#define OS_UNFAIR_LOCK_AVAILABILITY \
__API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
/*!
* @typedef os_unfair_lock
*
* @abstract
* Low-level lock that allows waiters to block efficiently on contention.
*
* In general, higher level synchronization primitives such as those provided by
* the pthread or dispatch subsystems should be preferred.
*
* The values stored in the lock should be considered opaque and implementation
* defined, they contain thread ownership information that the system may use
* to attempt to resolve priority inversions.
*
* This lock must be unlocked from the same thread that locked it, attempts to
* unlock from a different thread will cause an assertion aborting the process.
*
* This lock must not be accessed from multiple processes or threads via shared
* or multiply-mapped memory, the lock implementation relies on the address of
* the lock value and owning process.
*
* Must be initialized with OS_UNFAIR_LOCK_INIT
*
* @discussion
* Replacement for the deprecated OSSpinLock. Does not spin on contention but
* waits in the kernel to be woken up by an unlock.
*
* As with OSSpinLock there is no attempt at fairness or lock ordering, e.g. an
* unlocker can potentially immediately reacquire the lock before a woken up
* waiter gets an opportunity to attempt to acquire the lock. This may be
* advantageous for performance reasons, but also makes starvation of waiters a
* possibility.
*/
OS_UNFAIR_LOCK_AVAILABILITY
typedef struct os_unfair_lock_s {
uint32_t _os_unfair_lock_opaque;
} os_unfair_lock, *os_unfair_lock_t;
#ifndef OS_UNFAIR_LOCK_INIT
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define OS_UNFAIR_LOCK_INIT ((os_unfair_lock){0})
#elif defined(__cplusplus) && __cplusplus >= 201103L
#define OS_UNFAIR_LOCK_INIT (os_unfair_lock{})
#elif defined(__cplusplus)
#define OS_UNFAIR_LOCK_INIT (os_unfair_lock())
#else
#define OS_UNFAIR_LOCK_INIT {0}
#endif
#endif // OS_UNFAIR_LOCK_INIT
/*!
* @function os_unfair_lock_lock
*
* @abstract
* Locks an os_unfair_lock.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_lock(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_trylock
*
* @abstract
* Locks an os_unfair_lock if it is not already locked.
*
* @discussion
* It is invalid to surround this function with a retry loop, if this function
* returns false, the program must be able to proceed without having acquired
* the lock, or it must call os_unfair_lock_lock() directly (a retry loop around
* os_unfair_lock_trylock() amounts to an inefficient implementation of
* os_unfair_lock_lock() that hides the lock waiter from the system and prevents
* resolution of priority inversions).
*
* @param lock
* Pointer to an os_unfair_lock.
*
* @result
* Returns true if the lock was succesfully locked and false if the lock was
* already locked.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NONNULL_ALL
bool os_unfair_lock_trylock(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_unlock
*
* @abstract
* Unlocks an os_unfair_lock.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_unlock(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_assert_owner
*
* @abstract
* Asserts that the calling thread is the current owner of the specified
* unfair lock.
*
* @discussion
* If the lock is currently owned by the calling thread, this function returns.
*
* If the lock is unlocked or owned by a different thread, this function
* asserts and terminates the process.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_assert_owner(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_assert_not_owner
*
* @abstract
* Asserts that the calling thread is not the current owner of the specified
* unfair lock.
*
* @discussion
* If the lock is unlocked or owned by a different thread, this function
* returns.
*
* If the lock is currently owned by the current thread, this function asserts
* and terminates the process.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_assert_not_owner(os_unfair_lock_t lock);
__END_DECLS
OS_ASSUME_NONNULL_END
#endif // __OS_LOCK__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/log.h
================================================
/*
* Copyright (c) 2015-2016 Apple Inc. All rights reserved.
*/
#ifndef __OS_LOG_H__
#define __OS_LOG_H__
#include
#include
#include
#include
#include
#include
#include
#if !__has_builtin(__builtin_os_log_format)
#error using os/log.h requires Xcode 8 or later
#endif
__BEGIN_DECLS
#if OS_OBJECT_SWIFT3
OS_OBJECT_DECL_SWIFT(os_log);
#elif OS_OBJECT_USE_OBJC
OS_OBJECT_DECL(os_log);
#else
typedef struct os_log_s *os_log_t;
#endif /* OS_OBJECT_USE_OBJC */
/*!
* @const OS_LOG_DISABLED
*
* @discussion
* Use this to disable a specific log message.
*/
#if OS_LOG_TARGET_HAS_10_13_FEATURES
#define OS_LOG_DISABLED OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_disabled)
API_AVAILABLE(macosx(10.13), ios(11.0), watchos(4.0), tvos(11.0))
OS_EXPORT
struct os_log_s _os_log_disabled;
#else
#define OS_LOG_DISABLED ((os_log_t _Nonnull)NULL)
#endif
/*!
* @const OS_LOG_DEFAULT
*
* @discussion
* Use this to log a message in accordance with current system settings.
*/
#define OS_LOG_DEFAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_default)
API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
OS_EXPORT
struct os_log_s _os_log_default;
/*!
* @enum os_log_type_t
*
* @discussion
* Supported log message types.
*
* @constant OS_LOG_TYPE_DEFAULT
* Equivalent type for "os_log()" messages, i.e., default messages that are
* always captured to memory or disk.
*
* @constant OS_LOG_TYPE_INFO
* Equivalent type for "os_log_info()" messages, i.e., additional informational
* messages.
*
* @constant OS_LOG_TYPE_DEBUG
* Equivalent type for "os_log_debug()" messages, i.e., debug messages.
*
* @constant OS_LOG_TYPE_ERROR
* Equivalent type for "os_log_error()" messages, i.e., messages indicating
* error conditions.
*
* @constant OS_LOG_TYPE_FAULT
* Equivalent type for "os_log_fault()" messages, i.e., messages indicating
* that an unexpected condition occurred that likely indicates the presence of a
* bug.
*/
OS_ENUM(os_log_type, uint8_t,
OS_LOG_TYPE_DEFAULT = 0x00,
OS_LOG_TYPE_INFO = 0x01,
OS_LOG_TYPE_DEBUG = 0x02,
OS_LOG_TYPE_ERROR = 0x10,
OS_LOG_TYPE_FAULT = 0x11,
);
/*!
* @function os_log_create
*
* @abstract
* Creates a log object to be used with other log related functions.
*
* @discussion
* Creates a log object to be used with other log related functions. The
* log object serves two purposes: (1) tag related messages by subsystem
* and category name for easy filtering, and (2) control logging system
* behavior for messages.
*
* @param subsystem
* The identifier of the given subsystem should be in reverse DNS form
* (i.e., com.company.mysubsystem).
*
* @param category
* The category within the given subsystem that specifies the settings for
* the log object.
*
* @result
* Returns an os_log_t value to be passed to other os_log API calls. The
* logging runtime maintains a global collection of all os_log_t objects, one
* per subsystem/category pair. The os_log_t for a given subsystem/category is
* created upon the first call to os_log_create and any subsequent calls return
* the same object. These objects are never deallocated, so dynamic creation
* (e.g. on a per-operation basis) is generally inappropriate.
*
* A value will always be returned to allow for dynamic enablement.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_OBJECT_RETURNS_RETAINED OS_NONNULL_ALL
os_log_t
os_log_create(const char *subsystem, const char *category);
/*!
* @function os_log_info_enabled
*
* @abstract
* Returns if additional information is enabled
*
* @discussion
* Returns if additional information is enabled
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @result
* Returns ‘true’ if info log messages are enabled.
*/
#define os_log_info_enabled(log) os_log_type_enabled(log, OS_LOG_TYPE_INFO)
/*!
* @function os_log_debug_enabled
*
* @abstract
* Returns if debug log messages are enabled for a particular log object.
*
* @discussion
* Returns if debug log messages are enabled for a particular log object.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @result
* Returns ‘true’ if debug log messages are enabled.
*/
#define os_log_debug_enabled(log) os_log_type_enabled(log, OS_LOG_TYPE_DEBUG)
/*!
* @function os_log_with_type
*
* @abstract
* Log a message using a specific type.
*
* @discussion
* Will log a message with the provided os_log_type_t.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param type
* Pass a valid type from os_log_type_t.
*
* @param format
* A format string to generate a human-readable log message when the log
* line is decoded. This string must be a constant string, not dynamically
* generated. Supports all standard printf types in addition to %@ (objects).
*/
#define os_log_with_type(log, type, format, ...) __extension__({ \
os_log_t _log_tmp = (log); \
os_log_type_t _type_tmp = (type); \
if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
OS_LOG_CALL_WITH_FORMAT(_os_log_impl, \
(&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
} \
})
/*!
* @function os_log
*
* @abstract
* Insert a log message into the Unified Logging and Tracing system.
*
* @discussion
* Insert a log message into the Unified Logging and Tracing system in
* accordance with the preferences specified by the provided log object.
* These messages cannot be disabled and therefore always captured either
* to memory or disk.
*
* When an os_activity_id_t is present, the log message will also be scoped by
* that identifier. Activities provide granular filtering of log messages
* across threads and processes.
*
* There is a physical cap of 1024 bytes per log line for dynamic content,
* such as %s and %@, that can be written to the persistence store.
* All content exceeding the limit will be truncated before it is
* written to disk.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param format
* A format string to generate a human-readable log message when the log
* line is decoded. This string must be a constant string, not dynamically
* generated. Supports all standard printf types and %@ (objects).
*/
#define os_log(log, format, ...) \
os_log_with_type(log, OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__)
/*!
* @function os_log_info
*
* @abstract
* Insert an additional information log message into the Unified Logging
* and Tracing system.
*
* @discussion
* Insert a log message into the Unified Logging and Tracing system in
* accordance with the preferences specified by the provided log object.
*
* When an os_activity_id_t is present, the log message will also be scoped by
* that identifier. Activities provide granular filtering of log messages
* across threads and processes.
*
* There is a physical cap of 256 bytes per entry for dynamic content,
* i.e., %s and %@, that can be written to the persistence store. As such,
* all content exceeding the limit will be truncated before written to disk.
* Live streams will continue to show the full content.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param format
* A format string to generate a human-readable log message when the log
* line is decoded. This string must be a constant string, not dynamically
* generated. Supports all standard printf types and %@ (objects).
*/
#define os_log_info(log, format, ...) \
os_log_with_type(log, OS_LOG_TYPE_INFO, format, ##__VA_ARGS__)
/*!
* @function os_log_debug
*
* @abstract
* Insert a debug log message into the Unified Logging and Tracing system.
*
* @discussion
* Insert a debug log message into the Unified Logging and Tracing system in
* accordance with the preferences specified by the provided log object.
*
* When an os_activity_id_t is present, the log message will also be scoped by
* that identifier. Activities provide granular filtering of log messages
* across threads and processes.
*
* There is a physical cap of 256 bytes per entry for dynamic content,
* i.e., %s and %@, that can be written to the persistence store. As such,
* all content exceeding the limit will be truncated before written to disk.
* Live streams will continue to show the full content.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param format
* A format string to generate a human-readable log message when the log
* line is decoded. This string must be a constant string, not dynamically
* generated. Supports all standard printf types and %@ (objects).
*/
#if OS_LOG_TARGET_HAS_10_15_FEATURES
#define os_log_debug(log, format, ...) __extension__({ \
os_log_t _log_tmp = (log); \
os_log_type_t _type_tmp = OS_LOG_TYPE_DEBUG; \
if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
OS_LOG_CALL_WITH_FORMAT(_os_log_debug_impl, \
(&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
} \
})
#else
#define os_log_debug(log, format, ...) \
os_log_with_type(log, OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__)
#endif // OS_LOG_TARGET_HAS_10_15_FEATURES
/*!
* @function os_log_error
*
* @abstract
* Insert an error log message into the Unified Logging and Tracing system.
*
* @discussion
* Insert an error log message into the Unified Logging and Tracing system.
*
* When an os_activity_id_t is present, the log message will also be scoped by
* that identifier. Activities provide granular filtering of log messages
* across threads and processes.
*
* There is a physical cap of 256 bytes per entry for dynamic content,
* i.e., %s and %@, that can be written to the persistence store. As such,
* all content exceeding the limit will be truncated before written to disk.
* Live streams will continue to show the full content.
*
* Note, in a debugger, it is possible to set a breakpoint on _os_log_error_impl
* to break on any error being emitted.
*
* A common use of os_log_error is to log failures from system calls and
* library functions, including the value of errno. Like other system calls
* and library functions, the os_log functions do not preserve the value of
* errno across calls. errno can change even if the log message is logged
* successfully. Consider saving errno into a local variable before calling
* os_log, if you still need errno's value afterward.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param format
* A format string to generate a human-readable log message when the log
* line is decoded. This string must be a constant string, not dynamically
* generated. Supports all standard printf types and %@ (objects).
*/
#if OS_LOG_TARGET_HAS_10_13_FEATURES
#define os_log_error(log, format, ...) __extension__({ \
os_log_t _log_tmp = (log); \
os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; \
if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
OS_LOG_CALL_WITH_FORMAT(_os_log_error_impl, \
(&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
} \
})
#else
#define os_log_error(log, format, ...) \
os_log_with_type(log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__)
#endif // OS_LOG_TARGET_HAS_10_13_FEATURES
/*!
* @function os_log_fault
*
* @abstract
* Insert a fault log message into the Unified Logging and Tracing system.
*
* @discussion
* Log a fault message into the Unified Logging and Tracing system.
*
* Faults should be used to report conditions which indicate the
* presence of a bug. Faults will gather more expensive contextual information
* and record it for later inspection. They may also be reported to other
* debugging tools for display or aggregation.
*
* Note that faults should only be used for unexpected error conditions in
* which there's a clear and safe recovery path. If such a path does not
* exist, consider the os_crash(3) family of APIs instead.
*
* When an os_activity_id_t is present, the log message will also be scoped by
* that identifier. Activities provide granular filtering of log messages
* across threads and processes.
*
* There is a physical cap of 256 bytes per entry for dynamic content,
* i.e., %s and %@, that can be written to the persistence store. As such,
* all content exceeding the limit will be truncated before written to disk.
* Live streams will continue to show the full content.
*
* Note, in a debugger, it is possible to set a breakpoint on _os_log_fault_impl
* to break on any fault being emitted.
*
* @param log
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param format
* A format string to generate a human-readable log message when the log
* line is decoded. This string must be a constant string, not dynamically
* generated. Supports all standard printf types and %@ (objects).
*/
#if OS_LOG_TARGET_HAS_10_13_FEATURES
#define os_log_fault(log, format, ...) __extension__({ \
os_log_t _log_tmp = (log); \
os_log_type_t _type_tmp = OS_LOG_TYPE_FAULT; \
if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
OS_LOG_CALL_WITH_FORMAT(_os_log_fault_impl, \
(&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
} \
})
#else
#define os_log_fault(log, format, ...) \
os_log_with_type(log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__)
#endif // OS_LOG_TARGET_HAS_10_13_FEATURES
/*!
* @function os_log_type_enabled
*
* @abstract
* Evaluate if a specific log type is enabled before doing work
*
* @discussion
* Evaluate if a specific log type is enabled before doing work
*
* @param oslog
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
*
* @param type
* Pass a valid type from os_log_type_t.
*
* @result
* Will return a boolean.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_PURE
bool
os_log_type_enabled(os_log_t oslog, os_log_type_t type);
/*!
* @function _os_log_impl
*
* @abstract
* Internal function that takes compiler generated encoding and captures the necessary content.
*/
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_log_impl(void *dso, os_log_t log, os_log_type_t type,
const char *format, uint8_t *buf, uint32_t size);
/*!
* @function _os_log_debug_impl
*
* @abstract
* Internal function that is taken for any debug log emitted in the system.
*/
API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0), watchos(6.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED OS_COLD
void
_os_log_debug_impl(void *dso, os_log_t log, os_log_type_t type,
const char *format, uint8_t *buf, uint32_t size);
/*!
* @function _os_log_error_impl
*
* @abstract
* Internal function that is taken for any error emitted in the system.
*/
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED OS_COLD
void
_os_log_error_impl(void *dso, os_log_t log, os_log_type_t type,
const char *format, uint8_t *buf, uint32_t size);
/*!
* @function _os_log_fault_impl
*
* @abstract
* Internal function that is taken for any fault emitted in the system.
*/
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED OS_COLD
void
_os_log_fault_impl(void *dso, os_log_t log, os_log_type_t type,
const char *format, uint8_t *buf, uint32_t size);
/*
* Support for older iteration of API for source compatibility only...
*/
API_DEPRECATED("no longer supported, use os_log_debug(OS_LOG_DEFAULT, ...)",
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_log_internal(void *dso, os_log_t log, os_log_type_t type, const char *message, ...);
API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_OBJECT_RETURNS_RETAINED OS_NOT_TAIL_CALLED OS_NONNULL_ALL
os_log_t
_os_log_create(void *dso, const char *subsystem, const char *category);
API_DEPRECATED("no longer suppored - always returns true",
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
bool
os_log_is_enabled(os_log_t log);
API_DEPRECATED_WITH_REPLACEMENT("os_log_debug_enabled",
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
bool
os_log_is_debug_enabled(os_log_t log);
API_DEPRECATED("no longer supported - use os_log with per-parameter privacy options",
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
OS_NOTHROW OS_ALWAYS_INLINE
static inline void
_os_log_sensitive_deprecated(void) { }
#define os_log_sensitive(log, format, ...) __extension__({ \
os_log_with_type(log, OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__); \
_os_log_sensitive_deprecated(); \
})
#define os_log_sensitive_debug(log, format, ...) __extension__({ \
os_log_with_type(log, OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__); \
_os_log_sensitive_deprecated(); \
})
#if !OS_LOG_TARGET_HAS_10_12_FEATURES
#undef os_log_with_type
#define os_log_with_type(log, type, format, ...) __extension__({ \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic error \"-Wformat\"") \
_Static_assert(__builtin_constant_p(format), "format argument must be a string constant"); \
_os_log_internal(&__dso_handle, log, type, format, ##__VA_ARGS__); \
_Pragma("clang diagnostic pop") \
})
#undef os_log_debug_enabled
#define os_log_debug_enabled(...) os_log_is_debug_enabled(__VA_ARGS__)
#undef os_log_create
#define os_log_create(subsystem, category) \
_os_log_create(&__dso_handle, subsystem, category)
#endif // !OS_LOG_TARGET_HAS_10_12_FEATURES
__END_DECLS
#endif // !__OS_LOG_H__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/object.h
================================================
/*
* Copyright (c) 2011-2014 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_OBJECT__
#define __OS_OBJECT__
#ifdef __APPLE__
#include
#include
#include
#include
#elif defined(_WIN32)
#include
#elif defined(__unix__)
#include
#endif
/*!
* @header
*
* @preprocinfo
* By default, libSystem objects such as GCD and XPC objects are declared as
* Objective-C types when building with an Objective-C compiler. This allows
* them to participate in ARC, in RR management by the Blocks runtime and in
* leaks checking by the static analyzer, and enables them to be added to Cocoa
* collections.
*
* NOTE: this requires explicit cancellation of dispatch sources and xpc
* connections whose handler blocks capture the source/connection object,
* resp. ensuring that such captures do not form retain cycles (e.g. by
* declaring the source as __weak).
*
* To opt-out of this default behavior, add -DOS_OBJECT_USE_OBJC=0 to your
* compiler flags.
*
* This mode requires a platform with the modern Objective-C runtime, the
* Objective-C GC compiler option to be disabled, and at least a Mac OS X 10.8
* or iOS 6.0 deployment target.
*/
#ifndef OS_OBJECT_HAVE_OBJC_SUPPORT
#if !defined(__OBJC__) || defined(__OBJC_GC__)
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#elif !defined(TARGET_OS_MAC) || !TARGET_OS_MAC
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#elif TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#elif TARGET_OS_MAC && !TARGET_OS_IPHONE
# if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
# else
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
# endif
#else
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
#endif
#endif // OS_OBJECT_HAVE_OBJC_SUPPORT
#if OS_OBJECT_HAVE_OBJC_SUPPORT
#if defined(__swift__) && __swift__ && !OS_OBJECT_USE_OBJC
#define OS_OBJECT_USE_OBJC 1
#endif
#ifndef OS_OBJECT_USE_OBJC
#define OS_OBJECT_USE_OBJC 1
#endif
#elif defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
/* Unsupported platform for OS_OBJECT_USE_OBJC=1 */
#undef OS_OBJECT_USE_OBJC
#define OS_OBJECT_USE_OBJC 0
#else
#define OS_OBJECT_USE_OBJC 0
#endif
#ifndef OS_OBJECT_SWIFT3
#ifdef __swift__
#define OS_OBJECT_SWIFT3 1
#else // __swift__
#define OS_OBJECT_SWIFT3 0
#endif // __swift__
#endif // OS_OBJECT_SWIFT3
#if __has_feature(assume_nonnull)
#define OS_OBJECT_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define OS_OBJECT_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#else
#define OS_OBJECT_ASSUME_NONNULL_BEGIN
#define OS_OBJECT_ASSUME_NONNULL_END
#endif
#define OS_OBJECT_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#if OS_OBJECT_USE_OBJC
#import
#if __has_attribute(objc_independent_class)
#define OS_OBJC_INDEPENDENT_CLASS __attribute__((objc_independent_class))
#endif // __has_attribute(objc_independent_class)
#ifndef OS_OBJC_INDEPENDENT_CLASS
#define OS_OBJC_INDEPENDENT_CLASS
#endif
#define OS_OBJECT_CLASS(name) OS_##name
#define OS_OBJECT_DECL_PROTOCOL(name, ...) \
@protocol OS_OBJECT_CLASS(name) __VA_ARGS__ \
@end
#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL(name, proto) \
@interface name () \
@end
#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, proto) \
OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL( \
OS_OBJECT_CLASS(name), OS_OBJECT_CLASS(proto))
#define OS_OBJECT_DECL_IMPL(name, adhere, ...) \
OS_OBJECT_DECL_PROTOCOL(name, __VA_ARGS__) \
typedef adhere \
* OS_OBJC_INDEPENDENT_CLASS name##_t
#define OS_OBJECT_DECL_BASE(name, ...) \
@interface OS_OBJECT_CLASS(name) : __VA_ARGS__ \
- (instancetype)init OS_SWIFT_UNAVAILABLE("Unavailable in Swift"); \
@end
#define OS_OBJECT_DECL_IMPL_CLASS(name, ...) \
OS_OBJECT_DECL_BASE(name, ## __VA_ARGS__) \
typedef OS_OBJECT_CLASS(name) \
* OS_OBJC_INDEPENDENT_CLASS name##_t
#define OS_OBJECT_DECL(name, ...) \
OS_OBJECT_DECL_IMPL(name, NSObject, )
#define OS_OBJECT_DECL_SUBCLASS(name, super) \
OS_OBJECT_DECL_IMPL(name, NSObject, )
#if __has_attribute(ns_returns_retained)
#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
#else
#define OS_OBJECT_RETURNS_RETAINED
#endif
#if __has_attribute(ns_consumed)
#define OS_OBJECT_CONSUMED __attribute__((__ns_consumed__))
#else
#define OS_OBJECT_CONSUMED
#endif
#if __has_feature(objc_arc)
#define OS_OBJECT_BRIDGE __bridge
#define OS_WARN_RESULT_NEEDS_RELEASE
#else
#define OS_OBJECT_BRIDGE
#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
#endif
#if __has_attribute(objc_runtime_visible) && \
((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
!defined(__TV_OS_VERSION_MIN_REQUIRED) && \
!defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) || \
(defined(__TV_OS_VERSION_MIN_REQUIRED) && \
__TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) || \
(defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
__WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0))
/*
* To provide backward deployment of ObjC objects in Swift on pre-10.12
* SDKs, OS_object classes can be marked as OS_OBJECT_OBJC_RUNTIME_VISIBLE.
* When compiling with a deployment target earlier than OS X 10.12 (iOS 10.0,
* tvOS 10.0, watchOS 3.0) the Swift compiler will only refer to this type at
* runtime (using the ObjC runtime).
*/
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE __attribute__((objc_runtime_visible))
#else
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
#endif
#ifndef OS_OBJECT_USE_OBJC_RETAIN_RELEASE
#if defined(__clang_analyzer__)
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
#elif __has_feature(objc_arc) && !OS_OBJECT_SWIFT3
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
#else
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
#endif
#endif
#if OS_OBJECT_SWIFT3
#define OS_OBJECT_DECL_SWIFT(name) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_IMPL_CLASS(name, NSObject)
#define OS_OBJECT_DECL_SUBCLASS_SWIFT(name, super) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_IMPL_CLASS(name, OS_OBJECT_CLASS(super))
#endif // OS_OBJECT_SWIFT3
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE
OS_OBJECT_DECL_BASE(object, NSObject);
#else
/*! @parseOnly */
#define OS_OBJECT_RETURNS_RETAINED
/*! @parseOnly */
#define OS_OBJECT_CONSUMED
/*! @parseOnly */
#define OS_OBJECT_BRIDGE
/*! @parseOnly */
#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
/*! @parseOnly */
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
#endif
#if OS_OBJECT_SWIFT3
#define OS_OBJECT_DECL_CLASS(name) \
OS_OBJECT_DECL_SUBCLASS_SWIFT(name, object)
#elif OS_OBJECT_USE_OBJC
#define OS_OBJECT_DECL_CLASS(name) \
OS_OBJECT_DECL(name)
#else
#define OS_OBJECT_DECL_CLASS(name) \
typedef struct name##_s *name##_t
#endif
#if OS_OBJECT_USE_OBJC
/* Declares a class of the specific name and exposes the interface and typedefs
* name##_t to the pointer to the class */
#define OS_OBJECT_SHOW_CLASS(name, ...) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_IMPL_CLASS(name, ## __VA_ARGS__ )
/* Declares a subclass of the same name, and
* subclass adheres to protocol specified. Typedefs baseclass * to subclass##_t */
#define OS_OBJECT_SHOW_SUBCLASS(subclass_name, super, proto_name) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_BASE(subclass_name, OS_OBJECT_CLASS(super)); \
typedef OS_OBJECT_CLASS(super) \
* OS_OBJC_INDEPENDENT_CLASS subclass_name##_t
#else /* Plain C */
#define OS_OBJECT_DECL_PROTOCOL(name, ...)
#define OS_OBJECT_SHOW_CLASS(name, ...) \
typedef struct name##_s *name##_t
#define OS_OBJECT_SHOW_SUBCLASS(name, super, ...) \
typedef super##_t name##_t
#endif
#define OS_OBJECT_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object))
__BEGIN_DECLS
/*!
* @function os_retain
*
* @abstract
* Increment the reference count of an os_object.
*
* @discussion
* On a platform with the modern Objective-C runtime this is exactly equivalent
* to sending the object the -[retain] message.
*
* @param object
* The object to retain.
*
* @result
* The retained object.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
OS_EXPORT OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
void*
os_retain(void *object);
#if OS_OBJECT_USE_OBJC
#undef os_retain
#define os_retain(object) [object retain]
#endif
/*!
* @function os_release
*
* @abstract
* Decrement the reference count of a os_object.
*
* @discussion
* On a platform with the modern Objective-C runtime this is exactly equivalent
* to sending the object the -[release] message.
*
* @param object
* The object to release.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
OS_EXPORT
void OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
os_release(void *object);
#if OS_OBJECT_USE_OBJC
#undef os_release
#define os_release(object) [object release]
#endif
__END_DECLS
#endif
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/overflow.h
================================================
/*
* Copyright (c) 2015-2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Facilities for performing type- and overflow-checked arithmetic. These
* functions return non-zero if overflow occured, zero otherwise. In either case,
* the potentially overflowing operation is fully performed, mod the size of the
* output type. See:
* http://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins
* for full details.
*
* The compiler enforces that users of os_*_overflow() check the return value to
* determine whether overflow occured.
*/
#ifndef _OS_OVERFLOW_H
#define _OS_OVERFLOW_H
#include
#include
#include
bool __header_always_inline OS_WARN_RESULT
__os_warn_unused(__const bool x)
{
return x;
}
#if __has_builtin(__builtin_add_overflow) && \
__has_builtin(__builtin_sub_overflow) && \
__has_builtin(__builtin_mul_overflow)
#define os_add_overflow(a, b, res) __os_warn_unused(__builtin_add_overflow((a), (b), (res)))
#define os_sub_overflow(a, b, res) __os_warn_unused(__builtin_sub_overflow((a), (b), (res)))
#define os_mul_overflow(a, b, res) __os_warn_unused(__builtin_mul_overflow((a), (b), (res)))
#else
# error os_overflow expects type-generic builtins
#endif /* __has_builtin(...) */
/* os_add3_overflow(a, b, c) -> (a + b + c) */
#define os_add3_overflow(a, b, c, res) __os_warn_unused(__extension__({ \
__typeof(*(res)) _tmp; \
bool _s, _t; \
_s = os_add_overflow((a), (b), &_tmp); \
_t = os_add_overflow((c), _tmp, (res)); \
_s | _t; \
}))
/* os_mul3_overflow(a, b, c) -> (a * b * c) */
#define os_mul3_overflow(a, b, c, res) __os_warn_unused(__extension__({ \
__typeof(*(res)) _tmp; \
bool _s, _t; \
_s = os_mul_overflow((a), (b), &_tmp); \
_t = os_mul_overflow((c), _tmp, (res)); \
_s | _t; \
}))
/* os_add_and_mul_overflow(a, b, x) -> (a + b)*x */
#define os_add_and_mul_overflow(a, b, x, res) __os_warn_unused(__extension__({ \
__typeof(*(res)) _tmp; \
bool _s, _t; \
_s = os_add_overflow((a), (b), &_tmp); \
_t = os_mul_overflow((x), _tmp, (res)); \
_s | _t; \
}))
/* os_mul_and_add_overflow(a, x, b) -> a*x + b */
#define os_mul_and_add_overflow(a, x, b, res) __os_warn_unused(__extension__({ \
__typeof(*(res)) _tmp; \
bool _s, _t; \
_s = os_mul_overflow((a), (x), &_tmp); \
_t = os_add_overflow((b), _tmp, (res)); \
_s | _t; \
}))
/* os_convert_overflow(a) -> a [converted to the result type] */
#define os_convert_overflow(a, res) os_add_overflow((a), 0, (res))
/* os_inc_overflow(res) -> *res += 1 */
#define os_inc_overflow(res) __os_warn_unused(__extension__({ \
__typeof((res)) _tmp = (res); \
os_add_overflow(*_tmp, 1, _tmp); \
}))
/* os_dec_overflow(res) -> *res -= 1 */
#define os_dec_overflow(res) __os_warn_unused(__extension__({ \
__typeof((res)) _tmp = (res); \
os_sub_overflow(*_tmp, 1, _tmp); \
}))
#endif /* _OS_OVERFLOW_H */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/proc.h
================================================
/*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __OS_PROC__
#define __OS_PROC__
#include
#include
#include
/*!
* @header
*
* @preprocinfo
* This is for functions that operate on the calling process alone.
*/
__BEGIN_DECLS
/*!
* @function os_proc_available_memory
*
* @abstract
* Return the number of bytes remaining, at the time of the call, before the
* current process will hit its current dirty memory limit.
*
* @discussion
* Developers can query this value efficiently whenever it is needed. The return
* value is only a snapshot at the time of the call. Caching the result is not
* advised. The result may be instantaneously invalidated by actions taken in
* another thread or another framework.
*
* Memory limits can change during the app life cycle. Make sure to check accordingly.
*
* The size returned is not representative of the total memory of the device, it
* is the current dirty memory limit minus the dirty memory footprint used at the
* time of the query.
*
* This interface allows an app to efficiently consume all available memory resources.
* Significant memory use, even under the current memory limit, may still cause
* system-wide performance including the termination of other apps and system
* processes. Take care to use the minimum amount of memory needed to satisfy the
* user’s need.
*
* If you need more information than just the available memory, you can use task_info().
* The information returned is equivalent to the task_vm_info.limit_bytes_remaining
* field. task_info() is a more expensive call, and will return information such
* as your phys_footprint, which is used to calculate the return of this function.
*
* Dirty memory contains data that must be kept in RAM (or the equivalent) even
* when unused. It is memory that has been modified.
*
* @param none
*
* @result
* The remaining bytes. 0 is returned if the calling process is not an app, or
* the calling process exceeds its memory limit.
*/
API_UNAVAILABLE(macos) API_AVAILABLE(ios(13.0), tvos(13.0), watchos(6.0))
extern
size_t os_proc_available_memory(void);
__END_DECLS
#endif
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/signpost.h
================================================
/*
* Copyright (c) 2017-2018 Apple Inc. All rights reserved.
*/
#ifndef __OS_SIGNPOST_H__
#define __OS_SIGNPOST_H__
#include
__BEGIN_DECLS
OS_ASSUME_NONNULL_BEGIN
/*!
* @header os_signpost
*
* The os_signpost APIs let clients add lightweight instrumentation to
* code for collection and visualization by performance analysis tooling.
*
* Clients of os_signpost can instrument interesting periods of time
* ('intervals') and single points in time ('events'). Intervals can span
* processes, be specific to one process, or be specific to a single thread.
*
* Intervals and events include an os_log-style format string and arguments
* which can be used to convey contextual information.
*/
#pragma mark - Interval Matching Scope
/*!
* The matching scope for signpost intervals logged with a given os_log_t is
* specified in that log handles's configuration plist using the
* 'Signpost-Scope' key and defaults to process-wide scope (i.e. 'Process'
* value) if unspecified.
*
* Signpost interval begin and end matching can have 3 different scopes:
*
* - Thread-wide: The search scope for matching begins and ends is restricted to
* single threads. To set this as the search scope for an os_log_t, set
* 'Thread' as the string value for the 'Signpost-Scope' key in the
* os_log_t's configuration plist.
*
* - Process-wide (Default value): The search scope for matching begins and ends
* is restricted to a single process. (i.e. no cross-process intervals)
* To set this as the search scope for an os_log_t, set
* 'Process' as the string value for the 'Signpost-Scope' key in the
* os_log_t's configuration plist or do not specify any 'Signpost-Scope' key-
* value pair.
*
* - System-wide: The search scope for matching begins and ends is not
* restricted. (i.e. cross-process intervals are possible)
* To set this as the search scope for an os_log_t, set
* 'System' as the string value for the 'Signpost-Scope' key in the
* os_log_t's configuration plist.
*
*/
#pragma mark - Signpost IDs
/*!
* Disambiguating intervals with signpost IDs
*
* Intervals with the same log handle and interval name can be in flight
* simultaneously. In order for tools to correctly match begin signposts with
* end signposts, it is necessary to identify each interval with an
* os_signpost_id_t.
*
* If only one interval with a given os_log_t and interval name will ever be in
* flight at a time, use the os_signpost_t convenience value
* OS_SIGNPOST_ID_EXCLUSIVE. This can avoid having to share state between begin
* and end callsites.
*
* If there exists some non-pointer uint64_t value that uniquely identifies
* begin/end pairs, that value can be cast directly to an os_signpost_id_t.
* Note that the values OS_SIGNPOST_ID_NULL and OS_SIGNPOST_ID_INVALID are
* reserved and identical values may not be used in this manner.
*
* If there exists a pointer which can identify begin/end pairs, an
* os_signpost_id_t can be generated from that pointer with
* os_signpost_id_make_with_pointer(). This approach is not applicable to
* signposts that span process boundaries.
*
* If no existing pointer or value is applicable, a new unique value can be
* generated using the os_signpost_id_generate() function. The returned value
* is guaranteed to be unique within the matching scope specified on the log
* handle.
*/
/*!
* @typedef os_signpost_id_t
*
* @brief
* The type to represent a signpost ID.
*
* @discussion.
* Any 64-bit value can be cast to an os_signpost_id_t except for the
* OS_SIGNPOST_ID_NULL and OS_SIGNPOST_ID_INVALID reserved values.
*
* @const OS_SIGNPOST_ID_NULL
* Represents the null (absent) signpost ID. It is used by the signpost
* subsystem when a given signpost is disabled.
*
* @const OS_SIGNPOST_ID_INVALID
* Represents an invalid signpost ID, which signals that an error has occurred.
*
* @const OS_SIGNPOST_ID_EXCLUSIVE
* A convenience value for signpost intervals that will never occur
* concurrently.
*/
typedef uint64_t os_signpost_id_t;
#ifndef __swift__
#define OS_SIGNPOST_ID_NULL ((os_signpost_id_t)0)
#define OS_SIGNPOST_ID_INVALID ((os_signpost_id_t)~0)
#define OS_SIGNPOST_ID_EXCLUSIVE ((os_signpost_id_t)0xEEEEB0B5B2B2EEEE)
#endif
/*!
* @function os_signpost_id_make_with_pointer
*
* @abstract
* Make an os_signpost_id from a pointer value.
*
* @discussion
* Mangles the pointer to create a valid os_signpost_id, including removing
* address randomization. Checks that the signpost matching scope is not
* system-wide.
*
* @param log
* Log handle previously created with os_log_create.
*
* @param ptr
* Any pointer that disambiguates among concurrent intervals with the same
* os_log_t and interval names.
*
* @result
* Returns a valid os_signpost_id_t. Returns OS_SIGNPOST_ID_NULL if signposts
* are turned off. Returns OS_SIGNPOST_ID_INVALID if the log handle is
* system-scoped.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
OS_EXPORT OS_NOTHROW
os_signpost_id_t
os_signpost_id_make_with_pointer(os_log_t log, const void *_Nullable ptr);
#if __OBJC__
/*!
* @function os_signpost_id_make_with_id
*
* @abstract
* Make an os_signpost_id from an Objective-C id, as in
* os_signpost_id_make_with_pointer.
*/
#define os_signpost_id_make_with_id(log, ptr) \
os_signpost_id_make_with_pointer(log, (__bridge const void *_Nullable)(ptr))
#endif /* __OBJC__ */
/*!
* @function os_signpost_id_generate
*
* @abstract
* Generates an ID guaranteed to be unique within the matching scope of the
* provided log handle.
*
* @discussion
* Each call to os_signpost_id_generate() with a given log handle and its
* matching scope will return a different os_signpost_id_t.
*
* @param log
* Log handle previously created with os_log_create.
*
* @result
* Returns a valid os_signpost_id_t. Returns OS_SIGNPOST_ID_NULL if signposts
* are disabled.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
os_signpost_id_t
os_signpost_id_generate(os_log_t log);
#pragma mark - Signpost Enablement
/*!
* @function os_signpost_enabled
*
* @abstract
* Returns true if signpost log messages are enabled for a particular log
* handle.
*
* @discussion
* Returns true if signpost log messages are enabled for a particular log.
* Use this to avoid doing expensive argument marshalling leading into a call
* to os_signpost_*
*
* @param log
* Log handle previously created with os_log_create.
*
* @result
* Returns ‘true’ if signpost log messages are enabled.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
OS_EXPORT OS_NOTHROW OS_PURE OS_WARN_RESULT
bool
os_signpost_enabled(os_log_t log);
#pragma mark - Interval begin/end
/*!
* @function os_signpost_interval_begin
*
* @abstract
* Begins a signposted interval.
*
* @param log
* Log handle previously created with os_log_create.
*
* @param interval_id
* An ID for the event, see Signpost IDs above.
*
* @param name
* The name of this event. This must be a string literal.
*
* @param ... (format + arguments)
* Additional information to include with this signpost. This format string
* must be a string literal, as with the os_log family of functions.
*/
#define os_signpost_interval_begin(log, interval_id, name, ...) \
os_signpost_emit_with_type(log, OS_SIGNPOST_INTERVAL_BEGIN, \
interval_id, name, ##__VA_ARGS__)
/*!
* @function os_signpost_animation_interval_begin
*
* @abstract
* Begins a signposted interval that is tagged as an animation.
*
* @param log
* Log handle previously created with os_log_create.
*
* @param interval_id
* An ID for the event, see Signpost IDs above.
*
* @param name
* The name of this event. This must be a string literal.
*
* @param ... (format + arguments)
* Additional information to include with this signpost. This format string
* must be a string literal, as with the os_log family of functions.
*/
#define os_signpost_animation_interval_begin(log, interval_id, name, ...) \
_os_signpost_animation_interval_begin(log, interval_id, name, \
"" __VA_ARGS__)
/*!
* @function os_signpost_interval_end
*
* @abstract
* Ends a signposted interval.
*
* @param log
* The log handle which was provided to os_signpost_interval_begin,
*
* @param interval_id
* The ID for the event which was provided to os_signpost_interval_begin. See
* Signpost IDs above.
*
* @param name
* The name of the event provided to os_signost_interval_begin. This must be a
* string literal.
*
* @param ... (format + arguments)
* Additional information to include with this signpost. This format string
* must be a string literal, as with the os_log family of functions.
*/
#define os_signpost_interval_end(log, interval_id, name, ...) \
os_signpost_emit_with_type(log, OS_SIGNPOST_INTERVAL_END, \
interval_id, name, ##__VA_ARGS__)
#pragma mark - Signpost event marking
/*!
* @function os_signpost_event_emit
*
* @abstract
* os_signpost_event_emit marks a point of interest in time with no duration.
*
* @param log
* Log handle previously created with os_log_create.
*
* @param event_id
* An ID for the event, see Signpost IDs above. This ID can be used to convey
* additional information about the event that is being emitted without
* incurring extra performance overhead.
*
* @param name
* The name of this event. This must be a string literal.
*
* @param ... (format + arguments)
* Additional information to include with this signpost. This format string
* must be a string literal, as with the os_log family of functions.
*/
#define os_signpost_event_emit(log, event_id, name, ...) \
os_signpost_emit_with_type(log, OS_SIGNPOST_EVENT, \
event_id, name, ##__VA_ARGS__)
#pragma mark - Points of Interest
/*!
* @const OS_LOG_CATEGORY_POINTS_OF_INTEREST
*
* Provide this value as the category to os_log_create to indicate that
* signposts on the resulting log handle provide high-level events that can be
* used to orient a developer looking at performance data. These will be
* displayed by default by performance tools like Instruments.app.
*/
#ifndef __swift__
#define OS_LOG_CATEGORY_POINTS_OF_INTEREST "PointsOfInterest"
#endif
#pragma mark - Dynamic Tracing
/*!
* @const OS_LOG_CATEGORY_DYNAMIC_TRACING
*
* Provide this value as the category to os_log_create to indicate that
* signposts emitted to the resulting log handle should be disabled by
* default, reducing the runtime overhead. os_signpost_enabled calls on
* the resulting log handle will only return 'true' when a performance
* tool like Instruments.app is recording.
*/
#if OS_LOG_TARGET_HAS_10_15_FEATURES
#ifndef __swift__
#define OS_LOG_CATEGORY_DYNAMIC_TRACING "DynamicTracing"
#endif
#endif
/*!
* @const OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING
*
* Provide this value as the category to os_log_create to indicate that
* signposts emitted to the resulting log handle should capture user
* backtraces. This behavior is more expensive, so os_signpost_enabled
* will only return 'true' when a performance tool like Instruments.app
* is recording.
*/
#if OS_LOG_TARGET_HAS_10_15_FEATURES
#ifndef __swift__
#define OS_LOG_CATEGORY_DYNAMIC_STACK_TRACING "DynamicStackTracing"
#endif
#endif
#pragma mark - Signpost Internals
/*!
* @typedef os_signpost_type_t
*
* @brief
* The type of a signpost tracepoint, do not use directly.
*/
OS_ENUM(os_signpost_type, uint8_t,
OS_SIGNPOST_EVENT = 0x00,
OS_SIGNPOST_INTERVAL_BEGIN = 0x01,
OS_SIGNPOST_INTERVAL_END = 0x02,
);
#ifndef __swift__
#define OS_SIGNPOST_TYPE_MASK 0x03
#endif
#define _OS_SIGNPOST_ANIMATION_INTERVAL_TAG "isAnimation=YES"
#define _os_signpost_animation_interval_begin(log, spid, name, fmt, ...) \
os_signpost_interval_begin(log, spid, name, \
fmt " " _OS_SIGNPOST_ANIMATION_INTERVAL_TAG, \
##__VA_ARGS__)
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_signpost_emit_with_name_impl(void *dso, os_log_t log,
os_signpost_type_t type, os_signpost_id_t spid, const char *name,
const char *format, uint8_t *buf, uint32_t size);
#define _os_signpost_emit_with_type(emitfn, log, type, spid, name, ...) \
__extension__({ \
os_log_t _log_tmp = (log); \
os_signpost_type_t _type_tmp = (type); \
os_signpost_id_t _spid_tmp = (spid); \
if (_spid_tmp != OS_SIGNPOST_ID_NULL && \
_spid_tmp != OS_SIGNPOST_ID_INVALID && \
os_signpost_enabled(_log_tmp)) { \
OS_LOG_CALL_WITH_FORMAT_NAME((emitfn), \
(&__dso_handle, _log_tmp, _type_tmp, _spid_tmp), \
name, "" __VA_ARGS__); \
} \
})
#if OS_LOG_TARGET_HAS_10_14_FEATURES
#define os_signpost_emit_with_type(log, type, spid, name, ...) \
_os_signpost_emit_with_type(_os_signpost_emit_with_name_impl, log, \
type, spid, name, ##__VA_ARGS__)
#else
#define os_signpost_emit_with_type(log, type, spid, name, ...) \
__extension__({ \
if (_os_signpost_emit_with_name_impl != NULL) { \
_os_signpost_emit_with_type(_os_signpost_emit_with_name_impl, log, \
type, spid, name, ##__VA_ARGS__); \
} \
})
#endif
OS_ASSUME_NONNULL_END
__END_DECLS
#endif // __OS_SIGNPOST_H__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/trace.h
================================================
/*
* Copyright (c) 2013-2016 Apple Inc. All rights reserved.
*/
#ifndef __OS_TRACE_H__
#define __OS_TRACE_H__
#include
#if __has_include()
#include
typedef xpc_object_t os_trace_payload_object_t;
#else
typedef void *os_trace_payload_object_t;
#endif
#if !__GNUC__
#error "must be GNU C compatible"
#endif
__BEGIN_DECLS
/* We need at least clang 7.3 or later due to bugs in os_log_format parsing */
#if __has_builtin(__builtin_os_log_format) && (__clang_major__ > 7 || (__clang_major__ == 7 && __clang_minor__ >= 3))
OS_ALWAYS_INLINE __attribute__((format(os_trace, 1, 2)))
static inline void
_os_trace_verify_printf(const char *msg, ...)
{
#pragma unused(msg)
}
#if __has_attribute(uninitialized)
#define OS_TRACE_UNINITIALIZED __attribute__((uninitialized))
#else
#define OS_TRACE_UNINITIALIZED
#endif
/* Previous OSes must go through older style...
*
* Format:
* Items: [ ]
* Item sizes: [
* 8 bits * count
* ]
* Item count: 8 bits
*/
#define OS_TRACE_CALL(_t, _p, _f, ...) __extension__({ \
if (os_trace_type_enabled(_t)) { \
_os_trace_verify_printf(_f, ##__VA_ARGS__); \
OS_LOG_STRING(TRACE, __f, _f); \
uint32_t __size = (uint32_t)__builtin_os_log_format_buffer_size(_f, ##__VA_ARGS__); \
OS_TRACE_UNINITIALIZED uint8_t _buf[__size]; \
__builtin_os_log_format(_buf, _f, ##__VA_ARGS__); \
uint32_t tz = 0; \
OS_TRACE_UNINITIALIZED uint8_t tb[__size]; \
uint8_t *buff = _buf; \
uint8_t *p = ++buff; \
uint8_t count = *p++; \
uint8_t trailer[count + 1]; \
trailer[count] = count; \
for (uint8_t ii = 0; ii < count; ii++) { \
uint8_t desc = *p++; \
uint8_t size = *p++; \
uint8_t *value = p; \
p += size; \
if ((desc >> 4) || (desc & 0x1)) { \
size = 0;\
}\
if (size) {\
memcpy(&tb[tz], value, size);\
tz += size;\
}\
trailer[ii] = size;\
}\
memcpy(&tb[tz], trailer, sizeof(trailer));\
tz += sizeof(trailer);\
_os_trace_with_buffer(&__dso_handle, __f, _t, tb, tz, _p);\
} \
})
#else
#define OS_TRACE_CALL(...)
#endif
// macros to re-order arguments so we can call log function
#define _os_trace_with_payload_1(_t, _f, _p) OS_TRACE_CALL(_t, _p, _f)
#define _os_trace_with_payload_2(_t, _f, _1, _p) OS_TRACE_CALL(_t, _p, _f, _1)
#define _os_trace_with_payload_3(_t, _f, _1, _2, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2)
#define _os_trace_with_payload_4(_t, _f, _1, _2, _3, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3)
#define _os_trace_with_payload_5(_t, _f, _1, _2, _3, _4, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4)
#define _os_trace_with_payload_6(_t, _f, _1, _2, _3, _4, _5, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5)
#define _os_trace_with_payload_7(_t, _f, _1, _2, _3, _4, _5, _6, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5, _6)
#define _os_trace_with_payload_8(_t, _f, _1, _2, _3, _4, _5, _6, _7, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5, _6, _7)
#define _os_trace_call_n(_t, _f, ...) OS_TRACE_CALL(_t, NULL, _f, ##__VA_ARGS__)
/*!
*
* @abstract
* Hashtags in trace messages
*
* @discussion
* Developers are encouraged to include hashtags in log messages, regardless of
* what API you use.
* A hashtag is composed of a hash (#) symbol, followed by at least three
* non-whitespace characters, terminated by whitespace or the end of the
* message. Hashtags may not begin with a number.
*
* Below is the list of predefined tags:
* #System - Message in the context of a system process.
* #User - Message in the context of a user process.
* #Developer - Message in the context of software development. For example,
* deprecated APIs and debugging messages.
* #Attention - Message that should be investigated by a system
* administrator, because it may be a sign of a larger issue.
* For example, errors from a hard drive controller that
* typically occur when the drive is about to fail.
* #Critical - Message in the context of a critical event or failure.
* #Error - Message that is a noncritical error.
* #Comment - Message that is a comment.
* #Marker - Message that marks a change to divide the messages around it
* into those before and those after the change.
* #Clue - Message containing extra key/value pairs with additional
* information to help reconstruct the context.
* #Security - Message related to security concerns.
* #Filesystem - Message describing a file system related event.
* #Network - Message describing a network-related event.
* #Hardware - Message describing a hardware-related event.
* #CPU - Message describing CPU related event, e.g., initiating heavy
* work load
* #State - Message describing state changed, e.g., global state,
* preference, etc.
* #Graphics - Message describing significant graphics event
* #Disk - Message describing disk activity
*
*/
#pragma mark - Other defines
/*!
* @define OS_TRACE_TYPE_RELEASE
* Trace messages to be captured on a typical user install. These should be
* limited to things which improve diagnosis of a failure/crash/hang. Trace
* buffers are generally smaller on a production system.
*/
#define OS_TRACE_TYPE_RELEASE (1u << 0)
/*!
* @define OS_TRACE_TYPE_DEBUG
* Trace messages to be captured while debugger or other development tool is
* attached to the originator.
*/
#define OS_TRACE_TYPE_DEBUG (1u << 1)
/*!
* @define OS_TRACE_TYPE_INFO
* Trace messages that are captured when a debugger is attached, system or
* Application mode has been increased to include additional information.
*/
#define OS_TRACE_TYPE_INFO (1u << 2)
/*!
* @define OS_TRACE_TYPE_ERROR
* Trace the message as an error and force a collection as a failure may be
* imminent.
*/
#define OS_TRACE_TYPE_ERROR ((1u << 6) | (1u << 0))
/*!
* @define OS_TRACE_TYPE_FAULT
* Trace the message as a fatal error which forces a collection and a diagnostic
* to be initiated.
*/
#define OS_TRACE_TYPE_FAULT ((1u << 7) | (1u << 6) | (1u << 0))
/*!
* @typedef os_trace_payload_t
*
* @abstract
* A block that populates an xpc_object_t of type XPC_TYPE_DICTIONARY to
* represent complex data.
*
* @discussion
* This block will only be invoked under conditions where tools have attached to
* the process. The payload can be used to send arbitrary data via the trace
* call. Tools may use the data to validate state for integration tests or
* provide other introspection services. No assumptions are made about the
* format or structure of the data.
*/
#ifdef __BLOCKS__
typedef void (^os_trace_payload_t)(os_trace_payload_object_t xdict);
#else
typedef void *os_trace_payload_t;
#endif // __BLOCKS__
#pragma mark - function declarations
/*!
* @function os_trace
*
* @abstract
* Always inserts a trace message into a buffer pool for later decoding.
*
* @discussion
* Trace message that will be recorded on a typical user install. These should
* be limited to things which help diagnose a failure during postmortem
* analysis. Trace buffers are generally smaller on a production system.
*
* @param format
* A printf-style format string to generate a human-readable log message when
* the trace line is decoded. Only scalar types are supported, attempts
* to pass arbitrary strings will store a pointer that is unresolvable and
* will generate an error during decode.
*
*
* os_trace("network event: %ld, last seen: %ld, avg: %g",
* event_id, last_seen, avg);
*
*/
#define os_trace(format, ...) OS_TRACE_CALL(OS_TRACE_TYPE_RELEASE, NULL, format, ##__VA_ARGS__)
#if OS_LOG_TARGET_HAS_10_12_FEATURES
/*!
* @function os_trace_info
*
* @abstract
* Optionally inserts a trace message containing additional information into a
* buffer pool for later decoding.
*
* @discussion
* Trace messages that will be captured when additional information is needed
* and are not captured by default. They will only be captured if the
* system/process/activity mode has been increased or if a Development tool has
* been attached to the process.
*
* @param format
* A printf-style format string that represents a human-readable message when
* the trace line is decoded. Only scalar types are supported, attempts
* to pass arbitrary strings will store a pointer that is unresolvable and
* will generate an error during decode.
*
*
* os_trace_info("network interface status %ld", status);
*
*/
#define os_trace_info(format, ...) \
OS_TRACE_CALL(OS_TRACE_TYPE_INFO, NULL, format, ##__VA_ARGS__)
#endif
/*!
* @function os_trace_debug
*
* @abstract
* Insert debug trace message into a buffer pool for later decoding.
*
* @discussion
* Debug trace message to be recorded while debugger or other development tool
* is attached to the originator. This is transported interprocess to help
* diagnose the entire call chain including external helpers.
*
* @param format
* A printf-style format string that represents a human-readable message when
* the trace line is decoded. Only scalar types are supported, attempts
* to pass arbitrary strings will store a pointer that is unresolvable and
* will generate an error during decode.
*
*
* os_trace_debug("network interface status %ld", status);
*
*/
#define os_trace_debug(format, ...) \
OS_TRACE_CALL(OS_TRACE_TYPE_DEBUG, NULL, format, ##__VA_ARGS__)
/*!
* @function os_trace_info_enabled
*
* @abstract
* Avoid unnecessary work for a trace point by checking if additional
* information is enabled.
*
* @discussion
* Avoid unnecessary work for a trace point by checking if additional
* information is enabled. Generally trace points should not involve expensive
* operations, but some circumstances warrant it. Use this function to avoid
* doing the work unless debug level trace messages are requested.
*
*
* if (os_trace_info_enabled()) {
* os_trace_info("value = %d, average = %d",
* [[dict objectForKey: @"myKey"] intValue],
* (int)[self getAverage:dict]);
* }
*
*
* @result
* Returns true if info types are enabled.
*/
API_DEPRECATED_WITH_REPLACEMENT("os_log_info_enabled",
macos(10.12,10.13), ios(10.0,11.0), watchos(3.0,4.0), tvos(10.0,11.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
bool
os_trace_info_enabled(void);
/*!
* @function os_trace_debug_enabled
*
* @abstract
* Avoid unnecessary work for a trace point by checking if debug level is
* enabled.
*
* @discussion
* Avoid unnecessary work for a trace point by checking if debug level is
* enabled. Generally trace points should not involve expensive operations, but
* some circumstances warrant it. Use this function to avoid doing the work
* unless debug level trace messages are requested.
*
*
* if (os_trace_debug_enabled()) {
* os_trace_debug("value = %d, average = %d",
* [[dict objectForKey: @"myKey"] intValue],
* (int)[self getAverage:dict]);
* }
*
*
* @result
* Returns true if debug mode is enabled.
*/
API_DEPRECATED_WITH_REPLACEMENT("os_log_debug_enabled",
macos(10.10,10.13), ios(8.0,11.0), watchos(2.0,4.0), tvos(8.0,11.0))
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
bool
os_trace_debug_enabled(void);
/*!
* @function os_trace_type_enabled
*
* @abstract
* Avoid unnecessary work for a trace point by checking a specific type
*
* @discussion
* Avoid unnecessary work for a trace point by checking a specific type
*
* @result
* Returns true if type is enabled.
*/
API_DEPRECATED_WITH_REPLACEMENT("os_log_type_enabled",
macos(10.10,10.13), ios(8.0,11.0), watchos(2.0,4.0), tvos(8.0,11.0))
OS_NOTHROW OS_WARN_RESULT OS_ALWAYS_INLINE
static inline bool
os_trace_type_enabled(uint8_t type)
{
switch (type) {
case OS_TRACE_TYPE_INFO:
return os_trace_info_enabled();
case OS_TRACE_TYPE_DEBUG:
return os_trace_debug_enabled();
}
return true;
}
/*!
* @function os_trace_error
*
* @abstract
* Trace the message as an error and force a collection of the trace buffer as
* a failure may be imminent.
*
* @discussion
* Trace the message as an error and force a collection of the trace buffer as
* a failure may be imminent.
*
* @param format
* A printf-style format string to generate a human-readable log message when
* the trace line is decoded. Only scalar types are supported, attempts to pass
* arbitrary strings will store a pointer that is unresolvable and will generate
* an error during decode.
*
*
* os_trace_error("socket %d connection timeout %ld", fd, secs);
*
*/
#define os_trace_error(format, ...) \
OS_TRACE_CALL(OS_TRACE_TYPE_ERROR, NULL, format, ##__VA_ARGS__)
/*!
* @function os_trace_fault
*
* @abstract
* Trace the message as a fault which forces a collection of the trace buffer
* and diagnostic of the activity.
*
* @discussion
* Trace the message as a fault which forces a collection of the trace buffer
* and diagnostic of the activity.
*
* @param format
* A printf-style format string to generate a human-readable log message when
* the trace line is decoded. Only scalar types are supported, attempts
* to pass arbitrary strings will store a pointer that is unresolvable and
* will generate an error during decode.
*
*
* os_trace_fault("failed to lookup uid %d - aborting", uid);
*
*/
#define os_trace_fault(format, ...) \
OS_TRACE_CALL(OS_TRACE_TYPE_FAULT, NULL, format, ##__VA_ARGS__)
#ifdef __BLOCKS__
#if __has_include()
/*!
* @function os_trace_with_payload
*
* @abstract
* Add a trace entry containing the provided values and call the block if
* appropriate.
*
* @discussion
* Will insert a trace entry into a limited ring buffer for an activity or
* process. Trace points are for recording interesting data that would improve
* diagnosis of unexpected crashes, failures and hangs. The block will only be
* called under the required conditions.
*
* @param trace_msg
* A printf-style format string to generate a human-readable log message when
* the trace line is decoded. Only scalar types are supported. Attempts
* to pass arbitrary strings will store a pointer that is unresolvable and
* will generate an error during decode.
*
* The final parameter must be a block of type os_trace_payload_t.
*
*
* os_trace_with_payload("network event %ld", event, ^(xpc_object_t xdict) {
*
* // validate the network interface and address where what was expected
* xpc_dictionary_set_string(xdict, "network", ifp->ifa_name);
* xpc_dictionary_set_string(xdict, "ip_address", _get_address(ifp));
* });
*
*/
#define os_trace_with_payload(format, ...) \
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
OS_TRACE_TYPE_RELEASE, format, ##__VA_ARGS__)
#if OS_LOG_TARGET_HAS_10_12_FEATURES
#define os_trace_info_with_payload(format, ...) \
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
OS_TRACE_TYPE_INFO, format, ##__VA_ARGS__)
#else
API_DEPRECATED_WITH_REPLACEMENT("os_log_info",
macos(10.12,10.13), ios(10.0,11.0), watchos(3.0,4.0), tvos(10.0,11.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
os_trace_info_with_payload(const char *format, ...);
#endif // !OS_LOG_TARGET_HAS_10_12_FEATURES
#define os_trace_debug_with_payload(format, ...) \
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
OS_TRACE_TYPE_DEBUG, format, ##__VA_ARGS__)
#define os_trace_error_with_payload(format, ...) \
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
OS_TRACE_TYPE_ERROR, format, ##__VA_ARGS__)
#define os_trace_fault_with_payload(format, ...) \
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
OS_TRACE_TYPE_FAULT, format, ##__VA_ARGS__)
#endif // __has_include()
#endif // __BLOCKS__
/*!
* @function _os_trace_with_buffer
*
* @abstract
* Internal function to support pre-encoded buffer.
*/
API_DEPRECATED("use one of the following calls instead: os_log_info, os_log_debug, os_log_error, os_log_fault",
macos(10.10,10.13), ios(8.0,11.0), watchos(2.0,4.0), tvos(8.0,11.0))
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
void
_os_trace_with_buffer(void *dso, const char *message, uint8_t type,
const void *buffer, size_t buffer_size, os_trace_payload_t payload);
__END_DECLS
#endif // !__OS_TRACE_H__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/trace_base.h
================================================
/*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*/
#ifndef __OS_TRACE_BASE_H__
#define __OS_TRACE_BASE_H__
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OS_LOG_FORMATLIKE(x, y) __attribute__((format(os_log, x, y)))
#define __OS_LOG_OS_FEATURES_AT_LEAST(macos, ios, tvos, watchos) \
( (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_##macos) \
|| (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_##ios) \
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_##tvos) \
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_##watchos) \
)
#if __OS_LOG_OS_FEATURES_AT_LEAST(10_15, 13_0, 13_0, 6_0)
#define OS_LOG_TARGET_HAS_10_15_FEATURES 1
#else
#define OS_LOG_TARGET_HAS_10_15_FEATURES 0
#endif
#if __OS_LOG_OS_FEATURES_AT_LEAST(10_14, 12_0, 12_0, 5_0)
#define OS_LOG_TARGET_HAS_10_14_FEATURES 1
#else
#define OS_LOG_TARGET_HAS_10_14_FEATURES 0
#endif
#if __OS_LOG_OS_FEATURES_AT_LEAST(10_13, 11_0, 11_0, 4_0)
#define OS_LOG_TARGET_HAS_10_13_FEATURES 1
#else
#define OS_LOG_TARGET_HAS_10_13_FEATURES 0
#endif
#if __OS_LOG_OS_FEATURES_AT_LEAST(10_12, 10_0, 10_0, 3_0)
#define OS_LOG_TARGET_HAS_10_12_FEATURES 1
#else
#define OS_LOG_TARGET_HAS_10_12_FEATURES 0
#endif
#ifndef OS_COUNT_ARGS
#define OS_COUNT_ARGS(...) OS_COUNT_ARGS1(, ##__VA_ARGS__, _8, _7, _6, _5, _4, _3, _2, _1, _0)
#define OS_COUNT_ARGS1(z, a, b, c, d, e, f, g, h, cnt, ...) cnt
#endif
#ifdef OS_LOG_FORMAT_WARNINGS
#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic warning \"-Wformat\"")
#else
#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic error \"-Wformat\"")
#endif
#define OS_LOG_PRAGMA_PUSH \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wvla\"") \
OS_LOG_FORMAT_ERRORS
#define OS_LOG_PRAGMA_POP _Pragma("clang diagnostic pop")
#if __has_attribute(uninitialized)
#define OS_LOG_UNINITIALIZED __attribute__((uninitialized))
#else
#define OS_LOG_UNINITIALIZED
#endif
#define OS_LOG_STRING(_ns, _var, _str) \
_Static_assert(__builtin_constant_p(_str), \
"format/label/description argument must be a string constant"); \
__attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) \
static const char _var[] __asm(OS_STRINGIFY(OS_CONCAT(LOS_##_ns, __COUNTER__))) = _str
#define OS_LOG_REMOVE_PARENS(...) __VA_ARGS__
#define OS_LOG_CALL_WITH_FORMAT(fun, fun_args, fmt, ...) __extension__({ \
OS_LOG_PRAGMA_PUSH OS_LOG_STRING(LOG, _os_fmt_str, fmt); \
uint8_t _Alignas(16) OS_LOG_UNINITIALIZED _os_fmt_buf[__builtin_os_log_format_buffer_size(fmt, ##__VA_ARGS__)]; \
fun(OS_LOG_REMOVE_PARENS fun_args, _os_fmt_str, \
(uint8_t *)__builtin_os_log_format(_os_fmt_buf, fmt, ##__VA_ARGS__), \
(uint32_t)sizeof(_os_fmt_buf)) OS_LOG_PRAGMA_POP; \
})
#define OS_LOG_CALL_WITH_FORMAT_NAME(fun, fun_args, name, fmt, ...) __extension__({ \
OS_LOG_PRAGMA_PUSH OS_LOG_STRING(LOG, _os_fmt_str, fmt); \
OS_LOG_STRING(LOG, _os_name_str, name); \
uint8_t _Alignas(16) OS_LOG_UNINITIALIZED _os_fmt_buf[__builtin_os_log_format_buffer_size(fmt, ##__VA_ARGS__)]; \
fun(OS_LOG_REMOVE_PARENS fun_args, _os_name_str, _os_fmt_str, \
(uint8_t *)__builtin_os_log_format(_os_fmt_buf, fmt, ##__VA_ARGS__), \
(uint32_t)sizeof(_os_fmt_buf)) OS_LOG_PRAGMA_POP; \
})
__BEGIN_DECLS
extern struct mach_header __dso_handle;
__END_DECLS
#endif // !__OS_TRACE_BASE_H__
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/workgroup.h
================================================
/*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_WORKGROUP__
#define __OS_WORKGROUP__
#ifndef __DISPATCH_BUILDING_DISPATCH__
#ifndef __OS_WORKGROUP_INDIRECT__
#define __OS_WORKGROUP_INDIRECT__
#endif /* __OS_WORKGROUP_INDIRECT__ */
#include
#include
#include
#include
#undef __OS_WORKGROUP_INDIRECT__
#endif /* __DISPATCH_BUILDING_DISPATCH__ */
#endif /* __OS_WORKGROUP__ */
================================================
FILE: cross-macos/sysroot/macos-12/usr/include/os/workgroup_base.h
================================================
#ifndef __OS_WORKGROUP_BASE__
#define __OS_WORKGROUP_BASE__
#ifndef __OS_WORKGROUP_INDIRECT__
#error "Please #include instead of this file directly."
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include